IPC removed, replaced by WS

This commit is contained in:
Luis Fernando Molina committed 2020-04-06 08:33:07 +02:00
1 parent ba4217fb24
commit 656c193511
503 files changed
+28128 -34498

No files matched your search

+95 -17
View File
@@ -16,10 +16,14 @@ module.exports = class ftx extends Exchange {
'countries': [ 'HK' ],
'rateLimit': 100,
'certified': true,
'pro': true,
'urls': {
'logo': 'https://user-images.githubusercontent.com/1294454/67149189-df896480-f2b0-11e9-8816-41593e17f9ec.jpg',
'www': 'https://ftx.com',
'api': 'https://ftx.com',
'api': {
'public': 'https://ftx.com',
'private': 'https://ftx.com',
},
'doc': 'https://github.com/ftexchange/ftx',
'fees': 'https://ftexchange.zendesk.com/hc/en-us/articles/360024479432-Fees',
'referral': 'https://ftx.com/#a=1623029',
@@ -159,6 +163,19 @@ module.exports = class ftx extends Exchange {
},
},
'precisionMode': TICK_SIZE,
'options': {
// support for canceling conditional orders
// https://github.com/ccxt/ccxt/issues/6669
'cancelOrder': {
'method': 'privateDeleteOrdersOrderId', // privateDeleteConditionalOrdersOrderId
},
'fetchOpenOrders': {
'method': 'privateGetOrders', // privateGetConditionalOrders
},
'fetchOrders': {
'method': 'privateGetOrdersHistory', // privateGetConditionalOrdersHistory
},
},
});
}
@@ -334,14 +351,16 @@ module.exports = class ftx extends Exchange {
} else {
const base = this.safeCurrencyCode (this.safeString (ticker, 'baseCurrency'));
const quote = this.safeCurrencyCode (this.safeString (ticker, 'quoteCurrency'));
symbol = base + '/' + quote;
if ((base !== undefined) && (quote !== undefined)) {
symbol = base + '/' + quote;
}
}
}
if ((symbol === undefined) && (market !== undefined)) {
symbol = market['symbol'];
}
const last = this.safeFloat (ticker, 'last');
const timestamp = this.milliseconds ();
const timestamp = this.safeTimestamp (ticker, 'time', this.milliseconds ());
return {
'symbol': symbol,
'timestamp': timestamp,
@@ -349,9 +368,9 @@ module.exports = class ftx extends Exchange {
'high': this.safeFloat (ticker, 'high'),
'low': this.safeFloat (ticker, 'low'),
'bid': this.safeFloat (ticker, 'bid'),
'bidVolume': undefined,
'bidVolume': this.safeFloat (ticker, 'bidSize'),
'ask': this.safeFloat (ticker, 'ask'),
'askVolume': undefined,
'askVolume': this.safeFloat (ticker, 'askSize'),
'vwap': undefined,
'open': undefined,
'close': last,
@@ -502,11 +521,16 @@ module.exports = class ftx extends Exchange {
'market_name': market['id'],
'resolution': this.timeframes[timeframe],
};
if (limit !== undefined) {
// max 1501 candles, including the current candle when since is not specified
limit = (limit === undefined) ? 1501 : limit;
if (since === undefined) {
request['end_time'] = this.seconds ();
request['limit'] = limit;
}
if (since !== undefined) {
request['start_time'] = request['end_time'] - limit * this.parseTimeframe (timeframe);
} else {
request['start_time'] = parseInt (since / 1000);
request['limit'] = limit;
request['end_time'] = this.sum (request['start_time'], limit * this.parseTimeframe (timeframe));
}
const response = await this.publicGetMarketsMarketNameCandles (this.extend (request, params));
//
@@ -756,7 +780,7 @@ module.exports = class ftx extends Exchange {
parseOrder (order, market = undefined) {
//
// fetchOrder, fetchOrders, fetchOpenOrders, createOrder ("limit", "market")
// limit orders - fetchOrder, fetchOrders, fetchOpenOrders, createOrder
//
// {
// "createdAt": "2019-03-05T09:56:55.728933+00:00",
@@ -776,6 +800,27 @@ module.exports = class ftx extends Exchange {
// "clientId": null,
// }
//
// market orders - fetchOrder, fetchOrders, fetchOpenOrders, createOrder
//
// {
// "avgFillPrice": 2666.0,
// "clientId": None,
// "createdAt": "2020-02-12T00: 53: 49.009726+00: 00",
// "filledSize": 0.0007,
// "future": None,
// "id": 3109208514,
// "ioc": True,
// "market": "BNBBULL/USD",
// "postOnly": False,
// "price": None,
// "reduceOnly": False,
// "remainingSize": 0.0,
// "side": "buy",
// "size": 0.0007,
// "status": "closed",
// "type": "market"
// }
//
// createOrder (conditional, "stop", "trailingStop", or "takeProfit")
//
// {
@@ -812,15 +857,18 @@ module.exports = class ftx extends Exchange {
const side = this.safeString (order, 'side');
const type = this.safeString (order, 'type');
const amount = this.safeFloat (order, 'size');
const average = this.safeFloat (order, 'avgFillPrice');
const price = this.safeFloat2 (order, 'price', 'triggerPrice', average);
let cost = undefined;
if (filled !== undefined && amount !== undefined) {
cost = filled * amount;
if (filled !== undefined && price !== undefined) {
cost = filled * price;
}
const price = this.safeFloat2 (order, 'price', 'triggerPrice');
const lastTradeTimestamp = this.parse8601 (this.safeString (order, 'triggeredAt'));
const clientOrderId = this.safeString (order, 'clientId');
return {
'info': order,
'id': id,
'clientOrderId': clientOrderId,
'timestamp': timestamp,
'datetime': this.iso8601 (timestamp),
'lastTradeTimestamp': lastTradeTimestamp,
@@ -830,7 +878,7 @@ module.exports = class ftx extends Exchange {
'price': price,
'amount': amount,
'cost': cost,
'average': undefined,
'average': average,
'filled': filled,
'remaining': remaining,
'status': status,
@@ -933,7 +981,17 @@ module.exports = class ftx extends Exchange {
const request = {
'order_id': parseInt (id),
};
const response = await this.privateDeleteOrdersOrderId (this.extend (request, params));
// support for canceling conditional orders
// https://github.com/ccxt/ccxt/issues/6669
const options = this.safeValue (this.options, 'cancelOrder', {});
const defaultMethod = this.safeString (options, 'method', 'privateDeleteOrdersOrderId');
let method = this.safeString (params, 'method', defaultMethod);
const type = this.safeValue (params, 'type');
if ((type === 'stop') || (type === 'trailingStop') || (type === 'takeProfit')) {
method = 'privateDeleteConditionalOrdersOrderId';
}
const query = this.omit (params, [ 'method', 'type' ]);
const response = await this[method] (this.extend (request, query));
//
// {
// "success": true,
@@ -1008,7 +1066,17 @@ module.exports = class ftx extends Exchange {
market = this.market (symbol);
request['market'] = market['id'];
}
const response = await this.privateGetOrders (this.extend (request, params));
// support for canceling conditional orders
// https://github.com/ccxt/ccxt/issues/6669
const options = this.safeValue (this.options, 'fetchOpenOrders', {});
const defaultMethod = this.safeString (options, 'method', 'privateGetOrders');
let method = this.safeString (params, 'method', defaultMethod);
const type = this.safeValue (params, 'type');
if ((type === 'stop') || (type === 'trailingStop') || (type === 'takeProfit')) {
method = 'privateGetConditionalOrders';
}
const query = this.omit (params, [ 'method', 'type' ]);
const response = await this[method] (this.extend (request, query));
//
// {
// "success": true,
@@ -1052,7 +1120,17 @@ module.exports = class ftx extends Exchange {
if (since !== undefined) {
request['start_time'] = parseInt (since / 1000);
}
const response = await this.privateGetOrdersHistory (this.extend (request, params));
// support for canceling conditional orders
// https://github.com/ccxt/ccxt/issues/6669
const options = this.safeValue (this.options, 'fetchOrders', {});
const defaultMethod = this.safeString (options, 'method', 'privateGetOrdersHistory');
let method = this.safeString (params, 'method', defaultMethod);
const type = this.safeValue (params, 'type');
if ((type === 'stop') || (type === 'trailingStop') || (type === 'takeProfit')) {
method = 'privateGetConditionalOrdersHistory';
}
const query = this.omit (params, [ 'method', 'type' ]);
const response = await this[method] (this.extend (request, query));
//
// {
// "success": true,
@@ -1309,7 +1387,7 @@ module.exports = class ftx extends Exchange {
sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
let request = '/api/' + this.implodeParams (path, params);
const query = this.omit (params, this.extractParams (path));
let url = this.urls['api'] + request;
let url = this.urls['api'][api] + request;
if (method !== 'POST') {
if (Object.keys (query).length) {
const suffix = '?' + this.urlencode (query);