@danielgroen/dxtrade-api 1.0.19 → 1.0.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/README.md +7 -2
- package/dist/index.d.mts +72 -2
- package/dist/index.d.ts +72 -2
- package/dist/index.js +215 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +214 -43
- package/dist/index.mjs.map +1 -1
- package/llms.txt +3 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# DXtrade API
|
|
2
2
|
|
|
3
|
-
[](https://nodejs.org)
|
|
4
|
+
[](https://www.typescriptlang.org)
|
|
4
5
|
[](https://www.npmjs.com/package/@danielgroen/dxtrade-api)
|
|
5
6
|
[](LICENSE)
|
|
6
7
|
[](https://github.com/danielgroen/dxtrade-api/actions/workflows/tests.yml)
|
|
@@ -8,7 +9,7 @@
|
|
|
8
9
|
|
|
9
10
|
[](https://demo.dx.trade/developers/#/)
|
|
10
11
|
|
|
11
|
-
Unofficial
|
|
12
|
+
Unofficial Node.js client for the DXtrade trading API with full TypeScript support. Connect, trade, and manage positions on any broker that supports DXtrade.
|
|
12
13
|
|
|
13
14
|
## Install
|
|
14
15
|
|
|
@@ -23,8 +24,10 @@ npm install dxtrade-api
|
|
|
23
24
|
- [x] Positions (get & close)
|
|
24
25
|
- [x] Account metrics & trade journal
|
|
25
26
|
- [x] Symbol search & instrument info
|
|
27
|
+
- [x] OHLC / price bar data
|
|
26
28
|
- [x] PnL assessments
|
|
27
29
|
- [x] Multi-broker support (FTMO, Eightcap, Lark Funding)
|
|
30
|
+
- [x] Full TypeScript support
|
|
28
31
|
- [ ] Batch orders
|
|
29
32
|
- [ ] Close whole position helper
|
|
30
33
|
- [ ] Modify existing orders
|
|
@@ -97,6 +100,7 @@ BROKER.FTMO // "https://dxtrade.ftmo.com"
|
|
|
97
100
|
- `client.getSymbolInfo(symbol)` — Get instrument info (volume limits, lot size)
|
|
98
101
|
- `client.getSymbolLimits()` — Get order size limits and stop/limit distances for all symbols
|
|
99
102
|
- `client.getInstruments(params?)` — Get all available instruments, optionally filtered by partial match (e.g. `{ type: "FOREX" }`)
|
|
103
|
+
- `client.getOHLC(params)` — Fetch OHLC price bars for a symbol (resolution, range, maxBars, priceField)
|
|
100
104
|
|
|
101
105
|
### Trading
|
|
102
106
|
|
|
@@ -154,6 +158,7 @@ npm run example:assessments
|
|
|
154
158
|
npm run example:assessments:btc
|
|
155
159
|
npm run example:account
|
|
156
160
|
npm run example:instruments
|
|
161
|
+
npm run example:ohlc
|
|
157
162
|
npm run example:instruments:forex
|
|
158
163
|
npm run example:symbol
|
|
159
164
|
npm run example:symbol:btc
|
package/dist/index.d.mts
CHANGED
|
@@ -12,11 +12,13 @@ declare const endpoints: {
|
|
|
12
12
|
submitOrder: (base: string) => string;
|
|
13
13
|
closePosition: (base: string) => string;
|
|
14
14
|
assessments: (base: string) => string;
|
|
15
|
-
websocket: (base: string) => string;
|
|
15
|
+
websocket: (base: string, atmosphereId?: string | null) => string;
|
|
16
16
|
tradeJournal: (base: string, params: {
|
|
17
17
|
from: number;
|
|
18
18
|
to: number;
|
|
19
19
|
}) => string;
|
|
20
|
+
subscribeInstruments: (base: string) => string;
|
|
21
|
+
charts: (base: string) => string;
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
declare enum ORDER_TYPE {
|
|
@@ -37,11 +39,39 @@ declare enum TIF {
|
|
|
37
39
|
DAY = "DAY",
|
|
38
40
|
GTD = "GTD"
|
|
39
41
|
}
|
|
42
|
+
declare enum ERROR {
|
|
43
|
+
NO_SESSION = "NO_SESSION",
|
|
44
|
+
LOGIN_FAILED = "LOGIN_FAILED",
|
|
45
|
+
LOGIN_ERROR = "LOGIN_ERROR",
|
|
46
|
+
CSRF_NOT_FOUND = "CSRF_NOT_FOUND",
|
|
47
|
+
CSRF_ERROR = "CSRF_ERROR",
|
|
48
|
+
ACCOUNT_SWITCH_ERROR = "ACCOUNT_SWITCH_ERROR",
|
|
49
|
+
NO_SUGGESTIONS = "NO_SUGGESTIONS",
|
|
50
|
+
SUGGEST_ERROR = "SUGGEST_ERROR",
|
|
51
|
+
NO_SYMBOL_INFO = "NO_SYMBOL_INFO",
|
|
52
|
+
SYMBOL_INFO_ERROR = "SYMBOL_INFO_ERROR",
|
|
53
|
+
INSTRUMENTS_TIMEOUT = "INSTRUMENTS_TIMEOUT",
|
|
54
|
+
INSTRUMENTS_ERROR = "INSTRUMENTS_ERROR",
|
|
55
|
+
LIMITS_TIMEOUT = "LIMITS_TIMEOUT",
|
|
56
|
+
LIMITS_ERROR = "LIMITS_ERROR",
|
|
57
|
+
OHLC_TIMEOUT = "OHLC_TIMEOUT",
|
|
58
|
+
OHLC_ERROR = "OHLC_ERROR",
|
|
59
|
+
ORDER_ERROR = "ORDER_ERROR",
|
|
60
|
+
POSITION_CLOSE_ERROR = "POSITION_CLOSE_ERROR",
|
|
61
|
+
ACCOUNT_METRICS_TIMEOUT = "ACCOUNT_METRICS_TIMEOUT",
|
|
62
|
+
ACCOUNT_METRICS_ERROR = "ACCOUNT_METRICS_ERROR",
|
|
63
|
+
ACCOUNT_POSITIONS_TIMEOUT = "ACCOUNT_POSITIONS_TIMEOUT",
|
|
64
|
+
ACCOUNT_POSITIONS_ERROR = "ACCOUNT_POSITIONS_ERROR",
|
|
65
|
+
TRADE_JOURNAL_ERROR = "TRADE_JOURNAL_ERROR",
|
|
66
|
+
ASSESSMENTS_ERROR = "ASSESSMENTS_ERROR"
|
|
67
|
+
}
|
|
40
68
|
declare enum WS_MESSAGE {
|
|
41
69
|
ACCOUNT_METRICS = "ACCOUNT_METRICS",
|
|
42
70
|
ACCOUNTS = "ACCOUNTS",
|
|
43
71
|
AVAILABLE_WATCHLISTS = "AVAILABLE_WATCHLISTS",
|
|
72
|
+
CHART_FEED_SUBTOPIC = "chartFeedSubtopic",
|
|
44
73
|
INSTRUMENTS = "INSTRUMENTS",
|
|
74
|
+
INSTRUMENT_METRICS = "INSTRUMENT_METRICS",
|
|
45
75
|
LIMITS = "LIMITS",
|
|
46
76
|
MESSAGE = "MESSAGE",
|
|
47
77
|
ORDERS = "ORDERS",
|
|
@@ -49,8 +79,14 @@ declare enum WS_MESSAGE {
|
|
|
49
79
|
POSITION_CASH_TRANSFERS = "POSITION_CASH_TRANSFERS",
|
|
50
80
|
PRIVATE_LAYOUT_NAMES = "PRIVATE_LAYOUT_NAMES",
|
|
51
81
|
SHARED_PROPERTIES_MESSAGE = "SHARED_PROPERTIES_MESSAGE",
|
|
82
|
+
TRADE_STATUSES = "TRADE_STATUSES",
|
|
52
83
|
USER_LOGIN_INFO = "USER_LOGIN_INFO"
|
|
53
84
|
}
|
|
85
|
+
declare namespace WS_MESSAGE {
|
|
86
|
+
enum SUBTOPIC {
|
|
87
|
+
BIG_CHART_COMPONENT = "BigChartComponentPresenter-4"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
54
90
|
|
|
55
91
|
declare class DxtradeError extends Error {
|
|
56
92
|
code: string;
|
|
@@ -238,6 +274,31 @@ declare namespace Instrument {
|
|
|
238
274
|
}
|
|
239
275
|
}
|
|
240
276
|
|
|
277
|
+
declare namespace OHLC {
|
|
278
|
+
interface Params {
|
|
279
|
+
/** Symbol to fetch bars for (e.g. "EURUSD"). */
|
|
280
|
+
symbol: string;
|
|
281
|
+
/** Bar aggregation period in seconds (default: 60 = 1 min). Common values: 60 (1m), 300 (5m), 900 (15m), 1800 (30m), 3600 (1h), 14400 (4h), 86400 (1d). */
|
|
282
|
+
resolution?: number;
|
|
283
|
+
/** Lookback window in seconds from now (default: 432000 = 5 days). Determines how far back in history to fetch bars. */
|
|
284
|
+
range?: number;
|
|
285
|
+
/** Maximum number of bars to return (default: 3500). */
|
|
286
|
+
maxBars?: number;
|
|
287
|
+
/** Price field to use (default: "bid"). */
|
|
288
|
+
priceField?: "bid" | "ask";
|
|
289
|
+
}
|
|
290
|
+
interface Bar {
|
|
291
|
+
timestamp: number;
|
|
292
|
+
open: number;
|
|
293
|
+
high: number;
|
|
294
|
+
low: number;
|
|
295
|
+
close: number;
|
|
296
|
+
volume: number;
|
|
297
|
+
vwap: number;
|
|
298
|
+
time: number;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
241
302
|
declare namespace Position {
|
|
242
303
|
interface Get {
|
|
243
304
|
uid: string;
|
|
@@ -356,6 +417,15 @@ declare class DxtradeClient {
|
|
|
356
417
|
getInstruments(params?: Partial<Instrument.Info>): Promise<Instrument.Info[]>;
|
|
357
418
|
/** Fetch PnL assessments for an instrument within a date range. */
|
|
358
419
|
getAssessments(params: Assessments.Params): Promise<Assessments.Response>;
|
|
420
|
+
/**
|
|
421
|
+
* Fetch OHLC price bars for a symbol.
|
|
422
|
+
* @param params.symbol - Instrument symbol (e.g. "EURUSD")
|
|
423
|
+
* @param params.resolution - Bar period in seconds (default: 60 = 1 min)
|
|
424
|
+
* @param params.range - Lookback window in seconds (default: 432000 = 5 days)
|
|
425
|
+
* @param params.maxBars - Maximum bars to return (default: 3500)
|
|
426
|
+
* @param params.priceField - "bid" or "ask" (default: "bid")
|
|
427
|
+
*/
|
|
428
|
+
getOHLC(params: OHLC.Params): Promise<OHLC.Bar[]>;
|
|
359
429
|
}
|
|
360
430
|
|
|
361
|
-
export { ACTION, BROKER, type DxtradeCallbacks, DxtradeClient, type DxtradeConfig, DxtradeError, ORDER_TYPE, SIDE, TIF, WS_MESSAGE, type WsPayload, endpoints };
|
|
431
|
+
export { ACTION, BROKER, type DxtradeCallbacks, DxtradeClient, type DxtradeConfig, DxtradeError, ERROR, ORDER_TYPE, SIDE, TIF, WS_MESSAGE, type WsPayload, endpoints };
|
package/dist/index.d.ts
CHANGED
|
@@ -12,11 +12,13 @@ declare const endpoints: {
|
|
|
12
12
|
submitOrder: (base: string) => string;
|
|
13
13
|
closePosition: (base: string) => string;
|
|
14
14
|
assessments: (base: string) => string;
|
|
15
|
-
websocket: (base: string) => string;
|
|
15
|
+
websocket: (base: string, atmosphereId?: string | null) => string;
|
|
16
16
|
tradeJournal: (base: string, params: {
|
|
17
17
|
from: number;
|
|
18
18
|
to: number;
|
|
19
19
|
}) => string;
|
|
20
|
+
subscribeInstruments: (base: string) => string;
|
|
21
|
+
charts: (base: string) => string;
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
declare enum ORDER_TYPE {
|
|
@@ -37,11 +39,39 @@ declare enum TIF {
|
|
|
37
39
|
DAY = "DAY",
|
|
38
40
|
GTD = "GTD"
|
|
39
41
|
}
|
|
42
|
+
declare enum ERROR {
|
|
43
|
+
NO_SESSION = "NO_SESSION",
|
|
44
|
+
LOGIN_FAILED = "LOGIN_FAILED",
|
|
45
|
+
LOGIN_ERROR = "LOGIN_ERROR",
|
|
46
|
+
CSRF_NOT_FOUND = "CSRF_NOT_FOUND",
|
|
47
|
+
CSRF_ERROR = "CSRF_ERROR",
|
|
48
|
+
ACCOUNT_SWITCH_ERROR = "ACCOUNT_SWITCH_ERROR",
|
|
49
|
+
NO_SUGGESTIONS = "NO_SUGGESTIONS",
|
|
50
|
+
SUGGEST_ERROR = "SUGGEST_ERROR",
|
|
51
|
+
NO_SYMBOL_INFO = "NO_SYMBOL_INFO",
|
|
52
|
+
SYMBOL_INFO_ERROR = "SYMBOL_INFO_ERROR",
|
|
53
|
+
INSTRUMENTS_TIMEOUT = "INSTRUMENTS_TIMEOUT",
|
|
54
|
+
INSTRUMENTS_ERROR = "INSTRUMENTS_ERROR",
|
|
55
|
+
LIMITS_TIMEOUT = "LIMITS_TIMEOUT",
|
|
56
|
+
LIMITS_ERROR = "LIMITS_ERROR",
|
|
57
|
+
OHLC_TIMEOUT = "OHLC_TIMEOUT",
|
|
58
|
+
OHLC_ERROR = "OHLC_ERROR",
|
|
59
|
+
ORDER_ERROR = "ORDER_ERROR",
|
|
60
|
+
POSITION_CLOSE_ERROR = "POSITION_CLOSE_ERROR",
|
|
61
|
+
ACCOUNT_METRICS_TIMEOUT = "ACCOUNT_METRICS_TIMEOUT",
|
|
62
|
+
ACCOUNT_METRICS_ERROR = "ACCOUNT_METRICS_ERROR",
|
|
63
|
+
ACCOUNT_POSITIONS_TIMEOUT = "ACCOUNT_POSITIONS_TIMEOUT",
|
|
64
|
+
ACCOUNT_POSITIONS_ERROR = "ACCOUNT_POSITIONS_ERROR",
|
|
65
|
+
TRADE_JOURNAL_ERROR = "TRADE_JOURNAL_ERROR",
|
|
66
|
+
ASSESSMENTS_ERROR = "ASSESSMENTS_ERROR"
|
|
67
|
+
}
|
|
40
68
|
declare enum WS_MESSAGE {
|
|
41
69
|
ACCOUNT_METRICS = "ACCOUNT_METRICS",
|
|
42
70
|
ACCOUNTS = "ACCOUNTS",
|
|
43
71
|
AVAILABLE_WATCHLISTS = "AVAILABLE_WATCHLISTS",
|
|
72
|
+
CHART_FEED_SUBTOPIC = "chartFeedSubtopic",
|
|
44
73
|
INSTRUMENTS = "INSTRUMENTS",
|
|
74
|
+
INSTRUMENT_METRICS = "INSTRUMENT_METRICS",
|
|
45
75
|
LIMITS = "LIMITS",
|
|
46
76
|
MESSAGE = "MESSAGE",
|
|
47
77
|
ORDERS = "ORDERS",
|
|
@@ -49,8 +79,14 @@ declare enum WS_MESSAGE {
|
|
|
49
79
|
POSITION_CASH_TRANSFERS = "POSITION_CASH_TRANSFERS",
|
|
50
80
|
PRIVATE_LAYOUT_NAMES = "PRIVATE_LAYOUT_NAMES",
|
|
51
81
|
SHARED_PROPERTIES_MESSAGE = "SHARED_PROPERTIES_MESSAGE",
|
|
82
|
+
TRADE_STATUSES = "TRADE_STATUSES",
|
|
52
83
|
USER_LOGIN_INFO = "USER_LOGIN_INFO"
|
|
53
84
|
}
|
|
85
|
+
declare namespace WS_MESSAGE {
|
|
86
|
+
enum SUBTOPIC {
|
|
87
|
+
BIG_CHART_COMPONENT = "BigChartComponentPresenter-4"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
54
90
|
|
|
55
91
|
declare class DxtradeError extends Error {
|
|
56
92
|
code: string;
|
|
@@ -238,6 +274,31 @@ declare namespace Instrument {
|
|
|
238
274
|
}
|
|
239
275
|
}
|
|
240
276
|
|
|
277
|
+
declare namespace OHLC {
|
|
278
|
+
interface Params {
|
|
279
|
+
/** Symbol to fetch bars for (e.g. "EURUSD"). */
|
|
280
|
+
symbol: string;
|
|
281
|
+
/** Bar aggregation period in seconds (default: 60 = 1 min). Common values: 60 (1m), 300 (5m), 900 (15m), 1800 (30m), 3600 (1h), 14400 (4h), 86400 (1d). */
|
|
282
|
+
resolution?: number;
|
|
283
|
+
/** Lookback window in seconds from now (default: 432000 = 5 days). Determines how far back in history to fetch bars. */
|
|
284
|
+
range?: number;
|
|
285
|
+
/** Maximum number of bars to return (default: 3500). */
|
|
286
|
+
maxBars?: number;
|
|
287
|
+
/** Price field to use (default: "bid"). */
|
|
288
|
+
priceField?: "bid" | "ask";
|
|
289
|
+
}
|
|
290
|
+
interface Bar {
|
|
291
|
+
timestamp: number;
|
|
292
|
+
open: number;
|
|
293
|
+
high: number;
|
|
294
|
+
low: number;
|
|
295
|
+
close: number;
|
|
296
|
+
volume: number;
|
|
297
|
+
vwap: number;
|
|
298
|
+
time: number;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
241
302
|
declare namespace Position {
|
|
242
303
|
interface Get {
|
|
243
304
|
uid: string;
|
|
@@ -356,6 +417,15 @@ declare class DxtradeClient {
|
|
|
356
417
|
getInstruments(params?: Partial<Instrument.Info>): Promise<Instrument.Info[]>;
|
|
357
418
|
/** Fetch PnL assessments for an instrument within a date range. */
|
|
358
419
|
getAssessments(params: Assessments.Params): Promise<Assessments.Response>;
|
|
420
|
+
/**
|
|
421
|
+
* Fetch OHLC price bars for a symbol.
|
|
422
|
+
* @param params.symbol - Instrument symbol (e.g. "EURUSD")
|
|
423
|
+
* @param params.resolution - Bar period in seconds (default: 60 = 1 min)
|
|
424
|
+
* @param params.range - Lookback window in seconds (default: 432000 = 5 days)
|
|
425
|
+
* @param params.maxBars - Maximum bars to return (default: 3500)
|
|
426
|
+
* @param params.priceField - "bid" or "ask" (default: "bid")
|
|
427
|
+
*/
|
|
428
|
+
getOHLC(params: OHLC.Params): Promise<OHLC.Bar[]>;
|
|
359
429
|
}
|
|
360
430
|
|
|
361
|
-
export { ACTION, BROKER, type DxtradeCallbacks, DxtradeClient, type DxtradeConfig, DxtradeError, ORDER_TYPE, SIDE, TIF, WS_MESSAGE, type WsPayload, endpoints };
|
|
431
|
+
export { ACTION, BROKER, type DxtradeCallbacks, DxtradeClient, type DxtradeConfig, DxtradeError, ERROR, ORDER_TYPE, SIDE, TIF, WS_MESSAGE, type WsPayload, endpoints };
|