# BitMEX Exchange Specification # # Auto-generated by: mix ccxt.extract bitmex # CCXT version: 4.5.34 # Spec format version: 1 # # Review before use: # - signing: Detected from sign() method, verify with testnet # - endpoints: Raw paths extracted, map to unified API as needed # - exceptions: Extracted (exact, broad, HTTP status codes) # - features/options: Extracted from describe() # - classification: Set to :supported initially, promote after validation # %{ api_param_requirements: nil, certified: true, classification: :certified_pro, comment: nil, countries: [ "SC" ], currencies: %{}, currency_aliases: %{ "BCHSV" => "BSV", "GWEI" => "ETH", "Gwei" => "ETH", "LAMP" => "SOL", "LAMp" => "SOL", "USDt" => "USDT", "XBT" => "BTC", "XBt" => "BTC" }, dex: false, enable_rate_limit: true, endpoint_extraction_stats: %{ "capturedMethods" => 36, "coveragePercent" => 100, "enabledMethods" => 42, "excluded" => [ %{ "method" => "fetchDepositsWithdrawals", "reason" => "emulated (returns cached data, no HTTP call)" }, %{ "method" => "fetchDepositWithdrawFee", "reason" => "emulated (returns cached data, no HTTP call)" }, %{ "method" => "fetchFundingRate", "reason" => "emulated (returns cached data, no HTTP call)" }, %{ "method" => "fetchLeverage", "reason" => "emulated (returns cached data, no HTTP call)" }, %{ "method" => "fetchTransactions", "reason" => "emulated (returns cached data, no HTTP call)" } ], "excludedMethods" => 5, "extractableMethods" => 37, "failures" => [ %{ "error" => "bitmex createOrder() requires a triggerDirection argument, one of (above, below)", "method" => "createTrailingAmountOrder" } ] }, endpoints: [ %{ api_section: "private", auth: true, cost: 1, market_type: :spot, method: :delete, name: :cancel_all_orders, param_mappings: %{}, params: [ :symbol ], path: "/order/all", source: :intercepted }, %{ api_section: "private", auth: true, cost: 5, default_params: %{ "timeout" => 1 }, market_type: :spot, method: :post, name: :cancel_all_orders_after, param_mappings: %{}, params: [ :timeout ], path: "/order/cancelAllAfter", source: :intercepted }, %{ api_section: "private", auth: true, cost: 1, market_type: :spot, method: :delete, name: :cancel_order, param_mappings: %{ "id" => "orderID" }, params: [ :id, :symbol ], path: "/order", source: :intercepted }, %{ api_section: "private", auth: true, cost: 1, default_params: %{ "orderID" => [ "test-order-id" ] }, market_type: :spot, method: :delete, name: :cancel_orders, param_mappings: %{}, params: [ :ids, :symbol ], path: "/order", source: :intercepted }, %{ api_section: "private", auth: true, cost: 1, default_params: %{ "ordType" => "Limit", "orderQty" => 0, "text" => "CCXT" }, market_type: :spot, method: :post, name: :create_limit_order, param_mappings: %{}, params: [ :symbol, :side, :amount, :price ], path: "/order", source: :intercepted }, %{ api_section: "private", auth: true, cost: 1, default_params: %{ "ordType" => "Market", "orderQty" => 0, "text" => "CCXT" }, market_type: :spot, method: :post, name: :create_market_order, param_mappings: %{}, params: [ :symbol, :side, :amount, :price ], path: "/order", source: :intercepted }, %{ api_section: "private", auth: true, cost: 1, default_params: %{ "orderQty" => 0, "text" => "CCXT" }, market_type: :spot, method: :post, name: :create_order, param_mappings: %{ "type" => "ordType" }, params: [ :symbol, :type, :side, :amount, :price ], path: "/order", source: :intercepted }, %{ api_section: "private", auth: true, cost: 1, default_params: %{ "orderQty" => 0, "reduceOnly" => true, "symbol" => "BTCUSDT", "text" => "CCXT" }, market_type: :swap, method: :post, name: :create_reduce_only_order, param_mappings: %{ "type" => "ordType" }, params: [ :symbol, :type, :side, :amount, :price ], path: "/order", source: :intercepted }, %{ api_section: "private", auth: true, cost: 1, default_params: %{ "ordType" => "LimitIfTouched", "orderQty" => 0, "symbol" => "BTCUSDT", "text" => "CCXT" }, market_type: :swap, method: :post, name: :create_stop_order, param_mappings: %{ "triggerPrice" => "stopPx" }, params: [ :symbol, :type, :side, :amount, :price, :triggerPrice ], path: "/order", source: :intercepted }, %{ api_section: "private", auth: true, cost: 1, default_params: %{ "ordType" => "LimitIfTouched", "orderQty" => 0, "symbol" => "BTCUSDT", "text" => "CCXT" }, market_type: :swap, method: :post, name: :create_trigger_order, param_mappings: %{ "triggerPrice" => "stopPx" }, params: [ :symbol, :type, :side, :amount, :price, :triggerPrice ], path: "/order", source: :intercepted }, %{ api_section: "private", auth: true, cost: 1, default_params: %{ "orderQty" => 0, "text" => "CCXT" }, market_type: :spot, method: :put, name: :edit_order, param_mappings: %{ "id" => "orderID" }, params: [ :id, :symbol, :type, :side, :amount, :price ], path: "/order", source: :intercepted }, %{ api_section: "private", auth: true, cost: 5, default_params: %{ "currency" => "all" }, market_type: :spot, method: :get, name: :fetch_balance, param_mappings: %{}, params: [], path: "/user/margin", source: :intercepted }, %{ api_section: "private", auth: true, cost: 5, market_type: :spot, method: :get, name: :fetch_closed_orders, param_mappings: %{}, params: [ :symbol, :since, :limit ], path: "/order", source: :intercepted }, %{ api_section: "public", auth: false, cost: 5, market_type: :spot, method: :get, name: :fetch_currencies, param_mappings: %{}, params: [], path: "/wallet/assets", source: :intercepted }, %{ api_section: "private", auth: true, cost: 5, market_type: :spot, method: :get, name: :fetch_deposit_address, param_mappings: %{}, params: [ :code ], path: "/user/depositAddress", source: :intercepted }, %{ api_section: "public", auth: false, cost: 5, market_type: :spot, method: :get, name: :fetch_deposit_withdraw_fees, param_mappings: %{}, params: [ :codes ], path: "/wallet/assets", source: :intercepted }, %{ api_section: "public", auth: false, cost: 5, default_params: %{ "reverse" => true, "symbol" => "BTCUSDT" }, market_type: :swap, method: :get, name: :fetch_funding_rate_history, param_mappings: %{}, params: [ :symbol, :since, :limit ], path: "/funding", source: :intercepted }, %{ api_section: "public", auth: false, cost: 5, market_type: :swap, method: :get, name: :fetch_funding_rates, param_mappings: %{}, params: [ :symbols ], path: "/instrument/activeAndIndices", source: :intercepted }, %{ api_section: "public", auth: false, cost: 5, market_type: :spot, method: :get, name: :fetch_l2_order_book, param_mappings: %{}, params: [ :symbol, :limit ], path: "/orderBook/L2", source: :intercepted }, %{ api_section: "private", auth: true, cost: 5, market_type: :spot, method: :get, name: :fetch_ledger, param_mappings: %{ "code" => "currency" }, params: [ :code, :since, :limit ], path: "/user/walletHistory", source: :intercepted }, %{ api_section: "private", auth: true, cost: 5, market_type: :swap, method: :get, name: :fetch_leverages, param_mappings: %{}, params: [ :symbols ], path: "/position", source: :intercepted }, %{ api_section: "public", auth: false, cost: 5, default_params: %{ "symbol" => "BTCUSDT" }, market_type: :swap, method: :get, name: :fetch_liquidations, param_mappings: %{}, params: [ :symbol, :since, :limit ], path: "/liquidation", source: :intercepted }, %{ api_section: "public", auth: false, cost: 5, market_type: :spot, method: :get, name: :fetch_markets, param_mappings: %{}, params: [], path: "/instrument/active", source: :intercepted }, %{ api_section: "private", auth: true, cost: 5, market_type: :spot, method: :get, name: :fetch_my_trades, param_mappings: %{}, params: [ :symbol, :since, :limit ], path: "/execution/tradeHistory", source: :intercepted }, %{ api_section: "public", auth: false, cost: 5, default_params: %{ "partial" => true }, market_type: :spot, method: :get, name: :fetch_ohlcv, param_mappings: %{ "limit" => "count", "since" => "startTime", "timeframe" => "binSize" }, params: [ :symbol, :timeframe, :since, :limit ], path: "/trade/bucketed", source: :intercepted }, %{ api_section: "private", auth: true, cost: 5, default_params: %{ "filter" => "{\"open\":true}" }, market_type: :spot, method: :get, name: :fetch_open_orders, param_mappings: %{}, params: [ :symbol, :since, :limit ], path: "/order", source: :intercepted }, %{ api_section: "private", auth: true, cost: 5, default_params: %{ "filter" => "{\"orderID\":\"test-order-id\"}" }, market_type: :spot, method: :get, name: :fetch_order, param_mappings: %{}, params: [ :id, :symbol ], path: "/order", source: :intercepted }, %{ api_section: "public", auth: false, cost: 5, market_type: :spot, method: :get, name: :fetch_order_book, param_mappings: %{ "limit" => "depth" }, params: [ :symbol, :limit ], path: "/orderBook/L2", response_transformer: :order_book_from_flat_list, source: :intercepted }, %{ api_section: "private", auth: true, cost: 5, market_type: :spot, method: :get, name: :fetch_orders, param_mappings: %{}, params: [ :symbol, :since, :limit ], path: "/order", source: :intercepted }, %{ api_section: "private", auth: true, cost: 5, market_type: :swap, method: :get, name: :fetch_positions, param_mappings: %{}, params: [ :symbols ], path: "/position", source: :intercepted }, %{ api_section: "public", auth: false, cost: 5, market_type: :spot, method: :get, name: :fetch_ticker, param_mappings: %{}, params: [ :symbol ], path: "/instrument", response_transformer: :unwrap_single_element_list, source: :intercepted }, %{ api_section: "public", auth: false, cost: 5, market_type: :spot, method: :get, name: :fetch_tickers, param_mappings: %{}, params: [ :symbols ], path: "/instrument/activeAndIndices", source: :intercepted }, %{ api_section: "public", auth: false, cost: 5, market_type: :spot, method: :get, name: :fetch_trades, param_mappings: %{ "limit" => "count", "since" => "startTime" }, params: [ :symbol, :since, :limit ], path: "/trade", source: :intercepted }, %{ api_section: "private", auth: true, cost: 1, default_params: %{ "symbol" => "BTCUSDT" }, market_type: :swap, method: :post, name: :set_leverage, param_mappings: %{}, params: [ :leverage, :symbol ], path: "/position/leverage", source: :intercepted }, %{ api_section: "private", auth: true, cost: 1, default_params: %{ "enabled" => true, "symbol" => "BTCUSDT" }, market_type: :swap, method: :post, name: :set_margin_mode, param_mappings: %{}, params: [ :marginMode, :symbol ], path: "/position/isolate", source: :intercepted }, %{ api_section: "private", auth: true, cost: 5, default_params: %{ "amount" => 0.00125 }, market_type: :spot, method: :post, name: :withdraw, param_mappings: %{ "code" => "currency" }, params: [ :code, :amount, :address, :tag ], path: "/user/requestWithdrawal", source: :intercepted } ], error_code_details: %{ "Access Denied" => %{ description: nil, type: :access_restricted }, "Account has insufficient Available Balance" => %{ description: nil, type: :insufficient_balance }, "Account is restricted" => %{ description: "{\"error\":{\"message\":\"Account is restricted\",\"name\":\"HTTPError\"}}", type: :access_restricted }, "Duplicate clOrdID" => %{ description: nil, type: :invalid_order }, "Invalid API Key." => %{ description: nil, type: :invalid_credentials }, "Invalid price" => %{ description: nil, type: :invalid_order }, "Invalid stopPx for ordType" => %{ description: nil, type: :invalid_order }, "Server Error" => %{ description: "{\"error\":{\"message\":\"Server Error\",\"name\":\"HTTPError\"}}", type: :exchange_error }, "Service unavailable" => %{ description: "{\"error\":{\"message\":\"Service unavailable\",\"name\":\"HTTPError\"}}", type: :network_error }, "Signature not valid" => %{ description: nil, type: :invalid_credentials }, "This key is disabled." => %{ description: nil, type: :access_restricted }, "Unable to cancel order due to existing state" => %{ description: nil, type: :invalid_order }, "We require all new traders to verify" => %{ description: "We require all new traders to verify their identity before their first deposit. Please visit bitmex.com/verify to complete the process.", type: :access_restricted }, "orderQty is invalid" => %{ description: nil, type: :invalid_order }, "overloaded" => %{ description: nil, type: :network_error } }, error_codes: %{ "Access Denied" => :access_restricted, "Account has insufficient Available Balance" => :insufficient_balance, "Account is restricted" => :access_restricted, "Duplicate clOrdID" => :invalid_order, "Invalid API Key." => :invalid_credentials, "Invalid price" => :invalid_order, "Invalid stopPx for ordType" => :invalid_order, "Server Error" => :exchange_error, "Service unavailable" => :network_error, "Signature not valid" => :invalid_credentials, "This key is disabled." => :access_restricted, "Unable to cancel order due to existing state" => :invalid_order, "We require all new traders to verify" => :access_restricted, "orderQty is invalid" => :invalid_order, "overloaded" => :network_error }, exceptions: %{ broad: %{ "Account has insufficient Available Balance" => :insufficient_funds, "Server Error" => :exchange_error, "Service unavailable" => :exchange_not_available, "Signature not valid" => :authentication_error, "Unable to cancel order due to existing state" => :invalid_order, "We require all new traders to verify" => :permission_denied, "overloaded" => :exchange_not_available }, exact: %{ "Access Denied" => :permission_denied, "Account is restricted" => :permission_denied, "Duplicate clOrdID" => :invalid_order, "Invalid API Key." => :authentication_error, "Invalid price" => :invalid_order, "Invalid stopPx for ordType" => :invalid_order, "This key is disabled." => :permission_denied, "orderQty is invalid" => :invalid_order } }, exchange_options: %{ "api-expires" => 5, "defaultNetworkCodeReplacements" => %{ "BRC20" => %{ "BRC20" => "BTC" }, "CRO" => %{ "CRC20" => "CRONOS" }, "ETH" => %{ "ERC20" => "ETH" }, "TRX" => %{ "TRC20" => "TRX" } }, "fetchOHLCVOpenTimestamp" => true, "networks" => %{ "ADA" => "ada", "AVAXC" => "avax", "BEP20" => "bsc", "BTC" => "btc", "DOT" => "dot", "ERC20" => "eth", "NEAR" => "near", "SOL" => "sol", "TRC20" => "tron", "XTZ" => "xtz" }, "networksById" => %{ "ada" => "ADA", "avax" => "AVAXC", "bsc" => "BEP20", "btc" => "BTC", "dot" => "DOT", "eth" => "ERC20", "near" => "NEAR", "sol" => "SOL", "tron" => "TRC20", "xtz" => "XTZ" }, "oldPrecision" => false }, extended_metadata: %{ fees_url: "https://www.bitmex.com/app/fees", limits: %{ "amount" => %{}, "cost" => %{}, "leverage" => %{}, "price" => %{} }, logo_url: "https://github.com/user-attachments/assets/c78425ab-78d5-49d6-bd14-db7734798f04", referral_discount: 0.1, referral_url: "https://www.bitmex.com/app/register/NZTR1q" }, extracted_metadata: %{ ccxt_version: "4.5.34" }, features: %{ default: %{ create_order: %{ hedged: false, margin_mode: true, market_buy_by_cost: false, market_buy_requires_price: false, stop_loss_price: false, take_profit_price: false, time_in_force: %{ fok: true, gtd: false, ioc: true, po: true }, trailing: true, trigger_direction: true, trigger_price: true, trigger_price_type: %{ last: true, mark: true } }, fetch_closed_orders: %{ limit: 500, margin_mode: false, symbol_required: false, trailing: false, trigger: false, until_days: 1000000 }, fetch_my_trades: %{ limit: 500, margin_mode: false, symbol_required: false, until_days: 1000000 }, fetch_ohlcv: %{ limit: 10000 }, fetch_open_orders: %{ limit: 500, margin_mode: false, symbol_required: false, trailing: false, trigger: false }, fetch_order: %{ margin_mode: false, symbol_required: false, trailing: false, trigger: false }, fetch_orders: %{ limit: 500, margin_mode: false, symbol_required: false, trailing: false, trigger: false, until_days: 1000000 }, sandbox: true }, derivatives: %{ create_order: %{ trigger_price_type: %{ index: true } }, extends: "default" }, future: %{ inverse: %{ extends: "derivatives" }, linear: %{ extends: "derivatives" } }, spot: %{ create_order: %{ trigger_price_type: %{ index: false } }, extends: "default" }, swap: %{ inverse: %{ extends: "derivatives" }, linear: %{ extends: "derivatives" } } }, fees: nil, handle_content_type_application_zip: nil, handle_errors_source: "handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {\n if (response === undefined) {\n return undefined;\n }\n if (code === 429) {\n throw new errors.DDoSProtection(this.id + ' ' + body);\n }\n if (code >= 400) {\n const error = this.safeValue(response, 'error', {});\n const message = this.safeString(error, 'message');\n const feedback = this.id + ' ' + body;\n this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);\n this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);\n if (code === 400) {\n throw new errors.BadRequest(feedback);\n }\n throw new errors.ExchangeError(feedback); // unknown message\n }\n return undefined;\n }", has: %{ add_margin: false, borrow_cross_margin: false, borrow_isolated_margin: false, borrow_margin: false, c_o_r_s: false, cancel_all_orders: true, cancel_all_orders_after: true, cancel_all_orders_ws: false, cancel_order: true, cancel_order_with_client_order_id: false, cancel_order_ws: false, cancel_orders: true, cancel_orders_with_client_order_id: false, cancel_orders_ws: false, close_all_positions: false, close_position: true, create_deposit_address: false, create_limit_buy_order: false, create_limit_buy_order_ws: false, create_limit_order: true, create_limit_order_ws: false, create_limit_sell_order: false, create_limit_sell_order_ws: false, create_market_buy_order: false, create_market_buy_order_with_cost: false, create_market_buy_order_with_cost_ws: false, create_market_buy_order_ws: false, create_market_order: true, create_market_order_with_cost: false, create_market_order_with_cost_ws: false, create_market_order_ws: true, create_market_sell_order: false, create_market_sell_order_with_cost: false, create_market_sell_order_with_cost_ws: false, create_market_sell_order_ws: false, create_order: true, create_order_with_take_profit_and_stop_loss: false, create_order_with_take_profit_and_stop_loss_ws: false, create_order_ws: false, create_orders: false, create_post_only_order: false, create_post_only_order_ws: false, create_reduce_only_order: true, create_reduce_only_order_ws: false, create_stop_limit_order: false, create_stop_limit_order_ws: false, create_stop_loss_order: false, create_stop_loss_order_ws: false, create_stop_market_order: false, create_stop_market_order_ws: false, create_stop_order: true, create_stop_order_ws: false, create_take_profit_order: false, create_take_profit_order_ws: false, create_trailing_amount_order: true, create_trailing_amount_order_ws: false, create_trailing_percent_order: false, create_trailing_percent_order_ws: false, create_trigger_order: true, create_trigger_order_ws: false, deposit: false, edit_order: true, edit_order_with_client_order_id: false, edit_order_ws: false, edit_orders: false, fetch_accounts: false, fetch_balance: true, fetch_balance_ws: false, fetch_bids_asks: false, fetch_borrow_interest: false, fetch_borrow_rate: false, fetch_borrow_rate_histories: false, fetch_borrow_rate_history: false, fetch_borrow_rates: false, fetch_borrow_rates_per_symbol: false, fetch_canceled_and_closed_orders: false, fetch_canceled_orders: false, fetch_closed_order: false, fetch_closed_orders: true, fetch_closed_orders_ws: false, fetch_convert_currencies: false, fetch_convert_quote: false, fetch_convert_trade: false, fetch_convert_trade_history: false, fetch_cross_borrow_rate: false, fetch_cross_borrow_rates: false, fetch_currencies: true, fetch_currencies_ws: true, fetch_deposit: false, fetch_deposit_address: true, fetch_deposit_addresses: false, fetch_deposit_addresses_by_network: false, fetch_deposit_withdraw_fee: true, fetch_deposit_withdraw_fees: true, fetch_deposits: false, fetch_deposits_withdrawals: true, fetch_deposits_ws: false, fetch_funding_history: false, fetch_funding_interval: false, fetch_funding_intervals: false, fetch_funding_rate: true, fetch_funding_rate_history: true, fetch_funding_rates: true, fetch_greeks: false, fetch_index_ohlcv: false, fetch_isolated_borrow_rate: false, fetch_isolated_borrow_rates: false, fetch_isolated_positions: false, fetch_l2_order_book: true, fetch_l3_order_book: false, fetch_last_prices: false, fetch_ledger: true, fetch_ledger_entry: false, fetch_leverage: true, fetch_leverage_tiers: false, fetch_leverages: true, fetch_liquidations: true, fetch_long_short_ratio: false, fetch_long_short_ratio_history: false, fetch_margin_adjustment_history: false, fetch_margin_mode: false, fetch_margin_modes: false, fetch_mark_ohlcv: false, fetch_mark_prices: false, fetch_market_leverage_tiers: false, fetch_markets: true, fetch_markets_ws: false, fetch_my_liquidations: false, fetch_my_settlement_history: false, fetch_my_trades: true, fetch_my_trades_ws: false, fetch_ohlcv: true, fetch_ohlcv_ws: false, fetch_open_interest: false, fetch_open_interest_history: false, fetch_open_interests: false, fetch_open_order: false, fetch_open_orders: true, fetch_open_orders_ws: false, fetch_option: false, fetch_option_chain: false, fetch_order: true, fetch_order_book: true, fetch_order_book_ws: false, fetch_order_books: false, fetch_order_trades: false, fetch_order_with_client_order_id: false, fetch_order_ws: false, fetch_orders: true, fetch_orders_by_status: false, fetch_orders_ws: false, fetch_position: false, fetch_position_history: false, fetch_position_mode: false, fetch_position_ws: false, fetch_positions: true, fetch_positions_for_symbol: false, fetch_positions_for_symbol_ws: false, fetch_positions_history: false, fetch_positions_risk: false, fetch_positions_ws: false, fetch_premium_index_ohlcv: false, fetch_settlement_history: false, fetch_status: false, fetch_ticker: true, fetch_ticker_ws: false, fetch_tickers: true, fetch_tickers_ws: false, fetch_time: false, fetch_trades: true, fetch_trades_ws: false, fetch_trading_fee: false, fetch_trading_fees: false, fetch_trading_fees_ws: false, fetch_trading_limits: false, fetch_transaction_fee: false, fetch_transaction_fees: false, fetch_transactions: true, fetch_transfer: false, fetch_transfers: false, fetch_underlying_assets: false, fetch_volatility_history: false, fetch_withdraw_addresses: false, fetch_withdrawal: false, fetch_withdrawal_whitelist: false, fetch_withdrawals: false, fetch_withdrawals_ws: false, future: true, index: true, margin: false, option: false, private_api: true, public_api: true, reduce_margin: false, repay_cross_margin: false, repay_isolated_margin: false, sandbox: true, set_leverage: true, set_margin: false, set_margin_mode: true, set_position_mode: false, sign_in: false, spot: true, swap: true, transfer: false, un_watch_my_trades: false, un_watch_ohlcv: false, un_watch_ohlcv_for_symbols: false, un_watch_order_book: false, un_watch_order_book_for_symbols: false, un_watch_orders: false, un_watch_positions: false, un_watch_ticker: false, un_watch_tickers: false, un_watch_trades: false, un_watch_trades_for_symbols: false, watch_balance: true, watch_bids_asks: false, watch_liquidations: true, watch_liquidations_for_symbols: true, watch_my_liquidations: false, watch_my_liquidations_for_symbols: false, watch_my_trades: true, watch_ohlcv: true, watch_ohlcv_for_symbols: false, watch_order_book: true, watch_order_book_for_symbols: true, watch_orders: true, watch_orders_for_symbols: false, watch_position: false, watch_positions: false, watch_postions: true, watch_status: false, watch_ticker: true, watch_tickers: true, watch_trades: true, watch_trades_for_symbols: true, withdraw: true, ws: false }, http_config: nil, id: "bitmex", markets: nil, name: "BitMEX", ohlcv_timestamp_resolution: :unknown, options: %{ "api-expires": 5, fetch_o_h_l_c_v_open_timestamp: true, networks: %{ "ADA" => "ada", "AVAXC" => "avax", "BEP20" => "bsc", "BTC" => "btc", "DOT" => "dot", "ERC20" => "eth", "NEAR" => "near", "SOL" => "sol", "TRC20" => "tron", "XTZ" => "xtz" }, old_precision: false }, order_mappings: %{ side_format: :capitalize, side_key: "side", type_format: :capitalize, type_key: "ordType" }, param_mappings: %{ "code" => "currency", "id" => "orderID", "limit" => "count", "since" => "startTime", "timeframe" => "binSize", "triggerPrice" => "stopPx", "type" => "ordType" }, parse_methods: [ %{ "comment" => nil, "examples" => [ "[\n {\n \"account\":1455728,\n \"currency\":\"XBt\",\n \"riskLimit\":1000000000000,\n \"prevState\":\"\",\n \"state\":\"\",\n \"action\":\"\",\n \"amount\":263542,\n \"pendingCredit\":0,\n \"pendingDebit\":0,\n \"confirmedDebit\":0,\n \"prevRealisedPnl\":0,\n \"prevUnrealisedPnl\":0,\n \"grossComm\":0,\n \"grossOpenCost\":0,\n \"grossOpenPremium\":0,\n \"grossExecCost\":0,\n \"grossMarkValue\":0,\n \"riskValue\":0,\n \"taxableMargin\":0,\n \"initMargin\":0,\n \"maintMargin\":0,\n \"sessionMargin\":0,\n \"targetExcessMargin\":0,\n \"varMargin\":0,\n \"realisedPnl\":0,\n \"unrealisedPnl\":0,\n \"indicativeTax\":0,\n \"unrealisedProfit\":0,\n \"syntheticMargin\":null,\n \"walletBalance\":263542,\n \"marginBalance\":263542,\n \"marginBalancePcnt\":1,\n \"marginLeverage\":0,\n \"marginUsedPcnt\":0,\n \"excessMargin\":263542,\n \"excessMarginPcnt\":1,\n \"availableMargin\":263542,\n \"withdrawableMargin\":263542,\n \"timestamp\":\"2020-08-03T12:01:01.246Z\",\n \"grossLastValue\":0,\n \"commission\":null\n }\n ]" ], "line_end" => 898, "line_start" => 837, "mappings" => [], "name" => "parseBalance", "signature" => "parseBalance (response): Balances", "source" => "parseBalance (response): Balances {\n //\n // [\n // {\n // \"account\":1455728,\n // \"currency\":\"XBt\",\n // \"riskLimit\":1000000000000,\n // \"prevState\":\"\",\n // \"state\":\"\",\n // \"action\":\"\",\n // \"amount\":263542,\n // \"pendingCredit\":0,\n // \"pendingDebit\":0,\n // \"confirmedDebit\":0,\n // \"prevRealisedPnl\":0,\n // \"prevUnrealisedPnl\":0,\n // \"grossComm\":0,\n // \"grossOpenCost\":0,\n // \"grossOpenPremium\":0,\n // \"grossExecCost\":0,\n // \"grossMarkValue\":0,\n // \"riskValue\":0,\n // \"taxableMargin\":0,\n // \"initMargin\":0,\n // \"maintMargin\":0,\n // \"sessionMargin\":0,\n // \"targetExcessMargin\":0,\n // \"varMargin\":0,\n // \"realisedPnl\":0,\n // \"unrealisedPnl\":0,\n // \"indicativeTax\":0,\n // \"unrealisedProfit\":0,\n // \"syntheticMargin\":null,\n // \"walletBalance\":263542,\n // \"marginBalance\":263542,\n // \"marginBalancePcnt\":1,\n // \"marginLeverage\":0,\n // \"marginUsedPcnt\":0,\n // \"excessMargin\":263542,\n // \"excessMarginPcnt\":1,\n // \"availableMargin\":263542,\n // \"withdrawableMargin\":263542,\n // \"timestamp\":\"2020-08-03T12:01:01.246Z\",\n // \"grossLastValue\":0,\n // \"commission\":null\n // }\n // ]\n //\n const result: Dict = { 'info': response };\n for (let i = 0; i < response.length; i++) {\n const balance = response[i];\n const currencyId = this.safeString (balance, 'currency');\n const code = this.safeCurrencyCode (currencyId);\n const account = this.account ();\n const free = this.safeString (balance, 'availableMargin');\n const total = this.safeString (balance, 'marginBalance');\n account['free'] = this.convertToRealAmount (code, free);\n account['total'] = this.convertToRealAmount (code, total);\n result[code] = account;\n }\n return this.safeBalance (result);\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"asset\": \"XBT\",\n \"currency\": \"XBt\",\n \"majorCurrency\": \"XBT\",\n \"name\": \"Bitcoin\",\n \"currencyType\": \"Crypto\",\n \"scale\": \"8\",\n \"enabled\": true,\n \"isMarginCurrency\": true,\n \"minDepositAmount\": \"10000\",\n \"minWithdrawalAmount\": \"1000\",\n \"maxWithdrawalAmount\": \"100000000000000\",\n \"networks\": [\n {\n \"asset\": \"btc\",\n \"tokenAddress\": '',\n \"depositEnabled\": true,\n \"withdrawalEnabled\": true,\n \"withdrawalFee\": \"20000\",\n \"minFee\": \"20000\",\n \"maxFee\": \"10000000\"\n }\n ]\n }" ], "line_end" => 2943, "line_start" => 2881, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "fee" }, %{ "comment" => nil, "key" => "withdraw", "value" => "{\n 'fee': undefined,\n 'percentage': undefined,\n }" }, %{ "comment" => nil, "key" => "deposit", "value" => "{\n 'fee': undefined,\n 'percentage': undefined,\n }" }, %{ "comment" => nil, "key" => "networks", "value" => "{}" }, %{ "comment" => nil, "key" => "deposit", "value" => "{ 'fee': undefined, 'percentage': undefined }" }, %{ "comment" => nil, "key" => "withdraw", "value" => "{ 'fee': withdrawalFee, 'percentage': false }" } ], "name" => "parseDepositWithdrawFee", "signature" => "parseDepositWithdrawFee (fee, currency: Currency = undefined)", "source" => "parseDepositWithdrawFee (fee, currency: Currency = undefined) {\n //\n // {\n // \"asset\": \"XBT\",\n // \"currency\": \"XBt\",\n // \"majorCurrency\": \"XBT\",\n // \"name\": \"Bitcoin\",\n // \"currencyType\": \"Crypto\",\n // \"scale\": \"8\",\n // \"enabled\": true,\n // \"isMarginCurrency\": true,\n // \"minDepositAmount\": \"10000\",\n // \"minWithdrawalAmount\": \"1000\",\n // \"maxWithdrawalAmount\": \"100000000000000\",\n // \"networks\": [\n // {\n // \"asset\": \"btc\",\n // \"tokenAddress\": '',\n // \"depositEnabled\": true,\n // \"withdrawalEnabled\": true,\n // \"withdrawalFee\": \"20000\",\n // \"minFee\": \"20000\",\n // \"maxFee\": \"10000000\"\n // }\n // ]\n // }\n //\n const networks = this.safeValue (fee, 'networks', []);\n const networksLength = networks.length;\n const result: Dict = {\n 'info': fee,\n 'withdraw': {\n 'fee': undefined,\n 'percentage': undefined,\n },\n 'deposit': {\n 'fee': undefined,\n 'percentage': undefined,\n },\n 'networks': {},\n };\n if (networksLength !== 0) {\n const scale = this.safeString (fee, 'scale');\n const precision = this.parsePrecision (scale);\n for (let i = 0; i < networksLength; i++) {\n const network = networks[i];\n const networkId = this.safeString (network, 'asset');\n const currencyCode = this.safeString (currency, 'code');\n const networkCode = this.networkIdToCode (networkId, currencyCode);\n const withdrawalFeeId = this.safeString (network, 'withdrawalFee');\n const withdrawalFee = this.parseNumber (Precise.stringMul (withdrawalFeeId, precision));\n result['networks'][networkCode] = {\n 'deposit': { 'fee': undefined, 'percentage': undefined },\n 'withdraw': { 'fee': withdrawalFee, 'percentage': false },\n };\n if (networksLength === 1) {\n result['withdraw']['fee'] = withdrawalFee;\n result['withdraw']['percentage'] = false;\n }\n }\n }\n return result;\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 2697, "line_start" => 2672, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "contract" }, %{ "comment" => nil, "key" => "symbol", "value" => "this.safeSymbol (marketId, market)" }, %{ "comment" => nil, "key" => "markPrice", "value" => "this.safeNumber (contract, 'markPrice')" }, %{ "comment" => nil, "key" => "indexPrice", "value" => "undefined" }, %{ "comment" => nil, "key" => "interestRate", "value" => "undefined" }, %{ "comment" => nil, "key" => "estimatedSettlePrice", "value" => "this.safeNumber (contract, 'indicativeSettlePrice')" }, %{ "comment" => nil, "key" => "timestamp", "value" => "this.parse8601 (datetime)" }, %{ "comment" => nil, "key" => "datetime", "value" => "datetime" }, %{ "comment" => nil, "key" => "fundingRate", "value" => "this.safeNumber (contract, 'fundingRate')" }, %{ "comment" => nil, "key" => "fundingTimestamp", "value" => "this.parse8601 (fundingDatetime)" }, %{ "comment" => nil, "key" => "fundingDatetime", "value" => "fundingDatetime" }, %{ "comment" => nil, "key" => "nextFundingRate", "value" => "this.safeNumber (contract, 'indicativeFundingRate')" }, %{ "comment" => nil, "key" => "nextFundingTimestamp", "value" => "undefined" }, %{ "comment" => nil, "key" => "nextFundingDatetime", "value" => "undefined" }, %{ "comment" => nil, "key" => "previousFundingRate", "value" => "undefined" }, %{ "comment" => nil, "key" => "previousFundingTimestamp", "value" => "undefined" }, %{ "comment" => nil, "key" => "previousFundingDatetime", "value" => "undefined" }, %{ "comment" => nil, "key" => "interval", "value" => "undefined" } ], "name" => "parseFundingRate", "signature" => "parseFundingRate (contract, market: Market = undefined): FundingRate", "source" => "parseFundingRate (contract, market: Market = undefined): FundingRate {\n // see response sample under \"fetchMarkets\" because same endpoint is being used here\n const datetime = this.safeString (contract, 'timestamp');\n const marketId = this.safeString (contract, 'symbol');\n const fundingDatetime = this.safeString (contract, 'fundingTimestamp');\n return {\n 'info': contract,\n 'symbol': this.safeSymbol (marketId, market),\n 'markPrice': this.safeNumber (contract, 'markPrice'),\n 'indexPrice': undefined,\n 'interestRate': undefined,\n 'estimatedSettlePrice': this.safeNumber (contract, 'indicativeSettlePrice'),\n 'timestamp': this.parse8601 (datetime),\n 'datetime': datetime,\n 'fundingRate': this.safeNumber (contract, 'fundingRate'),\n 'fundingTimestamp': this.parse8601 (fundingDatetime),\n 'fundingDatetime': fundingDatetime,\n 'nextFundingRate': this.safeNumber (contract, 'indicativeFundingRate'),\n 'nextFundingTimestamp': undefined,\n 'nextFundingDatetime': undefined,\n 'previousFundingRate': undefined,\n 'previousFundingTimestamp': undefined,\n 'previousFundingDatetime': undefined,\n 'interval': undefined,\n } as FundingRate;\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"timestamp\": \"2016-05-07T12:00:00.000Z\",\n \"symbol\": \"ETHXBT\",\n \"fundingInterval\": \"2000-01-02T00:00:00.000Z\",\n \"fundingRate\": 0.0010890000000000001,\n \"fundingRateDaily\": 0.0010890000000000001\n }" ], "line_end" => 2783, "line_start" => 2764, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "info" }, %{ "comment" => nil, "key" => "symbol", "value" => "this.safeSymbol (marketId, market)" }, %{ "comment" => nil, "key" => "fundingRate", "value" => "this.safeNumber (info, 'fundingRate')" }, %{ "comment" => nil, "key" => "timestamp", "value" => "this.parse8601 (datetime)" }, %{ "comment" => nil, "key" => "datetime", "value" => "datetime" } ], "name" => "parseFundingRateHistory", "signature" => "parseFundingRateHistory (info, market: Market = undefined)", "source" => "parseFundingRateHistory (info, market: Market = undefined) {\n //\n // {\n // \"timestamp\": \"2016-05-07T12:00:00.000Z\",\n // \"symbol\": \"ETHXBT\",\n // \"fundingInterval\": \"2000-01-02T00:00:00.000Z\",\n // \"fundingRate\": 0.0010890000000000001,\n // \"fundingRateDaily\": 0.0010890000000000001\n // }\n //\n const marketId = this.safeString (info, 'symbol');\n const datetime = this.safeString (info, 'timestamp');\n return {\n 'info': info,\n 'symbol': this.safeSymbol (marketId, market),\n 'fundingRate': this.safeNumber (info, 'fundingRate'),\n 'timestamp': this.parse8601 (datetime),\n 'datetime': datetime,\n };\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"transactID\": \"69573da3-7744-5467-3207-89fd6efe7a47\",\n \"account\": 24321,\n \"currency\": \"XBt\",\n \"transactType\": \"Withdrawal\", // \"AffiliatePayout\", \"Transfer\", \"Deposit\", \"RealisedPNL\", ...\n \"amount\": -1000000,\n \"fee\": 300000,\n \"transactStatus\": \"Completed\", // \"Canceled\", ...\n \"address\": \"1Ex4fkF4NhQaQdRWNoYpqiPbDBbq18Kdd9\",\n \"tx\": \"3BMEX91ZhhKoWtsH9QRb5dNXnmnGpiEetA\",\n \"text\": \"\",\n \"transactTime\": \"2017-03-21T20:05:14.388Z\",\n \"walletBalance\": 0, // balance after\n \"marginBalance\": null,\n \"timestamp\": \"2017-03-22T13:09:23.514Z\"\n }", "{\n \"transactID\":\"00000000-0000-0000-0000-000000000000\",\n \"account\":121210,\n \"currency\":\"XBt\",\n \"transactType\":\"UnrealisedPNL\",\n \"amount\":-5508,\n \"fee\":0,\n \"transactStatus\":\"Pending\",\n \"address\":\"XBTUSD\",\n \"tx\":\"\",\n \"text\":\"\",\n \"transactTime\":null, # ←---------------------------- null\n \"walletBalance\":139198767,\n \"marginBalance\":139193259,\n \"timestamp\":null # ←---------------------------- null\n }" ], "line_end" => 1330, "line_start" => 1232, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "item" }, %{ "comment" => nil, "key" => "id", "value" => "id" }, %{ "comment" => nil, "key" => "timestamp", "value" => "timestamp" }, %{ "comment" => nil, "key" => "datetime", "value" => "this.iso8601 (timestamp)" }, %{ "comment" => nil, "key" => "direction", "value" => "direction" }, %{ "comment" => nil, "key" => "account", "value" => "account" }, %{ "comment" => nil, "key" => "referenceId", "value" => "referenceId" }, %{ "comment" => nil, "key" => "referenceAccount", "value" => "referenceAccount" }, %{ "comment" => nil, "key" => "type", "value" => "type" }, %{ "comment" => nil, "key" => "currency", "value" => "code" }, %{ "comment" => nil, "key" => "amount", "value" => "this.parseNumber (amount)" }, %{ "comment" => nil, "key" => "before", "value" => "before" }, %{ "comment" => nil, "key" => "after", "value" => "this.parseNumber (after)" }, %{ "comment" => nil, "key" => "status", "value" => "status" }, %{ "comment" => nil, "key" => "fee", "value" => "fee" } ], "name" => "parseLedgerEntry", "signature" => "parseLedgerEntry (item: Dict, currency: Currency = undefined): LedgerEntry", "source" => "parseLedgerEntry (item: Dict, currency: Currency = undefined): LedgerEntry {\n //\n // {\n // \"transactID\": \"69573da3-7744-5467-3207-89fd6efe7a47\",\n // \"account\": 24321,\n // \"currency\": \"XBt\",\n // \"transactType\": \"Withdrawal\", // \"AffiliatePayout\", \"Transfer\", \"Deposit\", \"RealisedPNL\", ...\n // \"amount\": -1000000,\n // \"fee\": 300000,\n // \"transactStatus\": \"Completed\", // \"Canceled\", ...\n // \"address\": \"1Ex4fkF4NhQaQdRWNoYpqiPbDBbq18Kdd9\",\n // \"tx\": \"3BMEX91ZhhKoWtsH9QRb5dNXnmnGpiEetA\",\n // \"text\": \"\",\n // \"transactTime\": \"2017-03-21T20:05:14.388Z\",\n // \"walletBalance\": 0, // balance after\n // \"marginBalance\": null,\n // \"timestamp\": \"2017-03-22T13:09:23.514Z\"\n // }\n //\n // ButMEX returns the unrealized pnl from the wallet history endpoint.\n // The unrealized pnl transaction has an empty timestamp.\n // It is not related to historical pnl it has status set to \"Pending\".\n // Therefore it's not a part of the history at all.\n // https://github.com/ccxt/ccxt/issues/6047\n //\n // {\n // \"transactID\":\"00000000-0000-0000-0000-000000000000\",\n // \"account\":121210,\n // \"currency\":\"XBt\",\n // \"transactType\":\"UnrealisedPNL\",\n // \"amount\":-5508,\n // \"fee\":0,\n // \"transactStatus\":\"Pending\",\n // \"address\":\"XBTUSD\",\n // \"tx\":\"\",\n // \"text\":\"\",\n // \"transactTime\":null, # ←---------------------------- null\n // \"walletBalance\":139198767,\n // \"marginBalance\":139193259,\n // \"timestamp\":null # ←---------------------------- null\n // }\n //\n const id = this.safeString (item, 'transactID');\n const account = this.safeString (item, 'account');\n const referenceId = this.safeString (item, 'tx');\n const referenceAccount = undefined;\n const type = this.parseLedgerEntryType (this.safeString (item, 'transactType'));\n const currencyId = this.safeString (item, 'currency');\n const code = this.safeCurrencyCode (currencyId, currency);\n currency = this.safeCurrency (currencyId, currency);\n const amountString = this.safeString (item, 'amount');\n let amount = this.convertToRealAmount (code, amountString);\n let timestamp = this.parse8601 (this.safeString (item, 'transactTime'));\n if (timestamp === undefined) {\n // https://github.com/ccxt/ccxt/issues/6047\n // set the timestamp to zero, 1970 Jan 1 00:00:00\n // for unrealized pnl and other transactions without a timestamp\n timestamp = 0; // see comments above\n }\n let fee = undefined;\n let feeCost = this.safeString (item, 'fee');\n if (feeCost !== undefined) {\n feeCost = this.convertToRealAmount (code, feeCost);\n fee = {\n 'cost': this.parseNumber (feeCost),\n 'currency': code,\n };\n }\n let after = this.safeString (item, 'walletBalance');\n if (after !== undefined) {\n after = this.convertToRealAmount (code, after);\n }\n const before = this.parseNumber (Precise.stringSub (this.numberToString (after), this.numberToString (amount)));\n let direction = undefined;\n if (Precise.stringLt (amountString, '0')) {\n direction = 'out';\n amount = this.convertToRealAmount (code, Precise.stringAbs (amountString));\n } else {\n direction = 'in';\n }\n const status = this.parseTransactionStatus (this.safeString (item, 'transactStatus'));\n return this.safeLedgerEntry ({\n 'info': item,\n 'id': id,\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n 'direction': direction,\n 'account': account,\n 'referenceId': referenceId,\n 'referenceAccount': referenceAccount,\n 'type': type,\n 'currency': code,\n 'amount': this.parseNumber (amount),\n 'before': before,\n 'after': this.parseNumber (after),\n 'status': status,\n 'fee': fee,\n }, currency) as LedgerEntry;\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 1230, "line_start" => 1219, "mappings" => [], "name" => "parseLedgerEntryType", "signature" => "parseLedgerEntryType (type)", "source" => "parseLedgerEntryType (type) {\n const types: Dict = {\n 'Withdrawal': 'transaction',\n 'RealisedPNL': 'margin',\n 'UnrealisedPNL': 'margin',\n 'Deposit': 'transaction',\n 'Transfer': 'transfer',\n 'AffiliatePayout': 'referral',\n 'SpotTrade': 'trade',\n };\n return this.safeString (types, type, type);\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 2330, "line_start" => 2321, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "leverage" }, %{ "comment" => nil, "key" => "symbol", "value" => "this.safeSymbol (marketId, market)" }, %{ "comment" => nil, "key" => "marginMode", "value" => "this.safeStringLower (leverage, 'marginMode')" }, %{ "comment" => nil, "key" => "longLeverage", "value" => "this.safeInteger (leverage, 'leverage')" }, %{ "comment" => nil, "key" => "shortLeverage", "value" => "this.safeInteger (leverage, 'leverage')" } ], "name" => "parseLeverage", "signature" => "parseLeverage (leverage: Dict, market: Market = undefined): Leverage", "source" => "parseLeverage (leverage: Dict, market: Market = undefined): Leverage {\n const marketId = this.safeString (leverage, 'symbol');\n return {\n 'info': leverage,\n 'symbol': this.safeSymbol (marketId, market),\n 'marginMode': this.safeStringLower (leverage, 'marginMode'),\n 'longLeverage': this.safeInteger (leverage, 'leverage'),\n 'shortLeverage': this.safeInteger (leverage, 'leverage'),\n } as Leverage;\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"orderID\": \"string\",\n \"symbol\": \"string\",\n \"side\": \"string\",\n \"price\": 0,\n \"leavesQty\": 0\n }" ], "line_end" => 3071, "line_start" => 3048, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "liquidation" }, %{ "comment" => nil, "key" => "symbol", "value" => "this.safeSymbol (marketId, market)" }, %{ "comment" => nil, "key" => "contracts", "value" => "undefined" }, %{ "comment" => nil, "key" => "contractSize", "value" => "this.safeNumber (market, 'contractSize')" }, %{ "comment" => nil, "key" => "price", "value" => "this.safeNumber (liquidation, 'price')" }, %{ "comment" => nil, "key" => "side", "value" => "this.safeStringLower (liquidation, 'side')" }, %{ "comment" => nil, "key" => "baseValue", "value" => "undefined" }, %{ "comment" => nil, "key" => "quoteValue", "value" => "undefined" }, %{ "comment" => nil, "key" => "timestamp", "value" => "undefined" }, %{ "comment" => nil, "key" => "datetime", "value" => "undefined" } ], "name" => "parseLiquidation", "signature" => "parseLiquidation (liquidation, market: Market = undefined)", "source" => "parseLiquidation (liquidation, market: Market = undefined) {\n //\n // {\n // \"orderID\": \"string\",\n // \"symbol\": \"string\",\n // \"side\": \"string\",\n // \"price\": 0,\n // \"leavesQty\": 0\n // }\n //\n const marketId = this.safeString (liquidation, 'symbol');\n return this.safeLiquidation ({\n 'info': liquidation,\n 'symbol': this.safeSymbol (marketId, market),\n 'contracts': undefined,\n 'contractSize': this.safeNumber (market, 'contractSize'),\n 'price': this.safeNumber (liquidation, 'price'),\n 'side': this.safeStringLower (liquidation, 'side'),\n 'baseValue': undefined,\n 'quoteValue': undefined,\n 'timestamp': undefined,\n 'datetime': undefined,\n });\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 835, "line_start" => 707, "mappings" => [ %{ "comment" => nil, "key" => "id", "value" => "id" }, %{ "comment" => nil, "key" => "symbol", "value" => "symbol" }, %{ "comment" => nil, "key" => "base", "value" => "base" }, %{ "comment" => nil, "key" => "quote", "value" => "quote" }, %{ "comment" => nil, "key" => "settle", "value" => "settle" }, %{ "comment" => nil, "key" => "baseId", "value" => "baseId" }, %{ "comment" => nil, "key" => "quoteId", "value" => "quoteId" }, %{ "comment" => nil, "key" => "settleId", "value" => "settleId" }, %{ "comment" => nil, "key" => "type", "value" => "type" }, %{ "comment" => nil, "key" => "spot", "value" => "spot" }, %{ "comment" => nil, "key" => "margin", "value" => "false" }, %{ "comment" => nil, "key" => "swap", "value" => "swap" }, %{ "comment" => nil, "key" => "future", "value" => "future" }, %{ "comment" => nil, "key" => "option", "value" => "false" }, %{ "comment" => nil, "key" => "active", "value" => "active" }, %{ "comment" => nil, "key" => "contract", "value" => "contract" }, %{ "comment" => nil, "key" => "linear", "value" => "linear" }, %{ "comment" => nil, "key" => "inverse", "value" => "isInverse" }, %{ "comment" => nil, "key" => "quanto", "value" => "isQuanto" }, %{ "comment" => nil, "key" => "taker", "value" => "this.safeNumber (market, 'takerFee')" }, %{ "comment" => nil, "key" => "maker", "value" => "this.safeNumber (market, 'makerFee')" }, %{ "comment" => nil, "key" => "contractSize", "value" => "contractSize" }, %{ "comment" => nil, "key" => "expiry", "value" => "expiry" }, %{ "comment" => nil, "key" => "expiryDatetime", "value" => "expiryDatetime" }, %{ "comment" => nil, "key" => "strike", "value" => "this.safeNumber (market, 'optionStrikePrice')" }, %{ "comment" => nil, "key" => "optionType", "value" => "undefined" }, %{ "comment" => nil, "key" => "precision", "value" => "{\n 'amount': this.safeNumber (market, 'lotSize'),\n 'price': this.safeNumber (market, 'tickSize'),\n }" }, %{ "comment" => nil, "key" => "limits", "value" => "{\n 'leverage': {\n 'min': contract ? this.parseNumber ('1') : undefined,\n 'max': contract ? maxLeverage : undefined,\n },\n 'amount': {\n 'min': undefined,\n 'max': positionIsQuote ? undefined : maxOrderQty,\n },\n 'price': {\n 'min': undefined,\n 'max': this.safeNumber (market, 'maxPrice'),\n },\n 'cost': {\n 'min': undefined,\n 'max': positionIsQuote ? maxOrderQty : undefined,\n },\n }" }, %{ "comment" => nil, "key" => "created", "value" => "undefined" }, %{ "comment" => nil, "key" => "amount", "value" => "this.safeNumber (market, 'lotSize')" }, %{ "comment" => nil, "key" => "price", "value" => "this.safeNumber (market, 'tickSize')" }, %{ "comment" => nil, "key" => "leverage", "value" => "{\n 'min': contract ? this.parseNumber ('1') : undefined,\n 'max': contract ? maxLeverage : undefined,\n }" }, %{ "comment" => nil, "key" => "amount", "value" => "{\n 'min': undefined,\n 'max': positionIsQuote ? undefined : maxOrderQty,\n }" }, %{ "comment" => nil, "key" => "price", "value" => "{\n 'min': undefined,\n 'max': this.safeNumber (market, 'maxPrice'),\n }" }, %{ "comment" => nil, "key" => "cost", "value" => "{\n 'min': undefined,\n 'max': positionIsQuote ? maxOrderQty : undefined,\n }" }, %{ "comment" => nil, "key" => "min", "value" => "undefined" }, %{ "comment" => nil, "key" => "max", "value" => "positionIsQuote ? maxOrderQty : undefined" } ], "name" => "parseMarket", "signature" => "parseMarket (market: Dict): Market", "source" => "parseMarket (market: Dict): Market {\n const id = this.safeString (market, 'symbol');\n let baseId = this.safeString (market, 'underlying');\n let quoteId = this.safeString (market, 'quoteCurrency');\n const settleId = this.safeString (market, 'settlCurrency');\n const settle = this.safeCurrencyCode (settleId);\n // 'positionCurrency' may be empty (\"\", as Bitmex currently returns for ETHUSD)\n // so let's take the settlCurrency first and then adjust if needed\n const typ = this.safeString (market, 'typ'); // type definitions at: https://www.bitmex.com/api/explorer/#!/Instrument/Instrument_get\n let type = undefined;\n let swap = false;\n let spot = false;\n let future = false;\n if (typ === 'FFWCSX') {\n type = 'swap';\n swap = true;\n } else if (typ === 'IFXXXP') {\n type = 'spot';\n spot = true;\n } else if (typ === 'FFCCSX') {\n type = 'future';\n future = true;\n } else if (typ === 'FFICSX') {\n // prediction markets (without any volume)\n quoteId = baseId;\n baseId = this.safeString (market, 'rootSymbol');\n type = 'future';\n future = true;\n } else if (typ === 'FFSCSX') {\n type = 'swap';\n swap = true;\n }\n const base = this.safeCurrencyCode (baseId);\n const quote = this.safeCurrencyCode (quoteId);\n const contract = swap || future;\n let contractSize = undefined;\n let isInverse = this.safeValue (market, 'isInverse'); // this is true when BASE and SETTLE are same, i.e. BTC/XXX:BTC\n let isQuanto = this.safeValue (market, 'isQuanto'); // this is true when BASE and SETTLE are different, i.e. AXS/XXX:BTC\n let linear = contract ? (!isInverse && !isQuanto) : undefined;\n const status = this.safeString (market, 'state');\n const active = status === 'Open'; // Open, Settled, Unlisted\n let expiry = undefined;\n let expiryDatetime = undefined;\n let symbol = undefined;\n if (spot) {\n symbol = base + '/' + quote;\n } else if (contract) {\n symbol = base + '/' + quote + ':' + settle;\n if (linear) {\n const multiplierString = this.safeString2 (market, 'underlyingToPositionMultiplier', 'underlyingToSettleMultiplier');\n contractSize = this.parseNumber (Precise.stringDiv ('1', multiplierString));\n } else {\n const multiplierString = Precise.stringAbs (this.safeString (market, 'multiplier'));\n contractSize = this.parseNumber (multiplierString);\n }\n expiryDatetime = this.safeString (market, 'expiry');\n expiry = this.parse8601 (expiryDatetime);\n if (expiry !== undefined) {\n symbol = symbol + '-' + this.yymmdd (expiry);\n }\n } else {\n // for index/exotic markets, default to id\n symbol = id;\n }\n const positionId = this.safeString2 (market, 'positionCurrency', 'underlying');\n const position = this.safeCurrencyCode (positionId);\n const positionIsQuote = (position === quote);\n const maxOrderQty = this.safeNumber (market, 'maxOrderQty');\n const initMargin = this.safeString (market, 'initMargin', '1');\n const maxLeverage = this.parseNumber (Precise.stringDiv ('1', initMargin));\n // subtype should be undefined for spot markets\n if (spot) {\n isInverse = undefined;\n isQuanto = undefined;\n linear = undefined;\n }\n return {\n 'id': id,\n 'symbol': symbol,\n 'base': base,\n 'quote': quote,\n 'settle': settle,\n 'baseId': baseId,\n 'quoteId': quoteId,\n 'settleId': settleId,\n 'type': type,\n 'spot': spot,\n 'margin': false,\n 'swap': swap,\n 'future': future,\n 'option': false,\n 'active': active,\n 'contract': contract,\n 'linear': linear,\n 'inverse': isInverse,\n 'quanto': isQuanto,\n 'taker': this.safeNumber (market, 'takerFee'),\n 'maker': this.safeNumber (market, 'makerFee'),\n 'contractSize': contractSize,\n 'expiry': expiry,\n 'expiryDatetime': expiryDatetime,\n 'strike': this.safeNumber (market, 'optionStrikePrice'),\n 'optionType': undefined,\n 'precision': {\n 'amount': this.safeNumber (market, 'lotSize'),\n 'price': this.safeNumber (market, 'tickSize'),\n },\n 'limits': {\n 'leverage': {\n 'min': contract ? this.parseNumber ('1') : undefined,\n 'max': contract ? maxLeverage : undefined,\n },\n 'amount': {\n 'min': undefined,\n 'max': positionIsQuote ? undefined : maxOrderQty,\n },\n 'price': {\n 'min': undefined,\n 'max': this.safeNumber (market, 'maxPrice'),\n },\n 'cost': {\n 'min': undefined,\n 'max': positionIsQuote ? maxOrderQty : undefined,\n },\n },\n 'created': undefined, // 'listing' field is buggy, e.g. 2200-02-01T00:00:00.000Z\n 'info': market,\n };\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"timestamp\":\"2015-09-25T13:38:00.000Z\",\n \"symbol\":\"XBTUSD\",\n \"open\":237.45,\n \"high\":237.45,\n \"low\":237.45,\n \"close\":237.45,\n \"trades\":0,\n \"volume\":0,\n \"vwap\":null,\n \"lastSize\":null,\n \"turnover\":0,\n \"homeNotional\":0,\n \"foreignNotional\":0\n }" ], "line_end" => 1615, "line_start" => 1586, "mappings" => [], "name" => "parseOHLCV", "signature" => "parseOHLCV (ohlcv, market: Market = undefined): OHLCV", "source" => "parseOHLCV (ohlcv, market: Market = undefined): OHLCV {\n //\n // {\n // \"timestamp\":\"2015-09-25T13:38:00.000Z\",\n // \"symbol\":\"XBTUSD\",\n // \"open\":237.45,\n // \"high\":237.45,\n // \"low\":237.45,\n // \"close\":237.45,\n // \"trades\":0,\n // \"volume\":0,\n // \"vwap\":null,\n // \"lastSize\":null,\n // \"turnover\":0,\n // \"homeNotional\":0,\n // \"foreignNotional\":0\n // }\n //\n const marketId = this.safeString (ohlcv, 'symbol');\n market = this.safeMarket (marketId, market);\n const volume = this.convertFromRawQuantity (market['symbol'], this.safeString (ohlcv, 'volume'));\n return [\n this.parse8601 (this.safeString (ohlcv, 'timestamp')),\n this.safeNumber (ohlcv, 'open'),\n this.safeNumber (ohlcv, 'high'),\n this.safeNumber (ohlcv, 'low'),\n this.safeNumber (ohlcv, 'close'),\n volume,\n ];\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"orderID\":\"56222c7a-9956-413a-82cf-99f4812c214b\",\n \"clOrdID\":\"\",\n \"clOrdLinkID\":\"\",\n \"account\":1455728,\n \"symbol\":\"XBTUSD\",\n \"side\":\"Sell\",\n \"simpleOrderQty\":null,\n \"orderQty\":1,\n \"price\":40000,\n \"displayQty\":null,\n \"stopPx\":null,\n \"pegOffsetValue\":null,\n \"pegPriceType\":\"\",\n \"currency\":\"USD\",\n \"settlCurrency\":\"XBt\",\n \"ordType\":\"Limit\",\n \"timeInForce\":\"GoodTillCancel\",\n \"execInst\":\"\",\n \"contingencyType\":\"\",\n \"exDestination\":\"XBME\",\n \"ordStatus\":\"New\",\n \"triggered\":\"\",\n \"workingIndicator\":true,\n \"ordRejReason\":\"\",\n \"simpleLeavesQty\":null,\n \"leavesQty\":1,\n \"simpleCumQty\":null,\n \"cumQty\":0,\n \"avgPx\":null,\n \"multiLegReportingType\":\"SingleSecurity\",\n \"text\":\"Submitted via API.\",\n \"transactTime\":\"2021-01-02T21:38:49.246Z\",\n \"timestamp\":\"2021-01-02T21:38:49.246Z\"\n }" ], "line_end" => 1934, "line_start" => 1836, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "order" }, %{ "comment" => nil, "key" => "id", "value" => "this.safeString (order, 'orderID')" }, %{ "comment" => nil, "key" => "clientOrderId", "value" => "this.safeString (order, 'clOrdID')" }, %{ "comment" => nil, "key" => "timestamp", "value" => "timestamp" }, %{ "comment" => nil, "key" => "datetime", "value" => "this.iso8601 (timestamp)" }, %{ "comment" => nil, "key" => "lastTradeTimestamp", "value" => "this.parse8601 (this.safeString (order, 'transactTime'))" }, %{ "comment" => nil, "key" => "symbol", "value" => "symbol" }, %{ "comment" => nil, "key" => "type", "value" => "this.safeStringLower (order, 'ordType')" }, %{ "comment" => nil, "key" => "timeInForce", "value" => "this.parseTimeInForce (this.safeString (order, 'timeInForce'))" }, %{ "comment" => nil, "key" => "postOnly", "value" => "postOnly" }, %{ "comment" => nil, "key" => "reduceOnly", "value" => "reduceOnly" }, %{ "comment" => nil, "key" => "side", "value" => "this.safeStringLower (order, 'side')" }, %{ "comment" => nil, "key" => "price", "value" => "this.safeString (order, 'price')" }, %{ "comment" => nil, "key" => "triggerPrice", "value" => "triggerPrice" }, %{ "comment" => nil, "key" => "amount", "value" => "amount" }, %{ "comment" => nil, "key" => "cost", "value" => "cost" }, %{ "comment" => nil, "key" => "average", "value" => "average" }, %{ "comment" => nil, "key" => "filled", "value" => "filled" }, %{ "comment" => nil, "key" => "remaining", "value" => "this.convertFromRawQuantity (symbol, remaining)" }, %{ "comment" => nil, "key" => "status", "value" => "this.parseOrderStatus (this.safeString (order, 'ordStatus'))" }, %{ "comment" => nil, "key" => "fee", "value" => "undefined" }, %{ "comment" => nil, "key" => "trades", "value" => "undefined" } ], "name" => "parseOrder", "signature" => "parseOrder (order: Dict, market: Market = undefined): Order", "source" => "parseOrder (order: Dict, market: Market = undefined): Order {\n //\n // {\n // \"orderID\":\"56222c7a-9956-413a-82cf-99f4812c214b\",\n // \"clOrdID\":\"\",\n // \"clOrdLinkID\":\"\",\n // \"account\":1455728,\n // \"symbol\":\"XBTUSD\",\n // \"side\":\"Sell\",\n // \"simpleOrderQty\":null,\n // \"orderQty\":1,\n // \"price\":40000,\n // \"displayQty\":null,\n // \"stopPx\":null,\n // \"pegOffsetValue\":null,\n // \"pegPriceType\":\"\",\n // \"currency\":\"USD\",\n // \"settlCurrency\":\"XBt\",\n // \"ordType\":\"Limit\",\n // \"timeInForce\":\"GoodTillCancel\",\n // \"execInst\":\"\",\n // \"contingencyType\":\"\",\n // \"exDestination\":\"XBME\",\n // \"ordStatus\":\"New\",\n // \"triggered\":\"\",\n // \"workingIndicator\":true,\n // \"ordRejReason\":\"\",\n // \"simpleLeavesQty\":null,\n // \"leavesQty\":1,\n // \"simpleCumQty\":null,\n // \"cumQty\":0,\n // \"avgPx\":null,\n // \"multiLegReportingType\":\"SingleSecurity\",\n // \"text\":\"Submitted via API.\",\n // \"transactTime\":\"2021-01-02T21:38:49.246Z\",\n // \"timestamp\":\"2021-01-02T21:38:49.246Z\"\n // }\n //\n const marketId = this.safeString (order, 'symbol');\n market = this.safeMarket (marketId, market);\n const symbol = market['symbol'];\n const qty = this.safeString (order, 'orderQty');\n let cost = undefined;\n let amount = undefined;\n let isInverse = false;\n if (marketId === undefined) {\n const defaultSubType = this.safeString (this.options, 'defaultSubType', 'linear');\n isInverse = (defaultSubType === 'inverse');\n } else {\n isInverse = this.safeBool (market, 'inverse', false);\n }\n if (isInverse) {\n cost = this.convertFromRawQuantity (symbol, qty);\n } else {\n amount = this.convertFromRawQuantity (symbol, qty);\n }\n const average = this.safeString (order, 'avgPx');\n let filled = undefined;\n const cumQty = this.numberToString (this.convertFromRawQuantity (symbol, this.safeString (order, 'cumQty')));\n if (isInverse) {\n filled = Precise.stringDiv (cumQty, average);\n } else {\n filled = cumQty;\n }\n const execInst = this.safeString (order, 'execInst', '');\n let postOnly = undefined;\n let reduceOnly = undefined;\n if (execInst.length > 0) {\n postOnly = (execInst.indexOf ('ParticipateDoNotInitiate') >= 0);\n reduceOnly = ((execInst.indexOf ('ReduceOnly') >= 0) || (execInst.indexOf ('Close') >= 0));\n }\n const timestamp = this.parse8601 (this.safeString (order, 'timestamp'));\n const triggerPrice = this.safeNumber (order, 'stopPx');\n const remaining = this.safeString (order, 'leavesQty');\n return this.safeOrder ({\n 'info': order,\n 'id': this.safeString (order, 'orderID'),\n 'clientOrderId': this.safeString (order, 'clOrdID'),\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n 'lastTradeTimestamp': this.parse8601 (this.safeString (order, 'transactTime')),\n 'symbol': symbol,\n 'type': this.safeStringLower (order, 'ordType'),\n 'timeInForce': this.parseTimeInForce (this.safeString (order, 'timeInForce')),\n 'postOnly': postOnly,\n 'reduceOnly': reduceOnly,\n 'side': this.safeStringLower (order, 'side'),\n 'price': this.safeString (order, 'price'),\n 'triggerPrice': triggerPrice,\n 'amount': amount,\n 'cost': cost,\n 'average': average,\n 'filled': filled,\n 'remaining': this.convertFromRawQuantity (symbol, remaining),\n 'status': this.parseOrderStatus (this.safeString (order, 'ordStatus')),\n 'fee': undefined,\n 'trades': undefined,\n }, market);\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 1824, "line_start" => 1808, "mappings" => [], "name" => "parseOrderStatus", "signature" => "parseOrderStatus (status: Str)", "source" => "parseOrderStatus (status: Str) {\n const statuses: Dict = {\n 'New': 'open',\n 'PartiallyFilled': 'open',\n 'Filled': 'closed',\n 'DoneForDay': 'open',\n 'Canceled': 'canceled',\n 'PendingCancel': 'open',\n 'PendingNew': 'open',\n 'Rejected': 'rejected',\n 'Expired': 'expired',\n 'Stopped': 'open',\n 'Untriggered': 'open',\n 'Triggered': 'open',\n };\n return this.safeString (statuses, status, status);\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"account\": 9371654,\n \"symbol\": \"ETHUSDT\",\n \"currency\": \"USDt\",\n \"underlying\": \"ETH\",\n \"quoteCurrency\": \"USDT\",\n \"commission\": 0.00075,\n \"initMarginReq\": 0.3333333333333333,\n \"maintMarginReq\": 0.01,\n \"riskLimit\": 1000000000000,\n \"leverage\": 3,\n \"crossMargin\": false,\n \"deleveragePercentile\": 1,\n \"rebalancedPnl\": 0,\n \"prevRealisedPnl\": 0,\n \"prevUnrealisedPnl\": 0,\n \"prevClosePrice\": 2053.738,\n \"openingTimestamp\": \"2022-05-21T04:00:00.000Z\",\n \"openingQty\": 0,\n \"openingCost\": 0,\n \"openingComm\": 0,\n \"openOrderBuyQty\": 0,\n \"openOrderBuyCost\": 0,\n \"openOrderBuyPremium\": 0,\n \"openOrderSellQty\": 0,\n \"openOrderSellCost\": 0,\n \"openOrderSellPremium\": 0,\n \"execBuyQty\": 2000,\n \"execBuyCost\": 39260000,\n \"execSellQty\": 0,\n \"execSellCost\": 0,\n \"execQty\": 2000,\n \"execCost\": 39260000,\n \"execComm\": 26500,\n \"currentTimestamp\": \"2022-05-21T04:35:16.397Z\",\n \"currentQty\": 2000,\n \"currentCost\": 39260000,\n \"currentComm\": 26500,\n \"realisedCost\": 0,\n \"unrealisedCost\": 39260000,\n \"grossOpenCost\": 0,\n \"grossOpenPremium\": 0,\n \"grossExecCost\": 39260000,\n \"isOpen\": true,\n \"markPrice\": 1964.195,\n \"markValue\": 39283900,\n \"riskValue\": 39283900,\n \"homeNotional\": 0.02,\n \"foreignNotional\": -39.2839,\n \"posState\": \"\",\n \"posCost\": 39260000,\n \"posCost2\": 39260000,\n \"posCross\": 0,\n \"posInit\": 13086667,\n \"posComm\": 39261,\n \"posLoss\": 0,\n \"posMargin\": 13125928,\n \"posMaint\": 435787,\n \"posAllowance\": 0,\n \"taxableMargin\": 0,\n \"initMargin\": 0,\n \"maintMargin\": 13149828,\n \"sessionMargin\": 0,\n \"targetExcessMargin\": 0,\n \"varMargin\": 0,\n \"realisedGrossPnl\": 0,\n \"realisedTax\": 0,\n \"realisedPnl\": -26500,\n \"unrealisedGrossPnl\": 23900,\n \"longBankrupt\": 0,\n \"shortBankrupt\": 0,\n \"taxBase\": 0,\n \"indicativeTaxRate\": null,\n \"indicativeTax\": 0,\n \"unrealisedTax\": 0,\n \"unrealisedPnl\": 23900,\n \"unrealisedPnlPcnt\": 0.0006,\n \"unrealisedRoePcnt\": 0.0018,\n \"simpleQty\": null,\n \"simpleCost\": null,\n \"simpleValue\": null,\n \"simplePnl\": null,\n \"simplePnlPcnt\": null,\n \"avgCostPrice\": 1963,\n \"avgEntryPrice\": 1963,\n \"breakEvenPrice\": 1964.35,\n \"marginCallPrice\": 1328.5,\n \"liquidationPrice\": 1328.5,\n \"bankruptPrice\": 1308.7,\n \"timestamp\": \"2022-05-21T04:35:16.397Z\",\n \"lastPrice\": 1964.195,\n \"lastValue\": 39283900\n }" ], "line_end" => 2590, "line_start" => 2445, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "position" }, %{ "comment" => nil, "key" => "id", "value" => "this.safeString (position, 'account')" }, %{ "comment" => nil, "key" => "symbol", "value" => "symbol" }, %{ "comment" => nil, "key" => "timestamp", "value" => "this.parse8601 (datetime)" }, %{ "comment" => nil, "key" => "datetime", "value" => "datetime" }, %{ "comment" => nil, "key" => "lastUpdateTimestamp", "value" => "undefined" }, %{ "comment" => nil, "key" => "hedged", "value" => "undefined" }, %{ "comment" => nil, "key" => "side", "value" => "side" }, %{ "comment" => nil, "key" => "contracts", "value" => "contracts" }, %{ "comment" => nil, "key" => "contractSize", "value" => "contractSize" }, %{ "comment" => nil, "key" => "entryPrice", "value" => "this.safeNumber (position, 'avgEntryPrice')" }, %{ "comment" => nil, "key" => "markPrice", "value" => "this.safeNumber (position, 'markPrice')" }, %{ "comment" => nil, "key" => "lastPrice", "value" => "undefined" }, %{ "comment" => nil, "key" => "notional", "value" => "this.parseNumber (notionalString)" }, %{ "comment" => nil, "key" => "leverage", "value" => "this.safeNumber (position, 'leverage')" }, %{ "comment" => nil, "key" => "collateral", "value" => "undefined" }, %{ "comment" => nil, "key" => "initialMargin", "value" => "this.safeNumber (position, 'initMargin')" }, %{ "comment" => nil, "key" => "initialMarginPercentage", "value" => "this.safeNumber (position, 'initMarginReq')" }, %{ "comment" => nil, "key" => "maintenanceMargin", "value" => "maintenanceMargin" }, %{ "comment" => nil, "key" => "maintenanceMarginPercentage", "value" => "this.safeNumber (position, 'maintMarginReq')" }, %{ "comment" => nil, "key" => "unrealizedPnl", "value" => "unrealisedPnl" }, %{ "comment" => nil, "key" => "liquidationPrice", "value" => "this.safeNumber (position, 'liquidationPrice')" }, %{ "comment" => nil, "key" => "marginMode", "value" => "marginMode" }, %{ "comment" => nil, "key" => "marginRatio", "value" => "undefined" }, %{ "comment" => nil, "key" => "percentage", "value" => "this.safeNumber (position, 'unrealisedPnlPcnt')" }, %{ "comment" => nil, "key" => "stopLossPrice", "value" => "undefined" }, %{ "comment" => nil, "key" => "takeProfitPrice", "value" => "undefined" } ], "name" => "parsePosition", "signature" => "parsePosition (position: Dict, market: Market = undefined)", "source" => "parsePosition (position: Dict, market: Market = undefined) {\n //\n // {\n // \"account\": 9371654,\n // \"symbol\": \"ETHUSDT\",\n // \"currency\": \"USDt\",\n // \"underlying\": \"ETH\",\n // \"quoteCurrency\": \"USDT\",\n // \"commission\": 0.00075,\n // \"initMarginReq\": 0.3333333333333333,\n // \"maintMarginReq\": 0.01,\n // \"riskLimit\": 1000000000000,\n // \"leverage\": 3,\n // \"crossMargin\": false,\n // \"deleveragePercentile\": 1,\n // \"rebalancedPnl\": 0,\n // \"prevRealisedPnl\": 0,\n // \"prevUnrealisedPnl\": 0,\n // \"prevClosePrice\": 2053.738,\n // \"openingTimestamp\": \"2022-05-21T04:00:00.000Z\",\n // \"openingQty\": 0,\n // \"openingCost\": 0,\n // \"openingComm\": 0,\n // \"openOrderBuyQty\": 0,\n // \"openOrderBuyCost\": 0,\n // \"openOrderBuyPremium\": 0,\n // \"openOrderSellQty\": 0,\n // \"openOrderSellCost\": 0,\n // \"openOrderSellPremium\": 0,\n // \"execBuyQty\": 2000,\n // \"execBuyCost\": 39260000,\n // \"execSellQty\": 0,\n // \"execSellCost\": 0,\n // \"execQty\": 2000,\n // \"execCost\": 39260000,\n // \"execComm\": 26500,\n // \"currentTimestamp\": \"2022-05-21T04:35:16.397Z\",\n // \"currentQty\": 2000,\n // \"currentCost\": 39260000,\n // \"currentComm\": 26500,\n // \"realisedCost\": 0,\n // \"unrealisedCost\": 39260000,\n // \"grossOpenCost\": 0,\n // \"grossOpenPremium\": 0,\n // \"grossExecCost\": 39260000,\n // \"isOpen\": true,\n // \"markPrice\": 1964.195,\n // \"markValue\": 39283900,\n // \"riskValue\": 39283900,\n // \"homeNotional\": 0.02,\n // \"foreignNotional\": -39.2839,\n // \"posState\": \"\",\n // \"posCost\": 39260000,\n // \"posCost2\": 39260000,\n // \"posCross\": 0,\n // \"posInit\": 13086667,\n // \"posComm\": 39261,\n // \"posLoss\": 0,\n // \"posMargin\": 13125928,\n // \"posMaint\": 435787,\n // \"posAllowance\": 0,\n // \"taxableMargin\": 0,\n // \"initMargin\": 0,\n // \"maintMargin\": 13149828,\n // \"sessionMargin\": 0,\n // \"targetExcessMargin\": 0,\n // \"varMargin\": 0,\n // \"realisedGrossPnl\": 0,\n // \"realisedTax\": 0,\n // \"realisedPnl\": -26500,\n // \"unrealisedGrossPnl\": 23900,\n // \"longBankrupt\": 0,\n // \"shortBankrupt\": 0,\n // \"taxBase\": 0,\n // \"indicativeTaxRate\": null,\n // \"indicativeTax\": 0,\n // \"unrealisedTax\": 0,\n // \"unrealisedPnl\": 23900,\n // \"unrealisedPnlPcnt\": 0.0006,\n // \"unrealisedRoePcnt\": 0.0018,\n // \"simpleQty\": null,\n // \"simpleCost\": null,\n // \"simpleValue\": null,\n // \"simplePnl\": null,\n // \"simplePnlPcnt\": null,\n // \"avgCostPrice\": 1963,\n // \"avgEntryPrice\": 1963,\n // \"breakEvenPrice\": 1964.35,\n // \"marginCallPrice\": 1328.5,\n // \"liquidationPrice\": 1328.5,\n // \"bankruptPrice\": 1308.7,\n // \"timestamp\": \"2022-05-21T04:35:16.397Z\",\n // \"lastPrice\": 1964.195,\n // \"lastValue\": 39283900\n // }\n //\n market = this.safeMarket (this.safeString (position, 'symbol'), market);\n const symbol = market['symbol'];\n const datetime = this.safeString (position, 'timestamp');\n const crossMargin = this.safeValue (position, 'crossMargin');\n const marginMode = (crossMargin === true) ? 'cross' : 'isolated';\n const notionalString = Precise.stringAbs (this.safeString2 (position, 'foreignNotional', 'homeNotional'));\n const settleCurrencyCode = this.safeString (market, 'settle');\n const maintenanceMargin = this.convertToRealAmount (settleCurrencyCode, this.safeString (position, 'maintMargin'));\n const unrealisedPnl = this.convertToRealAmount (settleCurrencyCode, this.safeString (position, 'unrealisedPnl'));\n const contracts = this.parseNumber (Precise.stringAbs (this.safeString (position, 'currentQty')));\n const contractSize = this.safeNumber (market, 'contractSize');\n let side = undefined;\n const homeNotional = this.safeString (position, 'homeNotional');\n if (homeNotional !== undefined) {\n if (homeNotional[0] === '-') {\n side = 'short';\n } else {\n side = 'long';\n }\n }\n return this.safePosition ({\n 'info': position,\n 'id': this.safeString (position, 'account'),\n 'symbol': symbol,\n 'timestamp': this.parse8601 (datetime),\n 'datetime': datetime,\n 'lastUpdateTimestamp': undefined,\n 'hedged': undefined,\n 'side': side,\n 'contracts': contracts,\n 'contractSize': contractSize,\n 'entryPrice': this.safeNumber (position, 'avgEntryPrice'),\n 'markPrice': this.safeNumber (position, 'markPrice'),\n 'lastPrice': undefined,\n 'notional': this.parseNumber (notionalString),\n 'leverage': this.safeNumber (position, 'leverage'),\n 'collateral': undefined,\n 'initialMargin': this.safeNumber (position, 'initMargin'),\n 'initialMarginPercentage': this.safeNumber (position, 'initMarginReq'),\n 'maintenanceMargin': maintenanceMargin,\n 'maintenanceMarginPercentage': this.safeNumber (position, 'maintMarginReq'),\n 'unrealizedPnl': unrealisedPnl,\n 'liquidationPrice': this.safeNumber (position, 'liquidationPrice'),\n 'marginMode': marginMode,\n 'marginRatio': undefined,\n 'percentage': this.safeNumber (position, 'unrealisedPnlPcnt'),\n 'stopLossPrice': undefined,\n 'takeProfitPrice': undefined,\n });\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 1584, "line_start" => 1554, "mappings" => [ %{ "comment" => nil, "key" => "symbol", "value" => "symbol" }, %{ "comment" => nil, "key" => "timestamp", "value" => "timestamp" }, %{ "comment" => nil, "key" => "datetime", "value" => "this.iso8601 (timestamp)" }, %{ "comment" => nil, "key" => "high", "value" => "this.safeString (ticker, 'highPrice')" }, %{ "comment" => nil, "key" => "low", "value" => "this.safeString (ticker, 'lowPrice')" }, %{ "comment" => nil, "key" => "bid", "value" => "this.safeString (ticker, 'bidPrice')" }, %{ "comment" => nil, "key" => "bidVolume", "value" => "undefined" }, %{ "comment" => nil, "key" => "ask", "value" => "this.safeString (ticker, 'askPrice')" }, %{ "comment" => nil, "key" => "askVolume", "value" => "undefined" }, %{ "comment" => nil, "key" => "vwap", "value" => "this.safeString (ticker, 'vwap')" }, %{ "comment" => nil, "key" => "open", "value" => "open" }, %{ "comment" => nil, "key" => "close", "value" => "last" }, %{ "comment" => nil, "key" => "last", "value" => "last" }, %{ "comment" => nil, "key" => "previousClose", "value" => "undefined" }, %{ "comment" => nil, "key" => "change", "value" => "undefined" }, %{ "comment" => nil, "key" => "percentage", "value" => "undefined" }, %{ "comment" => nil, "key" => "average", "value" => "undefined" }, %{ "comment" => nil, "key" => "baseVolume", "value" => "this.safeString (ticker, 'homeNotional24h')" }, %{ "comment" => nil, "key" => "quoteVolume", "value" => "this.safeString (ticker, 'foreignNotional24h')" }, %{ "comment" => nil, "key" => "markPrice", "value" => "this.safeString (ticker, 'markPrice')" }, %{ "comment" => nil, "key" => "info", "value" => "ticker" } ], "name" => "parseTicker", "signature" => "parseTicker (ticker: Dict, market: Market = undefined): Ticker", "source" => "parseTicker (ticker: Dict, market: Market = undefined): Ticker {\n // see response sample under \"fetchMarkets\" because same endpoint is being used here\n const marketId = this.safeString (ticker, 'symbol');\n const symbol = this.safeSymbol (marketId, market);\n const timestamp = this.parse8601 (this.safeString (ticker, 'timestamp'));\n const open = this.safeString (ticker, 'prevPrice24h');\n const last = this.safeString (ticker, 'lastPrice');\n return this.safeTicker ({\n 'symbol': symbol,\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n 'high': this.safeString (ticker, 'highPrice'),\n 'low': this.safeString (ticker, 'lowPrice'),\n 'bid': this.safeString (ticker, 'bidPrice'),\n 'bidVolume': undefined,\n 'ask': this.safeString (ticker, 'askPrice'),\n 'askVolume': undefined,\n 'vwap': this.safeString (ticker, 'vwap'),\n 'open': open,\n 'close': last,\n 'last': last,\n 'previousClose': undefined,\n 'change': undefined,\n 'percentage': undefined,\n 'average': undefined,\n 'baseVolume': this.safeString (ticker, 'homeNotional24h'),\n 'quoteVolume': this.safeString (ticker, 'foreignNotional24h'),\n 'markPrice': this.safeString (ticker, 'markPrice'),\n 'info': ticker,\n }, market);\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 1834, "line_start" => 1826, "mappings" => [], "name" => "parseTimeInForce", "signature" => "parseTimeInForce (timeInForce: Str)", "source" => "parseTimeInForce (timeInForce: Str) {\n const timeInForces: Dict = {\n 'Day': 'Day',\n 'GoodTillCancel': 'GTC',\n 'ImmediateOrCancel': 'IOC',\n 'FillOrKill': 'FOK',\n };\n return this.safeString (timeInForces, timeInForce, timeInForce);\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"timestamp\": \"2018-08-28T00:00:02.735Z\",\n \"symbol\": \"XBTUSD\",\n \"side\": \"Buy\",\n \"size\": 2000,\n \"price\": 6906.5,\n \"tickDirection\": \"PlusTick\",\n \"trdMatchID\": \"b9a42432-0a46-6a2f-5ecc-c32e9ca4baf8\",\n \"grossValue\": 28958000,\n \"homeNotional\": 0.28958,\n \"foreignNotional\": 2000\n }", "{\n \"execID\": \"string\",\n \"orderID\": \"string\",\n \"clOrdID\": \"string\",\n \"clOrdLinkID\": \"string\",\n \"account\": 0,\n \"symbol\": \"string\",\n \"side\": \"string\",\n \"lastQty\": 0,\n \"lastPx\": 0,\n \"underlyingLastPx\": 0,\n \"lastMkt\": \"string\",\n \"lastLiquidityInd\": \"string\",\n \"simpleOrderQty\": 0,\n \"orderQty\": 0,\n \"price\": 0,\n \"displayQty\": 0,\n \"stopPx\": 0,\n \"pegOffsetValue\": 0,\n \"pegPriceType\": \"string\",\n \"currency\": \"string\",\n \"settlCurrency\": \"string\",\n \"execType\": \"string\",\n \"ordType\": \"string\",\n \"timeInForce\": \"string\",\n \"execInst\": \"string\",\n \"contingencyType\": \"string\",\n \"exDestination\": \"string\",\n \"ordStatus\": \"string\",\n \"triggered\": \"string\",\n \"workingIndicator\": true,\n \"ordRejReason\": \"string\",\n \"simpleLeavesQty\": 0,\n \"leavesQty\": 0,\n \"simpleCumQty\": 0,\n \"cumQty\": 0,\n \"avgPx\": 0,\n \"commission\": 0,\n \"tradePublishIndicator\": \"string\",\n \"multiLegReportingType\": \"string\",\n \"text\": \"string\",\n \"trdMatchID\": \"string\",\n \"execCost\": 0,\n \"execComm\": 0,\n \"homeNotional\": 0,\n \"foreignNotional\": 0,\n \"transactTime\": \"2019-03-05T12:47:02.762Z\",\n \"timestamp\": \"2019-03-05T12:47:02.762Z\"\n }" ], "line_end" => 1806, "line_start" => 1695, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "trade" }, %{ "comment" => nil, "key" => "timestamp", "value" => "timestamp" }, %{ "comment" => nil, "key" => "datetime", "value" => "this.iso8601 (timestamp)" }, %{ "comment" => nil, "key" => "symbol", "value" => "symbol" }, %{ "comment" => nil, "key" => "id", "value" => "id" }, %{ "comment" => nil, "key" => "order", "value" => "order" }, %{ "comment" => nil, "key" => "type", "value" => "type" }, %{ "comment" => nil, "key" => "takerOrMaker", "value" => "takerOrMaker" }, %{ "comment" => nil, "key" => "side", "value" => "side" }, %{ "comment" => nil, "key" => "price", "value" => "priceString" }, %{ "comment" => nil, "key" => "cost", "value" => "Precise.stringAbs (execCost)" }, %{ "comment" => nil, "key" => "amount", "value" => "amountString" }, %{ "comment" => nil, "key" => "fee", "value" => "fee" }, %{ "comment" => nil, "key" => "cost", "value" => "feeCostString" }, %{ "comment" => nil, "key" => "currency", "value" => "this.safeCurrencyCode (currencyId)" }, %{ "comment" => nil, "key" => "rate", "value" => "this.safeString (trade, 'commission')" } ], "name" => "parseTrade", "signature" => "parseTrade (trade: Dict, market: Market = undefined): Trade", "source" => "parseTrade (trade: Dict, market: Market = undefined): Trade {\n //\n // fetchTrades (public)\n //\n // {\n // \"timestamp\": \"2018-08-28T00:00:02.735Z\",\n // \"symbol\": \"XBTUSD\",\n // \"side\": \"Buy\",\n // \"size\": 2000,\n // \"price\": 6906.5,\n // \"tickDirection\": \"PlusTick\",\n // \"trdMatchID\": \"b9a42432-0a46-6a2f-5ecc-c32e9ca4baf8\",\n // \"grossValue\": 28958000,\n // \"homeNotional\": 0.28958,\n // \"foreignNotional\": 2000\n // }\n //\n // fetchMyTrades (private)\n //\n // {\n // \"execID\": \"string\",\n // \"orderID\": \"string\",\n // \"clOrdID\": \"string\",\n // \"clOrdLinkID\": \"string\",\n // \"account\": 0,\n // \"symbol\": \"string\",\n // \"side\": \"string\",\n // \"lastQty\": 0,\n // \"lastPx\": 0,\n // \"underlyingLastPx\": 0,\n // \"lastMkt\": \"string\",\n // \"lastLiquidityInd\": \"string\",\n // \"simpleOrderQty\": 0,\n // \"orderQty\": 0,\n // \"price\": 0,\n // \"displayQty\": 0,\n // \"stopPx\": 0,\n // \"pegOffsetValue\": 0,\n // \"pegPriceType\": \"string\",\n // \"currency\": \"string\",\n // \"settlCurrency\": \"string\",\n // \"execType\": \"string\",\n // \"ordType\": \"string\",\n // \"timeInForce\": \"string\",\n // \"execInst\": \"string\",\n // \"contingencyType\": \"string\",\n // \"exDestination\": \"string\",\n // \"ordStatus\": \"string\",\n // \"triggered\": \"string\",\n // \"workingIndicator\": true,\n // \"ordRejReason\": \"string\",\n // \"simpleLeavesQty\": 0,\n // \"leavesQty\": 0,\n // \"simpleCumQty\": 0,\n // \"cumQty\": 0,\n // \"avgPx\": 0,\n // \"commission\": 0,\n // \"tradePublishIndicator\": \"string\",\n // \"multiLegReportingType\": \"string\",\n // \"text\": \"string\",\n // \"trdMatchID\": \"string\",\n // \"execCost\": 0,\n // \"execComm\": 0,\n // \"homeNotional\": 0,\n // \"foreignNotional\": 0,\n // \"transactTime\": \"2019-03-05T12:47:02.762Z\",\n // \"timestamp\": \"2019-03-05T12:47:02.762Z\"\n // }\n //\n const marketId = this.safeString (trade, 'symbol');\n const symbol = this.safeSymbol (marketId, market);\n const timestamp = this.parse8601 (this.safeString (trade, 'timestamp'));\n const priceString = this.safeString2 (trade, 'avgPx', 'price');\n const amountString = this.convertFromRawQuantity (symbol, this.safeString2 (trade, 'size', 'lastQty'));\n const execCost = this.numberToString (this.convertFromRawCost (symbol, this.safeString (trade, 'execCost')));\n const id = this.safeString (trade, 'trdMatchID');\n const order = this.safeString (trade, 'orderID');\n const side = this.safeStringLower (trade, 'side');\n // price * amount doesn't work for all symbols (e.g. XBT, ETH)\n let fee = undefined;\n const feeCostString = this.numberToString (this.convertFromRawCost (symbol, this.safeString (trade, 'execComm')));\n if (feeCostString !== undefined) {\n const currencyId = this.safeString2 (trade, 'settlCurrency', 'currency');\n fee = {\n 'cost': feeCostString,\n 'currency': this.safeCurrencyCode (currencyId),\n 'rate': this.safeString (trade, 'commission'),\n };\n }\n // Trade or Funding\n const execType = this.safeString (trade, 'execType');\n let takerOrMaker = undefined;\n if (feeCostString !== undefined && execType === 'Trade') {\n takerOrMaker = Precise.stringLt (feeCostString, '0') ? 'maker' : 'taker';\n }\n const type = this.safeStringLower (trade, 'ordType');\n return this.safeTrade ({\n 'info': trade,\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n 'symbol': symbol,\n 'id': id,\n 'order': order,\n 'type': type,\n 'takerOrMaker': takerOrMaker,\n 'side': side,\n 'price': priceString,\n 'cost': Precise.stringAbs (execCost),\n 'amount': amountString,\n 'fee': fee,\n }, market);\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"transactID\": \"ffe699c2-95ee-4c13-91f9-0faf41daec25\",\n \"account\": 123456,\n \"currency\": \"XBt\",\n \"network\":'', // \"tron\" for USDt, etc...\n \"transactType\": \"Withdrawal\",\n \"amount\": -100100000,\n \"fee\": 100000,\n \"transactStatus\": \"Completed\",\n \"address\": \"385cR5DM96n1HvBDMzLHPYcw89fZAXULJP\",\n \"tx\": \"3BMEXabcdefghijklmnopqrstuvwxyz123\",\n \"text\": '',\n \"transactTime\": \"2019-01-02T01:00:00.000Z\",\n \"walletBalance\": 99900000, // this field might be inexistent\n \"marginBalance\": None, // this field might be inexistent\n \"timestamp\": \"2019-01-02T13:00:00.000Z\"\n }" ], "line_end" => 1504, "line_start" => 1430, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "transaction" }, %{ "comment" => nil, "key" => "id", "value" => "this.safeString (transaction, 'transactID')" }, %{ "comment" => nil, "key" => "txid", "value" => "this.safeString (transaction, 'tx')" }, %{ "comment" => nil, "key" => "type", "value" => "type" }, %{ "comment" => nil, "key" => "currency", "value" => "currency['code']" }, %{ "comment" => nil, "key" => "network", "value" => "this.networkIdToCode (this.safeString (transaction, 'network'), currency['code'])" }, %{ "comment" => nil, "key" => "amount", "value" => "this.parseNumber (amount)" }, %{ "comment" => nil, "key" => "status", "value" => "status" }, %{ "comment" => nil, "key" => "timestamp", "value" => "transactTime" }, %{ "comment" => nil, "key" => "datetime", "value" => "this.iso8601 (transactTime)" }, %{ "comment" => nil, "key" => "address", "value" => "address" }, %{ "comment" => nil, "key" => "addressFrom", "value" => "addressFrom" }, %{ "comment" => nil, "key" => "addressTo", "value" => "addressTo" }, %{ "comment" => nil, "key" => "tag", "value" => "undefined" }, %{ "comment" => nil, "key" => "tagFrom", "value" => "undefined" }, %{ "comment" => nil, "key" => "tagTo", "value" => "undefined" }, %{ "comment" => nil, "key" => "updated", "value" => "timestamp" }, %{ "comment" => nil, "key" => "internal", "value" => "undefined" }, %{ "comment" => nil, "key" => "comment", "value" => "undefined" }, %{ "comment" => nil, "key" => "fee", "value" => "{\n 'currency': currency['code'],\n 'cost': this.parseNumber (feeCost),\n 'rate': undefined,\n }" }, %{ "comment" => nil, "key" => "cost", "value" => "this.parseNumber (feeCost)" }, %{ "comment" => nil, "key" => "rate", "value" => "undefined" } ], "name" => "parseTransaction", "signature" => "parseTransaction (transaction: Dict, currency: Currency = undefined): Transaction", "source" => "parseTransaction (transaction: Dict, currency: Currency = undefined): Transaction {\n //\n // {\n // \"transactID\": \"ffe699c2-95ee-4c13-91f9-0faf41daec25\",\n // \"account\": 123456,\n // \"currency\": \"XBt\",\n // \"network\":'', // \"tron\" for USDt, etc...\n // \"transactType\": \"Withdrawal\",\n // \"amount\": -100100000,\n // \"fee\": 100000,\n // \"transactStatus\": \"Completed\",\n // \"address\": \"385cR5DM96n1HvBDMzLHPYcw89fZAXULJP\",\n // \"tx\": \"3BMEXabcdefghijklmnopqrstuvwxyz123\",\n // \"text\": '',\n // \"transactTime\": \"2019-01-02T01:00:00.000Z\",\n // \"walletBalance\": 99900000, // this field might be inexistent\n // \"marginBalance\": None, // this field might be inexistent\n // \"timestamp\": \"2019-01-02T13:00:00.000Z\"\n // }\n //\n const currencyId = this.safeString (transaction, 'currency');\n currency = this.safeCurrency (currencyId, currency);\n // For deposits, transactTime == timestamp\n // For withdrawals, transactTime is submission, timestamp is processed\n const transactTime = this.parse8601 (this.safeString (transaction, 'transactTime'));\n const timestamp = this.parse8601 (this.safeString (transaction, 'timestamp'));\n const type = this.safeStringLower (transaction, 'transactType');\n // Deposits have no from address or to address, withdrawals have both\n let address = undefined;\n let addressFrom = undefined;\n let addressTo = undefined;\n if (type === 'withdrawal') {\n address = this.safeString (transaction, 'address');\n addressFrom = this.safeString (transaction, 'tx');\n addressTo = address;\n } else if (type === 'deposit') {\n addressTo = this.safeString (transaction, 'address');\n addressFrom = this.safeString (transaction, 'tx');\n }\n const amountString = this.safeString (transaction, 'amount');\n const amountStringAbs = Precise.stringAbs (amountString);\n const amount = this.convertToRealAmount (currency['code'], amountStringAbs);\n const feeCostString = this.safeString (transaction, 'fee');\n const feeCost = this.convertToRealAmount (currency['code'], feeCostString);\n let status = this.safeString (transaction, 'transactStatus');\n if (status !== undefined) {\n status = this.parseTransactionStatus (status);\n }\n return {\n 'info': transaction,\n 'id': this.safeString (transaction, 'transactID'),\n 'txid': this.safeString (transaction, 'tx'),\n 'type': type,\n 'currency': currency['code'],\n 'network': this.networkIdToCode (this.safeString (transaction, 'network'), currency['code']),\n 'amount': this.parseNumber (amount),\n 'status': status,\n 'timestamp': transactTime,\n 'datetime': this.iso8601 (transactTime),\n 'address': address,\n 'addressFrom': addressFrom,\n 'addressTo': addressTo,\n 'tag': undefined,\n 'tagFrom': undefined,\n 'tagTo': undefined,\n 'updated': timestamp,\n 'internal': undefined,\n 'comment': undefined,\n 'fee': {\n 'currency': currency['code'],\n 'cost': this.parseNumber (feeCost),\n 'rate': undefined,\n },\n } as Transaction;\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 1428, "line_start" => 1420, "mappings" => [], "name" => "parseTransactionStatus", "signature" => "parseTransactionStatus (status: Str)", "source" => "parseTransactionStatus (status: Str) {\n const statuses: Dict = {\n 'Confirmed': 'pending',\n 'Canceled': 'canceled',\n 'Completed': 'ok',\n 'Pending': 'pending',\n };\n return this.safeString (statuses, status, status);\n }" } ], path_prefix: "/api/v1/", pro: true, quote_json_numbers: nil, rate_limits: %{ interval_ms: 100, period: 1000, requests: 10, rolling_window_size: 60000 }, raw_endpoints: %{ private: [ %{ auth: false, cost: 5, method: :get, path: "/address" }, %{ auth: false, cost: 5, method: :get, path: "/apiKey" }, %{ auth: false, cost: 5, method: :get, path: "/execution" }, %{ auth: false, cost: 5, method: :get, path: "/execution/tradeHistory" }, %{ auth: false, cost: 5, method: :get, path: "/globalNotification" }, %{ auth: false, cost: 5, method: :get, path: "/leaderboard/name" }, %{ auth: false, cost: 5, method: :get, path: "/order" }, %{ auth: false, cost: 5, method: :get, path: "/porl/snapshots" }, %{ auth: false, cost: 5, method: :get, path: "/position" }, %{ auth: false, cost: 5, method: :get, path: "/user" }, %{ auth: false, cost: 5, method: :get, path: "/user/affiliateStatus" }, %{ auth: false, cost: 5, method: :get, path: "/user/checkReferralCode" }, %{ auth: false, cost: 5, method: :get, path: "/user/commission" }, %{ auth: false, cost: 5, method: :get, path: "/user/csa" }, %{ auth: false, cost: 5, method: :get, path: "/user/depositAddress" }, %{ auth: false, cost: 5, method: :get, path: "/user/executionHistory" }, %{ auth: false, cost: 5, method: :get, path: "/user/getWalletTransferAccounts" }, %{ auth: false, cost: 5, method: :get, path: "/user/margin" }, %{ auth: false, cost: 5, method: :get, path: "/user/quoteFillRatio" }, %{ auth: false, cost: 5, method: :get, path: "/user/quoteValueRatio" }, %{ auth: false, cost: 5, method: :get, path: "/user/staking" }, %{ auth: false, cost: 5, method: :get, path: "/user/staking/instruments" }, %{ auth: false, cost: 5, method: :get, path: "/user/staking/tiers" }, %{ auth: false, cost: 5, method: :get, path: "/user/tradingVolume" }, %{ auth: false, cost: 5, method: :get, path: "/user/unstakingRequests" }, %{ auth: false, cost: 5, method: :get, path: "/user/wallet" }, %{ auth: false, cost: 5, method: :get, path: "/user/walletHistory" }, %{ auth: false, cost: 5, method: :get, path: "/user/walletSummary" }, %{ auth: false, cost: 5, method: :get, path: "/userAffiliates" }, %{ auth: false, cost: 5, method: :get, path: "/userEvent" }, %{ auth: false, cost: 5, method: :post, path: "/address" }, %{ auth: false, cost: 5, method: :post, path: "/chat" }, %{ auth: false, cost: 5, method: :post, path: "/guild" }, %{ auth: false, cost: 5, method: :post, path: "/guild/archive" }, %{ auth: false, cost: 5, method: :post, path: "/guild/join" }, %{ auth: false, cost: 5, method: :post, path: "/guild/kick" }, %{ auth: false, cost: 5, method: :post, path: "/guild/leave" }, %{ auth: false, cost: 5, method: :post, path: "/guild/sharesTrades" }, %{ auth: false, cost: 1, method: :post, path: "/order" }, %{ auth: false, cost: 5, method: :post, path: "/order/cancelAllAfter" }, %{ auth: false, cost: 5, method: :post, path: "/order/closePosition" }, %{ auth: false, cost: 1, method: :post, path: "/position/isolate" }, %{ auth: false, cost: 1, method: :post, path: "/position/leverage" }, %{ auth: false, cost: 5, method: :post, path: "/position/riskLimit" }, %{ auth: false, cost: 1, method: :post, path: "/position/transferMargin" }, %{ auth: false, cost: 5, method: :post, path: "/user/addSubaccount" }, %{ auth: false, cost: 5, method: :post, path: "/user/cancelWithdrawal" }, %{ auth: false, cost: 5, method: :post, path: "/user/communicationToken" }, %{ auth: false, cost: 5, method: :post, path: "/user/confirmEmail" }, %{ auth: false, cost: 5, method: :post, path: "/user/confirmWithdrawal" }, %{ auth: false, cost: 5, method: :post, path: "/user/logout" }, %{ auth: false, cost: 5, method: :post, path: "/user/preferences" }, %{ auth: false, cost: 5, method: :post, path: "/user/requestWithdrawal" }, %{ auth: false, cost: 5, method: :post, path: "/user/unstakingRequests" }, %{ auth: false, cost: 5, method: :post, path: "/user/updateSubaccount" }, %{ auth: false, cost: 5, method: :post, path: "/user/walletTransfer" }, %{ auth: false, cost: 5, method: :put, path: "/guild" }, %{ auth: false, cost: 1, method: :put, path: "/order" }, %{ auth: false, cost: 1, method: :delete, path: "/order" }, %{ auth: false, cost: 1, method: :delete, path: "/order/all" }, %{ auth: false, cost: 5, method: :delete, path: "/user/unstakingRequests" } ], public: [ %{ auth: false, cost: 5, method: :get, path: "/announcement" }, %{ auth: false, cost: 5, method: :get, path: "/announcement/urgent" }, %{ auth: false, cost: 5, method: :get, path: "/chat" }, %{ auth: false, cost: 5, method: :get, path: "/chat/channels" }, %{ auth: false, cost: 5, method: :get, path: "/chat/connected" }, %{ auth: false, cost: 5, method: :get, path: "/chat/pinned" }, %{ auth: false, cost: 5, method: :get, path: "/funding" }, %{ auth: false, cost: 5, method: :get, path: "/guild" }, %{ auth: false, cost: 5, method: :get, path: "/instrument" }, %{ auth: false, cost: 5, method: :get, path: "/instrument/active" }, %{ auth: false, cost: 5, method: :get, path: "/instrument/activeAndIndices" }, %{ auth: false, cost: 5, method: :get, path: "/instrument/activeIntervals" }, %{ auth: false, cost: 5, method: :get, path: "/instrument/compositeIndex" }, %{ auth: false, cost: 5, method: :get, path: "/instrument/indices" }, %{ auth: false, cost: 5, method: :get, path: "/instrument/usdVolume" }, %{ auth: false, cost: 5, method: :get, path: "/insurance" }, %{ auth: false, cost: 5, method: :get, path: "/leaderboard" }, %{ auth: false, cost: 5, method: :get, path: "/liquidation" }, %{ auth: false, cost: 5, method: :get, path: "/orderBook/L2" }, %{ auth: false, cost: 5, method: :get, path: "/porl/nonce" }, %{ auth: false, cost: 5, method: :get, path: "/quote" }, %{ auth: false, cost: 5, method: :get, path: "/quote/bucketed" }, %{ auth: false, cost: 5, method: :get, path: "/schema" }, %{ auth: false, cost: 5, method: :get, path: "/schema/websocketHelp" }, %{ auth: false, cost: 5, method: :get, path: "/settlement" }, %{ auth: false, cost: 5, method: :get, path: "/stats" }, %{ auth: false, cost: 5, method: :get, path: "/stats/history" }, %{ auth: false, cost: 5, method: :get, path: "/stats/historyUSD" }, %{ auth: false, cost: 5, method: :get, path: "/trade" }, %{ auth: false, cost: 5, method: :get, path: "/trade/bucketed" }, %{ auth: false, cost: 5, method: :get, path: "/wallet/assets" }, %{ auth: false, cost: 5, method: :get, path: "/wallet/networks" } ] }, required_credentials: %{ api_key: true, password: false, secret: true, uid: false }, requires_eddsa: false, response_error: %{ code_field: [ "error", "message" ], field: nil, message_field: [ "error", "message" ], success_values: nil, type: :http_status_only }, signing: %{ api_key_header: "api-key", confidence: :high, pattern: :hmac_sha256_headers, signature_header: "api-signature" }, spec_format_version: 1, status: %{ "eta" => nil, "status" => "ok", "updated" => nil, "url" => nil }, symbol_format: nil, symbol_formats: %{ future: %{ base: "XRP", base_id: "XRP", case: :upper, contract: true, contract_size: 0.01, expiry: 1774612800000, expiry_datetime: "2026-03-27T12:00:00.000Z", id: "XRPH26", inverse: false, limits: %{ "amount" => %{ "max" => 1000000000 }, "cost" => %{}, "leverage" => %{ "max" => 33.333333333333336, "min" => 1 }, "price" => %{ "max" => 1 } }, linear: true, maker: 0.0005, precision: %{ "amount" => 1000, "price" => 1.0e-8 }, quote: "BTC", quote_id: "XBT", separator: "", settle: "BTC", settle_id: "XBt", symbol: "XRP/BTC:BTC-260327", taker: 0.0005 }, precision_mode: 4, sample_limits: %{ "amount" => %{ "max" => 1000000000000 }, "cost" => %{}, "price" => %{ "max" => 10000 } }, sample_precision: %{ "amount" => 1000000, "price" => 0.0001 }, spot: %{ base: "XRP", base_id: "XRP", case: :upper, contract: false, id: "XRP_USDT", limits: %{ "amount" => %{ "max" => 1000000000000 }, "cost" => %{}, "leverage" => %{}, "price" => %{ "max" => 10000 } }, maker: 0.0005, precision: %{ "amount" => 1000000, "price" => 0.0001 }, quote: "USDT", quote_id: "USDT", separator: "_", symbol: "XRP/USDT", taker: 0.0005 }, swap: %{ base: "SUI", base_id: "SUI", case: :upper, contract: true, contract_size: 0.001, id: "SUIUSDT", inverse: false, limits: %{ "amount" => %{ "max" => 1000000000 }, "cost" => %{}, "leverage" => %{ "max" => 100, "min" => 1 }, "price" => %{ "max" => 10000 } }, linear: true, maker: 0.0005, precision: %{ "amount" => 100, "price" => 0.0001 }, quote: "USDT", quote_id: "USDT", separator: "", settle: "USDT", settle_id: "USDt", symbol: "SUI/USDT:USDT", taker: 0.0005 } }, symbol_patterns: %{ future: %{ case: :upper, component_order: [ :base, :quote, :date ], date_format: :yymmdd, pattern: :future_unknown, separator: "-", suffix: nil }, spot: %{ case: :upper, component_order: nil, date_format: nil, pattern: :underscore_upper, separator: "_", suffix: nil }, swap: %{ case: :upper, component_order: nil, date_format: nil, pattern: :implicit, separator: "", suffix: nil } }, timeframes: %{ "1d" => "1d", "1h" => "1h", "1m" => "1m", "5m" => "5m" }, url_strategy: %{ detected_from: "sign_method", pattern: :api_version_slash, prefix: "/api/v1/" }, urls: %{ api: "https://www.bitmex.com", api_sections: %{ "private" => "https://www.bitmex.com", "public" => "https://www.bitmex.com" }, doc: [ "https://www.bitmex.com/app/apiOverview", "https://github.com/BitMEX/api-connectors/tree/master/official-http" ], other: nil, sandbox: %{ "private" => "https://testnet.bitmex.com", "public" => "https://testnet.bitmex.com" }, www: "https://www.bitmex.com" }, version: "v1", ws: %{ auth: %{ algorithm: :sha256, encoding: :base64, expires_offset_ms: 10000, market_specific: false, message_format: :op_args, op_field: "op", op_value: "authKeyExpires", pattern: :direct_hmac_expiry, payload_format: "GET/realtime{expires}", requires_passphrase: false, timestamp_unit: :milliseconds }, channel_templates: %{ watch_balance: %{ auth_required: true, market_id_format: :native, params: [], pattern: :topic_based, separator: "." }, watch_heartbeat: %{ market_id_format: :native, params: [], pattern: :topic_based, separator: "." }, watch_liquidations: %{ market_id_format: :native, params: [ %{ "default" => nil, "name" => "limit" } ], pattern: :topic_based, separator: "." }, watch_liquidations_for_symbols: %{ market_id_format: :native, params: [ %{ "default" => nil, "name" => "limit" } ], pattern: :topic_based, separator: "." }, watch_my_trades: %{ auth_required: true, channel_name: "execution", market_id_format: :native, params: [ %{ "default" => nil, "name" => "limit" } ], pattern: :topic_based, separator: "." }, watch_ohlcv: %{ market_id_format: :native, params: [ %{ "default" => nil, "name" => "limit" } ], pattern: :topic_based, separator: "." }, watch_order_book: %{ market_id_format: :native, params: [ %{ "default" => nil, "name" => "limit" } ], pattern: :topic_based, separator: "." }, watch_order_book_for_symbols: %{ market_id_format: :native, params: [ %{ "default" => nil, "name" => "limit" } ], pattern: :topic_based, separator: "." }, watch_orders: %{ auth_required: true, channel_name: "order", market_id_format: :native, params: [ %{ "default" => nil, "name" => "limit" } ], pattern: :topic_based, separator: "." }, watch_positions: %{ auth_required: true, market_id_format: :native, params: [ %{ "default" => nil, "name" => "limit" } ], pattern: :topic_based, separator: "." }, watch_ticker: %{ channel_name: "instrument", market_id_format: :native, params: [], pattern: :topic_based, separator: "." }, watch_tickers: %{ channel_name: "instrument", market_id_format: :native, params: [], pattern: :topic_based, separator: "." }, watch_trades: %{ market_id_format: :native, params: [ %{ "default" => nil, "name" => "limit" } ], pattern: :topic_based, separator: "." }, watch_trades_for_symbols: %{ market_id_format: :native, params: [ %{ "default" => nil, "name" => "limit" } ], pattern: :topic_based, separator: "." } }, has: %{ watch_balance: true, watch_bids_asks: nil, watch_liquidations: true, watch_liquidations_for_symbols: true, watch_my_liquidations: nil, watch_my_liquidations_for_symbols: nil, watch_my_trades: true, watch_ohlcv: true, watch_ohlcv_for_symbols: nil, watch_order_book: true, watch_order_book_for_symbols: true, watch_orders: true, watch_orders_for_symbols: nil, watch_position: nil, watch_positions: nil, watch_postions: true, watch_status: nil, watch_ticker: true, watch_tickers: true, watch_trades: true, watch_trades_for_symbols: true }, message_patterns: [ %{ args_field: "args", format: :op, keys: [ "args", "op" ], kind_field: "op", kind_value: "authKeyExpires", sources: [ :send, :watch ] }, %{ args_field: "args", format: :op, keys: [ "args", "op" ], kind_field: "op", kind_value: "subscribe", sources: [ :send, :watch, :watch_multiple ] } ], options: %{ "watchOrderBookLevel" => "orderBookL2" }, subscription_config: %{ args_field: "args", args_format: :string_list, market_id_format: :native, op_field: "op", separator: "." }, subscription_pattern: :op_subscribe, test_urls: "wss://ws.testnet.bitmex.com/realtime", urls: "wss://ws.bitmex.com/realtime", watch_methods: [ "watchBalance", "watchHeartbeat", "watchLiquidations", "watchLiquidationsForSymbols", "watchMyTrades", "watchOHLCV", "watchOrderBook", "watchOrderBookForSymbols", "watchOrders", "watchPositions", "watchTicker", "watchTickers", "watchTrades", "watchTradesForSymbols" ] } }