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

+72 -3
View File
@@ -3,7 +3,7 @@
// ---------------------------------------------------------------------------
const Exchange = require ('./base/Exchange');
const { InvalidNonce, InsufficientFunds, AuthenticationError, InvalidOrder, ExchangeError, OrderNotFound } = require ('./base/errors');
const { InvalidNonce, InsufficientFunds, AuthenticationError, InvalidOrder, ExchangeError, OrderNotFound, AccountSuspended, BadSymbol, OrderImmediatelyFillable, RateLimitExceeded } = require ('./base/errors');
// ---------------------------------------------------------------------------
@@ -19,6 +19,22 @@ module.exports = class bitbay extends Exchange {
'withdraw': true,
'fetchMyTrades': true,
'fetchOpenOrders': true,
'fetchOHLCV': true,
},
'timeframes': {
'1m': '60',
'3m': '180',
'5m': '300',
'15m': '900',
'30m': '1800',
'1h': '3600',
'2h': '7200',
'4h': '14400',
'6h': '21600',
'12h': '43200',
'1d': '86400',
'3d': '259200',
'1w': '604800',
},
'urls': {
'referral': 'https://auth.bitbay.net/ref/jHlbB4mIkdS1',
@@ -134,13 +150,15 @@ module.exports = class bitbay extends Exchange {
'503': InvalidNonce, // Invalid moment parameter. Request time doesn't match current server time
'504': ExchangeError, // Invalid method
'505': AuthenticationError, // Key has no permission for this action
'506': AuthenticationError, // Account locked. Please contact with customer service
'506': AccountSuspended, // Account locked. Please contact with customer service
// codes 507 and 508 are not specified in their docs
'509': ExchangeError, // The BIC/SWIFT is required for this currency
'510': ExchangeError, // Invalid market name
'510': BadSymbol, // Invalid market name
'FUNDS_NOT_SUFFICIENT': InsufficientFunds,
'OFFER_FUNDS_NOT_EXCEEDING_MINIMUMS': InvalidOrder,
'OFFER_NOT_FOUND': OrderNotFound,
'OFFER_WOULD_HAVE_BEEN_PARTIALLY_FILLED': OrderImmediatelyFillable,
'ACTION_LIMIT_EXCEEDED': RateLimitExceeded,
},
});
}
@@ -272,6 +290,7 @@ module.exports = class bitbay extends Exchange {
}
return {
'id': this.safeString (order, 'id'),
'clientOrderId': undefined,
'info': order,
'timestamp': timestamp,
'datetime': this.iso8601 (timestamp),
@@ -743,6 +762,55 @@ module.exports = class bitbay extends Exchange {
return this.safeString (types, type, type);
}
parseOHLCV (ohlcv, market = undefined, timeframe = '1m', since = undefined, limit = undefined) {
// [
// '1582399800000',
// {
// o: '0.0001428',
// c: '0.0001428',
// h: '0.0001428',
// l: '0.0001428',
// v: '4',
// co: '1'
// }
// ]
return [
parseInt (ohlcv[0]),
this.safeFloat (ohlcv[1], 'o'),
this.safeFloat (ohlcv[1], 'h'),
this.safeFloat (ohlcv[1], 'l'),
this.safeFloat (ohlcv[1], 'c'),
this.safeFloat (ohlcv[1], 'v'),
];
}
async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
await this.loadMarkets ();
const market = this.market (symbol);
const tradingSymbol = market['baseId'] + '-' + market['quoteId'];
const request = {
'symbol': tradingSymbol,
'resolution': this.timeframes[timeframe],
// 'from': 1574709092000, // unix timestamp in milliseconds, required
// 'to': 1574709092000, // unix timestamp in milliseconds, required
};
if (limit === undefined) {
limit = 100;
}
const duration = this.parseTimeframe (timeframe);
const timerange = limit * duration * 1000;
if (since === undefined) {
request['to'] = this.milliseconds ();
request['from'] = request['to'] - timerange;
} else {
request['from'] = parseInt (since);
request['to'] = this.sum (request['from'], timerange);
}
const response = await this.v1_01PublicGetTradingCandleHistorySymbolResolution (this.extend (request, params));
const ohlcvs = this.safeValue (response, 'items', []);
return this.parseOHLCVs (ohlcvs, market, timeframe, since, limit);
}
parseTrade (trade, market = undefined) {
//
// createOrder trades
@@ -978,6 +1046,7 @@ module.exports = class bitbay extends Exchange {
'average': undefined,
'fee': undefined,
'trades': trades,
'clientOrderId': undefined,
};
}