@danielgroen/dxtrade-api 1.0.11 → 1.0.12
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 +34 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,12 +14,12 @@ npm install dxtrade-api
|
|
|
14
14
|
## Quick Start
|
|
15
15
|
|
|
16
16
|
```ts
|
|
17
|
-
import { DxtradeClient,
|
|
17
|
+
import { DxtradeClient, ORDER_TYPE, SIDE, BROKER } from "dxtrade-api";
|
|
18
18
|
|
|
19
19
|
const client = new DxtradeClient({
|
|
20
20
|
username: "your_username",
|
|
21
21
|
password: "your_password",
|
|
22
|
-
broker: "
|
|
22
|
+
broker: "LARKFUNDING",
|
|
23
23
|
accountId: "optional_account_id",
|
|
24
24
|
});
|
|
25
25
|
|
|
@@ -30,9 +30,9 @@ const symbol = suggestions[0];
|
|
|
30
30
|
|
|
31
31
|
const order = await client.submitOrder({
|
|
32
32
|
symbol: symbol.name,
|
|
33
|
-
side:
|
|
33
|
+
side: SIDE.BUY,
|
|
34
34
|
quantity: 0.01,
|
|
35
|
-
orderType:
|
|
35
|
+
orderType: ORDER_TYPE.MARKET,
|
|
36
36
|
instrumentId: symbol.id,
|
|
37
37
|
});
|
|
38
38
|
|
|
@@ -45,10 +45,11 @@ console.log(`Order ${order.orderId}: ${order.status}`);
|
|
|
45
45
|
|---|---|---|---|
|
|
46
46
|
| `username` | `string` | Yes | DXtrade account username |
|
|
47
47
|
| `password` | `string` | Yes | DXtrade account password |
|
|
48
|
-
| `broker` | `string` | Yes | Broker identifier (e.g. `"
|
|
48
|
+
| `broker` | `string` | Yes | Broker identifier (e.g. `"LARKFUNDING"`, `"EIGHTCAP"`) |
|
|
49
49
|
| `accountId` | `string` | No | Account ID to auto-switch after login |
|
|
50
50
|
| `brokerUrls` | `Record<string, string>` | No | Custom broker URL mapping |
|
|
51
51
|
| `retries` | `number` | No | Retry count for failed requests (default: 3) |
|
|
52
|
+
| `debug` | `boolean \| string` | No | Enable debug logging (`true` for all, or a WS message type to filter) |
|
|
52
53
|
| `callbacks` | `DxtradeCallbacks` | No | Event callbacks |
|
|
53
54
|
|
|
54
55
|
## Built-in Brokers
|
|
@@ -56,9 +57,9 @@ console.log(`Order ${order.orderId}: ${order.status}`);
|
|
|
56
57
|
```ts
|
|
57
58
|
import { BROKER } from "dxtrade-api";
|
|
58
59
|
|
|
59
|
-
BROKER.
|
|
60
|
-
BROKER.EIGHTCAP
|
|
61
|
-
BROKER.FTMO
|
|
60
|
+
BROKER.LARKFUNDING // "https://trade.gooeytrade.com"
|
|
61
|
+
BROKER.EIGHTCAP // "https://trader.dx-eightcap.com"
|
|
62
|
+
BROKER.FTMO // "https://dxtrade.ftmo.com"
|
|
62
63
|
```
|
|
63
64
|
|
|
64
65
|
## API
|
|
@@ -74,15 +75,33 @@ BROKER.FTMO // "https://trade.dx-ftmo.com"
|
|
|
74
75
|
|
|
75
76
|
- `client.getSymbolSuggestions(text)` — Search for symbols
|
|
76
77
|
- `client.getSymbolInfo(symbol)` — Get instrument info (volume limits, lot size)
|
|
78
|
+
- `client.getSymbolLimits()` — Get order size limits and stop/limit distances for all symbols
|
|
79
|
+
- `client.getInstruments(params?)` — Get all available instruments, optionally filtered by partial match (e.g. `{ type: "FOREX" }`)
|
|
77
80
|
|
|
78
81
|
### Trading
|
|
79
82
|
|
|
80
83
|
- `client.submitOrder(params)` — Submit an order and wait for WebSocket confirmation
|
|
81
84
|
|
|
85
|
+
### Account
|
|
86
|
+
|
|
87
|
+
- `client.getAccountMetrics()` — Get account metrics (equity, balance, margin, open P&L, etc.)
|
|
88
|
+
- `client.getTradeJournal({ from, to })` — Fetch trade journal entries for a date range (Unix timestamps)
|
|
89
|
+
|
|
82
90
|
### Analytics
|
|
83
91
|
|
|
84
92
|
- `client.getAssessments(params)` — Fetch PnL assessments for a date range
|
|
85
93
|
|
|
94
|
+
## Enums
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import { ORDER_TYPE, SIDE, ACTION, TIF } from "dxtrade-api";
|
|
98
|
+
|
|
99
|
+
ORDER_TYPE.MARKET | ORDER_TYPE.LIMIT | ORDER_TYPE.STOP
|
|
100
|
+
SIDE.BUY | SIDE.SELL
|
|
101
|
+
ACTION.OPENING | ACTION.CLOSING
|
|
102
|
+
TIF.GTC | TIF.DAY | TIF.GTD
|
|
103
|
+
```
|
|
104
|
+
|
|
86
105
|
## Callbacks
|
|
87
106
|
|
|
88
107
|
```ts
|
|
@@ -105,6 +124,13 @@ cp .env.example .env # fill in credentials
|
|
|
105
124
|
npm run example:connect
|
|
106
125
|
npm run example:order
|
|
107
126
|
npm run example:assessments
|
|
127
|
+
npm run example:account
|
|
128
|
+
npm run example:instruments
|
|
129
|
+
npm run example:instruments:forex
|
|
130
|
+
npm run example:symbol
|
|
131
|
+
npm run example:symbol:btc
|
|
132
|
+
npm run example:trade-journal
|
|
133
|
+
npm run example:debug
|
|
108
134
|
```
|
|
109
135
|
|
|
110
136
|
## DXtrade API Docs
|