ccxt
Version:
1,125 lines (1,123 loc) • 109 kB
JavaScript
// ----------------------------------------------------------------------------
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
// ---------------------------------------------------------------------------
import Exchange from './abstract/bitteam.js';
import { ArgumentsRequired, AuthenticationError, BadRequest, BadSymbol, ExchangeError, ExchangeNotAvailable, InsufficientFunds, OrderNotFound } from './base/errors.js';
import { TICK_SIZE } from './base/functions/number.js';
import { Precise } from './base/Precise.js';
// ---------------------------------------------------------------------------
/**
* @class bitteam
* @augments Exchange
*/
export default class bitteam extends Exchange {
describe() {
return this.deepExtend(super.describe(), {
'id': 'bitteam',
'name': 'BIT.TEAM',
'countries': ['UK'],
'version': 'v2.0.6',
'rateLimit': 1,
'certified': false,
'pro': false,
'has': {
'CORS': undefined,
'spot': true,
'margin': false,
'swap': false,
'future': false,
'option': false,
'addMargin': false,
'borrowCrossMargin': false,
'borrowIsolatedMargin': false,
'borrowMargin': false,
'cancelAllOrders': true,
'cancelOrder': true,
'cancelOrders': false,
'closeAllPositions': false,
'closePosition': false,
'createDepositAddress': false,
'createOrder': true,
'createOrderWithTakeProfitAndStopLoss': false,
'createOrderWithTakeProfitAndStopLossWs': false,
'createPostOnlyOrder': false,
'createReduceOnlyOrder': false,
'createStopLimitOrder': false,
'createStopMarketOrder': false,
'createStopOrder': false,
'deposit': false,
'editOrder': false,
'fetchAccounts': false,
'fetchBalance': true,
'fetchBidsAsks': false,
'fetchBorrowInterest': false,
'fetchBorrowRate': false,
'fetchBorrowRateHistories': false,
'fetchBorrowRateHistory': false,
'fetchBorrowRates': false,
'fetchBorrowRatesPerSymbol': false,
'fetchCanceledOrders': true,
'fetchClosedOrder': false,
'fetchClosedOrders': true,
'fetchCrossBorrowRate': false,
'fetchCrossBorrowRates': false,
'fetchCurrencies': true,
'fetchDeposit': false,
'fetchDepositAddress': false,
'fetchDepositAddresses': false,
'fetchDepositAddressesByNetwork': false,
'fetchDeposits': false,
'fetchDepositsWithdrawals': true,
'fetchDepositWithdrawFee': false,
'fetchDepositWithdrawFees': false,
'fetchFundingHistory': false,
'fetchFundingInterval': false,
'fetchFundingIntervals': false,
'fetchFundingRate': false,
'fetchFundingRateHistory': false,
'fetchFundingRates': false,
'fetchGreeks': false,
'fetchIndexOHLCV': false,
'fetchIsolatedBorrowRate': false,
'fetchIsolatedBorrowRates': false,
'fetchIsolatedPositions': false,
'fetchL3OrderBook': false,
'fetchLedger': false,
'fetchLeverage': false,
'fetchLeverages': false,
'fetchLeverageTiers': false,
'fetchLiquidations': false,
'fetchLongShortRatio': false,
'fetchLongShortRatioHistory': false,
'fetchMarginAdjustmentHistory': false,
'fetchMarginMode': false,
'fetchMarginModes': false,
'fetchMarketLeverageTiers': false,
'fetchMarkets': true,
'fetchMarkOHLCV': false,
'fetchMarkPrices': false,
'fetchMyLiquidations': false,
'fetchMySettlementHistory': false,
'fetchMyTrades': true,
'fetchOHLCV': true,
'fetchOpenInterest': false,
'fetchOpenInterestHistory': false,
'fetchOpenInterests': false,
'fetchOpenOrder': false,
'fetchOpenOrders': true,
'fetchOption': false,
'fetchOptionChain': false,
'fetchOrder': true,
'fetchOrderBook': true,
'fetchOrderBooks': false,
'fetchOrders': true,
'fetchOrderTrades': false,
'fetchPosition': false,
'fetchPositionHistory': false,
'fetchPositionMode': false,
'fetchPositions': false,
'fetchPositionsForSymbol': false,
'fetchPositionsHistory': false,
'fetchPositionsRisk': false,
'fetchPremiumIndexOHLCV': false,
'fetchSettlementHistory': false,
'fetchStatus': false,
'fetchTicker': true,
'fetchTickers': true,
'fetchTime': false,
'fetchTrades': true,
'fetchTradingFee': false,
'fetchTradingFees': false,
'fetchTradingLimits': false,
'fetchTransactionFee': false,
'fetchTransactionFees': false,
'fetchTransactions': true,
'fetchTransfers': false,
'fetchVolatilityHistory': false,
'fetchWithdrawal': false,
'fetchWithdrawals': false,
'fetchWithdrawalWhitelist': false,
'reduceMargin': false,
'repayCrossMargin': false,
'repayIsolatedMargin': false,
'repayMargin': false,
'setLeverage': false,
'setMargin': false,
'setMarginMode': false,
'setPositionMode': false,
'signIn': false,
'transfer': false,
'withdraw': false,
'ws': false,
},
'timeframes': {
'1m': '1',
'5m': '5',
'15m': '15',
'1h': '60',
'1d': '1D',
},
'urls': {
'logo': 'https://github.com/user-attachments/assets/b41b5e0d-98e5-4bd3-8a6e-aeb230a4a135',
'api': {
'history': 'https://history.bit.team',
'public': 'https://bit.team',
'private': 'https://bit.team',
},
'www': 'https://bit.team/',
'referral': 'https://bit.team/auth/sign-up?ref=bitboy2023',
'doc': [
'https://bit.team/trade/api/documentation',
],
},
'api': {
'history': {
'get': {
'api/tw/history/{pairName}/{resolution}': 1,
},
},
'public': {
'get': {
'trade/api/asset': 1,
'trade/api/currencies': 1,
'trade/api/orderbooks/{symbol}': 1,
'trade/api/orders': 1,
'trade/api/pair/{name}': 1,
'trade/api/pairs': 1,
'trade/api/pairs/precisions': 1,
'trade/api/rates': 1,
'trade/api/trade/{id}': 1,
'trade/api/trades': 1,
'trade/api/ccxt/pairs': 1,
'trade/api/cmc/assets': 1,
'trade/api/cmc/orderbook/{pair}': 1,
'trade/api/cmc/summary': 1,
'trade/api/cmc/ticker': 1,
'trade/api/cmc/trades/{pair}': 1,
},
},
'private': {
'get': {
'trade/api/ccxt/balance': 1,
'trade/api/ccxt/order/{id}': 1,
'trade/api/ccxt/ordersOfUser': 1,
'trade/api/ccxt/tradesOfUser': 1,
'trade/api/transactionsOfUser': 1,
},
'post': {
'trade/api/ccxt/cancel-all-order': 1,
'trade/api/ccxt/cancelorder': 1,
'trade/api/ccxt/ordercreate': 1,
},
},
},
'fees': {
'trading': {
'feeSide': 'get',
'tierBased': false,
'percentage': true,
'taker': this.parseNumber('0.002'),
'maker': this.parseNumber('0.002'),
},
},
'precisionMode': TICK_SIZE,
// exchange-specific options
'options': {
'networksById': {
'Ethereum': 'ERC20',
'ethereum': 'ERC20',
'Tron': 'TRC20',
'tron': 'TRC20',
'Binance': 'BSC',
'binance': 'BSC',
'Binance Smart Chain': 'BSC',
'bscscan': 'BSC',
'Bitcoin': 'BTC',
'bitcoin': 'BTC',
'Litecoin': 'LTC',
'litecoin': 'LTC',
'Polygon': 'POLYGON',
'polygon': 'POLYGON',
'PRIZM': 'PRIZM',
'Decimal': 'Decimal',
'ufobject': 'ufobject',
'tonchain': 'tonchain',
},
'currenciesValuedInUsd': {
'USDT': true,
'BUSD': true,
},
},
'features': {
'spot': {
'sandbox': false,
'createOrder': {
'marginMode': false,
'triggerPrice': false,
'triggerPriceType': undefined,
'triggerDirection': undefined,
'stopLossPrice': false,
'takeProfitPrice': false,
'attachedStopLossTakeProfit': undefined,
'timeInForce': {
'IOC': false,
'FOK': false,
'PO': false,
'GTD': false,
},
'hedged': false,
'trailing': false,
'leverage': false,
'marketBuyRequiresPrice': false,
'marketBuyByCost': false,
'selfTradePrevention': false,
'iceberg': false,
},
'createOrders': undefined,
'fetchMyTrades': {
'marginMode': false,
'limit': 100,
'daysBack': 100000,
'untilDays': 100000,
'symbolRequired': false,
},
'fetchOrder': {
'marginMode': false,
'trigger': false,
'trailing': false,
'symbolRequired': false,
},
'fetchOpenOrders': {
'marginMode': false,
'limit': 100,
'trigger': false,
'trailing': false,
'symbolRequired': false,
},
'fetchOrders': {
'marginMode': true,
'limit': 100,
'daysBack': undefined,
'untilDays': undefined,
'trigger': false,
'trailing': false,
'symbolRequired': false,
},
'fetchClosedOrders': {
'marginMode': false,
'limit': 100,
'daysBack': undefined,
'daysBackCanceled': undefined,
'untilDays': undefined,
'trigger': false,
'trailing': false,
'symbolRequired': false,
},
'fetchOHLCV': {
'limit': 1000,
},
},
'swap': {
'linear': undefined,
'inverse': undefined,
},
'future': {
'linear': undefined,
'inverse': undefined,
},
},
'exceptions': {
'exact': {
'400002': BadSymbol,
'401000': AuthenticationError,
'403002': BadRequest,
'404200': BadSymbol, // {"ok":false,"code":404200,"data":{},"message":"Pair was not found"}
},
'broad': {
'is not allowed': BadRequest,
'Insufficient funds': InsufficientFunds,
'Invalid request params input': BadRequest,
'must be a number': BadRequest,
'must be a string': BadRequest,
'must be of type': BadRequest,
'must be one of': BadRequest,
'Order not found': OrderNotFound,
'Pair with pair name': BadSymbol,
'pairName': BadSymbol,
'Service Unavailable': ExchangeNotAvailable,
'Symbol ': BadSymbol, // {"ok":false,"code":404000,"data":{},"message":"Symbol asdfasdfas was not found"}
},
},
});
}
/**
* @method
* @name bitteam#fetchMarkets
* @description retrieves data on all markets for bitteam
* @see https://bit.team/trade/api/documentation#/CCXT/getTradeApiCcxtPairs
* @param {object} [params] extra parameters specific to the exchange api endpoint
* @returns {object[]} an array of objects representing market data
*/
async fetchMarkets(params = {}) {
const response = await this.publicGetTradeApiCcxtPairs(params);
//
// {
// "ok": true,
// "result": {
// "count": 28,
// "pairs": [
// {
// "id": 2,
// "name": "eth_usdt",
// "baseAssetId": 2,
// "quoteAssetId": 3,
// "fullName": "ETH USDT",
// "description": "ETH USDT",
// "lastBuy": 1964.665001,
// "lastSell": 1959.835005,
// "lastPrice": 1964.665001,
// "change24": 1.41,
// "volume24": 28.22627543,
// "volume24USD": 55662.35636401598,
// "active": true,
// "baseStep": 8,
// "quoteStep": 6,
// "status": 1,
// "settings": {
// "limit_usd": "0.1",
// "price_max": "10000000000000",
// "price_min": "1",
// "price_tick": "1",
// "pricescale": 10000,
// "lot_size_max": "1000000000000000",
// "lot_size_min": "1",
// "lot_size_tick": "1",
// "price_view_min": 6,
// "default_slippage": 10,
// "lot_size_view_min": 6
// },
// "updateId": "50620",
// "timeStart": "2021-01-28T09:19:30.706Z",
// "makerFee": 200,
// "takerFee": 200,
// "quoteVolume24": 54921.93404134529,
// "lowPrice24": 1919.355,
// "highPrice24": 1971.204995
// },
// {
// "id": 27,
// "name": "ltc_usdt",
// "baseAssetId": 13,
// "quoteAssetId": 3,
// "fullName": "LTC USDT",
// "description": "This is LTC USDT",
// "lastBuy": 53.14,
// "lastSell": 53.58,
// "lastPrice": 53.58,
// "change24": -6.72,
// "volume24": 0,
// "volume24USD": null,
// "active": true,
// "baseStep": 8,
// "quoteStep": 6,
// "status": 0,
// "settings": {
// "limit_usd": "0.1",
// "price_max": "1000000000000",
// "price_min": "1",
// "price_tick": "1",
// "pricescale": 10000,
// "lot_size_max": "1000000000000",
// "lot_size_min": "1",
// "lot_size_tick": "1",
// "price_view_min": 6,
// "default_slippage": 10,
// "lot_size_view_min": 6
// },
// "updateId": "30",
// "timeStart": "2021-10-13T12:11:05.359Z",
// "makerFee": 200,
// "takerFee": 200,
// "quoteVolume24": 0,
// "lowPrice24": null,
// "highPrice24": null
// }
// ]
// }
// }
//
const result = this.safeValue(response, 'result', {});
const markets = this.safeValue(result, 'pairs', []);
return this.parseMarkets(markets);
}
parseMarket(market) {
const id = this.safeString(market, 'name');
const numericId = this.safeInteger(market, 'id');
const parts = id.split('_');
const baseId = this.safeString(parts, 0);
const quoteId = this.safeString(parts, 1);
const base = this.safeCurrencyCode(baseId);
const quote = this.safeCurrencyCode(quoteId);
const active = this.safeValue(market, 'active');
const timeStart = this.safeString(market, 'timeStart');
const created = this.parse8601(timeStart);
let minCost = undefined;
const currenciesValuedInUsd = this.safeValue(this.options, 'currenciesValuedInUsd', {});
const quoteInUsd = this.safeBool(currenciesValuedInUsd, quote, false);
if (quoteInUsd) {
const settings = this.safeValue(market, 'settings', {});
minCost = this.safeNumber(settings, 'limit_usd');
}
return this.safeMarketStructure({
'id': id,
'numericId': numericId,
'symbol': base + '/' + quote,
'base': base,
'quote': quote,
'settle': undefined,
'baseId': baseId,
'quoteId': quoteId,
'settleId': undefined,
'type': 'spot',
'spot': true,
'margin': false,
'swap': false,
'future': false,
'option': false,
'active': active,
'contract': false,
'linear': undefined,
'inverse': undefined,
'contractSize': undefined,
'expiry': undefined,
'expiryDatetime': undefined,
'strike': undefined,
'optionType': undefined,
'precision': {
'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'baseStep'))),
'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'quoteStep'))),
},
'limits': {
'leverage': {
'min': undefined,
'max': undefined,
},
'amount': {
'min': undefined,
'max': undefined,
},
'price': {
'min': undefined,
'max': undefined,
},
'cost': {
'min': minCost,
'max': undefined,
},
},
'created': created,
'info': market,
});
}
/**
* @method
* @name bitteam#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://bit.team/trade/api/documentation#/PUBLIC/getTradeApiCurrencies
* @param {object} [params] extra parameters specific to the bitteam api endpoint
* @returns {object} an associative dictionary of currencies
*/
async fetchCurrencies(params = {}) {
const response = await this.publicGetTradeApiCurrencies(params);
//
// {
// "ok": true,
// "result": {
// "count": 24,
// "currencies": [
// {
// "txLimits": {
// "minDeposit": "0.0001",
// "minWithdraw": "0.02",
// "maxWithdraw": "10000",
// "withdrawCommissionPercentage": "NaN",
// "withdrawCommissionFixed": "0.005"
// },
// "id": 2,
// "status": 1,
// "symbol": "eth",
// "title": "Ethereum",
// "logoURL": "https://ethereum.org/static/6b935ac0e6194247347855dc3d328e83/34ca5/eth-diamond-black.png",
// "isDiscount": false,
// "address": "https://ethereum.org/",
// "description": "Ethereum ETH",
// "decimals": 18,
// "blockChain": "Ethereum",
// "precision": 8,
// "currentRate": null,
// "active": true,
// "timeStart": "2021-01-28T08:57:41.719Z",
// "type": "crypto",
// "typeNetwork": "internalGW",
// "idSorting": 2,
// "links": [
// {
// "tx": "https://etherscan.io/tx/",
// "address": "https://etherscan.io/address/",
// "blockChain": "Ethereum"
// }
// ]
// },
// {
// "txLimits": {
// "minDeposit": "0.001",
// "minWithdraw": "1",
// "maxWithdraw": "100000",
// "withdrawCommissionPercentage": "NaN",
// "withdrawCommissionFixed": {
// "Tron": "2",
// "Binance": "2",
// "Ethereum": "20"
// }
// },
// "id": 3,
// "status": 1,
// "symbol": "usdt",
// "title": "Tether USD",
// "logoURL": "https://cryptologos.cc/logos/tether-usdt-logo.png?v=010",
// "isDiscount": false,
// "address": "https://tether.to/",
// "description": "Tether USD",
// "decimals": 6,
// "blockChain": "",
// "precision": 6,
// "currentRate": null,
// "active": true,
// "timeStart": "2021-01-28T09:04:17.170Z",
// "type": "crypto",
// "typeNetwork": "internalGW",
// "idSorting": 0,
// "links": [
// {
// "tx": "https://etherscan.io/tx/",
// "address": "https://etherscan.io/address/",
// "blockChain": "Ethereum"
// },
// {
// "tx": "https://tronscan.org/#/transaction/",
// "address": "https://tronscan.org/#/address/",
// "blockChain": "Tron"
// },
// {
// "tx": "https://bscscan.com/tx/",
// "address": "https://bscscan.com/address/",
// "blockChain": "Binance"
// }
// ]
// }
// ]
// }
// }
//
const responseResult = this.safeValue(response, 'result', {});
const currencies = this.safeValue(responseResult, 'currencies', []);
// usding another endpoint to fetch statuses of deposits and withdrawals
let statusesResponse = await this.publicGetTradeApiCmcAssets();
//
// {
// "ZNX": {
// "name": "ZeNeX Coin",
// "unified_cryptoasset_id": 30,
// "withdrawStatus": true,
// "depositStatus": true,
// "min_withdraw": 0.00001,
// "max_withdraw": 10000
// },
// "USDT": {
// "name": "Tether USD",
// "unified_cryptoasset_id": 3,
// "withdrawStatus": true,
// "depositStatus": true,
// "min_withdraw": 1,
// "max_withdraw": 100000
// },
// }
//
statusesResponse = this.indexBy(statusesResponse, 'unified_cryptoasset_id');
const result = {};
for (let i = 0; i < currencies.length; i++) {
const currency = currencies[i];
const id = this.safeString(currency, 'symbol');
const numericId = this.safeInteger(currency, 'id');
const code = this.safeCurrencyCode(id);
const active = this.safeBool(currency, 'active', false);
const precision = this.parseNumber(this.parsePrecision(this.safeString(currency, 'precision')));
const txLimits = this.safeValue(currency, 'txLimits', {});
const minWithdraw = this.safeString(txLimits, 'minWithdraw');
const maxWithdraw = this.safeString(txLimits, 'maxWithdraw');
const minDeposit = this.safeString(txLimits, 'minDeposit');
let fee = undefined;
const withdrawCommissionFixed = this.safeValue(txLimits, 'withdrawCommissionFixed', {});
let feesByNetworkId = {};
const blockChain = this.safeString(currency, 'blockChain');
// if only one blockChain
if ((blockChain !== undefined) && (blockChain !== '')) {
fee = this.parseNumber(withdrawCommissionFixed);
feesByNetworkId[blockChain] = fee;
}
else {
feesByNetworkId = withdrawCommissionFixed;
}
const statuses = this.safeValue(statusesResponse, numericId, {});
const deposit = this.safeValue(statuses, 'depositStatus');
const withdraw = this.safeValue(statuses, 'withdrawStatus');
const networkIds = Object.keys(feesByNetworkId);
const networks = {};
const networkPrecision = this.parseNumber(this.parsePrecision(this.safeString(currency, 'decimals')));
const typeRaw = this.safeString(currency, 'type');
for (let j = 0; j < networkIds.length; j++) {
const networkId = networkIds[j];
const networkCode = this.networkIdToCode(networkId, code);
const networkFee = this.safeNumber(feesByNetworkId, networkId);
networks[networkCode] = {
'id': networkId,
'network': networkCode,
'deposit': deposit,
'withdraw': withdraw,
'active': active,
'fee': networkFee,
'precision': networkPrecision,
'limits': {
'amount': {
'min': undefined,
'max': undefined,
},
'withdraw': {
'min': this.parseNumber(minWithdraw),
'max': this.parseNumber(maxWithdraw),
},
'deposit': {
'min': this.parseNumber(minDeposit),
'max': undefined,
},
},
'info': currency,
};
}
result[code] = {
'id': id,
'numericId': numericId,
'code': code,
'name': code,
'info': currency,
'active': active,
'deposit': deposit,
'withdraw': withdraw,
'fee': fee,
'precision': precision,
'limits': {
'amount': {
'min': undefined,
'max': undefined,
},
'withdraw': {
'min': this.parseNumber(minWithdraw),
'max': this.parseNumber(maxWithdraw),
},
'deposit': {
'min': this.parseNumber(minDeposit),
'max': undefined,
},
},
'type': typeRaw,
'networks': networks,
};
}
return result;
}
/**
* @method
* @name bitteam#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum amount of candles to fetch
* @param {object} [params] extra parameters specific to the bitteam api endpoint
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
await this.loadMarkets();
const market = this.market(symbol);
const resolution = this.safeString(this.timeframes, timeframe, timeframe);
const request = {
'pairName': market['id'],
'resolution': resolution,
};
const response = await this.historyGetApiTwHistoryPairNameResolution(this.extend(request, params));
//
// {
// "ok": true,
// "result": {
// "count": 364,
// "data": [
// {
// "t": 1669593600,
// "o": 16211.259266,
// "h": 16476.985001,
// "l": 16023.714999,
// "c": 16430.636894,
// "v": 2.60150368999999
// },
// {
// "t": 1669680000,
// "o": 16430.636894,
// "h": 17065.229582,
// "l": 16346.114155,
// "c": 16882.297736,
// "v": 3.0872548400000115
// },
// ...
// ]
// }
// }
//
const result = this.safeValue(response, 'result', {});
const data = this.safeList(result, 'data', []);
return this.parseOHLCVs(data, market, timeframe, since, limit);
}
parseOHLCV(ohlcv, market = undefined) {
//
// {
// "t": 1669680000,
// "o": 16430.636894,
// "h": 17065.229582,
// "l": 16346.114155,
// "c": 16882.297736,
// "v": 3.0872548400000115
// },
//
return [
this.safeTimestamp(ohlcv, 't'),
this.safeNumber(ohlcv, 'o'),
this.safeNumber(ohlcv, 'h'),
this.safeNumber(ohlcv, 'l'),
this.safeNumber(ohlcv, 'c'),
this.safeNumber(ohlcv, 'v'),
];
}
/**
* @method
* @name bitteam#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://bit.team/trade/api/documentation#/CMC/getTradeApiCmcOrderbookPair
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return (default 100, max 200)
* @param {object} [params] extra parameters specific to the bitteam api endpoint
* @returns {object} A dictionary of [order book structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-book-structure} indexed by market symbols
*/
async fetchOrderBook(symbol, limit = undefined, params = {}) {
await this.loadMarkets();
const market = this.market(symbol);
const request = {
'pair': market['id'],
};
const response = await this.publicGetTradeApiCmcOrderbookPair(this.extend(request, params));
//
// {
// "timestamp": 1701166703285,
// "bids": [
// [
// 2019.334988,
// 0.09048525
// ],
// [
// 1999.860002,
// 0.0225
// ],
// ...
// ],
// "asks": [
// [
// 2019.334995,
// 0.00899078
// ],
// [
// 2019.335013,
// 0.09833052
// ],
// ...
// ]
// }
//
const timestamp = this.safeInteger(response, 'timestamp');
const orderbook = this.parseOrderBook(response, symbol, timestamp);
return orderbook;
}
/**
* @method
* @name bitteam#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrdersofuser
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of orde structures to retrieve (default 10)
* @param {object} [params] extra parameters specific to the bitteam api endpoint
* @param {string} [params.type] the status of the order - 'active', 'closed', 'cancelled', 'all', 'history' (default 'all')
* @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
*/
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
await this.loadMarkets();
const type = this.safeString(params, 'type', 'all');
const request = {
'type': type,
};
let market = undefined;
if (symbol !== undefined) {
market = this.market(symbol);
request['pair'] = market['id'];
}
if (limit !== undefined) {
request['limit'] = limit;
}
const response = await this.privateGetTradeApiCcxtOrdersOfUser(this.extend(request, params));
//
// {
// "ok": true,
// "result": {
// "count": 3,
// "orders": [
// {
// "id": 106733026,
// "orderId": null,
// "userId": 21639,
// "pair": "btc_usdt",
// "pairId": 22,
// "quantity": "0.00001",
// "price": "40",
// "executedPrice": "0",
// "fee": null,
// "orderCid": null,
// "executed": "0",
// "expires": null,
// "baseDecimals": 8,
// "quoteDecimals": 6,
// "timestamp": 1700594804,
// "status": "inactive",
// "side": "buy",
// "type": "limit",
// "createdAt": "2023-11-21T19:26:43.868Z",
// "updatedAt": "2023-11-21T19:26:43.868Z"
// },
// {
// "id": 106733308,
// "orderId": "13074362",
// "userId": 21639,
// "pair": "btc_usdt",
// "pairId": 22,
// "quantity": "0.00001",
// "price": "50000",
// "executedPrice": "37017.495008",
// "fee": {
// "amount": "0.00000002",
// "symbol": "btc",
// "userId": 21639,
// "decimals": 8,
// "symbolId": 11
// },
// "orderCid": null,
// "executed": "0.00001",
// "expires": null,
// "baseDecimals": 8,
// "quoteDecimals": 6,
// "timestamp": 1700594959,
// "status": "executed",
// "side": "buy",
// "type": "limit",
// "createdAt": "2023-11-21T19:29:19.946Z",
// "updatedAt": "2023-11-21T19:29:19.946Z"
// },
// {
// "id": 106734455,
// "orderId": "13248984",
// "userId": 21639,
// "pair": "eth_usdt",
// "pairId": 2,
// "quantity": "0.001",
// "price": "1750",
// "executedPrice": "0",
// "fee": null,
// "orderCid": null,
// "executed": "0",
// "expires": null,
// "baseDecimals": 18,
// "quoteDecimals": 6,
// "timestamp": 1700595523,
// "status": "accepted",
// "side": "buy",
// "type": "limit",
// "createdAt": "2023-11-21T19:38:43.530Z",
// "updatedAt": "2023-11-21T19:38:43.530Z"
// }
// ]
// }
// }
//
const result = this.safeValue(response, 'result', {});
const orders = this.safeList(result, 'orders', []);
return this.parseOrders(orders, market, since, limit);
}
/**
* @method
* @name bitteam#fetchOrder
* @description fetches information on an order
* @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrderId
* @param {int|string} id order id
* @param {string} symbol not used by bitteam fetchOrder ()
* @param {object} [params] extra parameters specific to the bitteam api endpoint
* @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
*/
async fetchOrder(id, symbol = undefined, params = {}) {
await this.loadMarkets();
const request = {
'id': id,
};
let market = undefined;
if (symbol !== undefined) {
market = this.market(symbol);
}
const response = await this.privateGetTradeApiCcxtOrderId(this.extend(request, params));
//
// {
// "ok": true,
// "result": {
// "id": 106494347,
// "orderId": "13214332",
// "userId": 15912,
// "pair": "eth_usdt",
// "pairId": 2,
// "quantity": "0.00448598",
// "price": "2015.644995",
// "executedPrice": "2015.644995",
// "fee": {
// "amount": "0",
// "symbol": "eth",
// "userId": 15912,
// "decimals": 18,
// "symbolId": 2,
// "discountAmount": "0",
// "discountSymbol": "btt",
// "discountDecimals": 18,
// "discountSymbolId": 5
// },
// "orderCid": null,
// "executed": "0.00448598",
// "expires": null,
// "baseDecimals": 18,
// "quoteDecimals": 6,
// "timestamp": 1700470476,
// "status": "executed",
// "side": "buy",
// "type": "limit",
// "stopPrice": null,
// "slippage": null
// }
// }
//
const result = this.safeDict(response, 'result');
return this.parseOrder(result, market);
}
/**
* @method
* @name bitteam#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrdersofuser
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open order structures to retrieve (default 10)
* @param {object} [params] extra parameters specific to the bitteam api endpoint
* @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
*/
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
await this.loadMarkets();
const request = {
'type': 'active',
};
return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
}
/**
* @method
* @name bitteam#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrdersofuser
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of closed order structures to retrieve (default 10)
* @param {object} [params] extra parameters specific to the bitteam api endpoint
* @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
*/
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
await this.loadMarkets();
const request = {
'type': 'closed',
};
return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
}
/**
* @method
* @name bitteam#fetchCanceledOrders
* @description fetches information on multiple canceled orders made by the user
* @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrdersofuser
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of canceled order structures to retrieve (default 10)
* @param {object} [params] extra parameters specific to the bitteam api endpoint
* @returns {object} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
*/
async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
await this.loadMarkets();
const request = {
'type': 'cancelled',
};
return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
}
/**
* @method
* @name bitteam#createOrder
* @description create a trade order
* @see https://bit.team/trade/api/documentation#/PRIVATE/postTradeApiCcxtOrdercreate
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the bitteam api endpoint
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
*/
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
await this.loadMarkets();
const market = this.market(symbol);
const request = {
'pairId': market['numericId'].toString(),
'type': type,
'side': side,
'amount': this.amountToPrecision(symbol, amount),
};
if (type === 'limit') {
if (price === undefined) {
throw new ArgumentsRequired(this.id + ' createOrder() requires a price argument for a ' + type + ' order');
}
else {
request['price'] = this.priceToPrecision(symbol, price);
}
}
const response = await this.privatePostTradeApiCcxtOrdercreate(this.extend(request, params));
//
// {
// "ok": true,
// "result": {
// "id": 106733308,
// "userId": 21639,
// "quantity":