UNPKG

ccxt

Version:

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

1,045 lines (1,043 loc) • 123 kB
// ---------------------------------------------------------------------------- // 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 { sha256 } from '@noble/hashes/sha2.js'; import Exchange from './abstract/bitvavo.js'; import { ExchangeError, BadSymbol, AuthenticationError, InsufficientFunds, InvalidOrder, ArgumentsRequired, OrderNotFound, InvalidAddress, BadRequest, RateLimitExceeded, PermissionDenied, ExchangeNotAvailable, AccountSuspended, OnMaintenance } from './base/errors.js'; import { TRUNCATE, TICK_SIZE } from './base/functions/number.js'; import { Precise } from './base/Precise.js'; // ---------------------------------------------------------------------------- /** * @class bitvavo * @augments Exchange */ export default class bitvavo extends Exchange { describe() { return this.deepExtend(super.describe(), { 'id': 'bitvavo', 'name': 'Bitvavo', 'countries': ['NL'], // Netherlands 'rateLimit': 60, // 1000 requests per minute 'version': 'v2', 'certified': false, 'pro': true, 'has': { 'CORS': undefined, 'spot': true, 'margin': false, 'swap': false, 'future': false, 'option': false, 'addMargin': false, 'borrowCrossMargin': false, 'borrowIsolatedMargin': false, 'borrowMargin': false, 'cancelAllOrders': true, 'cancelAllOrdersAfter': true, 'cancelOrder': true, 'closeAllPositions': false, 'closePosition': false, 'createLimitOrder': true, 'createMarketOrder': true, 'createMarketOrderWithCost': true, 'createOrder': true, 'createOrderWithTakeProfitAndStopLoss': false, 'createOrderWithTakeProfitAndStopLossWs': false, 'createPostOnlyOrder': true, 'createReduceOnlyOrder': false, 'createStopLimitOrder': true, 'createStopMarketOrder': true, 'createStopOrder': true, 'editOrder': true, 'fetchAccounts': true, 'fetchBalance': true, 'fetchBorrowInterest': false, 'fetchBorrowRate': false, 'fetchBorrowRateHistories': false, 'fetchBorrowRateHistory': false, 'fetchBorrowRates': false, 'fetchBorrowRatesPerSymbol': false, 'fetchCrossBorrowRate': false, 'fetchCrossBorrowRates': false, 'fetchCurrencies': true, 'fetchDepositAddress': true, 'fetchDepositAddresses': false, 'fetchDepositAddressesByNetwork': false, 'fetchDeposits': true, 'fetchDepositWithdrawFee': 'emulated', 'fetchDepositWithdrawFees': true, 'fetchFundingHistory': false, 'fetchFundingInterval': false, 'fetchFundingIntervals': false, 'fetchFundingRate': false, 'fetchFundingRateHistory': false, 'fetchFundingRates': false, 'fetchGreeks': false, 'fetchIndexOHLCV': false, 'fetchIsolatedBorrowRate': false, 'fetchIsolatedBorrowRates': false, 'fetchIsolatedPositions': false, 'fetchLedger': true, 'fetchLedgerEntry': 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, 'fetchOpenOrders': true, 'fetchOption': false, 'fetchOptionChain': false, 'fetchOrder': true, 'fetchOrderBook': true, 'fetchOrders': true, 'fetchPosition': false, 'fetchPositionHistory': false, 'fetchPositionMode': false, 'fetchPositions': false, 'fetchPositionsForSymbol': false, 'fetchPositionsHistory': false, 'fetchPositionsRisk': false, 'fetchPremiumIndexOHLCV': false, 'fetchSettlementHistory': false, 'fetchTicker': true, 'fetchTickers': true, 'fetchTime': true, 'fetchTrades': true, 'fetchTradingFee': true, 'fetchTradingFees': true, 'fetchTransactions': false, 'fetchTransfer': true, 'fetchTransfers': true, 'fetchVolatilityHistory': false, 'fetchWithdrawals': true, 'reduceMargin': false, 'repayCrossMargin': false, 'repayIsolatedMargin': false, 'repayMargin': false, 'setLeverage': false, 'setMargin': false, 'setMarginMode': false, 'setPositionMode': false, 'transfer': true, 'withdraw': true, }, 'timeframes': { '1m': '1m', '5m': '5m', '15m': '15m', '30m': '30m', '1h': '1h', '2h': '2h', '4h': '4h', '6h': '6h', '8h': '8h', '12h': '12h', '1d': '1d', }, 'urls': { 'logo': 'https://github.com/user-attachments/assets/35d690b1-5710-47f6-86e9-d638ce38685a', 'api': { 'public': 'https://api.bitvavo.com', 'private': 'https://api.bitvavo.com', }, 'www': 'https://bitvavo.com/', 'doc': 'https://docs.bitvavo.com/', 'fees': 'https://bitvavo.com/en/fees', 'referral': 'https://bitvavo.com/?a=24F34952F7', }, 'api': { 'public': { 'get': { '{market}/book': 1, 'report/{market}/book': 1, '{market}/trades': 5, 'report/{market}/trades': 5, 'ticker/price': 1, 'ticker/book': 1, '{market}/candles': 1, 'ticker/24h': { 'cost': 1, 'noMarket': 25 }, 'time': 1, 'markets': 1, 'assets': 1, }, }, 'private': { 'get': { 'order': 1, 'ordersOpen': { 'cost': 5, 'noMarket': 100 }, 'trades': 5, 'orders': 5, 'deposit': 1, 'depositHistory': 5, 'withdrawalHistory': 5, 'account': 1, 'balance': 5, 'stakingBalance': 1, 'account/fees': 1, 'account/history': 1, 'subaccounts': 5, 'subaccounts/transfers': 5, 'subaccounts/transfers/{transferId}': 5, 'institutional/subaccounts/balance': 5, 'institutional/subaccounts/history': 5, 'institutional/subaccounts/orders/open': { 'cost': 5, 'noMarket': 100 }, }, 'post': { 'order': 1, 'cancelOrdersAfter': 5, 'withdrawal': 1, 'crypto/withdrawal': 25, 'subaccounts': 5, 'subaccounts/transfers': 5, }, 'put': { 'order': 1, }, 'delete': { 'order': 1, 'orders': { 'cost': 25, 'noMarket': 100 }, 'atomic/orders': 100, 'institutional/subaccounts/order': 1, 'institutional/subaccounts/orders': { 'cost': 25, 'noMarket': 100 }, }, }, }, 'fees': { 'trading': { 'tierBased': true, 'percentage': true, 'taker': this.parseNumber('0.0025'), 'maker': this.parseNumber('0.002'), 'tiers': { 'taker': [ [this.parseNumber('0'), this.parseNumber('0.0025')], [this.parseNumber('100000'), this.parseNumber('0.0020')], [this.parseNumber('250000'), this.parseNumber('0.0016')], [this.parseNumber('500000'), this.parseNumber('0.0012')], [this.parseNumber('1000000'), this.parseNumber('0.0010')], [this.parseNumber('2500000'), this.parseNumber('0.0008')], [this.parseNumber('5000000'), this.parseNumber('0.0006')], [this.parseNumber('10000000'), this.parseNumber('0.0005')], [this.parseNumber('25000000'), this.parseNumber('0.0004')], ], 'maker': [ [this.parseNumber('0'), this.parseNumber('0.0015')], [this.parseNumber('100000'), this.parseNumber('0.0010')], [this.parseNumber('250000'), this.parseNumber('0.0008')], [this.parseNumber('500000'), this.parseNumber('0.0006')], [this.parseNumber('1000000'), this.parseNumber('0.0005')], [this.parseNumber('2500000'), this.parseNumber('0.0004')], [this.parseNumber('5000000'), this.parseNumber('0.0004')], [this.parseNumber('10000000'), this.parseNumber('0.0003')], [this.parseNumber('25000000'), this.parseNumber('0.0003')], ], }, }, }, 'requiredCredentials': { 'apiKey': true, 'secret': true, }, 'features': { 'spot': { 'sandbox': false, 'createOrder': { 'marginMode': false, 'triggerPrice': true, 'triggerPriceType': undefined, 'triggerDirection': undefined, 'stopLossPrice': true, 'takeProfitPrice': true, 'attachedStopLossTakeProfit': undefined, 'timeInForce': { 'IOC': true, 'FOK': true, 'PO': true, 'GTD': false, }, 'hedged': false, 'trailing': false, 'leverage': false, 'marketBuyRequiresPrice': false, 'marketBuyByCost': true, 'selfTradePrevention': { 'EXPIRE_MAKER': false, 'EXPIRE_TAKER': false, 'EXPIRE_BOTH': true, 'NONE': false, }, 'iceberg': false, }, 'createOrders': undefined, 'fetchMyTrades': { 'marginMode': false, 'limit': 1000, 'daysBack': 100000, 'untilDays': 100000, 'symbolRequired': true, }, 'fetchOrder': { 'marginMode': false, 'trigger': false, 'trailing': false, 'symbolRequired': true, }, 'fetchOpenOrders': { 'marginMode': false, 'limit': undefined, 'trigger': false, 'trailing': false, 'symbolRequired': true, }, 'fetchOrders': { 'marginMode': true, 'limit': 1000, 'daysBack': 100000, 'untilDays': 100000, 'trigger': false, 'trailing': false, 'symbolRequired': true, }, 'fetchClosedOrders': undefined, 'fetchOHLCV': { 'limit': 1440, }, }, 'swap': { 'linear': undefined, 'inverse': undefined, }, 'future': { 'linear': undefined, 'inverse': undefined, }, }, 'exceptions': { 'exact': { '101': ExchangeError, // Unknown error. Operation may or may not have succeeded. '102': BadRequest, // Invalid JSON. '103': RateLimitExceeded, // You have been rate limited. Please observe the Bitvavo-Ratelimit-AllowAt header to see when you can send requests again. Failure to respect this limit will result in an IP ban. The default value is 1000 weighted requests per minute. Please contact support if you wish to increase this limit. '104': RateLimitExceeded, // You have been rate limited by the number of new orders. The default value is 100 new orders per second or 100.000 new orders per day. Please update existing orders instead of cancelling and creating orders. Please contact support if you wish to increase this limit. '105': RateLimitExceeded, // Your IP or API key has been banned for not respecting the rate limit. The ban expires at ${expiryInMs}. '107': ExchangeNotAvailable, // The matching engine is overloaded. Please wait 500ms and resubmit your order. '108': ExchangeNotAvailable, // The matching engine could not process your order in time. Please consider increasing the access window or resubmit your order. '109': ExchangeNotAvailable, // The matching engine did not respond in time. Operation may or may not have succeeded. '110': BadRequest, // Invalid endpoint. Please check url and HTTP method. '200': BadRequest, // ${param} url parameter is not supported. Please note that parameters are case-sensitive and use body parameters for PUT and POST requests. '201': BadRequest, // ${param} body parameter is not supported. Please note that parameters are case-sensitive and use url parameters for GET and DELETE requests. '202': BadRequest, // ${param} order parameter is not supported. Please note that certain parameters are only allowed for market or limit orders. '203': BadSymbol, // {"errorCode":203,"error":"symbol parameter is required."} '204': BadRequest, // ${param} parameter is not supported. '205': BadRequest, // ${param} parameter is invalid. '206': BadRequest, // Use either ${paramA} or ${paramB}. The usage of both parameters at the same time is not supported. '210': InvalidOrder, // Amount exceeds the maximum allowed amount (1000000000). '211': InvalidOrder, // Price exceeds the maximum allowed amount (100000000000). '212': InvalidOrder, // Amount is below the minimum allowed amount for this asset. '213': InvalidOrder, // Price is below the minimum allowed amount (0.000000000000001). '214': InvalidOrder, // Price is too detailed '215': InvalidOrder, // Price is too detailed. A maximum of 15 digits behind the decimal point are allowed. '216': InsufficientFunds, // {"errorCode":216,"error":"You do not have sufficient balance to complete this operation."} '217': InvalidOrder, // {"errorCode":217,"error":"Minimum order size in quote currency is 5 EUR or 0.001 BTC."} '230': ExchangeError, // The order is rejected by the matching engine. '231': ExchangeError, // The order is rejected by the matching engine. TimeInForce must be GTC when markets are paused. '232': BadRequest, // You must change at least one of amount, amountRemaining, price, timeInForce, selfTradePrevention or postOnly. '233': OrderNotFound, // {"errorCode":233,"error":"Order must be active (status new or partiallyFilled) to allow updating/cancelling."}, canceling an already filled or canceled order, see https://github.com/ccxt/ccxt/issues/24154 '234': InvalidOrder, // Market orders cannot be updated. '235': ExchangeError, // You can only have 100 open orders on each book. '236': BadRequest, // You can only update amount or amountRemaining, not both. '240': OrderNotFound, // {"errorCode":240,"error":"No order found. Please be aware that simultaneously updating the same order may return this error."} '300': AuthenticationError, // Authentication is required for this endpoint. '301': AuthenticationError, // {"errorCode":301,"error":"API Key must be of length 64."} '302': AuthenticationError, // Timestamp is invalid. This must be a timestamp in ms. See Bitvavo-Access-Timestamp header or timestamp parameter for websocket. '303': AuthenticationError, // Window must be between 100 and 60000 ms. '304': AuthenticationError, // Request was not received within acceptable window (default 30s, or custom with Bitvavo-Access-Window header) of Bitvavo-Access-Timestamp header (or timestamp parameter for websocket). // "304": AuthenticationError, // Authentication is required for this endpoint. '305': AuthenticationError, // {"errorCode":305,"error":"No active API key found."} '306': AuthenticationError, // No active API key found. Please ensure that you have confirmed the API key by e-mail. '307': PermissionDenied, // This key does not allow access from this IP. '308': AuthenticationError, // {"errorCode":308,"error":"The signature length is invalid (HMAC-SHA256 should return a 64 length hexadecimal string)."} '309': AuthenticationError, // {"errorCode":309,"error":"The signature is invalid."} '310': PermissionDenied, // This key does not allow trading actions. '311': PermissionDenied, // This key does not allow showing account information. '312': PermissionDenied, // This key does not allow withdrawal of funds. '315': BadRequest, // Websocket connections may not be used in a browser. Please use REST requests for this. '317': AccountSuspended, // This account is locked. Please contact support. '400': ExchangeError, // Unknown error. Please contact support with a copy of your request. '401': ExchangeError, // Deposits for this asset are not available at this time. '402': PermissionDenied, // You need to verify your identitiy before you can deposit and withdraw digital assets. '403': PermissionDenied, // You need to verify your phone number before you can deposit and withdraw digital assets. '404': OnMaintenance, // Could not complete this operation, because our node cannot be reached. Possibly under maintenance. '405': ExchangeError, // You cannot withdraw digital assets during a cooldown period. This is the result of newly added bank accounts. '406': BadRequest, // {"errorCode":406,"error":"Your withdrawal is too small."} '407': ExchangeError, // Internal transfer is not possible. '408': InsufficientFunds, // {"errorCode":408,"error":"You do not have sufficient balance to complete this operation."} '409': InvalidAddress, // {"errorCode":409,"error":"This is not a verified bank account."} '410': ExchangeError, // Withdrawals for this asset are not available at this time. '411': BadRequest, // You can not transfer assets to yourself. '412': InvalidAddress, // {"errorCode":412,"error":"eth_address_invalid."} '413': InvalidAddress, // This address violates the whitelist. '414': ExchangeError, // You cannot withdraw assets within 2 minutes of logging in. }, 'broad': { 'start parameter is invalid': BadRequest, // {"errorCode":205,"error":"start parameter is invalid."} 'symbol parameter is invalid': BadSymbol, // {"errorCode":205,"error":"symbol parameter is invalid."} 'amount parameter is invalid': InvalidOrder, // {"errorCode":205,"error":"amount parameter is invalid."} 'orderId parameter is invalid': InvalidOrder, // {"errorCode":205,"error":"orderId parameter is invalid."} }, }, 'options': { 'mica': true, 'currencyToPrecisionRoundingMode': TRUNCATE, 'recvWindow': 10000, // default 10 sec 'networks': { 'ERC20': 'ETH', 'TRC20': 'TRX', }, 'operatorId': undefined, // this will be required soon for order-related endpoints 'fetchCurrencies': { 'fiatCurrencies': ['EUR'], // only fiat atm }, }, 'precisionMode': TICK_SIZE, 'commonCurrencies': { 'MIOTA': 'IOTA', // https://github.com/ccxt/ccxt/issues/7487 }, 'rollingWindowSize': 60000.0, }); } /** * @method * @name bitvavo#fetchTime * @see https://docs.bitvavo.com/docs/rest-api/get-server-time/ * @description fetches the current integer timestamp in milliseconds from the exchange server * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {int} the current integer timestamp in milliseconds from the exchange server */ async fetchTime(params = {}) { const response = await this.publicGetTime(params); // // { "time": 1590379519148 } // return this.safeInteger(response, 'time'); } /** * @method * @name bitvavo#fetchMarkets * @see https://docs.bitvavo.com/docs/rest-api/get-markets/ * @description retrieves data on all markets for bitvavo * @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.publicGetMarkets(params); // // { // "market": "BTC-EUR", // "status": "trading", // "base": "BTC", // "quote": "EUR", // "pricePrecision": "0", // deprecated, this is mostly 0 across other markets too, which is abnormal, so we ignore this. // "tickSize": "1.00", // "minOrderInBaseAsset": "0.00006100", // "minOrderInQuoteAsset": "5.00", // "maxOrderInBaseAsset": "1000000000.00000000", // "maxOrderInQuoteAsset": "1000000000.00", // "quantityDecimals": "8", // "notionalDecimals": "2", // "maxOpenOrders": "100", // "feeCategory": "A", // "orderTypes": [ "market", "limit", "stopLoss", "stopLossLimit", "takeProfit", "takeProfitLimit" ] // } // return this.parseMarkets(response); } parseMarkets(markets) { const result = []; const fees = this.fees; for (let i = 0; i < markets.length; i++) { const market = markets[i]; const id = this.safeString(market, 'market'); const baseId = this.safeString(market, 'base'); const quoteId = this.safeString(market, 'quote'); const base = this.safeCurrencyCode(baseId); const quote = this.safeCurrencyCode(quoteId); const status = this.safeString(market, 'status'); result.push(this.safeMarketStructure({ 'id': id, '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': (status === 'trading'), 'contract': false, 'linear': undefined, 'inverse': undefined, 'contractSize': undefined, 'expiry': undefined, 'expiryDatetime': undefined, 'strike': undefined, 'optionType': undefined, 'taker': fees['trading']['taker'], 'maker': fees['trading']['maker'], 'precision': { 'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'quantityDecimals'))), 'price': this.safeNumber(market, 'tickSize'), 'cost': this.parseNumber(this.parsePrecision(this.safeString(market, 'notionalDecimals'))), }, 'limits': { 'leverage': { 'min': undefined, 'max': undefined, }, 'amount': { 'min': this.safeNumber(market, 'minOrderInBaseAsset'), 'max': this.safeNumber(market, 'maxOrderInBaseAsset'), }, 'price': { 'min': undefined, 'max': undefined, }, 'cost': { 'min': this.safeNumber(market, 'minOrderInQuoteAsset'), 'max': this.safeNumber(market, 'maxOrderInQuoteAsset'), }, }, 'created': undefined, 'info': market, })); } return result; } /** * @method * @name bitvavo#fetchCurrencies * @see https://docs.bitvavo.com/docs/rest-api/get-asset-data/ * @description fetches all available currencies on an exchange * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} an associative dictionary of currencies */ async fetchCurrencies(params = {}) { const response = await this.publicGetAssets(params); // // [ // { // "symbol": "USDT", // "displayTicker": "USDT", // "name": "Tether", // "slug": "tether", // "popularity": -1, // "decimals": 6, // "depositFee": "0", // "depositConfirmations": 64, // "depositStatus": "OK", // "withdrawalFee": "3.2", // "withdrawalMinAmount": "3.2", // "withdrawalStatus": "OK", // "networks": [ // "ETH" // ], // "light": { // "color": "#009393", // "icon": { "hash": "4ad7c699", "svg": "https://...", "webp16": "https://...", "webp32": "https://...", "webp64": "https://...", "webp128": "https://...", "webp256": "https://...", "png16": "https://...", "png32": "https://...", "png64": "https://...", "png128": "https://...", "png256": "https://..." // } // }, // "dark": { // "color": "#009393", // "icon": { "hash": "4ad7c699", "svg": "https://...", "webp16": "https://...", "webp32": "https://...", "webp64": "https://...", "webp128": "https://...", "webp256": "https://...", "png16": "https://...", "png32": "https://...", "png64": "https://...", "png128": "https://...", "png256": "https://..." // } // }, // "visibility": "PUBLIC", // "message": "" // }, // ] // return this.parseCurrencies(response); } parseCurrency(rawCurrency) { // // [ // { // "symbol": "USDT", // "displayTicker": "USDT", // "name": "Tether", // "slug": "tether", // "popularity": -1, // "decimals": 6, // "depositFee": "0", // "depositConfirmations": 64, // "depositStatus": "OK", // "withdrawalFee": "3.2", // "withdrawalMinAmount": "3.2", // "withdrawalStatus": "OK", // "networks": [ // "ETH" // ], // "light": { // "color": "#009393", // "icon": { "hash": "4ad7c699", "svg": "https://...", "webp16": "https://...", "webp32": "https://...", "webp64": "https://...", "webp128": "https://...", "webp256": "https://...", "png16": "https://...", "png32": "https://...", "png64": "https://...", "png128": "https://...", "png256": "https://..." // } // }, // "dark": { // "color": "#009393", // "icon": { "hash": "4ad7c699", "svg": "https://...", "webp16": "https://...", "webp32": "https://...", "webp64": "https://...", "webp128": "https://...", "webp256": "https://...", "png16": "https://...", "png32": "https://...", "png64": "https://...", "png128": "https://...", "png256": "https://..." // } // }, // "visibility": "PUBLIC", // "message": "" // }, // ] // const fiatCurrencies = this.handleOption('fetchCurrencies', 'fiatCurrencies', []); const id = this.safeString(rawCurrency, 'symbol'); const code = this.safeCurrencyCode(id); const isFiat = this.inArray(code, fiatCurrencies); const networks = {}; const networksArray = this.safeList(rawCurrency, 'networks', []); const deposit = this.safeString(rawCurrency, 'depositStatus') === 'OK'; const withdrawal = this.safeString(rawCurrency, 'withdrawalStatus') === 'OK'; const active = deposit && withdrawal; const withdrawFee = this.safeNumber(rawCurrency, 'withdrawalFee'); const precision = this.safeString(rawCurrency, 'decimals', '8'); const minWithdraw = this.safeNumber(rawCurrency, 'withdrawalMinAmount'); // btw, absolutely all of them have 1 network atm for (let j = 0; j < networksArray.length; j++) { const networkId = networksArray[j]; const networkCode = this.networkIdToCode(networkId, code); if (networkCode !== undefined) { networks[networkCode] = { 'info': rawCurrency, 'id': networkId, 'network': networkCode, 'active': active, 'deposit': deposit, 'withdraw': withdrawal, 'fee': withdrawFee, 'precision': this.parseNumber(this.parsePrecision(precision)), 'limits': { 'withdraw': { 'min': minWithdraw, 'max': undefined, }, }, }; } } return this.safeCurrencyStructure({ 'info': rawCurrency, 'id': id, 'code': code, 'name': this.safeString(rawCurrency, 'name'), 'active': active, 'deposit': deposit, 'withdraw': withdrawal, 'networks': networks, 'fee': withdrawFee, 'precision': undefined, 'type': isFiat ? 'fiat' : 'crypto', 'limits': { 'amount': { 'min': undefined, 'max': undefined, }, 'deposit': { 'min': undefined, 'max': undefined, }, 'withdraw': { 'min': minWithdraw, 'max': undefined, }, }, }); } /** * @method * @name bitvavo#fetchTicker * @see https://docs.bitvavo.com/docs/rest-api/get-candlestick-data-24-h/ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market * @param {string} symbol unified symbol of the market to fetch the ticker for * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure} */ async fetchTicker(symbol, params = {}) { if (this.markets === undefined) { await this.loadMarkets(); } const market = this.market(symbol); const request = { 'market': market['id'], }; const response = await this.publicGetTicker24h(this.extend(request, params)); // // { // "market":"ETH-BTC", // "open":"0.022578", // "high":"0.023019", // "low":"0.022572", // "last":"0.023019", // "volume":"25.16366324", // "volumeQuote":"0.57333305", // "bid":"0.023039", // "bidSize":"0.53500578", // "ask":"0.023041", // "askSize":"0.47859202", // "timestamp":1590381666900 // } // return this.parseTicker(response, market); } parseTicker(ticker, market = undefined) { // // fetchTicker // // { // "market":"ETH-BTC", // "open":"0.022578", // "high":"0.023019", // "low":"0.022573", // "last":"0.023019", // "volume":"25.16366324", // "volumeQuote":"0.57333305", // "bid":"0.023039", // "bidSize":"0.53500578", // "ask":"0.023041", // "askSize":"0.47859202", // "timestamp":1590381666900 // } // const marketId = this.safeString(ticker, 'market'); const symbol = this.safeSymbol(marketId, market, '-'); const timestamp = this.safeInteger(ticker, 'timestamp'); const last = this.safeString(ticker, 'last'); const baseVolume = this.safeString(ticker, 'volume'); const quoteVolume = this.safeString(ticker, 'volumeQuote'); const open = this.safeString(ticker, 'open'); return this.safeTicker({ 'symbol': symbol, 'timestamp': timestamp, 'datetime': this.iso8601(timestamp), 'high': this.safeString(ticker, 'high'), 'low': this.safeString(ticker, 'low'), 'bid': this.safeString(ticker, 'bid'), 'bidVolume': this.safeString(ticker, 'bidSize'), 'ask': this.safeString(ticker, 'ask'), 'askVolume': this.safeString(ticker, 'askSize'), 'vwap': undefined, 'open': open, 'close': last, 'last': last, 'previousClose': undefined, // previous day close 'change': undefined, 'percentage': undefined, 'average': undefined, 'baseVolume': baseVolume, 'quoteVolume': quoteVolume, 'info': ticker, }, market); } /** * @method * @name bitvavo#fetchTickers * @see https://docs.bitvavo.com/docs/rest-api/get-candlestick-data-24-h/ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure} */ async fetchTickers(symbols = undefined, params = {}) { if (this.markets === undefined) { await this.loadMarkets(); } const response = await this.publicGetTicker24h(params); // // [ // { // "market":"ADA-BTC", // "open":"0.0000059595", // "high":"0.0000059765", // "low":"0.0000059595", // "last":"0.0000059765", // "volume":"2923.172", // "volumeQuote":"0.01743483", // "bid":"0.0000059515", // "bidSize":"1117.630919", // "ask":"0.0000059585", // "askSize":"809.999739", // "timestamp":1590382266324 // } // ] // return this.parseTickers(response, symbols); } /** * @method * @name bitvavo#fetchTrades * @see https://docs.bitvavo.com/docs/rest-api/get-trades/ * @description get the list of most recent trades for a particular symbol * @param {string} symbol unified symbol of the market to fetch trades for * @param {int} [since] timestamp in ms of the earliest trade to fetch * @param {int} [limit] the maximum amount of trades to fetch * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {int} [params.until] the latest time in ms to fetch entries for * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params) * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades} */ async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) { if (this.markets === undefined) { await this.loadMarkets(); } const market = this.market(symbol); let paginate = false; [paginate, params] = this.handleOptionAndParams(params, 'fetchTrades', 'paginate'); if (paginate) { return await this.fetchPaginatedCallDynamic('fetchTrades', symbol, since, limit, params); } let request = { 'market': market['id'], // "limit": 500, // default 500, max 1000 // "start": since, // "end": this.milliseconds (), // "tradeIdFrom": "57b1159b-6bf5-4cde-9e2c-6bd6a5678baf", // "tradeIdTo": "57b1159b-6bf5-4cde-9e2c-6bd6a5678baf", }; if (limit !== undefined) { request['limit'] = Math.min(limit, 1000); } if (since !== undefined) { request['start'] = since; } [request, params] = this.handleUntilOption('end', request, params); const response = await this.publicGetMarketTrades(this.extend(request, params)); // // [ // { // "id":"94154c98-6e8b-4e33-92a8-74e33fc05650", // "timestamp":1590382761859, // "amount":"0.06026079", // "price":"8095.3", // "side":"buy" // } // ] // return this.parseTrades(response, market, since, limit); } parseTrade(trade, market = undefined) { // // fetchTrades (public) // // { // "id":"94154c98-6e8b-4e33-92a8-74e33fc05650", // "timestamp":1590382761859, // "amount":"0.06026079", // "price":"8095.3", // "side":"buy" // } // // createOrder, fetchOpenOrders, fetchOrders, editOrder (private) // // { // "id":"b0c86aa5-6ed3-4a2d-ba3a-be9a964220f4", // "timestamp":1590505649245, // "amount":"0.249825", // "price":"183.49", // "taker":true, // "fee":"0.12038925", // "feeCurrency":"EUR", // "settled":true // } // // fetchMyTrades (private) // // { // "id":"b0c86aa5-6ed3-4a2d-ba3a-be9a964220f4", // "orderId":"af76d6ce-9f7c-4006-b715-bb5d430652d0", // "timestamp":1590505649245, // "market":"ETH-EUR", // "side":"sell", // "amount":"0.249825", // "price":"183.49", // "taker":true, // "fee":"0.12038925", // "feeCurrency":"EUR", // "settled":true // } // // watchMyTrades (private) // // { // "event": "fill", // "timestamp": 1590964470132, // "market": "ETH-EUR", // "orderId": "85d082e1-eda4-4209-9580-248281a29a9a", // "fillId": "861d2da5-aa93-475c-8d9a-dce431bd4211", // "side": "sell", // "amount": "0.1", // "price": "211.46", // "taker": true, // "fee": "0.056", // "feeCurrency": "EUR" // } // const priceString = this.safeString(trade, 'price'); const amountString = this.safeString(trade, 'amount'); const timestamp = this.safeInteger(trade, 'timestamp'); const side = this.safeString(trade, 'side'); const id = this.safeString2(trade, 'id', 'fillId'); const marketId = this.safeString(trade, 'market'); const symbol = this.safeSymbol(marketId, market, '-'); const taker = this.safeValue(trade, 'taker'); let takerOrMaker = undefined; if (taker !== undefined) { takerOrMaker = taker ? 'taker' : 'maker'; } const feeCostString = this.safeString(trade, 'fee'); let fee = undefined; if (feeCostString !== undefined) { const feeCurrencyId = this.safeString(trade, 'feeCurrency'); const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId); fee = { 'cost': feeCostString, 'currency': feeCurrencyCode, }; } const orderId = this.safeString(trade, 'orderId'); return this.safeTrade({ 'info': trade, 'id': id, 'symbol': symbol, 'timestamp': timestamp, 'datetime': this.iso8601(timestamp), 'order': orderId, 'type': undefined, 'side': side, 'takerOrMaker': takerOrMaker, 'price': priceString, 'amount': amountString, 'cost': undefined, 'fee': fee, }, market); } /** * @method * @name bitvavo#fetchTradingFees * @see https://docs.bitvavo.com/docs/rest-api/get-account-fees/ * @description fetch the trading fees for multiple markets * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure} indexed by market symbols */ async fetchTradingFees(params = {}) { if (this.markets === undefined) { await this.loadMarkets(); } const response = await this.privateGetAccount(params); // // { // "fees": { // "taker": "0.0025", // "maker": "0.0015", // "volume": "10000.00" // } // } // return this.parseTradingFees(response); } parseTradingFees(fees, market = undefined) { // // { // "fees": { // "taker": "0.0025", // "maker": "0.0015", // "volume": "10000.00" // } // } // const feesValue = this.safeValue(fees, 'fees'); const maker = this.safeNumber(feesValue, 'maker'); const taker = this.safeNumber(feesValue, 'taker'); const result = {}; for (let i = 0; i < this.symbols.length; i++) { const symbol = this.symbols[i]; result[symbol] = { 'info': fees, 'symbol': symbol, 'maker': maker, 'taker': taker, 'percentage': true, 'tierBased': true, }; } return result; } /** * @method * @name bitvavo#fetchTradingFee * @see https://docs.bitvavo.com/docs/rest-api/get-market-fees/ * @description fetch the trading fees for a market * @param {string} symbol unified market symbol * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [fee structure]{@link https://docs.ccxt.com/?id=fee-structure} */ async fetchTradingFee(symbol, params = {}) { if (this.markets === undefined) { await this.loadMarkets(); } const market = this.market(symbol); const request = { 'market': market['id'], }; const response = await this.privateGetAccountFees(this.extend(request, params)); // // { // "tier": "0", // "volume": "10000.00", // "taker": "0.0025", // "maker": "0.0015" // } // return this.parseTradingFee(response, market); } parseTradingFee(fee, market = undefined) { return { 'info': fee, 'symbol': this.safeSymbol(undefined, market), 'maker': this.safeNumber(fee, 'maker'), 'taker': this.safeNumber(fee, 'taker'), 'percentage': true, 'tierBased': true, }; } /** * @method * @name bitvavo#fetchOrderBook * @see https://docs.bitvavo.com/docs/rest-api/get-order-book/ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data * @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 * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} an [order boo