forked from tiagosiebler/binance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoinm-client.ts
168 lines (155 loc) · 10.4 KB
/
coinm-client.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import { AxiosRequestConfig } from 'axios';
import {
CoinMAccountTradeParams,
CoinMOpenInterest,
CoinMPositionTrade,
CoinMSymbolOrderBookTicker,
PositionRisk,
SymbolOrPair
} from './types/coin';
import { BinanceBaseUrlKey } from './types/shared';
import BaseRestClient from './util/BaseRestClient';
import {
asArray,
getServerTimeEndpoint,
RestClientOptions
} from './util/requestUtils';
export class CoinMClient extends BaseRestClient {
private clientId: BinanceBaseUrlKey;
constructor(
restClientOptions: RestClientOptions = {},
requestOptions: AxiosRequestConfig = {},
useTestnet?: boolean
) {
const clientId = useTestnet ? 'coinmtest' : 'coinm';
super(clientId, restClientOptions, requestOptions);
this.clientId = clientId;
return this;
}
/**
* Abstraction required by each client to aid with time sync / drift handling
*/
async getServerTime(): Promise<number> {
return this.get(getServerTimeEndpoint(this.clientId)).then(
(response) => response.serverTime
);
}
getFuturesUserDataListenKey(): Promise<{ listenKey: string }> {
return this.post('dapi/v1/listenKey');
}
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#change-log
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#general-info
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#testnet
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#general-api-information
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#limits
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#endpoint-security-type
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#signed-trade-and-user_data-endpoint-security
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#public-endpoints-info
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#filters
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#market-data-endpoints
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#test-connectivity
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#check-server-time
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#exchange-information
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#order-book
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#recent-trades-list
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#old-trades-lookup-market_data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#compressed-aggregate-trades-list
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#index-price-and-mark-price
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#get-funding-rate-history-of-perpetual-futures
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#kline-candlestick-data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#continuous-contract-kline-candlestick-data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#index-price-kline-candlestick-data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#mark-price-kline-candlestick-data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#24hr-ticker-price-change-statistics
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#symbol-price-ticker
getSymbolOrderBookTicker(
params?: SymbolOrPair
): Promise<CoinMSymbolOrderBookTicker[]> {
return this.get('dapi/v1/ticker/bookTicker', params).then((e) =>
asArray(e)
);
}
getOpenInterest(params: { symbol: string }): Promise<CoinMOpenInterest> {
return this.get('dapi/v1/openInterest', params);
}
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#open-interest-statistics
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#top-trader-long-short-ratio-accounts
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#top-trader-long-short-ratio-positions
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#long-short-ratio
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#taker-buy-sell-volume
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#basis
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#websocket-market-streams
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#live-subscribing-unsubscribing-to-streams
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#aggregate-trade-streams
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#index-price-stream
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#mark-price-stream
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#mark-price-of-all-symbols-of-a-pair
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#kline-candlestick-streams
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#continuous-contract-kline-candlestick-streams
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#index-kline-candlestick-streams
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#mark-price-kline-candlestick-streams
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#individual-symbol-mini-ticker-stream
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#all-market-mini-tickers-stream
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#individual-symbol-ticker-streams
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#all-market-tickers-streams
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#individual-symbol-book-ticker-streams
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#all-book-tickers-stream
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#liquidation-order-streams
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#all-market-liquidation-order-streams
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#partial-book-depth-streams
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#diff-book-depth-streams
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#how-to-manage-a-local-order-book-correctly
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#account-trades-endpoints
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#new-future-account-transfer
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#get-future-account-transaction-history-list
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#change-position-mode-trade
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#get-current-position-mode-user_data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#new-order-trade
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#modify-order-trade
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#place-multiple-orders-trade
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#modify-multiple-orders-trade
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#get-order-modify-history-user_data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#query-order-user_data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#cancel-order-trade
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#cancel-all-open-orders-trade
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#cancel-multiple-orders-trade
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#auto-cancel-all-open-orders-trade
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#query-current-open-order-user_data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#current-all-open-orders-user_data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#all-orders-user_data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#futures-account-balance-user_data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#change-initial-leverage-trade
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#change-margin-type-trade
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#modify-isolated-position-margin-trade
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#get-position-margin-change-history-trade
getPositions(): Promise<PositionRisk[]> {
return this.getPrivate('dapi/v1/positionRisk');
}
getAccountTrades(
params: CoinMAccountTradeParams
): Promise<CoinMPositionTrade[]> {
return this.getPrivate('dapi/v1/userTrades', params);
}
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#get-income-history-user_data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#notional-bracket-for-symbol-user_data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#notional-bracket-for-pair-user_data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#user-39-s-force-orders-user_data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#position-adl-quantile-estimation-user_data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#user-commission-rate-user_data
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#user-data-streams
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#start-user-data-stream-user_stream
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#keepalive-user-data-stream-user_stream
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#close-user-data-stream-user_stream
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#event-margin-call
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#event-balance-and-position-update
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#event-order-update
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#websocket-user-data-request
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#request-user-39-s-account-information
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#request-user-39-s-account-balance
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#request-user-39-s-position
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#event-account-configuration-update-leverage-update
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#portfolio-margin-endpoints
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#portfolio-margin-exchange-information
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#portfolio-margin-account-information-user_data
}