@stoqey/ib 1.3.20 → 1.3.21
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/api/api.d.ts +7 -7
- package/dist/api/api.js +1 -1
- package/dist/api/api.js.map +1 -1
- package/dist/api/historical/historicalTickLast.d.ts +2 -2
- package/dist/api-next/api-next.d.ts +8 -8
- package/dist/api-next/api-next.js +4 -4
- package/dist/api-next/api-next.js.map +1 -1
- package/dist/core/io/decoder.js +1 -1
- package/dist/core/io/decoder.js.map +1 -1
- package/dist/core/io/encoder.d.ts +2 -2
- package/dist/core/io/encoder.js.map +1 -1
- package/dist/tests/unit/api/historical-data.test.js +11 -14
- package/dist/tests/unit/api/historical-data.test.js.map +1 -1
- package/dist/tests/unit/api/order/placeConditionalOrder.test.js +7 -0
- package/dist/tests/unit/api/order/placeConditionalOrder.test.js.map +1 -1
- package/dist/tests/unit/api-next-live/get-historical-ticks.test.d.ts +4 -0
- package/dist/tests/unit/api-next-live/get-historical-ticks.test.js +82 -0
- package/dist/tests/unit/api-next-live/get-historical-ticks.test.js.map +1 -0
- package/dist/tests/unit/sample-data/contracts.js +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This file implements tests for the [[IBApiNext.getContractDetails]] function.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const __1 = require("../../..");
|
|
7
|
+
const contracts_1 = require("../sample-data/contracts");
|
|
8
|
+
describe("ApiNext: getContractDetails()", () => {
|
|
9
|
+
jest.setTimeout(10 * 1000);
|
|
10
|
+
const clientId = Math.floor(Math.random() * 32766) + 1; // ensure unique client
|
|
11
|
+
let api;
|
|
12
|
+
let error$;
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
api = new __1.IBApiNext();
|
|
15
|
+
if (!error$) {
|
|
16
|
+
error$ = api.errorSubject.subscribe((error) => {
|
|
17
|
+
if (error.reqId === -1) {
|
|
18
|
+
console.warn(`${error.error.message} (Error #${error.code})`);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
console.error(`${error.error.message} (Error #${error.code}) ${error.advancedOrderReject ? error.advancedOrderReject : ""}`);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
api.connect(clientId);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error(error.message);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
if (api) {
|
|
34
|
+
api.disconnect();
|
|
35
|
+
api = undefined;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
test("ETF historical ticks last", (done) => {
|
|
39
|
+
api
|
|
40
|
+
.getHistoricalTicksLast(contracts_1.sample_etf, "20240508-17:00:00", null, 1, true)
|
|
41
|
+
// eslint-disable-next-line rxjs/no-ignored-subscription
|
|
42
|
+
.subscribe({
|
|
43
|
+
next: (ticks) => {
|
|
44
|
+
// console.log(ticks.length, ticks);
|
|
45
|
+
expect(ticks.length).toEqual(17);
|
|
46
|
+
expect(ticks[0].time).toEqual(1715187600);
|
|
47
|
+
expect(ticks[0].price).toEqual(516.635);
|
|
48
|
+
expect(ticks[0].size).toEqual(1);
|
|
49
|
+
expect(ticks[0].exchange).toEqual("FINRA");
|
|
50
|
+
},
|
|
51
|
+
complete: () => {
|
|
52
|
+
done();
|
|
53
|
+
},
|
|
54
|
+
error: () => {
|
|
55
|
+
done("Some error occured!");
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
test("ETF historical bid/ask ticks", (done) => {
|
|
60
|
+
api
|
|
61
|
+
.getHistoricalTicksBidAsk(contracts_1.sample_etf, "20240508-17:00:00", null, 1, true, true)
|
|
62
|
+
// eslint-disable-next-line rxjs/no-ignored-subscription
|
|
63
|
+
.subscribe({
|
|
64
|
+
next: (ticks) => {
|
|
65
|
+
// console.log(ticks.length, ticks);
|
|
66
|
+
expect(ticks.length).toEqual(34);
|
|
67
|
+
expect(ticks[0].time).toEqual(1715187599);
|
|
68
|
+
expect(ticks[0].priceBid).toEqual(516.62);
|
|
69
|
+
expect(ticks[0].priceAsk).toEqual(516.63);
|
|
70
|
+
expect(ticks[0].sizeBid).toEqual(1100);
|
|
71
|
+
expect(ticks[0].sizeAsk).toEqual(1400);
|
|
72
|
+
},
|
|
73
|
+
complete: () => {
|
|
74
|
+
done();
|
|
75
|
+
},
|
|
76
|
+
error: () => {
|
|
77
|
+
done("Some error occured!");
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=get-historical-ticks.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-historical-ticks.test.js","sourceRoot":"","sources":["../../../../src/tests/unit/api-next-live/get-historical-ticks.test.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAGH,gCAAqC;AACrC,wDAAsD;AAEtD,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC7C,IAAI,CAAC,UAAU,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;IAE3B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,uBAAuB;IAE/E,IAAI,GAAc,CAAC;IACnB,IAAI,MAAoB,CAAC;IAEzB,UAAU,CAAC,GAAG,EAAE;QACd,GAAG,GAAG,IAAI,aAAS,EAAE,CAAC;QAEtB,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,GAAG,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;gBAC5C,IAAI,KAAK,CAAC,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;oBACvB,OAAO,CAAC,IAAI,CAAC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,EAAE,GAAG,EAAE;gBACb,IAAI,EAAE,CAAC;YACT,CAAC;YACD,KAAK,EAAE,GAAG,EAAE;gBACV,IAAI,CAAC,qBAAqB,CAAC,CAAC;YAC9B,CAAC;SACF,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -16,7 +16,7 @@ exports.sample_index = new __1.Index("ES", "USD");
|
|
|
16
16
|
exports.sample_dax_index = new __1.Index("DAX", "EUR", "EUREX");
|
|
17
17
|
exports.sample_crypto = new crypto_1.default("ETH");
|
|
18
18
|
// This one will need to be updated sometimes
|
|
19
|
-
exports.sample_future = new __1.Future("ES", "
|
|
19
|
+
exports.sample_future = new __1.Future("ES", "ESM4", "202406", "CME", 50);
|
|
20
20
|
// This one may need to be updated from times to times
|
|
21
21
|
exports.sample_option = new __1.Option("SPY", "20260116", 440, __1.OptionType.Call);
|
|
22
22
|
/*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoqey/ib",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.21",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Interactive Brokers TWS/IB Gateway API client library for Node.js (TS)",
|
|
6
6
|
"keywords": [
|
|
@@ -75,11 +75,11 @@
|
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@types/jest": "^29.5.12",
|
|
78
|
-
"@types/node": "^18.19.
|
|
78
|
+
"@types/node": "^18.19.33",
|
|
79
79
|
"@types/source-map-support": "^0.5.10",
|
|
80
80
|
"@typescript-eslint/eslint-plugin": "^7.1.1",
|
|
81
81
|
"@typescript-eslint/parser": "^7.1.1",
|
|
82
|
-
"ajv": "^8.
|
|
82
|
+
"ajv": "^8.13.0",
|
|
83
83
|
"eslint": "^8.57.0",
|
|
84
84
|
"eslint-plugin-jest": "^27.9.0",
|
|
85
85
|
"eslint-plugin-rxjs": "^5.0.3",
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
"jest-environment-node": "^29.7.0",
|
|
88
88
|
"jest-junit": "^16.0.0",
|
|
89
89
|
"ts-jest": "^29.1.2",
|
|
90
|
-
"typedoc": "^0.25.
|
|
91
|
-
"typescript": "^5.4.
|
|
90
|
+
"typedoc": "^0.25.13",
|
|
91
|
+
"typescript": "^5.4.5"
|
|
92
92
|
},
|
|
93
93
|
"engines": {
|
|
94
94
|
"node": ">=18.0.0"
|