Skip to content

Commit

Permalink
feat: Add ZIO streaming adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
Clark Andrianasolo committed Jun 21, 2023
1 parent 617e15b commit 9729373
Show file tree
Hide file tree
Showing 11 changed files with 959 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ The [talib-core-tests](/lib/talib-core-tests/) module provides tests for the cor
- [talib-streams-fs2](/lib/talib-fs2/) provides streaming adapters for the [fs2](https://fs2.io/) library using the _fs2_ API.
The [talib-streams-fs2-tests](/lib/talib-fs2-tests/) module provides tests for the fs2 module, to test the accuracy of the computations for each indicator, on any platform. The measured accuracy is compared to the accuracy of the batch computation of the indicator, which is the reference for the accuracy of the indicator.

- [talib-streams-zio](/lib/talib-zio/) provides streaming adapters for the [zio](https://zio.dev/) library using the _zio_ API.
The [talib-streams-zio-tests](/lib/talib-zio-tests/) module provides tests for the zio module, in an analogous way to the fs2 module.

- [signals](/lib/signals/) provides data types for type-safety when manipulating indicator inputs and outputs. Each indicator has its associated signal type, which simply contains as many output values as the indicator has outputs. It introduces concepts from trading signals, such as 'ohlc' (open-high-low-close), for which the streaming modules may provide helpers to compute indicators on.


Expand Down Expand Up @@ -66,7 +69,7 @@ Currently the roadmap is very open, and the project is in its early stages. The

## Special thanks to community

Thanks to maintainers of the [cats-effect](https://typelevel.org/cats-effect/) library, the [fs2](https://fs2.io/), and the [http4s](https://http4s.org/) libraries that made the [cross-platform capabilities](https://typelevel.org/blog/2022/09/19/typelevel-native.html) possible.
Thanks to maintainers of the [cats-effect](https://typelevel.org/cats-effect/) library, the [fs2](https://fs2.io/), and the [http4s](https://http4s.org/) libraries that made the [cross-platform capabilities](https://typelevel.org/blog/2022/09/19/typelevel-native.html) possible, also for the [zio](https://zio.dev/) library that cross-builds to Scala Native and JVM.


## License
Expand Down
26 changes: 26 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,21 @@ lazy val talibDependencies = Seq(
)
)

lazy val zioDependencies = Seq(
libraryDependencies ++= Seq(
"dev.zio" %%% "zio" % "2.0.14",
"dev.zio" %%% "zio-streams" % "2.0.14"
)
)

lazy val root = tlCrossRootProject
.aggregate(
talibCore.native,
talibCoreTests.native,
signalsLib.native,
talibStreams.native,
talibStreamsFs2.native,
talibStreamsZIO.native,
tradingDomain.native,
tradingPersistenceSkunk.native,
exampleSkunkApp.native
Expand Down Expand Up @@ -198,6 +207,23 @@ lazy val talibStreamsFs2Tests = crossProject(JVMPlatform, NativePlatform)
.dependsOn(talibStreamsFs2)
.nativeSettings(commonNativeSettings, testingNativeSettings)

lazy val talibStreamsZIO = crossProject(JVMPlatform, NativePlatform)
.crossType(CrossType.Full)
.in(file("lib/talib-zio"))
.settings(moduleName := "talib-streams-zio", name := "Talib streams ZIO")
.settings(sharedSettings)
.settings(zioDependencies)
.dependsOn(talibCore, signalsLib, talibStreams)
.nativeSettings(commonNativeSettings, testingNativeSettings)

lazy val talibStreamsZIOTests = crossProject(JVMPlatform, NativePlatform)
.crossType(CrossType.Full)
.in(file("lib/talib-zio-tests"))
.settings(moduleName := "talib-streams-zio-tests", name := "Talib streams ZIO tests")
.settings(sharedSettings)
.settings(zioDependencies, testingJUnitSettings)
.dependsOn(talibStreamsZIO)
.nativeSettings(commonNativeSettings, testingNativeSettings)

lazy val tradingDomain = crossProject(JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ class IndicatorStreamingFS2Test {
inputSingleChunk.map(_.value.doubleValue).compile.toVector.unsafeRunSync().toArray,
)

assertEquals(1, inputSingleChunk.chunks.compile.count.unsafeRunSync())

val RMSE_deviation = 0.01 // means that standard deviation of the error is 0.01
val result = output.compile.toList.unsafeRunSync()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ class IndicatorStreamingFS2Test {
inputSingleChunk.map(_.value.doubleValue).compile.toVector.unsafeRunSync().toArray,
)

assertEquals(1, inputSingleChunk.chunks.compile.count.unsafeRunSync())

val RMSE_deviation = 0.01 // means that standard deviation of the error is 0.01
val result = output.compile.toList.unsafeRunSync()

Expand Down
Loading

0 comments on commit 9729373

Please sign in to comment.