@mfxhub/sdk 0.2.3 → 0.3.0
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/CHANGELOG.md +42 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.js +7 -1
- package/dist/generated/api.d.ts +7914 -3234
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/dist/terminals.d.ts +48 -1
- package/dist/terminals.js +106 -1
- package/dist/trading-accounts.d.ts +44 -0
- package/dist/trading-accounts.js +76 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,48 @@ Every release of `@mfxhub/sdk`, newest first. The format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
|
|
5
5
|
[Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## 0.3.0
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- A terminal can be `QUEUED`: placed on a cell and waiting for its turn to start. A cell starts
|
|
12
|
+
terminals a few at a time so the ones already running are not slowed. `terminal.queue` says its
|
|
13
|
+
place, when it is expected to start (`expected_start_at`) and why it waits (a coarse `reason`).
|
|
14
|
+
`isUsable` is false for it, as for every state but ACTIVE.
|
|
15
|
+
- `terminals.waitUntilActive(id, { timeoutMs })`: reads the terminal until it is no longer on its
|
|
16
|
+
way to ACTIVE. A QUEUED terminal is read again at its expected start (2 s to 1 min away), not on
|
|
17
|
+
a fixed beat.
|
|
18
|
+
- `terminals.bulkRestart` and `terminals.bulkRetire` (`POST /v1/terminals:restart`,
|
|
19
|
+
`POST /v1/terminals:retire`): many terminals by farm, broker or ids, answered at once with the
|
|
20
|
+
action, what was refused and the expected finish. `getBulkAction` and `cancelBulkAction` follow
|
|
21
|
+
and cancel it.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- The vendored API description is the platform's current public contract, with the queued state,
|
|
26
|
+
the queue fields and the bulk routes; the generated types follow it.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- A request path whose first segment holds a colon (`/terminals:restart`) is sent to the API. The
|
|
31
|
+
URL parser read `terminals:` as a scheme.
|
|
32
|
+
|
|
33
|
+
## 0.2.4
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
|
|
37
|
+
- `client.tradingAccounts`: the trading accounts over every venue (`GET /v1/accounts`,
|
|
38
|
+
`GET /v1/accounts/{id}`, scope `acct:read`). `page()` and `list()` narrow by `venue`,
|
|
39
|
+
`environment` and `state` on the platform; `get(id)` takes the account's id or one of its
|
|
40
|
+
terminals' ids. An MT5 account's id is its terminal's id. The state is the venue-neutral word
|
|
41
|
+
(`CONNECTED`, `DEGRADED`, `REAUTH_NEEDED`, ...). `client.accounts` is unchanged: it is still the
|
|
42
|
+
balance, positions and deals of a terminal's account.
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
|
|
46
|
+
- The vendored API description is the platform's current public contract, and the generated types
|
|
47
|
+
follow it.
|
|
48
|
+
|
|
7
49
|
## 0.2.3
|
|
8
50
|
|
|
9
51
|
### Added
|
package/dist/client.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { Catalog } from "./catalog.js";
|
|
|
5
5
|
import { Execution } from "./execution.js";
|
|
6
6
|
import { MfxStream, type StreamOptions } from "./stream.js";
|
|
7
7
|
import { Terminals } from "./terminals.js";
|
|
8
|
+
import { TradingAccounts } from "./trading-accounts.js";
|
|
8
9
|
/** Default time a single request may take. */
|
|
9
10
|
export declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
10
11
|
/** How many times a rate-limited read is tried again. */
|
|
@@ -73,6 +74,8 @@ export declare class MfxClient {
|
|
|
73
74
|
readonly catalog: Catalog;
|
|
74
75
|
/** The trading account behind a terminal: figures, positions, pending orders and deals. */
|
|
75
76
|
readonly accounts: Accounts;
|
|
77
|
+
/** The trading accounts over every venue: an MT5 account, and later a cTrader one. */
|
|
78
|
+
readonly tradingAccounts: TradingAccounts;
|
|
76
79
|
/**
|
|
77
80
|
* @param baseUrl the API's base, including the version: `https://api.mfxhub.com/v1`, or
|
|
78
81
|
* `https://api.dev.mfxhub.com/v1` for development
|
package/dist/client.js
CHANGED
|
@@ -13,6 +13,7 @@ import { Catalog } from "./catalog.js";
|
|
|
13
13
|
import { Execution } from "./execution.js";
|
|
14
14
|
import { MfxStream } from "./stream.js";
|
|
15
15
|
import { Terminals } from "./terminals.js";
|
|
16
|
+
import { TradingAccounts } from "./trading-accounts.js";
|
|
16
17
|
import { USER_AGENT } from "./version.js";
|
|
17
18
|
/** Default time a single request may take. */
|
|
18
19
|
export const DEFAULT_TIMEOUT_MS = 30_000;
|
|
@@ -55,6 +56,8 @@ export class MfxClient {
|
|
|
55
56
|
catalog;
|
|
56
57
|
/** The trading account behind a terminal: figures, positions, pending orders and deals. */
|
|
57
58
|
accounts;
|
|
59
|
+
/** The trading accounts over every venue: an MT5 account, and later a cTrader one. */
|
|
60
|
+
tradingAccounts;
|
|
58
61
|
/**
|
|
59
62
|
* @param baseUrl the API's base, including the version: `https://api.mfxhub.com/v1`, or
|
|
60
63
|
* `https://api.dev.mfxhub.com/v1` for development
|
|
@@ -76,6 +79,7 @@ export class MfxClient {
|
|
|
76
79
|
this.execution = new Execution(this);
|
|
77
80
|
this.catalog = new Catalog(this);
|
|
78
81
|
this.accounts = new Accounts(this);
|
|
82
|
+
this.tradingAccounts = new TradingAccounts(this);
|
|
79
83
|
}
|
|
80
84
|
/** The id of the key this client signs with. Safe to log, unlike the private key. */
|
|
81
85
|
get keyId() {
|
|
@@ -133,7 +137,9 @@ export class MfxClient {
|
|
|
133
137
|
}
|
|
134
138
|
/** One attempt, signed afresh. Transport faults become MfxTransportError or MfxTimeout. */
|
|
135
139
|
async send(spec) {
|
|
136
|
-
|
|
140
|
+
// "./" keeps a path with a colon in its first segment (`/terminals:restart`) relative: without
|
|
141
|
+
// it the URL parser reads `terminals:` as a scheme and the request leaves the API.
|
|
142
|
+
const url = new URL("./" + spec.path.replace(/^\/+/, ""), this.#base);
|
|
137
143
|
for (const [name, value] of Object.entries(spec.query ?? {})) {
|
|
138
144
|
if (value === null || value === undefined)
|
|
139
145
|
continue;
|