Wrapping up the options trading app as a Scala web app

The idea is to get the trained model and construct the best policy JSON output for the maximum reward case. PlayML is a web app that uses the options trading Q-learning algorithm to provide a compute API endpoint that takes the input dataset and some options to calculate the q-values and returns them in JSON format to be modeled in the frontend.

The wrapped up Scala web ML app has the following directory structure:

Figure 15: Scala ML web app directory structure

In the preceding structure, the app folder has both the original QLearning implementation (see the ml folder) and some additional backend code. The controller subfolder has a Scala class named API.scala, used as the Scala controller for controlling the model behavior from the frontend. Finally, Filters.scala acts as the DefaultHttpFilters:

Figure 16: The ml directory structure

The conf folder has the Scala web app configuration file, application.conf, containing the necessary configurations. All the dependencies are defined in the build.sbt file, as shown in the following code:

name := "PlayML"version := "1.0"
lazy val `playml` = (project in file(".")).enablePlugins(PlayScala)
resolvers += "scalaz-bintray"
scalaVersion := "2.11.11"
libraryDependencies ++= Seq(filters, cache, ws, "org.apache.commons" % "commons-math3" %
"3.6","com.typesafe.play" %% "play-json" % "2.5",
"org.jfree" % "jfreechart" % "1.0.17",
"com.typesafe.akka" %% "akka-actor" % "2.3.8",
"org.apache.spark" %% "spark-core" % "2.1.0",
"org.apache.spark" %% "spark-mllib" % "2.1.0",
"org.apache.spark" %% "spark-streaming" % "2.1.0")

The lib folder has some .jar files used as external dependencies defined in the build.sbt file. The public folder has the static pages used in the UI. Additionally, the data files IBM.csv and IBM_O.csv are also there. Finally, the target folder holds the application as a packaged (if any).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset