@quantform/core 0.7.22 → 0.7.25
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/lib/app.d.ts +12 -0
- package/lib/app.d.ts.map +1 -0
- package/lib/app.js +35 -0
- package/lib/cli/build.d.ts.map +1 -1
- package/lib/cli/build.js +8 -18
- package/lib/cli/index.js +3 -12
- package/lib/cli/internal/script.d.ts +1 -1
- package/lib/cli/internal/script.d.ts.map +1 -1
- package/lib/cli/internal/script.js +8 -28
- package/lib/cli/live.js +10 -22
- package/lib/cli/paper.js +10 -22
- package/lib/cli/replay.d.ts.map +1 -1
- package/lib/cli/replay.js +15 -26
- package/lib/index.d.ts +1 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -6
- package/lib/make-test-module.d.ts +1 -6
- package/lib/make-test-module.d.ts.map +1 -1
- package/lib/make-test-module.js +19 -30
- package/lib/module.d.ts.map +1 -1
- package/lib/module.js +9 -24
- package/lib/module.spec.js +8 -17
- package/lib/replay/use-replay-options.d.ts +5 -4
- package/lib/replay/use-replay-options.d.ts.map +1 -1
- package/lib/replay/use-replay-options.js +5 -1
- package/lib/replay/use-replay-scheduler.d.ts +7 -6
- package/lib/replay/use-replay-scheduler.d.ts.map +1 -1
- package/lib/replay/use-replay-scheduler.js +64 -70
- package/lib/replay/use-replay-storage-buffer.d.ts +3 -2
- package/lib/replay/use-replay-storage-buffer.d.ts.map +1 -1
- package/lib/replay/use-replay-storage-buffer.js +12 -23
- package/lib/replay/use-replay-storage-cursor.d.ts +9 -8
- package/lib/replay/use-replay-storage-cursor.d.ts.map +1 -1
- package/lib/replay/use-replay-storage-cursor.js +17 -25
- package/lib/replay/use-replay-storage.d.ts +5 -4
- package/lib/replay/use-replay-storage.d.ts.map +1 -1
- package/lib/replay/use-replay-storage.js +32 -39
- package/lib/session/use-session-storage.d.ts +1 -1
- package/lib/session/use-session-storage.d.ts.map +1 -1
- package/lib/session/use-session-storage.js +8 -5
- package/lib/shared/environment.js +1 -1
- package/lib/shared/index.d.ts +0 -1
- package/lib/shared/index.d.ts.map +1 -1
- package/lib/shared/index.js +0 -1
- package/lib/simulator/use-simulator.spec.js +17 -30
- package/lib/storage/in-memory/in-memory-storage.d.ts.map +1 -1
- package/lib/storage/in-memory/in-memory-storage.factory.js +2 -2
- package/lib/storage/in-memory/in-memory-storage.js +56 -55
- package/lib/storage/in-memory/in-memory-storage.spec.js +90 -100
- package/lib/storage/storage.d.ts +9 -8
- package/lib/storage/storage.d.ts.map +1 -1
- package/lib/storage/storage.js +8 -2
- package/lib/storage/use-cache.d.ts +1 -1
- package/lib/storage/use-cache.d.ts.map +1 -1
- package/lib/storage/use-cache.js +5 -5
- package/lib/storage/use-cache.spec.js +14 -25
- package/lib/storage/use-storage.d.ts +1 -1
- package/lib/storage/use-storage.d.ts.map +1 -1
- package/lib/storage/use-storage.js +9 -6
- package/lib/use-execution-mode.js +2 -2
- package/lib/use-hash.spec.js +3 -6
- package/lib/use-logger.d.ts +1 -1
- package/lib/use-logger.d.ts.map +1 -1
- package/lib/use-logger.js +10 -7
- package/lib/use-memo.spec.js +14 -25
- package/lib/use-socket.d.ts +3 -2
- package/lib/use-socket.d.ts.map +1 -1
- package/lib/use-socket.js +2 -2
- package/lib/use-timestamp.d.ts +14 -1
- package/lib/use-timestamp.d.ts.map +1 -1
- package/lib/use-timestamp.js +30 -3
- package/lib/with-request.d.ts +2 -1
- package/lib/with-request.d.ts.map +1 -1
- package/lib/with-request.js +4 -13
- package/package.json +6 -10
- package/src/app.ts +52 -0
- package/src/cli/build.ts +11 -6
- package/src/cli/internal/script.ts +25 -54
- package/src/cli/replay.ts +13 -2
- package/src/index.ts +1 -6
- package/src/make-test-module.ts +13 -21
- package/src/module.ts +0 -3
- package/src/replay/use-replay-options.ts +7 -3
- package/src/replay/use-replay-scheduler.ts +75 -67
- package/src/replay/use-replay-storage-buffer.ts +2 -1
- package/src/replay/use-replay-storage-cursor.ts +33 -28
- package/src/replay/use-replay-storage.ts +36 -27
- package/src/session/use-session-storage.ts +7 -5
- package/src/shared/index.ts +0 -1
- package/src/storage/in-memory/in-memory-storage.spec.ts +55 -54
- package/src/storage/in-memory/in-memory-storage.ts +24 -7
- package/src/storage/storage.ts +16 -7
- package/src/storage/use-cache.ts +4 -4
- package/src/storage/use-storage.ts +8 -6
- package/src/use-hash.spec.ts +3 -6
- package/src/use-logger.ts +9 -6
- package/src/use-socket.ts +5 -5
- package/src/use-timestamp.ts +41 -3
- package/src/with-request.ts +3 -3
- package/lib/asset/asset.d.ts +0 -41
- package/lib/asset/asset.d.ts.map +0 -1
- package/lib/asset/asset.js +0 -76
- package/lib/asset/asset.spec.d.ts +0 -2
- package/lib/asset/asset.spec.d.ts.map +0 -1
- package/lib/asset/asset.spec.js +0 -54
- package/lib/asset/index.d.ts +0 -2
- package/lib/asset/index.d.ts.map +0 -1
- package/lib/asset/index.js +0 -17
- package/lib/component/distinct-until-timesamp-changed.d.ts +0 -5
- package/lib/component/distinct-until-timesamp-changed.d.ts.map +0 -1
- package/lib/component/distinct-until-timesamp-changed.js +0 -9
- package/lib/component/error.d.ts +0 -17
- package/lib/component/error.d.ts.map +0 -1
- package/lib/component/error.js +0 -33
- package/lib/component/index.d.ts +0 -8
- package/lib/component/index.d.ts.map +0 -1
- package/lib/component/index.js +0 -23
- package/lib/component/ohlc-operator.d.ts +0 -11
- package/lib/component/ohlc-operator.d.ts.map +0 -1
- package/lib/component/ohlc-operator.js +0 -69
- package/lib/component/ohlc-operator.spec.d.ts +0 -2
- package/lib/component/ohlc-operator.spec.d.ts.map +0 -1
- package/lib/component/ohlc-operator.spec.js +0 -110
- package/lib/component/ohlc.d.ts +0 -12
- package/lib/component/ohlc.d.ts.map +0 -1
- package/lib/component/ohlc.js +0 -20
- package/lib/component/ohlc.spec.d.ts +0 -2
- package/lib/component/ohlc.spec.d.ts.map +0 -1
- package/lib/component/ohlc.spec.js +0 -25
- package/lib/component/timeframe.d.ts +0 -15
- package/lib/component/timeframe.d.ts.map +0 -1
- package/lib/component/timeframe.js +0 -21
- package/lib/core.d.ts +0 -3
- package/lib/core.d.ts.map +0 -1
- package/lib/core.js +0 -17
- package/lib/instrument/commission/commission.d.ts +0 -16
- package/lib/instrument/commission/commission.d.ts.map +0 -1
- package/lib/instrument/commission/commission.js +0 -28
- package/lib/instrument/commission/commission.spec.d.ts +0 -2
- package/lib/instrument/commission/commission.spec.d.ts.map +0 -1
- package/lib/instrument/commission/commission.spec.js +0 -30
- package/lib/instrument/index.d.ts +0 -3
- package/lib/instrument/index.d.ts.map +0 -1
- package/lib/instrument/index.js +0 -18
- package/lib/instrument/instrument.d.ts +0 -28
- package/lib/instrument/instrument.d.ts.map +0 -1
- package/lib/instrument/instrument.js +0 -53
- package/lib/instrument/instrument.spec.d.ts +0 -2
- package/lib/instrument/instrument.spec.d.ts.map +0 -1
- package/lib/instrument/instrument.spec.js +0 -51
- package/lib/operators.d.ts +0 -5
- package/lib/operators.d.ts.map +0 -1
- package/lib/operators.js +0 -16
- package/lib/shared/datetime.d.ts +0 -3
- package/lib/shared/datetime.d.ts.map +0 -1
- package/lib/shared/datetime.js +0 -7
- package/lib/strategy.d.ts +0 -15
- package/lib/strategy.d.ts.map +0 -1
- package/lib/strategy.js +0 -26
- package/lib/strategy.spec.d.ts +0 -2
- package/lib/strategy.spec.d.ts.map +0 -1
- package/lib/strategy.spec.js +0 -34
- package/lib/when-socket.d.ts +0 -8
- package/lib/when-socket.d.ts.map +0 -1
- package/lib/when-socket.js +0 -53
- package/lib/with-memo.d.ts +0 -5
- package/lib/with-memo.d.ts.map +0 -1
- package/lib/with-memo.js +0 -20
- package/lib/with-memo.spec.d.ts +0 -2
- package/lib/with-memo.spec.d.ts.map +0 -1
- package/lib/with-memo.spec.js +0 -47
- package/src/asset/asset.spec.ts +0 -70
- package/src/asset/asset.ts +0 -89
- package/src/asset/index.ts +0 -1
- package/src/component/distinct-until-timesamp-changed.ts +0 -11
- package/src/component/error.ts +0 -32
- package/src/component/index.ts +0 -7
- package/src/component/ohlc-operator.spec.ts +0 -125
- package/src/component/ohlc-operator.ts +0 -122
- package/src/component/ohlc.spec.ts +0 -30
- package/src/component/ohlc.ts +0 -18
- package/src/component/timeframe.ts +0 -17
- package/src/core.ts +0 -16
- package/src/instrument/commission/commission.spec.ts +0 -35
- package/src/instrument/commission/commission.ts +0 -27
- package/src/instrument/index.ts +0 -2
- package/src/instrument/instrument.spec.ts +0 -76
- package/src/instrument/instrument.ts +0 -65
- package/src/operators.ts +0 -18
- package/src/shared/datetime.ts +0 -5
- package/src/strategy.spec.ts +0 -42
- package/src/strategy.ts +0 -36
- package/src/when-socket.ts +0 -61
- package/src/with-memo.spec.ts +0 -46
- package/src/with-memo.ts +0 -33
package/lib/asset/asset.spec.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const component_1 = require("../component");
|
|
4
|
-
const shared_1 = require("../shared");
|
|
5
|
-
describe(component_1.Asset.name, () => {
|
|
6
|
-
test('should construct a new asset', () => {
|
|
7
|
-
const sut = new component_1.Asset('abc', 'xyz', 4);
|
|
8
|
-
expect(sut.name).toEqual('abc');
|
|
9
|
-
expect(sut.adapterName).toEqual('xyz');
|
|
10
|
-
expect(sut.scale).toEqual(4);
|
|
11
|
-
expect(sut.tickSize).toEqual((0, shared_1.d)(0.0001));
|
|
12
|
-
expect(sut.floor((0, shared_1.d)(1.1234567))).toEqual((0, shared_1.d)(1.1234));
|
|
13
|
-
expect(sut.ceil((0, shared_1.d)(1.1234567))).toEqual((0, shared_1.d)(1.1235));
|
|
14
|
-
expect(sut.id).toEqual('xyz:abc');
|
|
15
|
-
});
|
|
16
|
-
test('should throw for missing asset name', () => {
|
|
17
|
-
const fn = () => new component_1.Asset('xyz', '', 5);
|
|
18
|
-
expect(fn).toThrowError();
|
|
19
|
-
});
|
|
20
|
-
test('should throw for missing adapter name', () => {
|
|
21
|
-
const fn = () => new component_1.Asset('', 'xyz', 5);
|
|
22
|
-
expect(fn).toThrowError();
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
describe(component_1.AssetSelector.name, () => {
|
|
26
|
-
test('should construct a new asset selector from unified string', () => {
|
|
27
|
-
const sut = (0, component_1.assetOf)('xyz:abc');
|
|
28
|
-
expect(sut.name).toEqual('abc');
|
|
29
|
-
expect(sut.adapterName).toEqual('xyz');
|
|
30
|
-
expect(sut.id).toEqual('xyz:abc');
|
|
31
|
-
});
|
|
32
|
-
test('should instantiate proper asset selector capital case', () => {
|
|
33
|
-
const sut = (0, component_1.assetOf)('XYZ:ABC');
|
|
34
|
-
expect(sut.name).toEqual('abc');
|
|
35
|
-
expect(sut.adapterName).toEqual('xyz');
|
|
36
|
-
expect(sut.id).toEqual('xyz:abc');
|
|
37
|
-
});
|
|
38
|
-
test('should throw invalid format message for missing separator', () => {
|
|
39
|
-
const fn = () => (0, component_1.assetOf)('xyzabc');
|
|
40
|
-
expect(fn).toThrowError();
|
|
41
|
-
});
|
|
42
|
-
test('should throw for multiple separators', () => {
|
|
43
|
-
const fn = () => (0, component_1.assetOf)('xyz:abc:');
|
|
44
|
-
expect(fn).toThrowError();
|
|
45
|
-
});
|
|
46
|
-
test('should throw for missing asset name', () => {
|
|
47
|
-
const fn = () => (0, component_1.assetOf)('xyz:');
|
|
48
|
-
expect(fn).toThrowError();
|
|
49
|
-
});
|
|
50
|
-
test('should throw for missing adapter name', () => {
|
|
51
|
-
const fn = () => (0, component_1.assetOf)(':abc');
|
|
52
|
-
expect(fn).toThrowError();
|
|
53
|
-
});
|
|
54
|
-
});
|
package/lib/asset/index.d.ts
DELETED
package/lib/asset/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/asset/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
package/lib/asset/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("../asset/asset"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"distinct-until-timesamp-changed.d.ts","sourceRoot":"","sources":["../../src/component/distinct-until-timesamp-changed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,UAAU,EAAO,MAAM,MAAM,CAAC;AAE/C,wBAAgB,6BAA6B,CAAC,CAAC,SAAS;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,cAG3D,WAAW,CAAC,CAAC,mBAK9B"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.distinctUntilTimestampChanged = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
function distinctUntilTimestampChanged() {
|
|
6
|
-
let prevTimestamp;
|
|
7
|
-
return (stream) => stream.pipe((0, rxjs_1.filter)(it => prevTimestamp === undefined || it.timestamp > prevTimestamp), (0, rxjs_1.tap)(it => (prevTimestamp = it.timestamp)));
|
|
8
|
-
}
|
|
9
|
-
exports.distinctUntilTimestampChanged = distinctUntilTimestampChanged;
|
package/lib/component/error.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { decimal } from '../shared';
|
|
2
|
-
export declare class InsufficientFundsError extends Error {
|
|
3
|
-
constructor(assetName: string, requiredAmount: decimal, availableAmount: decimal);
|
|
4
|
-
}
|
|
5
|
-
export declare class InvalidArgumentsError extends Error {
|
|
6
|
-
constructor(argName: Record<string, unknown>);
|
|
7
|
-
}
|
|
8
|
-
export declare class InvalidAssetSelectorError extends Error {
|
|
9
|
-
constructor(selector: string);
|
|
10
|
-
}
|
|
11
|
-
export declare class InvalidInstrumentSelectorError extends Error {
|
|
12
|
-
constructor(selector: string);
|
|
13
|
-
}
|
|
14
|
-
export declare class AdapterMismatchError extends Error {
|
|
15
|
-
constructor();
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=error.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/component/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO;CAKjF;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAG7C;AAED,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,QAAQ,EAAE,MAAM;CAG7B;AACD,qBAAa,8BAA+B,SAAQ,KAAK;gBAC3C,QAAQ,EAAE,MAAM;CAG7B;AAED,qBAAa,oBAAqB,SAAQ,KAAK;;CAI9C"}
|
package/lib/component/error.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AdapterMismatchError = exports.InvalidInstrumentSelectorError = exports.InvalidAssetSelectorError = exports.InvalidArgumentsError = exports.InsufficientFundsError = void 0;
|
|
4
|
-
class InsufficientFundsError extends Error {
|
|
5
|
-
constructor(assetName, requiredAmount, availableAmount) {
|
|
6
|
-
super(`insufficient funds of ${assetName} has: ${availableAmount.toString()} requires: ${requiredAmount.toString()}`);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
exports.InsufficientFundsError = InsufficientFundsError;
|
|
10
|
-
class InvalidArgumentsError extends Error {
|
|
11
|
-
constructor(argName) {
|
|
12
|
-
super(`invalid arguments: ${argName}`);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.InvalidArgumentsError = InvalidArgumentsError;
|
|
16
|
-
class InvalidAssetSelectorError extends Error {
|
|
17
|
-
constructor(selector) {
|
|
18
|
-
super(`invalid asset selector: ${selector}`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.InvalidAssetSelectorError = InvalidAssetSelectorError;
|
|
22
|
-
class InvalidInstrumentSelectorError extends Error {
|
|
23
|
-
constructor(selector) {
|
|
24
|
-
super(`invalid instrument selector: ${selector}`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.InvalidInstrumentSelectorError = InvalidInstrumentSelectorError;
|
|
28
|
-
class AdapterMismatchError extends Error {
|
|
29
|
-
constructor() {
|
|
30
|
-
super('adapters must be the same');
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.AdapterMismatchError = AdapterMismatchError;
|
package/lib/component/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from '../asset';
|
|
2
|
-
export * from '../component/error';
|
|
3
|
-
export * from '../component/ohlc';
|
|
4
|
-
export * from '../component/ohlc-operator';
|
|
5
|
-
export * from '../instrument';
|
|
6
|
-
export * from '../component/timeframe';
|
|
7
|
-
export * from '../component/distinct-until-timesamp-changed';
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/component/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gDAAgD,CAAC"}
|
package/lib/component/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("../asset"), exports);
|
|
18
|
-
__exportStar(require("../component/error"), exports);
|
|
19
|
-
__exportStar(require("../component/ohlc"), exports);
|
|
20
|
-
__exportStar(require("../component/ohlc-operator"), exports);
|
|
21
|
-
__exportStar(require("../instrument"), exports);
|
|
22
|
-
__exportStar(require("../component/timeframe"), exports);
|
|
23
|
-
__exportStar(require("../component/distinct-until-timesamp-changed"), exports);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { Ohlc } from '../component';
|
|
3
|
-
import { decimal } from '../shared';
|
|
4
|
-
export declare function ohlc<T extends {
|
|
5
|
-
timestamp: number;
|
|
6
|
-
}>(timeframe: number, fn: (x: T) => decimal, candleToStartWith?: Ohlc): (source: Observable<T>) => Observable<Ohlc>;
|
|
7
|
-
export declare function mergeOhlc<T extends {
|
|
8
|
-
timestamp: number;
|
|
9
|
-
}>(timeframe: number, fn: (x: T) => decimal, history$: Observable<Ohlc>): (source$: Observable<T>) => Observable<Ohlc>;
|
|
10
|
-
export declare function ohlcCompleted(): (source: Observable<Ohlc>) => Observable<Ohlc>;
|
|
11
|
-
//# sourceMappingURL=ohlc-operator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ohlc-operator.d.ts","sourceRoot":"","sources":["../../src/component/ohlc-operator.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,UAAU,EAKX,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,IAAI,EAAM,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAsBtC,wBAAgB,IAAI,CAAC,CAAC,SAAS;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,EAClD,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,EACrB,iBAAiB,CAAC,EAAE,IAAI,YAEC,WAAW,CAAC,CAAC,KAAG,WAAW,IAAI,CAAC,CAmC1D;AAED,wBAAgB,SAAS,CAAC,CAAC,SAAS;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,EACvD,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,EACrB,QAAQ,EAAE,UAAU,CAAC,IAAI,CAAC,aAEA,WAAW,CAAC,CAAC,KAAG,WAAW,IAAI,CAAC,CAY3D;AAED,wBAAgB,aAAa,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,KAAK,UAAU,CAAC,IAAI,CAAC,CAwB9E"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ohlcCompleted = exports.mergeOhlc = exports.ohlc = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const component_1 = require("../component");
|
|
6
|
-
function aggregate(candle, timeframe, value, timestamp) {
|
|
7
|
-
const frame = (0, component_1.tf)(timestamp, timeframe);
|
|
8
|
-
if (!candle) {
|
|
9
|
-
return new component_1.Ohlc(frame, value, value, value, value);
|
|
10
|
-
}
|
|
11
|
-
if (candle.timestamp === frame) {
|
|
12
|
-
candle.apply(value);
|
|
13
|
-
return undefined;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
return new component_1.Ohlc(frame, candle.close, value, value, value);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function ohlc(timeframe, fn, candleToStartWith) {
|
|
20
|
-
return function (source) {
|
|
21
|
-
let candle = candleToStartWith;
|
|
22
|
-
return source.pipe((0, rxjs_1.map)(it => {
|
|
23
|
-
const newCandle = aggregate(candle, timeframe, fn(it), it.timestamp);
|
|
24
|
-
if (newCandle) {
|
|
25
|
-
const prevCandle = candle;
|
|
26
|
-
candle = newCandle;
|
|
27
|
-
if (candleToStartWith && candleToStartWith.timestamp < newCandle.timestamp) {
|
|
28
|
-
candleToStartWith = undefined;
|
|
29
|
-
if (prevCandle) {
|
|
30
|
-
return [prevCandle, candle];
|
|
31
|
-
}
|
|
32
|
-
return [candle];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (candleToStartWith) {
|
|
36
|
-
candleToStartWith = undefined;
|
|
37
|
-
}
|
|
38
|
-
if (candle) {
|
|
39
|
-
return [candle];
|
|
40
|
-
}
|
|
41
|
-
return [];
|
|
42
|
-
}), (0, rxjs_1.mergeMap)(it => it), (0, rxjs_1.share)());
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
exports.ohlc = ohlc;
|
|
46
|
-
function mergeOhlc(timeframe, fn, history$) {
|
|
47
|
-
return function (source$) {
|
|
48
|
-
return (0, rxjs_1.concat)(history$.pipe((0, rxjs_1.skipLast)(1)), history$.pipe((0, rxjs_1.last)(), (0, rxjs_1.switchMap)(lastHistoricalCandle => source$.pipe(ohlc(timeframe, fn, lastHistoricalCandle))), (0, rxjs_1.share)()));
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
exports.mergeOhlc = mergeOhlc;
|
|
52
|
-
function ohlcCompleted() {
|
|
53
|
-
let currCandle;
|
|
54
|
-
return (source) => source.pipe((0, rxjs_1.map)(it => {
|
|
55
|
-
if (!currCandle) {
|
|
56
|
-
currCandle = it;
|
|
57
|
-
return undefined;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
if (currCandle.timestamp !== it.timestamp) {
|
|
61
|
-
const prevCandle = currCandle;
|
|
62
|
-
currCandle = it;
|
|
63
|
-
return prevCandle;
|
|
64
|
-
}
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
}), (0, rxjs_1.filter)(it => it !== undefined), (0, rxjs_1.share)());
|
|
68
|
-
}
|
|
69
|
-
exports.ohlcCompleted = ohlcCompleted;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ohlc-operator.spec.d.ts","sourceRoot":"","sources":["../../src/component/ohlc-operator.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const rxjs_1 = require("rxjs");
|
|
4
|
-
const component_1 = require("../component");
|
|
5
|
-
const shared_1 = require("../shared");
|
|
6
|
-
describe(component_1.ohlc.name, () => {
|
|
7
|
-
test('should aggregate and pipe ohlc updates', done => {
|
|
8
|
-
const input$ = (0, rxjs_1.from)([
|
|
9
|
-
{ timestamp: 1, rate: (0, shared_1.d)(1) },
|
|
10
|
-
{ timestamp: 2, rate: (0, shared_1.d)(2) },
|
|
11
|
-
{ timestamp: 3, rate: (0, shared_1.d)(3) },
|
|
12
|
-
{ timestamp: 4, rate: shared_1.d.Zero },
|
|
13
|
-
{ timestamp: 5, rate: (0, shared_1.d)(7) },
|
|
14
|
-
{ timestamp: 6, rate: (0, shared_1.d)(8) }
|
|
15
|
-
]);
|
|
16
|
-
const output = [
|
|
17
|
-
new component_1.Ohlc(0, (0, shared_1.d)(1), (0, shared_1.d)(1), (0, shared_1.d)(1), (0, shared_1.d)(1)),
|
|
18
|
-
new component_1.Ohlc(0, (0, shared_1.d)(1), (0, shared_1.d)(2), (0, shared_1.d)(1), (0, shared_1.d)(2)),
|
|
19
|
-
new component_1.Ohlc(0, (0, shared_1.d)(1), (0, shared_1.d)(3), (0, shared_1.d)(1), (0, shared_1.d)(3)),
|
|
20
|
-
new component_1.Ohlc(0, (0, shared_1.d)(1), (0, shared_1.d)(3), shared_1.d.Zero, shared_1.d.Zero),
|
|
21
|
-
new component_1.Ohlc(5, shared_1.d.Zero, (0, shared_1.d)(7), (0, shared_1.d)(7), (0, shared_1.d)(7)),
|
|
22
|
-
new component_1.Ohlc(5, shared_1.d.Zero, (0, shared_1.d)(8), (0, shared_1.d)(7), (0, shared_1.d)(8))
|
|
23
|
-
].reverse();
|
|
24
|
-
input$.pipe((0, component_1.ohlc)(5, it => it.rate)).subscribe({
|
|
25
|
-
next: it => {
|
|
26
|
-
expect(it).toEqual(output.pop());
|
|
27
|
-
if (output.length === 0) {
|
|
28
|
-
done();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
describe(component_1.ohlcCompleted.name, () => {
|
|
35
|
-
test('should aggregate and pipe distinct completed ohlc', done => {
|
|
36
|
-
const input$ = (0, rxjs_1.from)([
|
|
37
|
-
{ timestamp: 1, rate: (0, shared_1.d)(1) },
|
|
38
|
-
{ timestamp: 2, rate: (0, shared_1.d)(2) },
|
|
39
|
-
{ timestamp: 3, rate: (0, shared_1.d)(3) },
|
|
40
|
-
{ timestamp: 4, rate: shared_1.d.Zero },
|
|
41
|
-
{ timestamp: 5, rate: (0, shared_1.d)(7) },
|
|
42
|
-
{ timestamp: 6, rate: (0, shared_1.d)(8) }
|
|
43
|
-
]);
|
|
44
|
-
input$
|
|
45
|
-
.pipe((0, component_1.ohlc)(5, it => it.rate), (0, component_1.ohlcCompleted)())
|
|
46
|
-
.subscribe({
|
|
47
|
-
next: it => {
|
|
48
|
-
expect(it).toEqual(new component_1.Ohlc(0, (0, shared_1.d)(1), (0, shared_1.d)(3), shared_1.d.Zero, shared_1.d.Zero));
|
|
49
|
-
done();
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
describe(component_1.mergeOhlc.name, () => {
|
|
55
|
-
test('should pipe and merge ohlc from history', done => {
|
|
56
|
-
const history$ = (0, rxjs_1.from)([
|
|
57
|
-
new component_1.Ohlc(1, (0, shared_1.d)(1), (0, shared_1.d)(1.5), (0, shared_1.d)(0.5), (0, shared_1.d)(2)),
|
|
58
|
-
new component_1.Ohlc(2, (0, shared_1.d)(2), (0, shared_1.d)(2.5), (0, shared_1.d)(1.5), (0, shared_1.d)(3)),
|
|
59
|
-
new component_1.Ohlc(3, (0, shared_1.d)(3), (0, shared_1.d)(3.5), (0, shared_1.d)(2.5), (0, shared_1.d)(4))
|
|
60
|
-
]);
|
|
61
|
-
const input$ = (0, rxjs_1.from)([
|
|
62
|
-
{ timestamp: 3, rate: (0, shared_1.d)(5) },
|
|
63
|
-
{ timestamp: 4, rate: (0, shared_1.d)(3) },
|
|
64
|
-
{ timestamp: 5, rate: (0, shared_1.d)(4) }
|
|
65
|
-
]);
|
|
66
|
-
const output = [
|
|
67
|
-
new component_1.Ohlc(1, (0, shared_1.d)(1), (0, shared_1.d)(1.5), (0, shared_1.d)(0.5), (0, shared_1.d)(2)),
|
|
68
|
-
new component_1.Ohlc(2, (0, shared_1.d)(2), (0, shared_1.d)(2.5), (0, shared_1.d)(1.5), (0, shared_1.d)(3)),
|
|
69
|
-
new component_1.Ohlc(3, (0, shared_1.d)(3), (0, shared_1.d)(5), (0, shared_1.d)(2.5), (0, shared_1.d)(5)),
|
|
70
|
-
new component_1.Ohlc(4, (0, shared_1.d)(5), (0, shared_1.d)(3), (0, shared_1.d)(3), (0, shared_1.d)(3)),
|
|
71
|
-
new component_1.Ohlc(5, (0, shared_1.d)(3), (0, shared_1.d)(4), (0, shared_1.d)(4), (0, shared_1.d)(4))
|
|
72
|
-
].reverse();
|
|
73
|
-
input$.pipe((0, component_1.mergeOhlc)(1, it => it.rate, history$)).subscribe({
|
|
74
|
-
next: it => {
|
|
75
|
-
expect(it).toEqual(output.pop());
|
|
76
|
-
if (output.length === 0) {
|
|
77
|
-
done();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
test('should pipe and not merge ohlc from history', done => {
|
|
83
|
-
const history$ = (0, rxjs_1.from)([
|
|
84
|
-
new component_1.Ohlc(1, (0, shared_1.d)(1), (0, shared_1.d)(1.5), (0, shared_1.d)(0.5), (0, shared_1.d)(2)),
|
|
85
|
-
new component_1.Ohlc(2, (0, shared_1.d)(2), (0, shared_1.d)(2.5), (0, shared_1.d)(1.5), (0, shared_1.d)(3)),
|
|
86
|
-
new component_1.Ohlc(3, (0, shared_1.d)(3), (0, shared_1.d)(3.5), (0, shared_1.d)(2.5), (0, shared_1.d)(4))
|
|
87
|
-
]);
|
|
88
|
-
const input$ = (0, rxjs_1.from)([
|
|
89
|
-
{ timestamp: 4, rate: (0, shared_1.d)(5) },
|
|
90
|
-
{ timestamp: 5, rate: (0, shared_1.d)(3) },
|
|
91
|
-
{ timestamp: 6, rate: (0, shared_1.d)(4) }
|
|
92
|
-
]);
|
|
93
|
-
const output = [
|
|
94
|
-
new component_1.Ohlc(1, (0, shared_1.d)(1), (0, shared_1.d)(1.5), (0, shared_1.d)(0.5), (0, shared_1.d)(2)),
|
|
95
|
-
new component_1.Ohlc(2, (0, shared_1.d)(2), (0, shared_1.d)(2.5), (0, shared_1.d)(1.5), (0, shared_1.d)(3)),
|
|
96
|
-
new component_1.Ohlc(3, (0, shared_1.d)(3), (0, shared_1.d)(3.5), (0, shared_1.d)(2.5), (0, shared_1.d)(4)),
|
|
97
|
-
new component_1.Ohlc(4, (0, shared_1.d)(4), (0, shared_1.d)(5), (0, shared_1.d)(5), (0, shared_1.d)(5)),
|
|
98
|
-
new component_1.Ohlc(5, (0, shared_1.d)(5), (0, shared_1.d)(3), (0, shared_1.d)(3), (0, shared_1.d)(3)),
|
|
99
|
-
new component_1.Ohlc(6, (0, shared_1.d)(3), (0, shared_1.d)(4), (0, shared_1.d)(4), (0, shared_1.d)(4))
|
|
100
|
-
].reverse();
|
|
101
|
-
input$.pipe((0, component_1.mergeOhlc)(1, it => it.rate, history$)).subscribe({
|
|
102
|
-
next: it => {
|
|
103
|
-
expect(it).toEqual(output.pop());
|
|
104
|
-
if (output.length === 0) {
|
|
105
|
-
done();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
});
|
package/lib/component/ohlc.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { decimal, timestamp } from '../shared';
|
|
2
|
-
export declare class Ohlc {
|
|
3
|
-
timestamp: timestamp;
|
|
4
|
-
open: decimal;
|
|
5
|
-
high: decimal;
|
|
6
|
-
low: decimal;
|
|
7
|
-
close: decimal;
|
|
8
|
-
volume?: decimal | undefined;
|
|
9
|
-
constructor(timestamp: timestamp, open: decimal, high: decimal, low: decimal, close: decimal, volume?: decimal | undefined);
|
|
10
|
-
apply(value: decimal): void;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=ohlc.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ohlc.d.ts","sourceRoot":"","sources":["../../src/component/ohlc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEjD,qBAAa,IAAI;IAEN,SAAS,EAAE,SAAS;IACpB,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,OAAO;IACb,GAAG,EAAE,OAAO;IACZ,KAAK,EAAE,OAAO;IACd,MAAM,CAAC;gBALP,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,OAAO,EACd,MAAM,CAAC,qBAAS;IAGzB,KAAK,CAAC,KAAK,EAAE,OAAO;CAKrB"}
|
package/lib/component/ohlc.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Ohlc = void 0;
|
|
4
|
-
const shared_1 = require("../shared");
|
|
5
|
-
class Ohlc {
|
|
6
|
-
constructor(timestamp, open, high, low, close, volume) {
|
|
7
|
-
this.timestamp = timestamp;
|
|
8
|
-
this.open = open;
|
|
9
|
-
this.high = high;
|
|
10
|
-
this.low = low;
|
|
11
|
-
this.close = close;
|
|
12
|
-
this.volume = volume;
|
|
13
|
-
}
|
|
14
|
-
apply(value) {
|
|
15
|
-
this.high = shared_1.decimal.max(this.high, value);
|
|
16
|
-
this.low = shared_1.decimal.min(this.low, value);
|
|
17
|
-
this.close = value;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.Ohlc = Ohlc;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ohlc.spec.d.ts","sourceRoot":"","sources":["../../src/component/ohlc.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const component_1 = require("../component");
|
|
4
|
-
const shared_1 = require("../shared");
|
|
5
|
-
describe('Ohlc', () => {
|
|
6
|
-
test('should construct a ohlc', () => {
|
|
7
|
-
const timestamp = (0, shared_1.now)();
|
|
8
|
-
const sut = new component_1.Ohlc(timestamp, (0, shared_1.d)(2), (0, shared_1.d)(4), (0, shared_1.d)(1), (0, shared_1.d)(3));
|
|
9
|
-
expect(sut.timestamp).toEqual(timestamp);
|
|
10
|
-
expect(sut.open).toEqual((0, shared_1.d)(2));
|
|
11
|
-
expect(sut.high).toEqual((0, shared_1.d)(4));
|
|
12
|
-
expect(sut.low).toEqual((0, shared_1.d)(1));
|
|
13
|
-
expect(sut.close).toEqual((0, shared_1.d)(3));
|
|
14
|
-
});
|
|
15
|
-
test('should modify a ohlc', () => {
|
|
16
|
-
const timestamp = (0, shared_1.now)();
|
|
17
|
-
const sut = new component_1.Ohlc(timestamp, (0, shared_1.d)(2), (0, shared_1.d)(4), (0, shared_1.d)(1), (0, shared_1.d)(3));
|
|
18
|
-
sut.apply((0, shared_1.d)(10));
|
|
19
|
-
expect(sut.timestamp).toEqual(timestamp);
|
|
20
|
-
expect(sut.open).toEqual((0, shared_1.d)(2));
|
|
21
|
-
expect(sut.high).toEqual((0, shared_1.d)(10));
|
|
22
|
-
expect(sut.low).toEqual((0, shared_1.d)(1));
|
|
23
|
-
expect(sut.close).toEqual((0, shared_1.d)(10));
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare class Timeframe {
|
|
2
|
-
static S1: number;
|
|
3
|
-
static M1: number;
|
|
4
|
-
static M5: number;
|
|
5
|
-
static M15: number;
|
|
6
|
-
static M30: number;
|
|
7
|
-
static H1: number;
|
|
8
|
-
static H4: number;
|
|
9
|
-
static H6: number;
|
|
10
|
-
static H12: number;
|
|
11
|
-
static D1: number;
|
|
12
|
-
static W1: number;
|
|
13
|
-
}
|
|
14
|
-
export declare function tf(timestamp: number, timeframe: number): number;
|
|
15
|
-
//# sourceMappingURL=timeframe.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timeframe.d.ts","sourceRoot":"","sources":["../../src/component/timeframe.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAS;IACpB,MAAM,CAAC,EAAE,SAAQ;IACjB,MAAM,CAAC,EAAE,SAAqB;IAC9B,MAAM,CAAC,EAAE,SAAoB;IAC7B,MAAM,CAAC,GAAG,SAAoB;IAC9B,MAAM,CAAC,GAAG,SAAqB;IAC/B,MAAM,CAAC,EAAE,SAAqB;IAC9B,MAAM,CAAC,EAAE,SAAoB;IAC7B,MAAM,CAAC,EAAE,SAAoB;IAC7B,MAAM,CAAC,GAAG,SAAoB;IAC9B,MAAM,CAAC,EAAE,SAAqB;IAC9B,MAAM,CAAC,EAAE,SAAoB;CAC9B;AAED,wBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE/D"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tf = exports.Timeframe = void 0;
|
|
4
|
-
class Timeframe {
|
|
5
|
-
}
|
|
6
|
-
Timeframe.S1 = 1000;
|
|
7
|
-
Timeframe.M1 = Timeframe.S1 * 60;
|
|
8
|
-
Timeframe.M5 = Timeframe.M1 * 5;
|
|
9
|
-
Timeframe.M15 = Timeframe.M5 * 3;
|
|
10
|
-
Timeframe.M30 = Timeframe.M15 * 2;
|
|
11
|
-
Timeframe.H1 = Timeframe.M30 * 2;
|
|
12
|
-
Timeframe.H4 = Timeframe.H1 * 4;
|
|
13
|
-
Timeframe.H6 = Timeframe.H1 * 6;
|
|
14
|
-
Timeframe.H12 = Timeframe.H6 * 2;
|
|
15
|
-
Timeframe.D1 = Timeframe.H12 * 2;
|
|
16
|
-
Timeframe.W1 = Timeframe.D1 * 7;
|
|
17
|
-
exports.Timeframe = Timeframe;
|
|
18
|
-
function tf(timestamp, timeframe) {
|
|
19
|
-
return timestamp - (timestamp % timeframe);
|
|
20
|
-
}
|
|
21
|
-
exports.tf = tf;
|
package/lib/core.d.ts
DELETED
package/lib/core.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAQzC,wBAAgB,IAAI,IAAI,UAAU,EAAE,CAOnC"}
|
package/lib/core.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.core = void 0;
|
|
4
|
-
const use_memo_1 = require("./use-memo");
|
|
5
|
-
const storage_1 = require("./storage");
|
|
6
|
-
const use_storage_factory_1 = require("./storage/use-storage-factory");
|
|
7
|
-
const use_execution_mode_1 = require("./use-execution-mode");
|
|
8
|
-
const use_logger_1 = require("./use-logger");
|
|
9
|
-
function core() {
|
|
10
|
-
return [
|
|
11
|
-
use_memo_1.useMemo.options(),
|
|
12
|
-
(0, use_logger_1.logger)(new use_logger_1.ConsoleLoggerFactory()),
|
|
13
|
-
use_execution_mode_1.useExecutionMode.paperOptions({ recording: false }),
|
|
14
|
-
use_storage_factory_1.useStorageFactory.options(new storage_1.InMemoryStorageFactory())
|
|
15
|
-
];
|
|
16
|
-
}
|
|
17
|
-
exports.core = core;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { decimal } from '../../shared';
|
|
2
|
-
export declare class Commission {
|
|
3
|
-
readonly makerRate: decimal;
|
|
4
|
-
readonly takerRate: decimal;
|
|
5
|
-
static readonly Zero: Commission;
|
|
6
|
-
constructor(makerRate: decimal, takerRate: decimal);
|
|
7
|
-
calculateMakerFee(value: decimal): import("decimal.js").default;
|
|
8
|
-
calculateTakerFee(value: decimal): import("decimal.js").default;
|
|
9
|
-
applyMakerFee(value: decimal): decimal;
|
|
10
|
-
applyTakerFee(value: decimal): decimal;
|
|
11
|
-
}
|
|
12
|
-
export declare function commissionPercentOf(fees: {
|
|
13
|
-
maker: decimal;
|
|
14
|
-
taker: decimal;
|
|
15
|
-
}): Commission;
|
|
16
|
-
//# sourceMappingURL=commission.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commission.d.ts","sourceRoot":"","sources":["../../../src/instrument/commission/commission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAEzC,qBAAa,UAAU;IAGT,QAAQ,CAAC,SAAS,EAAE,OAAO;IAAE,QAAQ,CAAC,SAAS,EAAE,OAAO;IAFpE,MAAM,CAAC,QAAQ,CAAC,IAAI,aAAyD;gBAExD,SAAS,EAAE,OAAO,EAAW,SAAS,EAAE,OAAO;IAEpE,iBAAiB,CAAC,KAAK,EAAE,OAAO;IAIhC,iBAAiB,CAAC,KAAK,EAAE,OAAO;IAIhC,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAItC,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;CAGvC;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,cAE3E"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.commissionPercentOf = exports.Commission = void 0;
|
|
4
|
-
const shared_1 = require("../../shared");
|
|
5
|
-
class Commission {
|
|
6
|
-
constructor(makerRate, takerRate) {
|
|
7
|
-
this.makerRate = makerRate;
|
|
8
|
-
this.takerRate = takerRate;
|
|
9
|
-
}
|
|
10
|
-
calculateMakerFee(value) {
|
|
11
|
-
return value.mul(this.makerRate);
|
|
12
|
-
}
|
|
13
|
-
calculateTakerFee(value) {
|
|
14
|
-
return value.mul(this.takerRate);
|
|
15
|
-
}
|
|
16
|
-
applyMakerFee(value) {
|
|
17
|
-
return value.minus(this.calculateMakerFee(value));
|
|
18
|
-
}
|
|
19
|
-
applyTakerFee(value) {
|
|
20
|
-
return value.minus(this.calculateTakerFee(value));
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
Commission.Zero = commissionPercentOf({ maker: shared_1.d.Zero, taker: shared_1.d.Zero });
|
|
24
|
-
exports.Commission = Commission;
|
|
25
|
-
function commissionPercentOf(fees) {
|
|
26
|
-
return new Commission(fees.maker.div(100.0), fees.taker.div(100.0));
|
|
27
|
-
}
|
|
28
|
-
exports.commissionPercentOf = commissionPercentOf;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commission.spec.d.ts","sourceRoot":"","sources":["../../../src/instrument/commission/commission.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const shared_1 = require("../../shared");
|
|
4
|
-
const commission_1 = require("./commission");
|
|
5
|
-
describe(commission_1.Commission.name, () => {
|
|
6
|
-
test('should construct a Commission', () => {
|
|
7
|
-
const sut = (0, commission_1.commissionPercentOf)({
|
|
8
|
-
maker: (0, shared_1.d)(0.1),
|
|
9
|
-
taker: (0, shared_1.d)(0.2)
|
|
10
|
-
});
|
|
11
|
-
expect(sut.makerRate).toEqual((0, shared_1.d)(0.001));
|
|
12
|
-
expect(sut.takerRate).toEqual((0, shared_1.d)(0.002));
|
|
13
|
-
});
|
|
14
|
-
test('should calculate a maker fee', () => {
|
|
15
|
-
const sut = (0, commission_1.commissionPercentOf)({
|
|
16
|
-
maker: (0, shared_1.d)(0.1),
|
|
17
|
-
taker: (0, shared_1.d)(0.2)
|
|
18
|
-
});
|
|
19
|
-
expect(sut.calculateMakerFee((0, shared_1.d)(2000))).toEqual((0, shared_1.d)(2));
|
|
20
|
-
expect(sut.applyMakerFee((0, shared_1.d)(2000))).toEqual((0, shared_1.d)(1998));
|
|
21
|
-
});
|
|
22
|
-
test('should calculate a taker fee', () => {
|
|
23
|
-
const sut = (0, commission_1.commissionPercentOf)({
|
|
24
|
-
maker: (0, shared_1.d)(0.1),
|
|
25
|
-
taker: (0, shared_1.d)(0.2)
|
|
26
|
-
});
|
|
27
|
-
expect(sut.calculateTakerFee((0, shared_1.d)(2000))).toEqual((0, shared_1.d)(4));
|
|
28
|
-
expect(sut.applyTakerFee((0, shared_1.d)(2000))).toEqual((0, shared_1.d)(1996));
|
|
29
|
-
});
|
|
30
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/instrument/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uCAAuC,CAAC"}
|