@quantform/core 0.6.6 → 0.7.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/as-readonly.d.ts +3 -0
- package/dist/as-readonly.d.ts.map +1 -0
- package/dist/as-readonly.js +8 -0
- package/dist/{domain → asset}/asset.d.ts +6 -1
- package/dist/asset/asset.d.ts.map +1 -0
- package/dist/{domain → asset}/asset.js +16 -7
- package/dist/asset/asset.spec.d.ts +2 -0
- package/dist/asset/asset.spec.d.ts.map +1 -0
- package/dist/asset/asset.spec.js +54 -0
- package/dist/asset/index.d.ts +2 -0
- package/dist/asset/index.d.ts.map +1 -0
- package/dist/{adapter/paper → asset}/index.js +1 -2
- package/dist/cli/build.js +1 -1
- package/dist/cli/dev.d.ts.map +1 -1
- package/dist/cli/dev.js +15 -11
- package/dist/cli/index.js +8 -8
- package/dist/cli/internal/workspace.js +1 -1
- package/dist/cli/pull.d.ts.map +1 -1
- package/dist/cli/pull.js +50 -20
- package/dist/cli/{test.d.ts → replay.d.ts} +1 -1
- package/dist/cli/replay.d.ts.map +1 -0
- package/dist/cli/{test.js → replay.js} +18 -20
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +16 -11
- package/dist/component/distinct-until-timesamp-changed.d.ts +5 -0
- package/dist/component/distinct-until-timesamp-changed.d.ts.map +1 -0
- package/dist/component/distinct-until-timesamp-changed.js +9 -0
- package/dist/component/error.d.ts +17 -0
- package/dist/component/error.d.ts.map +1 -0
- package/dist/component/error.js +33 -0
- package/dist/component/index.d.ts +8 -0
- package/dist/component/index.d.ts.map +1 -0
- package/dist/{store → component}/index.js +7 -9
- package/dist/{domain → component}/ohlc-operator.d.ts +1 -1
- package/dist/component/ohlc-operator.d.ts.map +1 -0
- package/dist/{domain → component}/ohlc-operator.js +4 -5
- package/dist/component/ohlc-operator.spec.d.ts +2 -0
- package/dist/component/ohlc-operator.spec.d.ts.map +1 -0
- package/dist/component/ohlc-operator.spec.js +110 -0
- package/dist/component/ohlc.d.ts.map +1 -0
- package/dist/component/ohlc.spec.d.ts +2 -0
- package/dist/component/ohlc.spec.d.ts.map +1 -0
- package/dist/component/ohlc.spec.js +25 -0
- package/dist/component/timeframe.d.ts.map +1 -0
- package/dist/core.d.ts +3 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +15 -0
- package/dist/defined.d.ts +3 -0
- package/dist/defined.d.ts.map +1 -0
- package/dist/defined.js +8 -0
- package/dist/exclude.d.ts +3 -0
- package/dist/exclude.d.ts.map +1 -0
- package/dist/exclude.js +8 -0
- package/dist/index.d.ts +25 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -66
- package/dist/{domain → instrument/commission}/commission.d.ts +1 -1
- package/dist/instrument/commission/commission.d.ts.map +1 -0
- package/dist/{domain → instrument/commission}/commission.js +2 -2
- package/dist/instrument/commission/commission.spec.d.ts +2 -0
- package/dist/instrument/commission/commission.spec.d.ts.map +1 -0
- package/dist/instrument/commission/commission.spec.js +30 -0
- package/dist/instrument/index.d.ts +3 -0
- package/dist/instrument/index.d.ts.map +1 -0
- package/dist/{adapter → instrument}/index.js +2 -4
- package/dist/{domain → instrument}/instrument.d.ts +4 -4
- package/dist/instrument/instrument.d.ts.map +1 -0
- package/dist/{domain → instrument}/instrument.js +8 -5
- package/dist/instrument/instrument.spec.d.ts +2 -0
- package/dist/instrument/instrument.spec.d.ts.map +1 -0
- package/dist/instrument/instrument.spec.js +51 -0
- package/dist/make-test-module.d.ts +13 -0
- package/dist/make-test-module.d.ts.map +1 -0
- package/dist/make-test-module.js +46 -0
- package/dist/module.d.ts +57 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +136 -0
- package/dist/module.spec.d.ts +2 -0
- package/dist/module.spec.d.ts.map +1 -0
- package/dist/module.spec.js +86 -0
- package/dist/not-found.d.ts +2 -0
- package/dist/not-found.d.ts.map +1 -0
- package/dist/{domain/component.js → not-found.js} +2 -0
- package/dist/replay/index.d.ts +7 -0
- package/dist/replay/index.d.ts.map +1 -0
- package/dist/replay/index.js +22 -0
- package/dist/replay/use-replay-coordinator.d.ts +10 -0
- package/dist/replay/use-replay-coordinator.d.ts.map +1 -0
- package/dist/replay/use-replay-coordinator.js +119 -0
- package/dist/replay/use-replay-options.d.ts +15 -0
- package/dist/replay/use-replay-options.d.ts.map +1 -0
- package/dist/replay/use-replay-options.js +20 -0
- package/dist/replay/use-replay-reader.d.ts +7 -0
- package/dist/replay/use-replay-reader.d.ts.map +1 -0
- package/dist/replay/use-replay-reader.js +32 -0
- package/dist/replay/use-replay-reader.spec.d.ts +2 -0
- package/dist/replay/use-replay-reader.spec.d.ts.map +1 -0
- package/dist/replay/use-replay-reader.spec.js +58 -0
- package/dist/replay/use-replay-storage.d.ts +10 -0
- package/dist/replay/use-replay-storage.d.ts.map +1 -0
- package/dist/replay/use-replay-storage.js +10 -0
- package/dist/replay/use-replay-writer.d.ts +6 -0
- package/dist/replay/use-replay-writer.d.ts.map +1 -0
- package/dist/replay/use-replay-writer.js +14 -0
- package/dist/replay/use-replay-writer.spec.d.ts +2 -0
- package/dist/replay/use-replay-writer.spec.d.ts.map +1 -0
- package/dist/replay/use-replay-writer.spec.js +53 -0
- package/dist/replay/use-replay.d.ts +10 -0
- package/dist/replay/use-replay.d.ts.map +1 -0
- package/dist/replay/use-replay.js +32 -0
- package/dist/replay/use-replay.spec.d.ts +2 -0
- package/dist/replay/use-replay.spec.d.ts.map +1 -0
- package/dist/replay/use-replay.spec.js +106 -0
- package/dist/replay/with-replay.d.ts +4 -0
- package/dist/replay/with-replay.d.ts.map +1 -0
- package/dist/replay/with-replay.js +8 -0
- package/dist/session/index.d.ts +4 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +19 -0
- package/dist/session/use-session-object.d.ts +18 -0
- package/dist/session/use-session-object.d.ts.map +1 -0
- package/dist/session/use-session-object.js +13 -0
- package/dist/session/use-session-storage.d.ts +2 -0
- package/dist/session/use-session-storage.d.ts.map +1 -0
- package/dist/session/use-session-storage.js +10 -0
- package/dist/session/use-session.d.ts +4 -0
- package/dist/session/use-session.d.ts.map +1 -0
- package/dist/session/use-session.js +7 -0
- package/dist/shared/datetime.d.ts +1 -1
- package/dist/shared/datetime.d.ts.map +1 -1
- package/dist/shared/decimals.d.ts.map +1 -1
- package/dist/shared/decimals.js +5 -0
- package/dist/shared/decimals.spec.d.ts +2 -0
- package/dist/shared/decimals.spec.d.ts.map +1 -0
- package/dist/shared/decimals.spec.js +28 -0
- package/dist/shared/index.d.ts +3 -7
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +3 -7
- package/dist/simulator/index.d.ts +2 -0
- package/dist/simulator/index.d.ts.map +1 -0
- package/dist/{adapter/backtester → simulator}/index.js +1 -2
- package/dist/simulator/use-simulator.d.ts +2 -0
- package/dist/simulator/use-simulator.d.ts.map +1 -0
- package/dist/simulator/use-simulator.js +9 -0
- package/dist/simulator/use-simulator.spec.d.ts +2 -0
- package/dist/simulator/use-simulator.spec.d.ts.map +1 -0
- package/dist/simulator/use-simulator.spec.js +49 -0
- package/dist/storage/in-memory/in-memory-storage.d.ts +9 -0
- package/dist/storage/in-memory/in-memory-storage.d.ts.map +1 -0
- package/dist/storage/in-memory/in-memory-storage.factory.d.ts +6 -0
- package/dist/storage/in-memory/in-memory-storage.factory.d.ts.map +1 -0
- package/dist/storage/in-memory/in-memory-storage.factory.js +23 -0
- package/dist/storage/in-memory/in-memory-storage.js +72 -0
- package/dist/storage/in-memory/in-memory-storage.spec.d.ts +2 -0
- package/dist/storage/in-memory/in-memory-storage.spec.d.ts.map +1 -0
- package/dist/storage/in-memory/in-memory-storage.spec.js +167 -0
- package/dist/storage/in-memory/index.d.ts +3 -0
- package/dist/storage/in-memory/index.d.ts.map +1 -0
- package/dist/storage/in-memory/index.js +18 -0
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +3 -3
- package/dist/storage/storage.d.ts +51 -61
- package/dist/storage/storage.d.ts.map +1 -1
- package/dist/storage/storage.js +20 -85
- package/dist/storage/use-cache.d.ts +4 -0
- package/dist/storage/use-cache.d.ts.map +1 -0
- package/dist/storage/use-cache.js +34 -0
- package/dist/storage/use-cache.spec.d.ts +2 -0
- package/dist/storage/use-cache.spec.d.ts.map +1 -0
- package/dist/storage/use-cache.spec.js +36 -0
- package/dist/storage/use-storage-factory.d.ts +10 -0
- package/dist/storage/use-storage-factory.d.ts.map +1 -0
- package/dist/storage/use-storage-factory.js +14 -0
- package/dist/storage/use-storage.d.ts +3 -0
- package/dist/storage/use-storage.d.ts.map +1 -0
- package/dist/storage/use-storage.js +11 -0
- package/dist/strat.d.ts +7 -0
- package/dist/strat.d.ts.map +1 -0
- package/dist/strat.js +7 -0
- package/dist/use-execution-mode.d.ts +29 -0
- package/dist/use-execution-mode.d.ts.map +1 -0
- package/dist/use-execution-mode.js +37 -0
- package/dist/use-hash.d.ts +5 -0
- package/dist/use-hash.d.ts.map +1 -0
- package/dist/use-hash.js +7 -0
- package/dist/use-hash.spec.d.ts +2 -0
- package/dist/use-hash.spec.d.ts.map +1 -0
- package/dist/use-hash.spec.js +16 -0
- package/dist/use-lock.d.ts +9 -0
- package/dist/use-lock.d.ts.map +1 -0
- package/dist/use-lock.js +40 -0
- package/dist/use-logger.d.ts +10 -0
- package/dist/use-logger.d.ts.map +1 -0
- package/dist/use-logger.js +37 -0
- package/dist/use-memo.d.ts +21 -0
- package/dist/use-memo.d.ts.map +1 -0
- package/dist/use-memo.js +35 -0
- package/dist/use-memo.spec.d.ts +2 -0
- package/dist/use-memo.spec.d.ts.map +1 -0
- package/dist/use-memo.spec.js +35 -0
- package/dist/use-request.d.ts +16 -0
- package/dist/use-request.d.ts.map +1 -0
- package/dist/use-request.js +27 -0
- package/dist/use-socket.d.ts +6 -0
- package/dist/use-socket.d.ts.map +1 -0
- package/dist/use-socket.js +52 -0
- package/dist/use-state.d.ts +4 -0
- package/dist/use-state.d.ts.map +1 -0
- package/dist/use-state.js +24 -0
- package/dist/use-state.spec.d.ts +2 -0
- package/dist/use-state.spec.d.ts.map +1 -0
- package/dist/use-state.spec.js +36 -0
- package/dist/use-timestamp.d.ts +2 -0
- package/dist/use-timestamp.d.ts.map +1 -0
- package/dist/use-timestamp.js +13 -0
- package/dist/use.d.ts +5 -0
- package/dist/use.d.ts.map +1 -0
- package/dist/use.js +20 -0
- package/dist/use.spec.d.ts +2 -0
- package/dist/use.spec.d.ts.map +1 -0
- package/dist/use.spec.js +47 -0
- package/jest.config.ts +23 -2
- package/package.json +14 -11
- package/src/as-readonly.ts +5 -0
- package/src/{domain → asset}/asset.spec.ts +4 -4
- package/src/{domain → asset}/asset.ts +17 -6
- package/src/asset/index.ts +1 -0
- package/src/cli/build.ts +1 -1
- package/src/cli/dev.ts +18 -13
- package/src/cli/index.ts +7 -7
- package/src/cli/internal/workspace.ts +1 -1
- package/src/cli/pull.ts +22 -10
- package/src/cli/replay.ts +31 -0
- package/src/cli/run.ts +17 -13
- package/src/component/distinct-until-timesamp-changed.ts +11 -0
- package/src/component/error.ts +32 -0
- package/src/component/index.ts +7 -0
- package/src/{domain → component}/ohlc-operator.spec.ts +5 -6
- package/src/{domain → component}/ohlc-operator.ts +2 -3
- package/src/{domain → component}/ohlc.spec.ts +2 -2
- package/src/{domain → component}/ohlc.ts +2 -2
- package/src/core.ts +14 -0
- package/src/defined.ts +6 -0
- package/src/exclude.ts +9 -0
- package/src/index.ts +27 -80
- package/src/{domain → instrument/commission}/commission.spec.ts +4 -3
- package/src/{domain → instrument/commission}/commission.ts +1 -1
- package/src/instrument/index.ts +2 -0
- package/src/{domain → instrument}/instrument.spec.ts +11 -6
- package/src/{domain → instrument}/instrument.ts +12 -8
- package/src/make-test-module.ts +46 -0
- package/src/module.spec.ts +74 -0
- package/src/module.ts +156 -0
- package/src/not-found.ts +1 -0
- package/src/replay/index.ts +6 -0
- package/src/replay/use-replay-coordinator.ts +142 -0
- package/src/replay/use-replay-options.ts +23 -0
- package/src/replay/use-replay-reader.spec.ts +64 -0
- package/src/replay/use-replay-reader.ts +23 -0
- package/src/replay/use-replay-storage.ts +8 -0
- package/src/replay/use-replay-writer.spec.ts +56 -0
- package/src/replay/use-replay-writer.ts +17 -0
- package/src/replay/use-replay.spec.ts +132 -0
- package/src/replay/use-replay.ts +34 -0
- package/src/replay/with-replay.ts +10 -0
- package/src/session/index.ts +3 -0
- package/src/session/use-session-object.ts +26 -0
- package/src/session/use-session-storage.ts +9 -0
- package/src/session/use-session.ts +5 -0
- package/src/shared/decimals.spec.ts +1 -1
- package/src/shared/decimals.ts +5 -0
- package/src/shared/index.ts +3 -7
- package/src/simulator/index.ts +1 -0
- package/src/simulator/use-simulator.spec.ts +54 -0
- package/src/simulator/use-simulator.ts +7 -0
- package/src/storage/in-memory/in-memory-storage.factory.ts +16 -0
- package/src/storage/in-memory/in-memory-storage.spec.ts +193 -0
- package/src/storage/in-memory/in-memory-storage.ts +80 -0
- package/src/storage/in-memory/index.ts +2 -0
- package/src/storage/index.ts +3 -3
- package/src/storage/storage.ts +63 -119
- package/src/storage/use-cache.spec.ts +31 -0
- package/src/storage/use-cache.ts +50 -0
- package/src/storage/use-storage-factory.ts +17 -0
- package/src/storage/use-storage.ts +11 -0
- package/src/strat.ts +7 -0
- package/src/use-execution-mode.ts +41 -0
- package/src/use-hash.spec.ts +16 -0
- package/src/use-hash.ts +5 -0
- package/src/use-lock.ts +52 -0
- package/src/use-logger.ts +47 -0
- package/src/use-memo.spec.ts +30 -0
- package/src/use-memo.ts +35 -0
- package/src/use-request.ts +47 -0
- package/src/use-socket.ts +59 -0
- package/src/use-state.spec.ts +31 -0
- package/src/use-state.ts +30 -0
- package/src/use-timestamp.ts +12 -0
- package/src/use.spec.ts +46 -0
- package/src/use.ts +33 -0
- package/tsconfig.json +7 -4
- package/dist/adapter/adapter-aggregate.d.ts +0 -57
- package/dist/adapter/adapter-aggregate.d.ts.map +0 -1
- package/dist/adapter/adapter-aggregate.js +0 -157
- package/dist/adapter/adapter.d.ts +0 -54
- package/dist/adapter/adapter.d.ts.map +0 -1
- package/dist/adapter/adapter.js +0 -20
- package/dist/adapter/backtester/backtester-adapter.d.ts +0 -30
- package/dist/adapter/backtester/backtester-adapter.d.ts.map +0 -1
- package/dist/adapter/backtester/backtester-adapter.js +0 -67
- package/dist/adapter/backtester/backtester-cursor.d.ts +0 -16
- package/dist/adapter/backtester/backtester-cursor.d.ts.map +0 -1
- package/dist/adapter/backtester/backtester-cursor.js +0 -52
- package/dist/adapter/backtester/backtester-streamer.d.ts +0 -50
- package/dist/adapter/backtester/backtester-streamer.d.ts.map +0 -1
- package/dist/adapter/backtester/backtester-streamer.js +0 -119
- package/dist/adapter/backtester/error.d.ts +0 -3
- package/dist/adapter/backtester/error.d.ts.map +0 -1
- package/dist/adapter/backtester/error.js +0 -11
- package/dist/adapter/backtester/index.d.ts +0 -3
- package/dist/adapter/backtester/index.d.ts.map +0 -1
- package/dist/adapter/error.d.ts +0 -4
- package/dist/adapter/error.d.ts.map +0 -1
- package/dist/adapter/error.js +0 -15
- package/dist/adapter/index.d.ts +0 -5
- package/dist/adapter/index.d.ts.map +0 -1
- package/dist/adapter/paper/engine/paper-engine.d.ts +0 -12
- package/dist/adapter/paper/engine/paper-engine.d.ts.map +0 -1
- package/dist/adapter/paper/engine/paper-engine.js +0 -109
- package/dist/adapter/paper/index.d.ts +0 -3
- package/dist/adapter/paper/index.d.ts.map +0 -1
- package/dist/adapter/paper/paper-adapter.d.ts +0 -30
- package/dist/adapter/paper/paper-adapter.d.ts.map +0 -1
- package/dist/adapter/paper/paper-adapter.js +0 -87
- package/dist/cli/error.d.ts +0 -2
- package/dist/cli/error.d.ts.map +0 -1
- package/dist/cli/error.js +0 -7
- package/dist/cli/test.d.ts.map +0 -1
- package/dist/domain/asset.d.ts.map +0 -1
- package/dist/domain/balance-operator.d.ts +0 -7
- package/dist/domain/balance-operator.d.ts.map +0 -1
- package/dist/domain/balance-operator.js +0 -9
- package/dist/domain/balance.d.ts +0 -47
- package/dist/domain/balance.d.ts.map +0 -1
- package/dist/domain/balance.js +0 -97
- package/dist/domain/commission.d.ts.map +0 -1
- package/dist/domain/component.d.ts +0 -6
- package/dist/domain/component.d.ts.map +0 -1
- package/dist/domain/error.d.ts +0 -7
- package/dist/domain/error.d.ts.map +0 -1
- package/dist/domain/error.js +0 -23
- package/dist/domain/index.d.ts +0 -22
- package/dist/domain/index.d.ts.map +0 -1
- package/dist/domain/index.js +0 -37
- package/dist/domain/instrument-operator.d.ts +0 -7
- package/dist/domain/instrument-operator.d.ts.map +0 -1
- package/dist/domain/instrument-operator.js +0 -13
- package/dist/domain/instrument.d.ts.map +0 -1
- package/dist/domain/ohlc-operator.d.ts.map +0 -1
- package/dist/domain/ohlc.d.ts.map +0 -1
- package/dist/domain/order-operator.d.ts +0 -8
- package/dist/domain/order-operator.d.ts.map +0 -1
- package/dist/domain/order-operator.js +0 -16
- package/dist/domain/order.d.ts +0 -24
- package/dist/domain/order.d.ts.map +0 -1
- package/dist/domain/order.js +0 -49
- package/dist/domain/orderbook-operator.d.ts +0 -7
- package/dist/domain/orderbook-operator.d.ts.map +0 -1
- package/dist/domain/orderbook-operator.js +0 -9
- package/dist/domain/orderbook.d.ts +0 -30
- package/dist/domain/orderbook.d.ts.map +0 -1
- package/dist/domain/orderbook.js +0 -20
- package/dist/domain/position-operator.d.ts +0 -13
- package/dist/domain/position-operator.d.ts.map +0 -1
- package/dist/domain/position-operator.js +0 -45
- package/dist/domain/position.d.ts +0 -18
- package/dist/domain/position.d.ts.map +0 -1
- package/dist/domain/position.js +0 -23
- package/dist/domain/session-builder.d.ts +0 -54
- package/dist/domain/session-builder.d.ts.map +0 -1
- package/dist/domain/session-builder.js +0 -106
- package/dist/domain/session.d.ts +0 -77
- package/dist/domain/session.d.ts.map +0 -1
- package/dist/domain/session.js +0 -162
- package/dist/domain/timeframe.d.ts.map +0 -1
- package/dist/domain/trade-operator.d.ts +0 -7
- package/dist/domain/trade-operator.d.ts.map +0 -1
- package/dist/domain/trade-operator.js +0 -9
- package/dist/domain/trade.d.ts +0 -16
- package/dist/domain/trade.d.ts.map +0 -1
- package/dist/domain/trade.js +0 -17
- package/dist/shared/collections.d.ts +0 -29
- package/dist/shared/collections.d.ts.map +0 -1
- package/dist/shared/collections.js +0 -123
- package/dist/shared/logger.d.ts +0 -8
- package/dist/shared/logger.d.ts.map +0 -1
- package/dist/shared/logger.js +0 -33
- package/dist/shared/pipe.d.ts +0 -5
- package/dist/shared/pipe.d.ts.map +0 -1
- package/dist/shared/pipe.js +0 -8
- package/dist/shared/policy.d.ts +0 -2
- package/dist/shared/policy.d.ts.map +0 -1
- package/dist/shared/policy.js +0 -8
- package/dist/storage/cache.d.ts +0 -10
- package/dist/storage/cache.d.ts.map +0 -1
- package/dist/storage/cache.js +0 -43
- package/dist/storage/feed.d.ts +0 -38
- package/dist/storage/feed.d.ts.map +0 -1
- package/dist/storage/feed.js +0 -108
- package/dist/storage/measurement.d.ts +0 -34
- package/dist/storage/measurement.d.ts.map +0 -1
- package/dist/storage/measurement.js +0 -59
- package/dist/store/error.d.ts +0 -9
- package/dist/store/error.d.ts.map +0 -1
- package/dist/store/error.js +0 -31
- package/dist/store/index.d.ts +0 -10
- package/dist/store/index.d.ts.map +0 -1
- package/dist/store/store-balance-event.d.ts +0 -46
- package/dist/store/store-balance-event.d.ts.map +0 -1
- package/dist/store/store-balance-event.js +0 -134
- package/dist/store/store-event.d.ts +0 -7
- package/dist/store/store-event.d.ts.map +0 -1
- package/dist/store/store-event.js +0 -2
- package/dist/store/store-instrument-event.d.ts +0 -22
- package/dist/store/store-instrument-event.d.ts.map +0 -1
- package/dist/store/store-instrument-event.js +0 -60
- package/dist/store/store-order-event.d.ts +0 -64
- package/dist/store/store-order-event.d.ts.map +0 -1
- package/dist/store/store-order-event.js +0 -185
- package/dist/store/store-orderbook-event.d.ts +0 -13
- package/dist/store/store-orderbook-event.d.ts.map +0 -1
- package/dist/store/store-orderbook-event.js +0 -43
- package/dist/store/store-position-event.d.ts +0 -22
- package/dist/store/store-position-event.d.ts.map +0 -1
- package/dist/store/store-position-event.js +0 -96
- package/dist/store/store-state.d.ts +0 -28
- package/dist/store/store-state.d.ts.map +0 -1
- package/dist/store/store-state.js +0 -29
- package/dist/store/store-trade-event.d.ts +0 -17
- package/dist/store/store-trade-event.d.ts.map +0 -1
- package/dist/store/store-trade-event.js +0 -34
- package/dist/store/store.d.ts +0 -15
- package/dist/store/store.d.ts.map +0 -1
- package/dist/store/store.js +0 -32
- package/src/adapter/adapter-aggregate.ts +0 -171
- package/src/adapter/adapter.ts +0 -83
- package/src/adapter/backtester/backtester-adapter.ts +0 -96
- package/src/adapter/backtester/backtester-cursor.spec.ts +0 -44
- package/src/adapter/backtester/backtester-cursor.ts +0 -47
- package/src/adapter/backtester/backtester-streamer.spec.ts +0 -60
- package/src/adapter/backtester/backtester-streamer.ts +0 -155
- package/src/adapter/backtester/error.ts +0 -7
- package/src/adapter/backtester/index.ts +0 -2
- package/src/adapter/error.ts +0 -13
- package/src/adapter/index.ts +0 -4
- package/src/adapter/paper/engine/paper-engine.spec.ts +0 -116
- package/src/adapter/paper/engine/paper-engine.ts +0 -151
- package/src/adapter/paper/index.ts +0 -2
- package/src/adapter/paper/paper-adapter.ts +0 -111
- package/src/cli/error.ts +0 -5
- package/src/cli/test.ts +0 -40
- package/src/domain/balance-operator.spec.ts +0 -26
- package/src/domain/balance-operator.ts +0 -15
- package/src/domain/balance.spec.ts +0 -116
- package/src/domain/balance.ts +0 -123
- package/src/domain/component.ts +0 -6
- package/src/domain/error.ts +0 -27
- package/src/domain/index.ts +0 -21
- package/src/domain/instrument-operator.spec.ts +0 -35
- package/src/domain/instrument-operator.ts +0 -25
- package/src/domain/order-operator.spec.ts +0 -85
- package/src/domain/order-operator.ts +0 -23
- package/src/domain/order.spec.ts +0 -43
- package/src/domain/order.ts +0 -68
- package/src/domain/orderbook-operator.spec.ts +0 -40
- package/src/domain/orderbook-operator.ts +0 -15
- package/src/domain/orderbook.spec.ts +0 -26
- package/src/domain/orderbook.ts +0 -30
- package/src/domain/position-operator.spec.ts +0 -64
- package/src/domain/position-operator.ts +0 -71
- package/src/domain/position.spec.ts +0 -43
- package/src/domain/position.ts +0 -31
- package/src/domain/session-builder.ts +0 -158
- package/src/domain/session.spec.ts +0 -33
- package/src/domain/session.ts +0 -256
- package/src/domain/trade-operator.spec.ts +0 -35
- package/src/domain/trade-operator.ts +0 -15
- package/src/domain/trade.spec.ts +0 -21
- package/src/domain/trade.ts +0 -20
- package/src/shared/collections.spec.ts +0 -34
- package/src/shared/collections.ts +0 -154
- package/src/shared/logger.ts +0 -39
- package/src/shared/pipe.ts +0 -12
- package/src/shared/policy.ts +0 -5
- package/src/storage/cache.spec.ts +0 -18
- package/src/storage/cache.ts +0 -37
- package/src/storage/feed.ts +0 -124
- package/src/storage/measurement.ts +0 -56
- package/src/store/error.ts +0 -36
- package/src/store/index.ts +0 -9
- package/src/store/store-balance-event.spec.ts +0 -30
- package/src/store/store-balance-event.ts +0 -167
- package/src/store/store-event.ts +0 -8
- package/src/store/store-instrument-event.spec.ts +0 -26
- package/src/store/store-instrument-event.ts +0 -83
- package/src/store/store-order-event.spec.ts +0 -32
- package/src/store/store-order-event.ts +0 -219
- package/src/store/store-orderbook-event.spec.ts +0 -39
- package/src/store/store-orderbook-event.ts +0 -56
- package/src/store/store-position-event.ts +0 -121
- package/src/store/store-state.ts +0 -48
- package/src/store/store-trade-event.spec.ts +0 -62
- package/src/store/store-trade-event.ts +0 -42
- package/src/store/store.spec.ts +0 -182
- package/src/store/store.ts +0 -37
- package/dist/{domain → component}/ohlc.d.ts +0 -0
- package/dist/{domain → component}/ohlc.js +0 -0
- package/dist/{domain → component}/timeframe.d.ts +0 -0
- package/dist/{domain → component}/timeframe.js +1 -1
- /package/src/{domain → component}/timeframe.ts +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRequest = exports.RequestNetworkError = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const undici_1 = require("undici");
|
|
6
|
+
const use_timestamp_1 = require("./use-timestamp");
|
|
7
|
+
class RequestNetworkError extends Error {
|
|
8
|
+
constructor(statusCode, json) {
|
|
9
|
+
super(`Request network error, received status code: ${statusCode}`);
|
|
10
|
+
this.statusCode = statusCode;
|
|
11
|
+
this.json = json;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.RequestNetworkError = RequestNetworkError;
|
|
15
|
+
function useRequest(args) {
|
|
16
|
+
return (0, rxjs_1.from)((0, undici_1.request)(args.url, {
|
|
17
|
+
method: args.method,
|
|
18
|
+
headers: args.headers,
|
|
19
|
+
body: args.body
|
|
20
|
+
})).pipe((0, rxjs_1.switchMap)(it => {
|
|
21
|
+
if (it.statusCode !== 200) {
|
|
22
|
+
return (0, rxjs_1.throwError)(() => new RequestNetworkError(it.statusCode, () => it.body.json()));
|
|
23
|
+
}
|
|
24
|
+
return (0, rxjs_1.from)(it.body.json());
|
|
25
|
+
}), (0, rxjs_1.map)(payload => ({ timestamp: (0, use_timestamp_1.useTimestamp)(), payload })));
|
|
26
|
+
}
|
|
27
|
+
exports.useRequest = useRequest;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-socket.d.ts","sourceRoot":"","sources":["../src/use-socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAMlC,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,GACV,CAAC,UAAU,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC,CAkDnF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSocket = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const ws_1 = require("ws");
|
|
6
|
+
const use_logger_1 = require("./use-logger");
|
|
7
|
+
const use_timestamp_1 = require("./use-timestamp");
|
|
8
|
+
function useSocket(url) {
|
|
9
|
+
const { debug } = (0, use_logger_1.useLogger)('useSocket');
|
|
10
|
+
const message = new rxjs_1.Observable(stream => {
|
|
11
|
+
const socket = new ws_1.WebSocket(url);
|
|
12
|
+
let isAlive = false;
|
|
13
|
+
let interval;
|
|
14
|
+
socket.onmessage = it => stream.next({ timestamp: (0, use_timestamp_1.useTimestamp)(), payload: JSON.parse(it.data) });
|
|
15
|
+
socket.onerror = it => {
|
|
16
|
+
clearInterval(interval);
|
|
17
|
+
stream.error(it);
|
|
18
|
+
};
|
|
19
|
+
socket.onclose = () => {
|
|
20
|
+
debug('closed', url);
|
|
21
|
+
clearInterval(interval);
|
|
22
|
+
stream.error();
|
|
23
|
+
};
|
|
24
|
+
socket.onopen = () => {
|
|
25
|
+
debug('opened', url);
|
|
26
|
+
isAlive = true;
|
|
27
|
+
interval = setInterval(() => {
|
|
28
|
+
if (isAlive) {
|
|
29
|
+
isAlive = false;
|
|
30
|
+
socket.ping();
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
socket.terminate();
|
|
34
|
+
clearInterval(interval);
|
|
35
|
+
}
|
|
36
|
+
}, 5000);
|
|
37
|
+
socket.on('pong', () => {
|
|
38
|
+
isAlive = true;
|
|
39
|
+
});
|
|
40
|
+
socket.on('ping', () => {
|
|
41
|
+
isAlive = true;
|
|
42
|
+
socket.pong();
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
return () => {
|
|
46
|
+
socket.terminate();
|
|
47
|
+
clearInterval(interval);
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
return [message, (message) => JSON.stringify(message)];
|
|
51
|
+
}
|
|
52
|
+
exports.useSocket = useSocket;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-state.d.ts","sourceRoot":"","sources":["../src/use-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,UAAU,EAAE,MAAM,MAAM,CAAC;AAInD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,wBAAgB,QAAQ,CAAC,CAAC,EACxB,YAAY,EAAE,CAAC,EACf,YAAY,EAAE,UAAU,EAAE,GACzB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAoBtE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useState = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const use_memo_1 = require("./use-memo");
|
|
6
|
+
function useState(initialValue, dependencies) {
|
|
7
|
+
return (0, use_memo_1.useMemo)(() => {
|
|
8
|
+
const state = new rxjs_1.BehaviorSubject(initialValue);
|
|
9
|
+
const setState = (newState) => {
|
|
10
|
+
if (newState instanceof Function) {
|
|
11
|
+
const value = newState(state.value);
|
|
12
|
+
if (value) {
|
|
13
|
+
state.next(value);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
state.next(newState);
|
|
18
|
+
}
|
|
19
|
+
return state.value;
|
|
20
|
+
};
|
|
21
|
+
return [state.asObservable(), setState];
|
|
22
|
+
}, dependencies);
|
|
23
|
+
}
|
|
24
|
+
exports.useState = useState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-state.spec.d.ts","sourceRoot":"","sources":["../src/use-state.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const make_test_module_1 = require("./make-test-module");
|
|
13
|
+
const use_state_1 = require("./use-state");
|
|
14
|
+
describe(use_state_1.useState.name, () => {
|
|
15
|
+
let fixtures;
|
|
16
|
+
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
fixtures = yield getFixtures();
|
|
18
|
+
}));
|
|
19
|
+
test('keep same state between multiple requests for the same dependency', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
const state1 = yield fixtures.givenState({ text: 'Hello my state' }, ['my-state']);
|
|
21
|
+
const state2 = yield fixtures.givenState({ text: 'Hello my override state' }, [
|
|
22
|
+
'my-state'
|
|
23
|
+
]);
|
|
24
|
+
expect(Object.is(state1, state2)).toBeTruthy();
|
|
25
|
+
}));
|
|
26
|
+
});
|
|
27
|
+
function getFixtures() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const { act } = yield (0, make_test_module_1.makeTestModule)([]);
|
|
30
|
+
return {
|
|
31
|
+
givenState(value, dependencies) {
|
|
32
|
+
return act(() => (0, use_state_1.useState)(value, dependencies));
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-timestamp.d.ts","sourceRoot":"","sources":["../src/use-timestamp.ts"],"names":[],"mappings":"AAGA,wBAAgB,YAAY,WAQ3B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTimestamp = void 0;
|
|
4
|
+
const use_replay_coordinator_1 = require("./replay/use-replay-coordinator");
|
|
5
|
+
const use_execution_mode_1 = require("./use-execution-mode");
|
|
6
|
+
function useTimestamp() {
|
|
7
|
+
const { isReplay } = (0, use_execution_mode_1.useExecutionMode)();
|
|
8
|
+
if (isReplay) {
|
|
9
|
+
return (0, use_replay_coordinator_1.useReplayCoordinator)().timestamp();
|
|
10
|
+
}
|
|
11
|
+
return Date.now();
|
|
12
|
+
}
|
|
13
|
+
exports.useTimestamp = useTimestamp;
|
package/dist/use.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { dependency } from './use-hash';
|
|
3
|
+
export declare function use<T extends Array<dependency>, U>(fn: (...args: T) => U): (...args: T) => U;
|
|
4
|
+
export declare function use<T extends Array<dependency>, U>(fn: (...args: T) => Observable<U>): (...args: T) => Observable<U>;
|
|
5
|
+
//# sourceMappingURL=use.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../src/use.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAe,MAAM,MAAM,CAAC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGxC,wBAAgB,GAAG,CAAC,CAAC,SAAS,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,EAChD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GACpB,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;AACrB,wBAAgB,GAAG,CAAC,CAAC,SAAS,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,EAChD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,GAChC,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/use.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.use = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const uuid_1 = require("uuid");
|
|
6
|
+
const as_readonly_1 = require("./as-readonly");
|
|
7
|
+
const module_1 = require("./module");
|
|
8
|
+
const use_memo_1 = require("./use-memo");
|
|
9
|
+
function use(fn) {
|
|
10
|
+
(0, module_1.throwWithContext)();
|
|
11
|
+
const uniqueId = (0, uuid_1.v4)();
|
|
12
|
+
return (...args) => (0, use_memo_1.useMemo)(() => {
|
|
13
|
+
const value = fn(...args);
|
|
14
|
+
if ((0, rxjs_1.isObservable)(value)) {
|
|
15
|
+
return value.pipe((0, as_readonly_1.asReadonly)(), (0, rxjs_1.shareReplay)(1));
|
|
16
|
+
}
|
|
17
|
+
return value;
|
|
18
|
+
}, [uniqueId, ...args]);
|
|
19
|
+
}
|
|
20
|
+
exports.use = use;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use.spec.d.ts","sourceRoot":"","sources":["../src/use.spec.ts"],"names":[],"mappings":""}
|
package/dist/use.spec.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const make_test_module_1 = require("./make-test-module");
|
|
13
|
+
const instrument_1 = require("./instrument");
|
|
14
|
+
const use_1 = require("./use");
|
|
15
|
+
describe(use_1.use.name, () => {
|
|
16
|
+
let fixtures;
|
|
17
|
+
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
fixtures = yield getFixtures();
|
|
19
|
+
}));
|
|
20
|
+
test('memorize same values for same arguments', () => {
|
|
21
|
+
const { act, getValue } = fixtures;
|
|
22
|
+
act(() => {
|
|
23
|
+
const value1 = getValue((0, instrument_1.instrumentOf)('binance:btc-usdt'));
|
|
24
|
+
const value2 = getValue((0, instrument_1.instrumentOf)('binance:btc-usdt'));
|
|
25
|
+
expect(Object.is(value1, value2)).toBeTruthy();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
test('memorize different values for different arguments', () => {
|
|
29
|
+
const { act, getValue } = fixtures;
|
|
30
|
+
act(() => {
|
|
31
|
+
const value1 = getValue((0, instrument_1.instrumentOf)('binance:btc-usdt'));
|
|
32
|
+
const value2 = getValue((0, instrument_1.instrumentOf)('binance:btc-busd'));
|
|
33
|
+
expect(value1).toEqual('binance:btc-usdt');
|
|
34
|
+
expect(value2).toEqual('binance:btc-busd');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
function getFixtures() {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const { act } = yield (0, make_test_module_1.makeTestModule)([]);
|
|
41
|
+
const getValue = (0, use_1.use)((instrument) => instrument.id);
|
|
42
|
+
return {
|
|
43
|
+
act,
|
|
44
|
+
getValue: act(() => (instrument) => getValue(instrument))
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}
|
package/jest.config.ts
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
import { Config } from 'jest';
|
|
2
|
+
import { pathsToModuleNameMapper } from 'ts-jest';
|
|
3
|
+
import { parseJsonConfigFileContent, readConfigFile, sys } from 'typescript';
|
|
4
|
+
|
|
5
|
+
const tsconfig = parseJsonConfigFileContent(
|
|
6
|
+
readConfigFile('tsconfig.json', sys.readFile).config,
|
|
7
|
+
sys,
|
|
8
|
+
process.cwd()
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const compilerOptions = tsconfig.raw.compilerOptions as any;
|
|
2
12
|
|
|
3
13
|
const config: Config = {
|
|
4
14
|
preset: 'ts-jest',
|
|
5
15
|
testEnvironment: 'node',
|
|
6
16
|
testMatch: ['**/src/**/?(*.)+(spec|test).[jt]s?(x)'],
|
|
7
17
|
transform: {
|
|
8
|
-
'^.+\\.ts?$':
|
|
18
|
+
'^.+\\.ts?$': [
|
|
19
|
+
'ts-jest',
|
|
20
|
+
{
|
|
21
|
+
isolatedModules: true,
|
|
22
|
+
tsconfig: { ...compilerOptions, sourceMap: true }
|
|
23
|
+
}
|
|
24
|
+
]
|
|
9
25
|
},
|
|
10
|
-
testPathIgnorePatterns: ['src/cli/test.ts']
|
|
26
|
+
testPathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/src/cli/test.ts'],
|
|
27
|
+
roots: ['<rootDir>'],
|
|
28
|
+
modulePaths: [compilerOptions.baseUrl],
|
|
29
|
+
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
|
|
30
|
+
prefix: '<rootDir>'
|
|
31
|
+
})
|
|
11
32
|
};
|
|
12
33
|
|
|
13
34
|
export default config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quantform/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-beta.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Mateusz Majchrzak",
|
|
6
6
|
"description": "Node.js library for building systematic trading strategies in reactive way.",
|
|
@@ -17,27 +17,30 @@
|
|
|
17
17
|
"main": "dist/index.js",
|
|
18
18
|
"typings": "dist/index.d.ts",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@swc/cli": "^0.1.
|
|
21
|
-
"@swc/core": "^1.3.
|
|
20
|
+
"@swc/cli": "^0.1.62",
|
|
21
|
+
"@swc/core": "^1.3.44",
|
|
22
|
+
"@types/ws": "^8.5.4",
|
|
22
23
|
"chalk": "4.1.2",
|
|
23
|
-
"cli-progress": "^3.
|
|
24
|
-
"commander": "^
|
|
25
|
-
"decimal.js": "^10.4.
|
|
24
|
+
"cli-progress": "^3.12.0",
|
|
25
|
+
"commander": "^10.0.0",
|
|
26
|
+
"decimal.js": "^10.4.3",
|
|
26
27
|
"node-watch": "^0.7.3",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
28
|
+
"reflect-metadata": "^0.1.13",
|
|
29
|
+
"tsyringe": "^4.7.0",
|
|
30
|
+
"undici": "^5.21.0",
|
|
31
|
+
"ws": "^8.13.0"
|
|
29
32
|
},
|
|
30
33
|
"devDependencies": {
|
|
31
34
|
"@types/cli-progress": "^3.11.0",
|
|
32
35
|
"@types/tsc-watch": "^4.2.0",
|
|
33
|
-
"@types/uuid": "^
|
|
34
|
-
"rxjs": "^7.
|
|
36
|
+
"@types/uuid": "^9.0.1",
|
|
37
|
+
"rxjs": "^7.8.0"
|
|
35
38
|
},
|
|
36
39
|
"peerDependencies": {
|
|
37
40
|
"rxjs": "^7.5.6"
|
|
38
41
|
},
|
|
39
42
|
"scripts": {
|
|
40
|
-
"build": "tsc",
|
|
43
|
+
"build": "tsc && tsc-alias",
|
|
41
44
|
"test": "jest"
|
|
42
45
|
}
|
|
43
46
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Asset, assetOf, AssetSelector } from '@lib/component';
|
|
2
|
+
import { d } from '@lib/shared';
|
|
3
3
|
|
|
4
|
-
describe(
|
|
4
|
+
describe(Asset.name, () => {
|
|
5
5
|
test('should construct a new asset', () => {
|
|
6
6
|
const sut = new Asset('abc', 'xyz', 4);
|
|
7
7
|
|
|
@@ -27,7 +27,7 @@ describe('Asset', () => {
|
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
describe(
|
|
30
|
+
describe(AssetSelector.name, () => {
|
|
31
31
|
test('should construct a new asset selector from unified string', () => {
|
|
32
32
|
const sut = assetOf('xyz:abc');
|
|
33
33
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { InvalidArgumentsError, InvalidAssetSelectorError } from '@lib/component';
|
|
2
|
+
import { d, decimal } from '@lib/shared';
|
|
3
3
|
|
|
4
4
|
export const AssetSelectorSeparator = ':';
|
|
5
5
|
|
|
@@ -13,17 +13,21 @@ export class AssetSelector {
|
|
|
13
13
|
|
|
14
14
|
constructor(name: string, adapterName: string) {
|
|
15
15
|
if (!name?.length) {
|
|
16
|
-
throw
|
|
16
|
+
throw new InvalidArgumentsError({ name });
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
if (!adapterName?.length) {
|
|
20
|
-
throw
|
|
20
|
+
throw new InvalidArgumentsError({ adapterName });
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
this.name = name.toLowerCase();
|
|
24
24
|
this.adapterName = adapterName.toLowerCase();
|
|
25
25
|
this.id = `${this.adapterName}${AssetSelectorSeparator}${this.name}`;
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
toString() {
|
|
29
|
+
return this.id;
|
|
30
|
+
}
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
/**
|
|
@@ -33,7 +37,7 @@ export function assetOf(selector: string): AssetSelector {
|
|
|
33
37
|
const [adapterName, name, ...rest] = selector.split(AssetSelectorSeparator);
|
|
34
38
|
|
|
35
39
|
if (!adapterName || !name || rest.length) {
|
|
36
|
-
throw
|
|
40
|
+
throw new InvalidAssetSelectorError(selector);
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
return new AssetSelector(name, adapterName);
|
|
@@ -50,12 +54,19 @@ export class Asset extends AssetSelector {
|
|
|
50
54
|
super(name, adapterName);
|
|
51
55
|
|
|
52
56
|
if (scale && (scale < 0 || Number.isNaN(scale))) {
|
|
53
|
-
throw
|
|
57
|
+
throw new InvalidArgumentsError({ scale });
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
this.tickSize = d(1.0).div(Math.pow(10, this.scale));
|
|
57
61
|
}
|
|
58
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Formats a number to string with fixed number of decimal places.
|
|
65
|
+
*/
|
|
66
|
+
fixed(number: decimal): string {
|
|
67
|
+
return number.toFixed(this.scale);
|
|
68
|
+
}
|
|
69
|
+
|
|
59
70
|
/**
|
|
60
71
|
* Rounds down a number to the asset precision.
|
|
61
72
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@lib/asset/asset';
|
package/src/cli/build.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from 'child_process';
|
|
2
2
|
|
|
3
|
-
import { buildDirectory } from '
|
|
3
|
+
import { buildDirectory } from '@lib/cli/internal/workspace';
|
|
4
4
|
|
|
5
5
|
export default async function (): Promise<number> {
|
|
6
6
|
return new Promise<number>((resolve, reject) => {
|
package/src/cli/dev.ts
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
|
+
import { lastValueFrom } from 'rxjs';
|
|
2
3
|
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
4
|
+
import build from '@lib/cli/build';
|
|
5
|
+
import { buildDirectory } from '@lib/cli/internal/workspace';
|
|
6
|
+
import { core } from '@lib/core';
|
|
7
|
+
import { Module } from '@lib/module';
|
|
8
|
+
import { strat } from '@lib/strat';
|
|
9
|
+
import { paperExecutionMode } from '@lib/use-execution-mode';
|
|
8
10
|
|
|
9
11
|
export default async function (name: string, options: any) {
|
|
10
12
|
if (await build()) {
|
|
11
13
|
return;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
await import(join(buildDirectory(),
|
|
16
|
+
const script = (await import(join(buildDirectory(), name))).default as ReturnType<
|
|
17
|
+
typeof strat
|
|
18
|
+
>;
|
|
15
19
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
const module = new Module([
|
|
21
|
+
...core(),
|
|
22
|
+
...script.dependencies,
|
|
23
|
+
paperExecutionMode({ recording: false })
|
|
24
|
+
]);
|
|
19
25
|
|
|
20
|
-
const
|
|
26
|
+
const { act } = await module.awake();
|
|
21
27
|
|
|
22
|
-
const
|
|
23
|
-
await session.awake();
|
|
28
|
+
const output = await act(() => lastValueFrom(script.fn()));
|
|
24
29
|
|
|
25
|
-
|
|
30
|
+
console.log(output);
|
|
26
31
|
}
|
package/src/cli/index.ts
CHANGED
|
@@ -4,11 +4,11 @@ import { ChildProcess, spawn } from 'child_process';
|
|
|
4
4
|
import { program } from 'commander';
|
|
5
5
|
import watch from 'node-watch';
|
|
6
6
|
|
|
7
|
-
import build from '
|
|
8
|
-
import dev from '
|
|
9
|
-
import pull from '
|
|
10
|
-
import
|
|
11
|
-
import
|
|
7
|
+
import build from '@lib/cli/build';
|
|
8
|
+
import dev from '@lib/cli/dev';
|
|
9
|
+
import pull from '@lib/cli/pull';
|
|
10
|
+
import test from '@lib/cli/replay';
|
|
11
|
+
import run from '@lib/cli/run';
|
|
12
12
|
|
|
13
13
|
program
|
|
14
14
|
.command('build')
|
|
@@ -34,7 +34,7 @@ program
|
|
|
34
34
|
.action(dev);
|
|
35
35
|
|
|
36
36
|
program
|
|
37
|
-
.command('
|
|
37
|
+
.command('replay')
|
|
38
38
|
.description('executes strategy in backtesting mode for specified period')
|
|
39
39
|
.argument('<name>', 'strategy to execute')
|
|
40
40
|
.option('-f, --from <from>', 'date from')
|
|
@@ -70,7 +70,7 @@ if (process.argv.length < 3) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
child = spawn('node', argv, {
|
|
73
|
-
stdio:
|
|
73
|
+
stdio: 'pipe'
|
|
74
74
|
});
|
|
75
75
|
};
|
|
76
76
|
|
package/src/cli/pull.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { Presets, SingleBar } from 'cli-progress';
|
|
2
1
|
import { join } from 'path';
|
|
3
2
|
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
3
|
+
import build from '@lib/cli/build';
|
|
4
|
+
import { buildDirectory } from '@lib/cli/internal/workspace';
|
|
5
|
+
import { core } from '@lib/core';
|
|
6
|
+
import { Module } from '@lib/module';
|
|
7
|
+
import { strat } from '@lib/strat';
|
|
8
|
+
import { paperExecutionMode } from '@lib/use-execution-mode';
|
|
9
|
+
import { token } from '@lib/use-memo';
|
|
11
10
|
|
|
12
11
|
export default async function (name: string, instrument: string, options: any) {
|
|
13
12
|
if (await build()) {
|
|
@@ -15,7 +14,20 @@ export default async function (name: string, instrument: string, options: any) {
|
|
|
15
14
|
}
|
|
16
15
|
await import(join(buildDirectory(), 'index'));
|
|
17
16
|
|
|
18
|
-
const
|
|
17
|
+
const script = (await import(join(buildDirectory(), name))) as ReturnType<typeof strat>;
|
|
18
|
+
|
|
19
|
+
const module = new Module([
|
|
20
|
+
...core(),
|
|
21
|
+
...script.dependencies,
|
|
22
|
+
paperExecutionMode({ recording: false })
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
const { act } = await module.awake();
|
|
26
|
+
|
|
27
|
+
const o = await act(() => script.fn());
|
|
28
|
+
console.log(module.get<any>(token));
|
|
29
|
+
|
|
30
|
+
/*const builder = new SessionBuilder().useSessionId(
|
|
19
31
|
options.id ? Number(options.id) : now()
|
|
20
32
|
);
|
|
21
33
|
|
|
@@ -59,5 +71,5 @@ export default async function (name: string, instrument: string, options: any) {
|
|
|
59
71
|
|
|
60
72
|
await session.dispose();
|
|
61
73
|
|
|
62
|
-
console.timeLog('Pulling completed in')
|
|
74
|
+
console.timeLog('Pulling completed in');*/
|
|
63
75
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import { lastValueFrom } from 'rxjs';
|
|
3
|
+
|
|
4
|
+
import build from '@lib/cli/build';
|
|
5
|
+
import { buildDirectory } from '@lib/cli/internal/workspace';
|
|
6
|
+
import { core } from '@lib/core';
|
|
7
|
+
import { Dependency, Module } from '@lib/module';
|
|
8
|
+
import { replayOptions } from '@lib/replay';
|
|
9
|
+
import { replayExecutionMode } from '@lib/use-execution-mode';
|
|
10
|
+
|
|
11
|
+
export default async function (name: string, options: any) {
|
|
12
|
+
if (await build()) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const script = await import(join(buildDirectory(), name));
|
|
17
|
+
const dependencies = script.module2 as Dependency[];
|
|
18
|
+
|
|
19
|
+
const module = new Module([
|
|
20
|
+
...core(),
|
|
21
|
+
...dependencies,
|
|
22
|
+
replayOptions({ from: 0, to: Number.MAX_VALUE }),
|
|
23
|
+
replayExecutionMode()
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
const { act } = await module.awake();
|
|
27
|
+
|
|
28
|
+
const output = await act(() => lastValueFrom(script.default(options)));
|
|
29
|
+
|
|
30
|
+
console.log(output);
|
|
31
|
+
}
|