# Gate Exchange Specification # # Auto-generated by: mix ccxt.extract gate # CCXT version: 4.5.42 # Spec format version: 2 # # 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: [ "KR" ], currencies: %{}, currency_aliases: %{ "88MPH" => "MPH", "ASS" => "ASSF", "AXIS" => "AXISDEFI", "BCHSV" => "BSV", "BIFI" => "BITCOINFILE", "BOX" => "DEFIBOX", "BYN" => "BEYONDFI", "EGG" => "GOOSEFINANCE", "GTC" => "GAMECOM", "GTC_BSC" => "GAMECOM_BSC", "GTC_HT" => "GAMECOM_HT", "HIT" => "HITCHAIN", "MM" => "MILLION", "MPH" => "MORPHER", "ORT" => "XREATORS", "POINT" => "GATEPOINT", "RAI" => "RAIREFLEXINDEX", "RED" => "RedLang", "SBTC" => "SUPERBITCOIN", "TNC" => "TRINITYNETWORKCREDIT", "TRAC" => "TRACO", "VAI" => "VAIOT", "XBT" => "BTC" }, dex: false, enable_rate_limit: true, endpoint_extraction_stats: %{ "capturedMethods" => 71, "coveragePercent" => 100, "enabledMethods" => 74, "excluded" => [ %{ "method" => "fetchLeverageTiers", "reason" => "gate fetchLeverageTiers only supports swap and future" }, %{ "method" => "fetchDepositWithdrawFee", "reason" => "emulated (returns cached data, no HTTP call)" }, %{ "method" => "fetchPositionHistory", "reason" => "emulated (returns cached data, no HTTP call)" } ], "excludedMethods" => 3, "extractableMethods" => 71, "failures" => [] }, endpoints: [ %{ api_section: "private/account", auth: true, cost: 1.3333333333333333, expects: :single, market_type: :spot, method: :get, name: :borrow_cross_margin, param_mappings: %{}, params: [ :code, :amount ], path: "/spot/detail", source: :intercepted }, %{ api_section: "private/margin", auth: true, cost: 1.3333333333333333, default_params: %{ "type" => "borrow" }, expects: :single, market_type: :spot, method: :post, name: :borrow_isolated_margin, param_mappings: %{ "code" => "currency", "symbol" => "currency_pair" }, params: [ :symbol, :code, :amount ], path: "/spot/uni/loans", source: :intercepted }, %{ api_section: "private/spot", auth: true, cost: 0.26666666666666666, default_params: %{ _by_market_type: %{ spot: %{ "account" => "spot" }, swap: %{ "contract" => "BTCUSDT", "settle" => "USDT" } } }, expects: :list, market_type: :spot, method: :delete, name: :cancel_all_orders, param_mappings: %{ "symbol" => "currency_pair" }, params: [ :symbol ], path: "/spot/orders", source: :intercepted }, %{ api_section: "private/spot", auth: true, cost: 0.26666666666666666, default_params: %{ _by_market_type: %{ spot: %{ "account" => "spot" }, swap: %{ "contract" => "BTCUSDT", "settle" => "USDT" } } }, expects: :single, market_type: :spot, method: :delete, name: :cancel_order, param_mappings: %{ "id" => "order_id", "symbol" => "currency_pair" }, params: [ :id, :symbol ], path: "/spot/orders/{order_id}", source: :intercepted }, %{ api_section: "private/futures", auth: true, cost: 0.4, expects: :list, market_type: :spot, method: :post, name: :cancel_orders, param_mappings: %{}, params: [ :ids, :symbol ], path: "/{settle}/batch_cancel_orders", source: :intercepted }, %{ api_section: "private/spot", auth: true, cost: 0.26666666666666666, expects: :list, market_type: :spot, method: :post, name: :cancel_orders_for_symbols, param_mappings: %{}, params: [ :orders ], path: "/spot/cancel_batch_orders", source: :intercepted }, %{ api_section: "private/spot", auth: true, cost: 0.4, default_params: %{ "account" => "spot", "type" => "limit" }, expects: :single, market_type: :spot, method: :post, name: :create_limit_order, param_mappings: %{ "symbol" => "currency_pair" }, params: [ :symbol, :side, :amount, :price ], path: "/spot/orders", source: :intercepted }, %{ api_section: "private/spot", auth: true, cost: 0.4, default_params: %{ "account" => "spot", "side" => "buy", "time_in_force" => "ioc", "type" => "market" }, expects: :single, market_type: :spot, method: :post, name: :create_market_buy_order_with_cost, param_mappings: %{ "cost" => "amount", "symbol" => "currency_pair" }, params: [ :symbol, :cost ], path: "/spot/orders", source: :intercepted }, %{ api_section: "private/spot", auth: true, cost: 0.4, default_params: %{ "account" => "spot", "time_in_force" => "ioc", "type" => "market" }, expects: :single, market_type: :spot, method: :post, name: :create_market_order, param_mappings: %{ "symbol" => "currency_pair" }, params: [ :symbol, :side, :amount, :price ], path: "/spot/orders", source: :intercepted }, %{ api_section: "private/spot", auth: true, cost: 0.4, default_params: %{ "account" => "spot" }, expects: :single, market_type: :spot, method: :post, name: :create_order, param_mappings: %{ "symbol" => "currency_pair" }, params: [ :symbol, :type, :side, :amount, :price ], path: "/spot/orders", source: :intercepted }, %{ api_section: "private/futures", auth: true, cost: 0.4, expects: :list, market_type: :spot, method: :post, name: :create_orders, param_mappings: %{}, params: [ :orders ], path: "/{settle}/batch_orders", source: :intercepted }, %{ api_section: "private/spot", auth: true, cost: 0.4, default_params: %{ "account" => "spot", "time_in_force" => "poc" }, expects: :single, market_type: :spot, method: :post, name: :create_post_only_order, param_mappings: %{ "symbol" => "currency_pair" }, params: [ :symbol, :type, :side, :amount, :price ], path: "/spot/orders", source: :intercepted }, %{ api_section: "private/futures", auth: true, cost: 0.4, default_params: %{ "contract" => "BTCUSDT", "reduce_only" => true, "settle" => "USDT", "size" => 0 }, expects: :single, market_type: :swap, method: :post, name: :create_reduce_only_order, param_mappings: %{ "amount" => "size" }, params: [ :symbol, :type, :side, :amount, :price ], path: "/{settle}/orders", source: :intercepted }, %{ api_section: "private/futures", auth: true, cost: 0.4, default_params: %{ "initial" => %{ "contract" => "BTCUSDT", "price" => "50000", "size" => 0 }, "settle" => "USDT", "trigger" => %{ "price" => "48000", "price_type" => 0, "rule" => 1 }, "triggerDirection" => "below" }, expects: :single, market_type: :swap, method: :post, name: :create_stop_limit_order, param_mappings: %{}, params: [ :symbol, :side, :amount, :price, :triggerPrice ], path: "/{settle}/price_orders", source: :intercepted }, %{ api_section: "private/futures", auth: true, cost: 0.4, default_params: %{ "initial" => %{ "contract" => "BTCUSDT", "price" => "50000", "size" => 0 }, "settle" => "USDT", "trigger" => %{ "price" => "48000", "price_type" => 0, "rule" => 1 }, "triggerDirection" => "below" }, expects: :single, market_type: :swap, method: :post, name: :create_stop_loss_order, param_mappings: %{}, params: [ :symbol, :type, :side, :amount, :price, :stopLossPrice ], path: "/{settle}/price_orders", source: :intercepted }, %{ api_section: "private/futures", auth: true, cost: 0.4, default_params: %{ "initial" => %{ "contract" => "BTCUSDT", "price" => "50000", "size" => 0 }, "settle" => "USDT", "trigger" => %{ "price" => "48000", "price_type" => 0, "rule" => 1 }, "triggerDirection" => "below" }, expects: :single, market_type: :swap, method: :post, name: :create_stop_order, param_mappings: %{}, params: [ :symbol, :type, :side, :amount, :price, :triggerPrice ], path: "/{settle}/price_orders", source: :intercepted }, %{ api_section: "private/futures", auth: true, cost: 0.4, default_params: %{ "initial" => %{ "contract" => "BTCUSDT", "price" => "50000", "size" => 0 }, "settle" => "USDT", "trigger" => %{ "price" => "52000", "price_type" => 0, "rule" => 2 }, "triggerDirection" => "above" }, expects: :single, market_type: :swap, method: :post, name: :create_take_profit_order, param_mappings: %{}, params: [ :symbol, :type, :side, :amount, :price, :takeProfitPrice ], path: "/{settle}/price_orders", source: :intercepted }, %{ api_section: "private/futures", auth: true, cost: 0.4, default_params: %{ "initial" => %{ "contract" => "BTCUSDT", "price" => "50000", "size" => 0 }, "settle" => "USDT", "trigger" => %{ "price" => "48000", "price_type" => 0, "rule" => 1 }, "triggerDirection" => "below" }, expects: :single, market_type: :swap, method: :post, name: :create_trigger_order, param_mappings: %{}, params: [ :symbol, :type, :side, :amount, :price, :triggerPrice ], path: "/{settle}/price_orders", source: :intercepted }, %{ api_section: "private/spot", auth: true, cost: 0.4, default_params: %{ _by_market_type: %{ spot: %{ "account" => "spot" }, swap: %{ "account" => "futures", "settle" => "USDT" } } }, expects: :single, market_type: :spot, method: :patch, name: :edit_order, param_mappings: %{ "id" => "order_id", "symbol" => "currency_pair" }, params: [ :id, :symbol, :type, :side, :amount, :price ], path: "/spot/orders/{order_id}", source: :intercepted }, %{ api_section: "private/spot", auth: true, cost: 1, default_params: %{ _by_market_type: %{ spot: %{}, swap: %{ "settle" => "usdt" } } }, expects: :single, market_type: :spot, method: :get, name: :fetch_balance, param_mappings: %{}, params: [], path: "/spot/accounts", source: :intercepted }, %{ api_section: "private/margin", auth: true, cost: 1.3333333333333333, expects: :list, market_type: :spot, method: :get, name: :fetch_borrow_interest, param_mappings: %{ "code" => "currency" }, params: [ :code, :symbol, :since, :limit ], path: "/spot/cross/interest_records", source: :intercepted }, %{ api_section: "private/spot", auth: true, cost: 1, default_params: %{ _by_market_type: %{ spot: %{ "account" => "spot", "status" => "finished" }, swap: %{ "contract" => "BTCUSDT", "settle" => "USDT", "status" => "finished" } } }, expects: :list, market_type: :spot, method: :get, name: :fetch_closed_orders, param_mappings: %{ "symbol" => "currency_pair" }, params: [ :symbol, :since, :limit ], path: "/spot/orders", source: :intercepted }, %{ api_section: "public/spot", auth: false, cost: 1, expects: :list, market_type: :spot, method: :get, name: :fetch_currencies, param_mappings: %{}, params: [], path: "/spot/currencies", source: :intercepted }, %{ api_section: "private/wallet", auth: true, cost: 1, expects: :single, market_type: :spot, method: :get, name: :fetch_deposit_address, param_mappings: %{ "code" => "currency" }, params: [ :code ], path: "/spot/deposit_address", response_transformer: {:extract_path_unwrap, ["multichain_addresses"]}, source: :intercepted }, %{ api_section: "private/wallet", auth: true, cost: 1, expects: :list, market_type: :spot, method: :get, name: :fetch_deposit_addresses_by_network, param_mappings: %{ "code" => "currency" }, params: [ :code ], path: "/spot/deposit_address", response_transformer: {:extract_path, ["multichain_addresses"]}, source: :intercepted }, %{ api_section: "private/wallet", auth: true, cost: 1, expects: :list, market_type: :spot, method: :get, name: :fetch_deposit_withdraw_fees, param_mappings: %{}, params: [ :codes ], path: "/spot/withdraw_status", source: :intercepted }, %{ api_section: "private/wallet", auth: true, cost: 1, expects: :list, market_type: :spot, method: :get, name: :fetch_deposits, pagination: %{ style: :dynamic }, param_mappings: %{ "code" => "currency" }, params: [ :code, :since, :limit ], path: "/spot/deposits", source: :intercepted }, %{ api_section: "private/futures", auth: true, cost: 1, default_params: %{ "contract" => "BTCUSDT", "settle" => "USDT", "type" => "fund" }, expects: :list, market_type: :swap, method: :get, name: :fetch_funding_history, param_mappings: %{}, params: [ :symbol, :since, :limit ], path: "/{settle}/account_book", source: :intercepted }, %{ api_section: "public/futures", auth: false, cost: 1, default_params: %{ "contract" => "BTCUSDT", "settle" => "USDT" }, expects: :single, market_type: :swap, method: :get, name: :fetch_funding_rate, param_mappings: %{}, params: [ :symbol ], path: "/{settle}/contracts/{contract}", source: :intercepted }, %{ api_section: "public/futures", auth: false, cost: 1, default_params: %{ "contract" => "BTCUSDT", "settle" => "USDT" }, expects: :list, market_type: :swap, method: :get, name: :fetch_funding_rate_history, pagination: %{ style: :time_window }, param_mappings: %{}, params: [ :symbol, :since, :limit ], path: "/{settle}/funding_rate", source: :intercepted }, %{ api_section: "public/futures", auth: false, cost: 1, default_params: %{ "contract" => "BTCUSDT", "settle" => "USDT" }, expects: :list, market_type: :swap, method: :get, name: :fetch_funding_rates, param_mappings: %{}, params: [ :symbols ], path: "/{settle}/contracts", source: :intercepted }, %{ api_section: "public/options", auth: false, cost: 1, expects: :list, market_type: :option, method: :get, name: :fetch_greeks, param_mappings: %{}, params: [ :symbol ], path: "/spot/tickers", source: :intercepted }, %{ api_section: "public/futures", auth: false, cost: 1, default_params: %{ "contract" => "index_BTCUSDT", "interval" => "1m", "limit" => 1999, "settle" => "USDT" }, expects: :list, market_type: :swap, method: :get, name: :fetch_index_ohlcv, pagination: %{ style: :time_window }, param_mappings: %{ "timeframe" => "interval" }, params: [ :symbol, :timeframe, :since, :limit ], path: "/{settle}/candlesticks", source: :intercepted }, %{ api_section: "public/spot", auth: false, cost: 1, default_params: %{ "with_id" => true }, expects: :single, market_type: :spot, method: :get, name: :fetch_l2_order_book, param_mappings: %{ "symbol" => "currency_pair" }, params: [ :symbol, :limit ], path: "/spot/order_book", source: :intercepted }, %{ api_section: "private/spot", auth: true, cost: 1, default_params: %{ _by_market_type: %{ spot: %{}, swap: %{ "settle" => "usdt" } } }, expects: :list, market_type: :spot, method: :get, name: :fetch_ledger, pagination: %{ style: :dynamic }, param_mappings: %{ "code" => "currency" }, params: [ :code, :since, :limit ], path: "/spot/account_book", source: :intercepted }, %{ api_section: "public/margin", auth: false, cost: 1, expects: :single, market_type: :swap, method: :get, name: :fetch_leverage, param_mappings: %{ "symbol" => "currency_pair" }, params: [ :symbol ], path: "/spot/currency_pairs/{currency_pair}", source: :intercepted }, %{ api_section: "public/margin", auth: false, cost: 1, expects: :list, market_type: :swap, method: :get, name: :fetch_leverages, param_mappings: %{}, params: [ :symbols ], path: "/spot/currency_pairs", source: :intercepted }, %{ api_section: "public/futures", auth: false, cost: 1, default_params: %{ "contract" => "BTCUSDT", "settle" => "USDT" }, expects: :list, market_type: :swap, method: :get, name: :fetch_liquidations, param_mappings: %{}, params: [ :symbol, :since, :limit ], path: "/{settle}/liq_orders", source: :intercepted }, %{ api_section: "public/futures", auth: false, cost: 1, default_params: %{ "contract" => "mark_BTCUSDT", "interval" => "1m", "limit" => 1999, "settle" => "USDT" }, expects: :list, market_type: :swap, method: :get, name: :fetch_mark_ohlcv, pagination: %{ style: :time_window }, param_mappings: %{ "timeframe" => "interval" }, params: [ :symbol, :timeframe, :since, :limit ], path: "/{settle}/candlesticks", source: :intercepted }, %{ api_section: "public/futures", auth: false, cost: 1, default_params: %{ "contract" => "BTCUSDT", "settle" => "USDT" }, expects: :list, market_type: :swap, method: :get, name: :fetch_market_leverage_tiers, param_mappings: %{}, params: [ :symbol ], path: "/{settle}/risk_limit_tiers", source: :intercepted }, %{ api_section: "public/margin", auth: false, cost: 1, expects: :list, market_type: :spot, method: :get, name: :fetch_markets, param_mappings: %{}, params: [], path: "/spot/currency_pairs", source: :intercepted }, %{ api_section: "private/futures", auth: true, cost: 1, default_params: %{ "contract" => "BTCUSDT", "settle" => "USDT" }, expects: :list, market_type: :swap, method: :get, name: :fetch_my_liquidations, param_mappings: %{}, params: [ :symbol, :since, :limit ], path: "/{settle}/liquidates", source: :intercepted }, %{ api_section: "private/options", auth: true, cost: 1.3333333333333333, default_params: %{ "contract" => "BTC-250103-100000-C", "underlying" => "BTC" }, expects: :list, market_type: :swap, method: :get, name: :fetch_my_settlement_history, param_mappings: %{}, params: [], path: "/spot/my_settlements", response_transformer: {:extract_path, ["result", "list"]}, source: :intercepted }, %{ api_section: "private/spot", auth: true, cost: 1, default_params: %{ _by_market_type: %{ spot: %{ "account" => "spot" }, swap: %{ "contract" => "BTCUSDT", "settle" => "USDT" } } }, expects: :list, market_type: :spot, method: :get, name: :fetch_my_trades, pagination: %{ style: :dynamic }, param_mappings: %{ "symbol" => "currency_pair" }, params: [ :symbol, :since, :limit ], path: "/spot/my_trades", source: :intercepted }, %{ api_section: "private/wallet", auth: true, cost: 1, expects: :single, market_type: :spot, method: :get, name: :fetch_network_deposit_address, param_mappings: %{}, params: [], path: "/spot/deposit_address", response_transformer: {:extract_path_unwrap, ["multichain_addresses"]}, source: :intercepted }, %{ api_section: "public/spot", auth: false, cost: 1, default_params: %{ "limit" => 1000, "to" => "" }, expects: :list, market_type: :spot, method: :get, name: :fetch_ohlcv, pagination: %{ style: :time_window }, param_mappings: %{ "since" => "from", "symbol" => "currency_pair", "timeframe" => "interval" }, params: [ :symbol, :timeframe, :since, :limit ], path: "/spot/candlesticks", source: :intercepted }, %{ api_section: "public/futures", auth: false, cost: 1, default_params: %{ "contract" => "BTCUSDT", "interval" => "5m", "settle" => "USDT" }, expects: :list, market_type: :swap, method: :get, name: :fetch_open_interest_history, pagination: %{ style: :time_window }, param_mappings: %{ "timeframe" => "interval" }, params: [ :symbol, :timeframe, :since, :limit ], path: "/{settle}/contract_stats", source: :intercepted }, %{ api_section: "private/spot", auth: true, cost: 1, default_params: %{ _by_market_type: %{ spot: %{ "account" => "spot", "status" => "open" }, swap: %{ "contract" => "BTCUSDT", "settle" => "USDT", "status" => "open" } } }, expects: :list, market_type: :spot, method: :get, name: :fetch_open_orders, param_mappings: %{ "symbol" => "currency_pair" }, params: [ :symbol, :since, :limit ], path: "/spot/open_orders", source: :intercepted }, %{ api_section: "public/options", auth: false, cost: 1, default_params: %{ "contract" => "BTC-250103-100000-C" }, expects: :single, market_type: :option, method: :get, name: :fetch_option, param_mappings: %{}, params: [ :symbol ], path: "/spot/contracts/{contract}", source: :intercepted }, %{ api_section: "public/options", auth: false, cost: 1, default_params: %{ "underlying" => "BTC_USDT" }, expects: :list, market_type: :option, method: :get, name: :fetch_option_chain, param_mappings: %{}, params: [ :code ], path: "/spot/contracts", source: :intercepted }, %{ api_section: "private/spot", auth: true, cost: 1, default_params: %{ _by_market_type: %{ spot: %{ "account" => "spot" }, swap: %{ "contract" => "BTCUSDT", "settle" => "USDT" } } }, expects: :single, market_type: :spot, method: :get, name: :fetch_order, param_mappings: %{ "id" => "order_id", "symbol" => "currency_pair" }, params: [ :id, :symbol ], path: "/spot/orders/{order_id}", source: :intercepted }, %{ api_section: "public/spot", auth: false, cost: 1, default_params: %{ "with_id" => true }, expects: :single, market_type: :spot, method: :get, name: :fetch_order_book, param_mappings: %{ "symbol" => "currency_pair" }, params: [ :symbol, :limit ], path: "/spot/order_book", source: :intercepted }, %{ api_section: "private/futures", auth: true, cost: 1, default_params: %{ "contract" => "BTCUSDT", "settle" => "USDT" }, expects: :single, market_type: :swap, method: :get, name: :fetch_position, param_mappings: %{}, params: [ :symbol ], path: "/{settle}/positions/{contract}", source: :intercepted }, %{ api_section: "private/futures", auth: true, cost: 1, default_params: %{ "settle" => "usdt" }, expects: :list, market_type: :swap, method: :get, name: :fetch_positions, param_mappings: %{}, params: [ :symbols ], path: "/{settle}/positions", source: :intercepted }, %{ api_section: "private/futures", auth: true, cost: 1, default_params: %{ "contract" => "BTCUSDT", "settle" => "USDT" }, expects: :list, market_type: :swap, method: :get, name: :fetch_positions_history, param_mappings: %{}, params: [ :symbols, :since, :limit ], path: "/{settle}/position_close", source: :intercepted }, %{ api_section: "public/options", auth: false, cost: 1, default_params: %{ "underlying" => "BTC" }, expects: :list, market_type: :swap, method: :get, name: :fetch_settlement_history, param_mappings: %{}, params: [], path: "/spot/settlements", source: :intercepted }, %{ api_section: "public/spot", auth: false, cost: 1, expects: :single, market_type: :spot, method: :get, name: :fetch_ticker, param_mappings: %{ "symbol" => "currency_pair" }, params: [ :symbol ], path: "/spot/tickers", response_transformer: {:extract_path_unwrap, []}, source: :intercepted }, %{ api_section: "public/spot", auth: false, cost: 1, default_params: %{ _by_market_type: %{ spot: %{ "timezone" => "utc0" }, swap: %{ "settle" => "usdt", "timezone" => "utc0" } } }, expects: :list, market_type: :spot, method: :get, name: :fetch_tickers, param_mappings: %{}, params: [ :symbols ], path: "/spot/tickers", source: :intercepted }, %{ api_section: "public/spot", auth: false, cost: 1, expects: :single, market_type: :spot, method: :get, name: :fetch_time, param_mappings: %{}, params: [], path: "/spot/time", response_transformer: {:extract_path_unwrap, ["server_time"]}, source: :intercepted }, %{ api_section: "public/spot", auth: false, cost: 1, expects: :list, market_type: :spot, method: :get, name: :fetch_trades, pagination: %{ style: :dynamic }, param_mappings: %{ "symbol" => "currency_pair" }, params: [ :symbol, :since, :limit ], path: "/spot/trades", source: :intercepted }, %{ api_section: "private/wallet", auth: true, cost: 1, expects: :single, market_type: :spot, method: :get, name: :fetch_trading_fee, param_mappings: %{ "symbol" => "currency_pair" }, params: [ :symbol ], path: "/spot/fee", source: :intercepted }, %{ api_section: "private/wallet", auth: true, cost: 1, expects: :list, market_type: :spot, method: :get, name: :fetch_trading_fees, param_mappings: %{}, params: [], path: "/spot/fee", source: :intercepted }, %{ api_section: "private/wallet", auth: true, cost: 1, expects: :list, market_type: :spot, method: :get, name: :fetch_transaction_fees, param_mappings: %{}, params: [ :codes ], path: "/spot/withdraw_status", source: :intercepted }, %{ api_section: "public/options", auth: false, cost: 1, expects: :list, market_type: :spot, method: :get, name: :fetch_underlying_assets, param_mappings: %{}, params: [], path: "/spot/underlyings", source: :intercepted }, %{ api_section: "private/wallet", auth: true, cost: 1, expects: :list, market_type: :spot, method: :get, name: :fetch_withdrawals, pagination: %{ style: :dynamic }, param_mappings: %{ "code" => "currency" }, params: [ :code, :since, :limit ], path: "/spot/withdrawals", source: :intercepted }, %{ api_section: "private/margin", auth: true, cost: 1.3333333333333333, expects: :single, market_type: :spot, method: :post, name: :repay_cross_margin, param_mappings: %{ "code" => "currency" }, params: [ :code, :amount ], path: "/spot/cross/repayments", source: :intercepted }, %{ api_section: "private/margin", auth: true, cost: 1.3333333333333333, default_params: %{ "type" => "repay" }, expects: :single, market_type: :spot, method: :post, name: :repay_isolated_margin, param_mappings: %{ "code" => "currency", "symbol" => "currency_pair" }, params: [ :symbol, :code, :amount ], path: "/spot/uni/loans", source: :intercepted }, %{ api_section: "private/futures", auth: true, cost: 1, default_params: %{ "contract" => "BTCUSDT", "settle" => "USDT" }, expects: :single, market_type: :swap, method: :post, name: :set_leverage, param_mappings: %{}, params: [ :leverage, :symbol ], path: "/{settle}/positions/{contract}/leverage", source: :intercepted }, %{ api_section: "private/futures", auth: true, cost: 1, default_params: %{ "contract" => "BTCUSDT", "settle" => "USDT" }, expects: :single, market_type: :swap, method: :post, name: :set_position_mode, param_mappings: %{ "hedged" => "dual_mode" }, params: [ :hedged, :symbol ], path: "/{settle}/dual_mode", source: :intercepted }, %{ api_section: "private/wallet", auth: true, cost: 2.5, expects: :single, market_type: :spot, method: :post, name: :transfer, param_mappings: %{ "fromAccount" => "from", "toAccount" => "to" }, params: [ :code, :amount, :fromAccount, :toAccount ], path: "/spot/transfers", source: :intercepted }, %{ api_section: "private/withdrawals", auth: true, cost: 20, expects: :single, market_type: :spot, method: :post, name: :withdraw, param_mappings: %{ "code" => "currency" }, params: [ :code, :amount, :address, :tag ], path: "/spot/withdrawals", source: :intercepted } ], error_code_details: %{ "ACCOUNT_EXCEPTION" => %{ description: nil, type: :exchange_error }, "ACCOUNT_LOCKED" => %{ description: nil, type: :access_restricted }, "ADDRESS_NOT_USED" => %{ description: nil, type: :exchange_error }, "AMOUNT_TOO_LITTLE" => %{ description: nil, type: :invalid_order }, "AMOUNT_TOO_MUCH" => %{ description: nil, type: :invalid_order }, "API_WITHDRAW_DISABLED" => %{ description: nil, type: :network_error }, "AUTHENTICATION_FAILED" => %{ description: nil, type: :invalid_credentials }, "AUTO_BORROW_TOO_MUCH" => %{ description: nil, type: :exchange_error }, "AUTO_TRIGGER_PRICE_GREATE_LAST" => %{ description: "invalid argument: Trigger.Price must > last_price", type: :invalid_order }, "AUTO_TRIGGER_PRICE_LESS_LAST" => %{ description: "invalid argument: Trigger.Price must < last_price", type: :invalid_order }, "BAD_REQUEST" => %{ description: nil, type: :invalid_parameters }, "BALANCE_NOT_ENOUGH" => %{ description: nil, type: :insufficient_balance }, "CLIENT_ID_NOT_FOUND" => %{ description: nil, type: :order_not_found }, "CONTRACT_IN_DELISTING" => %{ description: nil, type: :exchange_error }, "CONTRACT_NOT_FOUND" => %{ description: nil, type: :invalid_order }, "CONTRACT_NO_COUNTER" => %{ description: nil, type: :exchange_error }, "CROSS_ACCOUNT_NOT_FOUND" => %{ description: nil, type: :exchange_error }, "FORBIDDEN" => %{ description: nil, type: :access_restricted }, "FUTURES_BALANCE_NOT_ENOUGH" => %{ description: nil, type: :insufficient_balance }, "INCREASE_POSITION" => %{ description: nil, type: :invalid_order }, "INSUFFICIENT_AVAILABLE" => %{ description: nil, type: :insufficient_balance }, "INTERNAL" => %{ description: nil, type: :network_error }, "INVALID_ARGUMENT" => %{ description: nil, type: :invalid_parameters }, "INVALID_CONTENT_TYPE" => %{ description: nil, type: :invalid_parameters }, "INVALID_CREDENTIALS" => %{ description: nil, type: :invalid_credentials }, "INVALID_CURRENCY" => %{ description: nil, type: :invalid_order }, "INVALID_CURRENCY_PAIR" => %{ description: nil, type: :invalid_order }, "INVALID_KEY" => %{ description: nil, type: :invalid_credentials }, "INVALID_PARAM_VALUE" => %{ description: "{\"label\":\"INVALID_PARAM_VALUE\",\"message\":\"Your order size 0.003749448 USDT is too small. The minimum is 3 USDT\"} or {\"label\":\"INVALID_PARAM_VALUE\",\"message\":\"Candlestick too long ago. Maximum 10000 points ago are allowed\"}", type: :invalid_parameters }, "INVALID_PRECISION" => %{ description: nil, type: :invalid_order }, "INVALID_PROTOCOL" => %{ description: nil, type: :invalid_parameters }, "INVALID_REQUEST_BODY" => %{ description: nil, type: :invalid_parameters }, "INVALID_SIGNATURE" => %{ description: nil, type: :invalid_credentials }, "INVALID_WITHDRAW_CANCEL_STATUS" => %{ description: nil, type: :exchange_error }, "INVALID_WITHDRAW_ID" => %{ description: nil, type: :exchange_error }, "IP_FORBIDDEN" => %{ description: nil, type: :invalid_credentials }, "LEVERAGE_TOO_HIGH" => %{ description: nil, type: :invalid_order }, "LEVERAGE_TOO_LOW" => %{ description: nil, type: :invalid_order }, "LIQUIDATE_IMMEDIATELY" => %{ description: nil, type: :invalid_order }, "LOAN_NOT_FOUND" => %{ description: nil, type: :order_not_found }, "LOAN_RECORD_NOT_FOUND" => %{ description: nil, type: :order_not_found }, "MARGIN_BALANCE_EXCEPTION" => %{ description: nil, type: :exchange_error }, "MARGIN_BALANCE_NOT_ENOUGH" => %{ description: nil, type: :insufficient_balance }, "MARGIN_NOT_SUPPORTED" => %{ description: nil, type: :invalid_order }, "MARGIN_TRANSFER_FAILED" => %{ description: nil, type: :exchange_error }, "METHOD_NOT_ALLOWED" => %{ description: nil, type: :invalid_parameters }, "MISSING_REQUIRED_HEADER" => %{ description: nil, type: :invalid_credentials }, "MISSING_REQUIRED_PARAM" => %{ description: nil, type: :invalid_parameters }, "MIXED_ACCOUNT_TYPE" => %{ description: nil, type: :invalid_order }, "NOT_ACCEPTABLE" => %{ description: nil, type: :invalid_parameters }, "NOT_FOUND" => %{ description: nil, type: :exchange_error }, "NOT_MERGEABLE" => %{ description: nil, type: :exchange_error }, "NO_CHANGE" => %{ description: "No change is made", type: :invalid_order }, "NO_MATCHED_LOAN" => %{ description: nil, type: :exchange_error }, "ORDER_CANCELLED" => %{ description: nil, type: :invalid_order }, "ORDER_CLOSED" => %{ description: nil, type: :invalid_order }, "ORDER_FINISHED" => %{ description: nil, type: :exchange_error }, "ORDER_NOT_FOUND" => %{ description: nil, type: :order_not_found }, "ORDER_NOT_OWNED" => %{ description: nil, type: :exchange_error }, "ORDER_POC_IMMEDIATE" => %{ description: "{\"label\":\"ORDER_POC_IMMEDIATE\",\"detail\":\"order price 1700 while counter price 1793.55\"}", type: :invalid_order }, "POC_FILL_IMMEDIATELY" => %{ description: "Order would match and take immediately so its cancelled", type: :invalid_order }, "POSITION_CROSS_MARGIN" => %{ description: nil, type: :exchange_error }, "POSITION_EMPTY" => %{ description: nil, type: :invalid_order }, "POSITION_HOLDING" => %{ description: nil, type: :invalid_parameters }, "POSITION_IN_CLOSE" => %{ description: nil, type: :exchange_error }, "POSITION_IN_LIQUIDATION" => %{ description: nil, type: :exchange_error }, "PRICE_OVER_BANKRUPT" => %{ description: nil, type: :invalid_order }, "PRICE_OVER_LIQUIDATION" => %{ description: nil, type: :invalid_order }, "PRICE_THRESHOLD_EXCEEDED" => %{ description: ": 0.45288", type: :invalid_order }, "PRICE_TOO_DEVIATED" => %{ description: nil, type: :invalid_order }, "QUANTITY_NOT_ENOUGH" => %{ description: nil, type: :invalid_order }, "READ_ONLY" => %{ description: nil, type: :access_restricted }, "REMOVE_TOO_MUCH" => %{ description: nil, type: :exchange_error }, "REPAY_TOO_MUCH" => %{ description: nil, type: :exchange_error }, "REPEATED_CREATION" => %{ description: nil, type: :invalid_order }, "REQUEST_EXPIRED" => %{ description: nil, type: :invalid_credentials }, "RISK_LIMIT_EXCEEDED" => %{ description: nil, type: :exchange_error }, "RISK_LIMIT_NOT_MULTIPLE" => %{ description: nil, type: :exchange_error }, "RISK_LIMIT_TOO_HIGH" => %{ description: nil, type: :exchange_error }, "RISK_LIMIT_TOO_LOW" => %{ description: "{\"label\":\"RISK_LIMIT_TOO_LOW\",\"detail\":\"limit 1000000\"}", type: :invalid_parameters }, "RISK_LIMIT_TOO_lOW" => %{ description: nil, type: :exchange_error }, "SERVER_ERROR" => %{ description: nil, type: :network_error }, "SIZE_TOO_LARGE" => %{ description: nil, type: :invalid_order }, "SIZE_TOO_SMALL" => %{ description: nil, type: :invalid_order }, "SUB_ACCOUNT_LOCKED" => %{ description: nil, type: :access_restricted }, "SUB_ACCOUNT_NOT_FOUND" => %{ description: nil, type: :exchange_error }, "SUB_ACCOUNT_TRANSFER_FAILED" => %{ description: nil, type: :exchange_error }, "TOO_BUSY" => %{ description: nil, type: :network_error }, "TOO_FAST" => %{ description: nil, type: :rate_limited }, "TOO_MANY_CURRENCY_PAIRS" => %{ description: nil, type: :invalid_order }, "TOO_MANY_ORDERS" => %{ description: nil, type: :invalid_order }, "TOO_MANY_REQUESTS" => %{ description: nil, type: :rate_limited }, "TOO_MUCH_FUTURES_AVAILABLE" => %{ description: nil, type: :exchange_error }, "TRADE_RESTRICTED" => %{ description: nil, type: :insufficient_balance }, "USER_LOAN_EXCEEDED" => %{ description: "Max loan amount per user would be exceeded", type: :invalid_parameters }, "USER_NOT_FOUND" => %{ description: nil, type: :access_restricted }, "WITHDRAWAL_OVER_LIMIT" => %{ description: nil, type: :exchange_error }, "Your order size" => %{ description: "Your order size 0.003749448 USDT is too small. The minimum is 3 USDT", type: :invalid_order } }, error_codes: %{ "ACCOUNT_EXCEPTION" => :exchange_error, "ACCOUNT_LOCKED" => :access_restricted, "ADDRESS_NOT_USED" => :exchange_error, "AMOUNT_TOO_LITTLE" => :invalid_order, "AMOUNT_TOO_MUCH" => :invalid_order, "API_WITHDRAW_DISABLED" => :network_error, "AUTHENTICATION_FAILED" => :invalid_credentials, "AUTO_BORROW_TOO_MUCH" => :exchange_error, "AUTO_TRIGGER_PRICE_GREATE_LAST" => :invalid_order, "AUTO_TRIGGER_PRICE_LESS_LAST" => :invalid_order, "BAD_REQUEST" => :invalid_parameters, "BALANCE_NOT_ENOUGH" => :insufficient_balance, "CLIENT_ID_NOT_FOUND" => :order_not_found, "CONTRACT_IN_DELISTING" => :exchange_error, "CONTRACT_NOT_FOUND" => :invalid_order, "CONTRACT_NO_COUNTER" => :exchange_error, "CROSS_ACCOUNT_NOT_FOUND" => :exchange_error, "FORBIDDEN" => :access_restricted, "FUTURES_BALANCE_NOT_ENOUGH" => :insufficient_balance, "INCREASE_POSITION" => :invalid_order, "INSUFFICIENT_AVAILABLE" => :insufficient_balance, "INTERNAL" => :network_error, "INVALID_ARGUMENT" => :invalid_parameters, "INVALID_CONTENT_TYPE" => :invalid_parameters, "INVALID_CREDENTIALS" => :invalid_credentials, "INVALID_CURRENCY" => :invalid_order, "INVALID_CURRENCY_PAIR" => :invalid_order, "INVALID_KEY" => :invalid_credentials, "INVALID_PARAM_VALUE" => :invalid_parameters, "INVALID_PRECISION" => :invalid_order, "INVALID_PROTOCOL" => :invalid_parameters, "INVALID_REQUEST_BODY" => :invalid_parameters, "INVALID_SIGNATURE" => :invalid_credentials, "INVALID_WITHDRAW_CANCEL_STATUS" => :exchange_error, "INVALID_WITHDRAW_ID" => :exchange_error, "IP_FORBIDDEN" => :invalid_credentials, "LEVERAGE_TOO_HIGH" => :invalid_order, "LEVERAGE_TOO_LOW" => :invalid_order, "LIQUIDATE_IMMEDIATELY" => :invalid_order, "LOAN_NOT_FOUND" => :order_not_found, "LOAN_RECORD_NOT_FOUND" => :order_not_found, "MARGIN_BALANCE_EXCEPTION" => :exchange_error, "MARGIN_BALANCE_NOT_ENOUGH" => :insufficient_balance, "MARGIN_NOT_SUPPORTED" => :invalid_order, "MARGIN_TRANSFER_FAILED" => :exchange_error, "METHOD_NOT_ALLOWED" => :invalid_parameters, "MISSING_REQUIRED_HEADER" => :invalid_credentials, "MISSING_REQUIRED_PARAM" => :invalid_parameters, "MIXED_ACCOUNT_TYPE" => :invalid_order, "NOT_ACCEPTABLE" => :invalid_parameters, "NOT_FOUND" => :exchange_error, "NOT_MERGEABLE" => :exchange_error, "NO_CHANGE" => :invalid_order, "NO_MATCHED_LOAN" => :exchange_error, "ORDER_CANCELLED" => :invalid_order, "ORDER_CLOSED" => :invalid_order, "ORDER_FINISHED" => :exchange_error, "ORDER_NOT_FOUND" => :order_not_found, "ORDER_NOT_OWNED" => :exchange_error, "ORDER_POC_IMMEDIATE" => :invalid_order, "POC_FILL_IMMEDIATELY" => :invalid_order, "POSITION_CROSS_MARGIN" => :exchange_error, "POSITION_EMPTY" => :invalid_order, "POSITION_HOLDING" => :invalid_parameters, "POSITION_IN_CLOSE" => :exchange_error, "POSITION_IN_LIQUIDATION" => :exchange_error, "PRICE_OVER_BANKRUPT" => :invalid_order, "PRICE_OVER_LIQUIDATION" => :invalid_order, "PRICE_THRESHOLD_EXCEEDED" => :invalid_order, "PRICE_TOO_DEVIATED" => :invalid_order, "QUANTITY_NOT_ENOUGH" => :invalid_order, "READ_ONLY" => :access_restricted, "REMOVE_TOO_MUCH" => :exchange_error, "REPAY_TOO_MUCH" => :exchange_error, "REPEATED_CREATION" => :invalid_order, "REQUEST_EXPIRED" => :invalid_credentials, "RISK_LIMIT_EXCEEDED" => :exchange_error, "RISK_LIMIT_NOT_MULTIPLE" => :exchange_error, "RISK_LIMIT_TOO_HIGH" => :exchange_error, "RISK_LIMIT_TOO_LOW" => :invalid_parameters, "RISK_LIMIT_TOO_lOW" => :exchange_error, "SERVER_ERROR" => :network_error, "SIZE_TOO_LARGE" => :invalid_order, "SIZE_TOO_SMALL" => :invalid_order, "SUB_ACCOUNT_LOCKED" => :access_restricted, "SUB_ACCOUNT_NOT_FOUND" => :exchange_error, "SUB_ACCOUNT_TRANSFER_FAILED" => :exchange_error, "TOO_BUSY" => :network_error, "TOO_FAST" => :rate_limited, "TOO_MANY_CURRENCY_PAIRS" => :invalid_order, "TOO_MANY_ORDERS" => :invalid_order, "TOO_MANY_REQUESTS" => :rate_limited, "TOO_MUCH_FUTURES_AVAILABLE" => :exchange_error, "TRADE_RESTRICTED" => :insufficient_balance, "USER_LOAN_EXCEEDED" => :invalid_parameters, "USER_NOT_FOUND" => :access_restricted, "WITHDRAWAL_OVER_LIMIT" => :exchange_error, "Your order size" => :invalid_order }, exceptions: %{ broad: %{ "Your order size" => :invalid_order }, exact: %{ "ACCOUNT_EXCEPTION" => :exchange_error, "ACCOUNT_LOCKED" => :account_suspended, "ADDRESS_NOT_USED" => :exchange_error, "AMOUNT_TOO_LITTLE" => :invalid_order, "AMOUNT_TOO_MUCH" => :invalid_order, "API_WITHDRAW_DISABLED" => :exchange_not_available, "AUTHENTICATION_FAILED" => :authentication_error, "AUTO_BORROW_TOO_MUCH" => :exchange_error, "AUTO_TRIGGER_PRICE_GREATE_LAST" => :invalid_order, "AUTO_TRIGGER_PRICE_LESS_LAST" => :invalid_order, "BAD_REQUEST" => :bad_request, "BALANCE_NOT_ENOUGH" => :insufficient_funds, "CLIENT_ID_NOT_FOUND" => :order_not_found, "CONTRACT_IN_DELISTING" => :exchange_error, "CONTRACT_NOT_FOUND" => :bad_symbol, "CONTRACT_NO_COUNTER" => :exchange_error, "CROSS_ACCOUNT_NOT_FOUND" => :exchange_error, "FORBIDDEN" => :permission_denied, "FUTURES_BALANCE_NOT_ENOUGH" => :insufficient_funds, "INCREASE_POSITION" => :invalid_order, "INSUFFICIENT_AVAILABLE" => :insufficient_funds, "INTERNAL" => :exchange_not_available, "INVALID_ARGUMENT" => :bad_request, "INVALID_CONTENT_TYPE" => :bad_request, "INVALID_CREDENTIALS" => :authentication_error, "INVALID_CURRENCY" => :bad_symbol, "INVALID_CURRENCY_PAIR" => :bad_symbol, "INVALID_KEY" => :authentication_error, "INVALID_PARAM_VALUE" => :bad_request, "INVALID_PRECISION" => :invalid_order, "INVALID_PROTOCOL" => :bad_request, "INVALID_REQUEST_BODY" => :bad_request, "INVALID_SIGNATURE" => :authentication_error, "INVALID_WITHDRAW_CANCEL_STATUS" => :exchange_error, "INVALID_WITHDRAW_ID" => :exchange_error, "IP_FORBIDDEN" => :authentication_error, "LEVERAGE_TOO_HIGH" => :invalid_order, "LEVERAGE_TOO_LOW" => :invalid_order, "LIQUIDATE_IMMEDIATELY" => :invalid_order, "LOAN_NOT_FOUND" => :order_not_found, "LOAN_RECORD_NOT_FOUND" => :order_not_found, "MARGIN_BALANCE_EXCEPTION" => :exchange_error, "MARGIN_BALANCE_NOT_ENOUGH" => :insufficient_funds, "MARGIN_NOT_SUPPORTED" => :invalid_order, "MARGIN_TRANSFER_FAILED" => :exchange_error, "METHOD_NOT_ALLOWED" => :bad_request, "MISSING_REQUIRED_HEADER" => :authentication_error, "MISSING_REQUIRED_PARAM" => :arguments_required, "MIXED_ACCOUNT_TYPE" => :invalid_order, "NOT_ACCEPTABLE" => :bad_request, "NOT_FOUND" => :exchange_error, "NOT_MERGEABLE" => :exchange_error, "NO_CHANGE" => :invalid_order, "NO_MATCHED_LOAN" => :exchange_error, "ORDER_CANCELLED" => :invalid_order, "ORDER_CLOSED" => :invalid_order, "ORDER_FINISHED" => :exchange_error, "ORDER_NOT_FOUND" => :order_not_found, "ORDER_NOT_OWNED" => :exchange_error, "ORDER_POC_IMMEDIATE" => :order_immediately_fillable, "POC_FILL_IMMEDIATELY" => :order_immediately_fillable, "POSITION_CROSS_MARGIN" => :exchange_error, "POSITION_EMPTY" => :invalid_order, "POSITION_HOLDING" => :bad_request, "POSITION_IN_CLOSE" => :exchange_error, "POSITION_IN_LIQUIDATION" => :exchange_error, "PRICE_OVER_BANKRUPT" => :invalid_order, "PRICE_OVER_LIQUIDATION" => :invalid_order, "PRICE_THRESHOLD_EXCEEDED" => :invalid_order, "PRICE_TOO_DEVIATED" => :invalid_order, "QUANTITY_NOT_ENOUGH" => :invalid_order, "READ_ONLY" => :permission_denied, "REMOVE_TOO_MUCH" => :exchange_error, "REPAY_TOO_MUCH" => :exchange_error, "REPEATED_CREATION" => :invalid_order, "REQUEST_EXPIRED" => :authentication_error, "RISK_LIMIT_EXCEEDED" => :exchange_error, "RISK_LIMIT_NOT_MULTIPLE" => :exchange_error, "RISK_LIMIT_TOO_HIGH" => :exchange_error, "RISK_LIMIT_TOO_LOW" => :bad_request, "RISK_LIMIT_TOO_lOW" => :exchange_error, "SERVER_ERROR" => :exchange_not_available, "SIZE_TOO_LARGE" => :invalid_order, "SIZE_TOO_SMALL" => :invalid_order, "SUB_ACCOUNT_LOCKED" => :account_suspended, "SUB_ACCOUNT_NOT_FOUND" => :exchange_error, "SUB_ACCOUNT_TRANSFER_FAILED" => :exchange_error, "TOO_BUSY" => :exchange_not_available, "TOO_FAST" => :rate_limit_exceeded, "TOO_MANY_CURRENCY_PAIRS" => :invalid_order, "TOO_MANY_ORDERS" => :invalid_order, "TOO_MANY_REQUESTS" => :rate_limit_exceeded, "TOO_MUCH_FUTURES_AVAILABLE" => :exchange_error, "TRADE_RESTRICTED" => :insufficient_funds, "USER_LOAN_EXCEEDED" => :bad_request, "USER_NOT_FOUND" => :account_not_enabled, "WITHDRAWAL_OVER_LIMIT" => :exchange_error } }, exchange_options: %{ "accountsByType" => %{ "cross" => "cross_margin", "cross_margin" => "cross_margin", "delivery" => "delivery", "funding" => "spot", "future" => "delivery", "futures" => "futures", "isolated" => "margin", "margin" => "margin", "option" => "options", "options" => "options", "spot" => "spot", "swap" => "futures" }, "adjustForTimeDifference" => false, "createMarketBuyOrderRequiresPrice" => true, "createOrder" => %{ "expiration" => 86400 }, "defaultNetworkCodeReplacements" => %{ "BRC20" => %{ "BRC20" => "BTC" }, "CRO" => %{ "CRC20" => "CRONOS" }, "ETH" => %{ "ERC20" => "ETH" }, "TRX" => %{ "TRC20" => "TRX" } }, "fetchMarkets" => %{ "types" => [ "spot", "swap", "future", "option" ] }, "future" => %{ "fetchMarkets" => %{ "settlementCurrencies" => [ "usdt" ] } }, "networks" => %{ "ACA" => "ACA", "ADA" => "ADA", "ALGO" => "ALGO", "APT" => "APT", "ARBONE" => "ARBEVM", "AURORA" => "AURORAEVM", "AVAXC" => "AVAX_C", "BASE" => "BASEEVM", "BEP20" => "BSC", "BLAST" => "BLASTETH", "BRC20" => "BTCBRC", "BSC" => "BSC", "BTC" => "BTC", "CELO" => "CELO", "CRO" => "CRO", "CRONOS" => "CRO", "EGLD" => "EGLD", "EOS" => "EOS", "ERC20" => "ETH", "ETH" => "ETH", "GATECHAIN" => "GTEVM", "GLMR" => "GLMR", "HBAR" => "HBAR", "HECO" => "HT", "HRC20" => "HT", "HYPE" => "HYPE", "KLAY" => "KLAY", "KON" => "KONET", "KUSAMA" => "KSMSM", "LINEA" => "LINEAETH", "LUNA" => "LUNC", "MATIC" => "MATIC", "MNT" => "MNT", "NEAR" => "NEAR", "OKC" => "OKT", "OPTIMISM" => "OPETH", "POLKADOT" => "DOTSM", "RSK" => "RBTC", "SCROLL" => "SCROLLETH", "SOL" => "SOL", "SUI" => "SUI", "TAIKO" => "TAIKOETH", "TON" => "TON", "TRC20" => "TRX", "TRX" => "TRX", "XLM" => "XLM", "XTZ" => "XTZ", "ZKSERA" => "ZKSERA" }, "networksById" => %{ "ACA" => "ACA", "ADA" => "ADA", "ALGO" => "ALGO", "APT" => "APT", "ARBEVM" => "ARBONE", "AURORAEVM" => "AURORA", "AVAX_C" => "AVAXC", "BASEEVM" => "BASE", "BEP20" => "BEP20", "BLASTETH" => "BLAST", "BSC" => "BEP20", "BTC" => "BTC", "BTCBRC" => "BRC20", "CELO" => "CELO", "CRO" => "CRO", "DOTSM" => "POLKADOT", "EGLD" => "EGLD", "EOS" => "EOS", "ERC20" => "ERC20", "ETH" => "ERC20", "GLMR" => "GLMR", "GTEVM" => "GATECHAIN", "HBAR" => "HBAR", "HECO" => "HRC20", "HT" => "HRC20", "HYPE" => "HYPE", "KLAY" => "KLAY", "KONET" => "KON", "KSMSM" => "KUSAMA", "LINEAETH" => "LINEA", "LUNC" => "LUNA", "MATIC" => "MATIC", "MNT" => "MNT", "NEAR" => "NEAR", "OKT" => "OKC", "OPETH" => "OP", "POL" => "MATIC", "POLYGON" => "MATIC", "RBTC" => "RSK", "SCROLLETH" => "SCROLL", "SOL" => "SOL", "SUI" => "SUI", "TAIKOETH" => "TAIKO", "TON" => "TON", "TRC20" => "TRC20", "TRX" => "TRC20", "XLM" => "XLM", "XTZ" => "XTZ", "ZKSERA" => "ZKSERA" }, "sandboxMode" => false, "swap" => %{ "fetchMarkets" => %{ "settlementCurrencies" => [ "usdt", "btc" ] } }, "timeDifference" => 0, "timeInForce" => %{ "FOK" => "fok", "GTC" => "gtc", "IOC" => "ioc", "PO" => "poc", "POC" => "poc" }, "unifiedAccount" => nil }, extended_metadata: %{ limits: %{ "amount" => %{}, "cost" => %{}, "leverage" => %{}, "price" => %{} }, logo_url: "https://github.com/user-attachments/assets/64f988c5-07b6-4652-b5c1-679a6bf67c85", referral_discount: 0.2, referral_url: "https://www.gate.com/share/CCXTGATE" }, extracted_metadata: %{ ccxt_version: "4.5.42" }, features: %{ default: %{ create_order: %{ hedged: false, iceberg: true, leverage: false, margin_mode: true, market_buy_by_cost: true, market_buy_requires_price: true, self_trade_prevention: true, stop_loss_price: true, take_profit_price: true, time_in_force: %{ fok: true, gtd: false, ioc: true, po: true }, trailing: false, trigger_direction: true, trigger_price: true }, create_orders: %{ max: 40 }, fetch_closed_orders: %{ limit: 100, margin_mode: true, symbol_required: false, trailing: false, trigger: true, until_days: 30 }, fetch_my_trades: %{ limit: 1000, margin_mode: true, symbol_required: false, until_days: 30 }, fetch_ohlcv: %{ limit: 1000 }, fetch_open_orders: %{ limit: 100, margin_mode: true, symbol_required: false, trailing: false, trigger: true }, fetch_order: %{ margin_mode: false, symbol_required: true, trailing: false, trigger: true }, sandbox: true }, for_derivatives: %{ create_order: %{ margin_mode: false, trigger_price_type: %{ index: true, last: true, mark: true } }, create_orders: %{ max: 10 }, extends: "spot", fetch_closed_orders: %{ limit: 1000, margin_mode: false }, fetch_my_trades: %{ margin_mode: false }, fetch_ohlcv: %{ limit: 1999 }, fetch_open_orders: %{ margin_mode: false } }, future: %{ inverse: %{ extends: "forDerivatives" }, linear: %{ extends: "forDerivatives" } }, spot: %{ extends: "default" }, swap: %{ inverse: %{ extends: "forDerivatives" }, linear: %{ extends: "forDerivatives" } } }, fees: %{ swap: %{ fee_side: "base", maker: 0, percentage: true, taker: 0.0005, tier_based: true, tiers: %{ maker: [ %{ fee: 0, volume: 0 }, %{ fee: -5.0e-5, volume: 1.5 }, %{ fee: -5.0e-5, volume: 3 }, %{ fee: -5.0e-5, volume: 6 }, %{ fee: -5.0e-5, volume: 12.5 }, %{ fee: -5.0e-5, volume: 25 }, %{ fee: -5.0e-5, volume: 75 }, %{ fee: -5.0e-5, volume: 200 }, %{ fee: -5.0e-5, volume: 500 }, %{ fee: -5.0e-5, volume: 1250 }, %{ fee: -5.0e-5, volume: 2500 }, %{ fee: -8.0e-5, volume: 3000 }, %{ fee: -0.01, volume: 6000 }, %{ fee: -0.01002, volume: 11000 }, %{ fee: -0.01005, volume: 20000 }, %{ fee: -0.02, volume: 40000 }, %{ fee: -0.02005, volume: 75000 } ], taker: [ %{ fee: 0.0005, volume: 0 }, %{ fee: 4.8e-4, volume: 1.5 }, %{ fee: 4.6e-4, volume: 3 }, %{ fee: 4.4e-4, volume: 6 }, %{ fee: 4.2e-4, volume: 12.5 }, %{ fee: 0.0004, volume: 25 }, %{ fee: 3.8e-4, volume: 75 }, %{ fee: 3.6e-4, volume: 200 }, %{ fee: 3.4e-4, volume: 500 }, %{ fee: 3.2e-4, volume: 1250 }, %{ fee: 0.0003, volume: 2500 }, %{ fee: 0.0003, volume: 3000 }, %{ fee: 0.0003, volume: 6000 }, %{ fee: 0.0003, volume: 11000 }, %{ fee: 0.0003, volume: 20000 }, %{ fee: 0.0003, volume: 40000 }, %{ fee: 0.0003, volume: 75000 } ] } }, trading: %{ fee_side: "get", maker: 0.002, percentage: true, taker: 0.002, tier_based: true, tiers: %{ maker: [ %{ fee: 0.002, volume: 0 }, %{ fee: 0.00185, volume: 1.5 }, %{ fee: 0.00175, volume: 3 }, %{ fee: 0.00165, volume: 6 }, %{ fee: 0.00155, volume: 12.5 }, %{ fee: 0.00145, volume: 25 }, %{ fee: 0.00135, volume: 75 }, %{ fee: 0.00125, volume: 200 }, %{ fee: 0.00115, volume: 500 }, %{ fee: 0.00105, volume: 1250 }, %{ fee: 9.5e-4, volume: 2500 }, %{ fee: 8.5e-4, volume: 3000 }, %{ fee: 7.5e-4, volume: 6000 }, %{ fee: 6.5e-4, volume: 11000 }, %{ fee: 5.5e-4, volume: 20000 }, %{ fee: 5.5e-4, volume: 40000 }, %{ fee: 5.5e-4, volume: 75000 } ], taker: [ %{ fee: 0.002, volume: 0 }, %{ fee: 0.00195, volume: 1.5 }, %{ fee: 0.00185, volume: 3 }, %{ fee: 0.00175, volume: 6 }, %{ fee: 0.00165, volume: 12.5 }, %{ fee: 0.00155, volume: 25 }, %{ fee: 0.00145, volume: 75 }, %{ fee: 0.00135, volume: 200 }, %{ fee: 0.00125, volume: 500 }, %{ fee: 0.00115, volume: 1250 }, %{ fee: 0.00105, volume: 2500 }, %{ fee: 9.5e-4, volume: 3000 }, %{ fee: 8.5e-4, volume: 6000 }, %{ fee: 7.5e-4, volume: 11000 }, %{ fee: 6.5e-4, volume: 20000 }, %{ fee: 6.5e-4, volume: 40000 }, %{ fee: 6.5e-4, volume: 75000 } ] } } }, forward_aliases: %{ spot: %{ "BEYONDFI" => "BYN", "BITCOINFILE" => "BIFI", "DEFIBOX" => "BOX", "GOOSEFINANCE" => "EGG", "MORPHER" => "MPH", "RAIREFLEXINDEX" => "RAI", "RedLang" => "RED", "SUPERBITCOIN" => "SBTC", "TRACO" => "TRAC", "VAIOT" => "VAI", "XREATORS" => "ORT" }, swap: %{ "RedLang" => "RED" } }, 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 //\n // {\"label\": \"ORDER_NOT_FOUND\", \"message\": \"Order not found\"}\n // {\"label\": \"INVALID_PARAM_VALUE\", \"message\": \"invalid argument: status\"}\n // {\"label\": \"INVALID_PARAM_VALUE\", \"message\": \"invalid argument: Trigger.rule\"}\n // {\"label\": \"INVALID_PARAM_VALUE\", \"message\": \"invalid argument: trigger.expiration invalid range\"}\n // {\"label\": \"INVALID_ARGUMENT\", \"detail\": \"invalid size\"}\n // {\"user_id\":10406147,\"id\":\"id\",\"succeeded\":false,\"message\":\"INVALID_PROTOCOL\",\"label\":\"INVALID_PROTOCOL\"}\n //\n const label = this.safeString(response, 'label');\n if (label !== undefined) {\n const feedback = this.id + ' ' + body;\n this.throwExactlyMatchedException(this.exceptions['exact'], label, feedback);\n throw new errors.ExchangeError(feedback);\n }\n return undefined;\n }", has: %{ add_margin: true, borrow_cross_margin: true, borrow_isolated_margin: true, borrow_margin: false, c_o_r_s: false, cancel_all_orders: 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_for_symbols: true, cancel_orders_with_client_order_id: false, cancel_orders_ws: false, close_all_positions: false, close_position: false, 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: true, 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: true, create_post_only_order: true, create_post_only_order_ws: false, create_reduce_only_order: true, create_reduce_only_order_ws: false, create_stop_limit_order: true, create_stop_limit_order_ws: false, create_stop_loss_order: true, 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: true, create_take_profit_order_ws: false, create_trailing_amount_order: false, 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_a_d_l_rank: false, fetch_accounts: false, fetch_balance: true, fetch_balance_ws: false, fetch_bids_asks: false, fetch_borrow_interest: true, 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: true, fetch_deposit_withdraw_fee: true, fetch_deposit_withdraw_fees: true, fetch_deposits: true, fetch_deposits_withdrawals: false, fetch_deposits_ws: false, fetch_funding_history: true, fetch_funding_interval: false, fetch_funding_intervals: false, fetch_funding_rate: true, fetch_funding_rate_history: true, fetch_funding_rates: true, fetch_greeks: true, fetch_index_ohlcv: true, 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: true, 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: true, fetch_mark_prices: false, fetch_market_leverage_tiers: true, fetch_markets: true, fetch_markets_ws: false, fetch_my_liquidations: true, fetch_my_settlement_history: true, fetch_my_trades: true, fetch_my_trades_ws: false, fetch_network_deposit_address: true, fetch_ohlcv: true, fetch_ohlcv_ws: false, fetch_open_interest: false, fetch_open_interest_history: true, fetch_open_interests: false, fetch_open_order: false, fetch_open_orders: true, fetch_open_orders_ws: false, fetch_option: true, fetch_option_chain: true, 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: false, fetch_orders_by_status: false, fetch_orders_ws: false, fetch_position: true, fetch_position_a_d_l_rank: false, fetch_position_history: true, fetch_position_mode: false, fetch_position_ws: false, fetch_positions: true, fetch_positions_a_d_l_rank: false, fetch_positions_for_symbol: false, fetch_positions_for_symbol_ws: false, fetch_positions_history: true, fetch_positions_risk: false, fetch_positions_ws: false, fetch_premium_index_ohlcv: false, fetch_settlement_history: true, fetch_status: false, fetch_ticker: true, fetch_ticker_ws: false, fetch_tickers: true, fetch_tickers_ws: false, fetch_time: true, fetch_trades: true, fetch_trades_ws: false, fetch_trading_fee: true, fetch_trading_fees: true, fetch_trading_fees_ws: false, fetch_trading_limits: false, fetch_transaction_fee: false, fetch_transaction_fees: true, fetch_transactions: false, fetch_transfer: false, fetch_transfers: false, fetch_underlying_assets: true, fetch_volatility_history: false, fetch_withdraw_addresses: false, fetch_withdrawal: false, fetch_withdrawal_whitelist: false, fetch_withdrawals: true, fetch_withdrawals_ws: false, future: true, margin: true, option: true, private_api: true, public_api: true, reduce_margin: true, repay_cross_margin: true, repay_isolated_margin: true, sandbox: true, set_leverage: true, set_margin: false, set_margin_mode: false, set_position_mode: true, sign_in: false, spot: true, swap: true, transfer: true, 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: true, watch_liquidations: false, watch_liquidations_for_symbols: false, watch_my_liquidations: true, watch_my_liquidations_for_symbols: true, watch_my_trades: true, watch_ohlcv: true, watch_ohlcv_for_symbols: false, watch_order_book: true, watch_order_book_for_symbols: false, watch_orders: true, watch_orders_for_symbols: false, watch_position: false, watch_positions: true, watch_status: false, watch_ticker: true, watch_tickers: true, watch_trades: true, watch_trades_for_symbols: true, withdraw: true, ws: false }, http_config: %{ headers: %{ "X-Gate-Channel-Id" => "ccxt" } }, id: "gate", markets: nil, name: "Gate", ohlcv_timestamp_resolution: :seconds, options: %{ accounts_by_type: %{ "cross" => "cross_margin", "cross_margin" => "cross_margin", "delivery" => "delivery", "funding" => "spot", "future" => "delivery", "futures" => "futures", "isolated" => "margin", "margin" => "margin", "option" => "options", "options" => "options", "spot" => "spot", "swap" => "futures" }, adjust_for_time_difference: false, create_market_buy_order_requires_price: true, create_order: %{ "expiration" => 86400 }, fetch_markets: %{ "types" => [ "spot", "swap", "future", "option" ] }, future: %{ "fetchMarkets" => %{ "settlementCurrencies" => [ "usdt" ] } }, networks: %{ "ACA" => "ACA", "ADA" => "ADA", "ALGO" => "ALGO", "APT" => "APT", "ARBONE" => "ARBEVM", "AURORA" => "AURORAEVM", "AVAXC" => "AVAX_C", "BASE" => "BASEEVM", "BEP20" => "BSC", "BLAST" => "BLASTETH", "BRC20" => "BTCBRC", "BSC" => "BSC", "BTC" => "BTC", "CELO" => "CELO", "CRO" => "CRO", "CRONOS" => "CRO", "EGLD" => "EGLD", "EOS" => "EOS", "ERC20" => "ETH", "ETH" => "ETH", "GATECHAIN" => "GTEVM", "GLMR" => "GLMR", "HBAR" => "HBAR", "HECO" => "HT", "HRC20" => "HT", "HYPE" => "HYPE", "KLAY" => "KLAY", "KON" => "KONET", "KUSAMA" => "KSMSM", "LINEA" => "LINEAETH", "LUNA" => "LUNC", "MATIC" => "MATIC", "MNT" => "MNT", "NEAR" => "NEAR", "OKC" => "OKT", "OPTIMISM" => "OPETH", "POLKADOT" => "DOTSM", "RSK" => "RBTC", "SCROLL" => "SCROLLETH", "SOL" => "SOL", "SUI" => "SUI", "TAIKO" => "TAIKOETH", "TON" => "TON", "TRC20" => "TRX", "TRX" => "TRX", "XLM" => "XLM", "XTZ" => "XTZ", "ZKSERA" => "ZKSERA" }, networks_by_id: %{ "BEP20" => "BEP20", "BSC" => "BEP20", "ERC20" => "ERC20", "ETH" => "ERC20", "HECO" => "HRC20", "HT" => "HRC20", "OPETH" => "OP", "POL" => "MATIC", "POLYGON" => "MATIC", "TRC20" => "TRC20", "TRX" => "TRC20" }, sandbox_mode: false, swap: %{ "fetchMarkets" => %{ "settlementCurrencies" => [ "usdt", "btc" ] } }, time_difference: 0, time_in_force: %{ "FOK" => "fok", "GTC" => "gtc", "IOC" => "ioc", "PO" => "poc", "POC" => "poc" }, unified_account: nil }, order_mappings: %{ side_format: :lowercase, side_key: "side", type_format: :lowercase, type_key: "type" }, param_mappings: %{ "amount" => "size", "code" => "currency", "cost" => "amount", "fromAccount" => "from", "hedged" => "dual_mode", "id" => "order_id", "since" => "from", "symbol" => "currency_pair", "timeframe" => "interval", "toAccount" => "to" }, parse_methods: [ %{ "comment" => nil, "examples" => [], "line_end" => 3035, "line_start" => 3026, "mappings" => [], "name" => "parseBalanceHelper", "signature" => "parseBalanceHelper (entry)", "source" => "parseBalanceHelper (entry) {\n const account = this.account ();\n account['used'] = this.safeString2 (entry, 'freeze', 'locked');\n account['free'] = this.safeString (entry, 'available');\n account['total'] = this.safeString (entry, 'total');\n if ('borrowed' in entry) {\n account['debt'] = this.safeString (entry, 'borrowed');\n }\n return account;\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 6860, "line_start" => 6844, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "info" }, %{ "comment" => nil, "key" => "symbol", "value" => "this.safeString (market, 'symbol')" }, %{ "comment" => nil, "key" => "currency", "value" => "this.safeCurrencyCode (this.safeString (info, 'currency'))" }, %{ "comment" => nil, "key" => "interest", "value" => "this.safeNumber (info, 'interest')" }, %{ "comment" => nil, "key" => "interestRate", "value" => "this.safeNumber (info, 'actual_rate')" }, %{ "comment" => nil, "key" => "amountBorrowed", "value" => "undefined" }, %{ "comment" => nil, "key" => "marginMode", "value" => "marginMode" }, %{ "comment" => nil, "key" => "timestamp", "value" => "timestamp" }, %{ "comment" => nil, "key" => "datetime", "value" => "this.iso8601 (timestamp)" } ], "name" => "parseBorrowInterest", "signature" => "parseBorrowInterest (info: Dict, market: Market = undefined): BorrowInterest", "source" => "parseBorrowInterest (info: Dict, market: Market = undefined): BorrowInterest {\n const marketId = this.safeString (info, 'currency_pair');\n market = this.safeMarket (marketId, market);\n const marginMode = (marketId !== undefined) ? 'isolated' : 'cross';\n const timestamp = this.safeInteger (info, 'create_time');\n return {\n 'info': info,\n 'symbol': this.safeString (market, 'symbol'),\n 'currency': this.safeCurrencyCode (this.safeString (info, 'currency')),\n 'interest': this.safeNumber (info, 'interest'),\n 'interestRate': this.safeNumber (info, 'actual_rate'),\n 'amountBorrowed': undefined,\n 'marginMode': marginMode,\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n } as BorrowInterest;\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"name\": \"BTC_USDT\",\n \"type\": \"direct\",\n \"quanto_multiplier\": \"0.0001\",\n \"ref_discount_rate\": \"0\",\n \"order_price_deviate\": \"0.5\",\n \"maintenance_rate\": \"0.005\",\n \"mark_type\": \"index\",\n \"last_price\": \"38026\",\n \"mark_price\": \"37985.6\",\n \"index_price\": \"37954.92\",\n \"funding_rate_indicative\": \"0.000219\",\n \"mark_price_round\": \"0.01\",\n \"funding_offset\": 0,\n \"in_delisting\": false,\n \"risk_limit_base\": \"1000000\",\n \"interest_rate\": \"0.0003\",\n \"order_price_round\": \"0.1\",\n \"order_size_min\": 1,\n \"ref_rebate_rate\": \"0.2\",\n \"funding_interval\": 28800,\n \"risk_limit_step\": \"1000000\",\n \"leverage_min\": \"1\",\n \"leverage_max\": \"100\",\n \"risk_limit_max\": \"8000000\",\n \"maker_fee_rate\": \"-0.00025\", // not actual value for regular users\n \"taker_fee_rate\": \"0.00075\", // not actual value for regular users\n \"funding_rate\": \"0.002053\",\n \"order_size_max\": 1000000,\n \"funding_next_apply\": 1610035200,\n \"short_users\": 977,\n \"config_change_time\": 1609899548,\n \"create_time\": 1609800048,\n \"trade_size\": 28530850594,\n \"position_size\": 5223816,\n \"long_users\": 455,\n \"funding_impact_value\": \"60000\",\n \"orders_limit\": 50,\n \"trade_id\": 10851092,\n \"orderbook_id\": 2129638396\n }", "{\n \"name\": \"BTC_USDT_20200814\",\n \"underlying\": \"BTC_USDT\",\n \"cycle\": \"WEEKLY\",\n \"type\": \"direct\",\n \"quanto_multiplier\": \"0.0001\",\n \"mark_type\": \"index\",\n \"last_price\": \"9017\",\n \"mark_price\": \"9019\",\n \"index_price\": \"9005.3\",\n \"basis_rate\": \"0.185095\",\n \"basis_value\": \"13.7\",\n \"basis_impact_value\": \"100000\",\n \"settle_price\": \"0\",\n \"settle_price_interval\": 60,\n \"settle_price_duration\": 1800,\n \"settle_fee_rate\": \"0.0015\",\n \"expire_time\": 1593763200,\n \"order_price_round\": \"0.1\",\n \"mark_price_round\": \"0.1\",\n \"leverage_min\": \"1\",\n \"leverage_max\": \"100\",\n \"maintenance_rate\": \"1000000\",\n \"risk_limit_base\": \"140.726652109199\",\n \"risk_limit_step\": \"1000000\",\n \"risk_limit_max\": \"8000000\",\n \"maker_fee_rate\": \"-0.00025\", // not actual value for regular users\n \"taker_fee_rate\": \"0.00075\", // not actual value for regular users\n \"ref_discount_rate\": \"0\",\n \"ref_rebate_rate\": \"0.2\",\n \"order_price_deviate\": \"0.5\",\n \"order_size_min\": 1,\n \"order_size_max\": 1000000,\n \"orders_limit\": 50,\n \"orderbook_id\": 63,\n \"trade_id\": 26,\n \"trade_size\": 435,\n \"position_size\": 130,\n \"config_change_time\": 1593158867,\n \"in_delisting\": false\n }" ], "line_end" => 1669, "line_start" => 1499, "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" => "marketType" }, %{ "comment" => nil, "key" => "spot", "value" => "false" }, %{ "comment" => nil, "key" => "margin", "value" => "false" }, %{ "comment" => nil, "key" => "swap", "value" => "marketType === 'swap'" }, %{ "comment" => nil, "key" => "future", "value" => "marketType === 'future'" }, %{ "comment" => nil, "key" => "option", "value" => "marketType === 'option'" }, %{ "comment" => nil, "key" => "active", "value" => "true" }, %{ "comment" => nil, "key" => "contract", "value" => "true" }, %{ "comment" => nil, "key" => "linear", "value" => "isLinear" }, %{ "comment" => nil, "key" => "inverse", "value" => "!isLinear" }, %{ "comment" => nil, "key" => "taker", "value" => "this.parseNumber ('0.0005')" }, %{ "comment" => nil, "key" => "expiry", "value" => "expiry" }, %{ "comment" => nil, "key" => "expiryDatetime", "value" => "this.iso8601 (expiry)" }, %{ "comment" => nil, "key" => "strike", "value" => "undefined" }, %{ "comment" => nil, "key" => "optionType", "value" => "undefined" }, %{ "comment" => "all contracts have this step size\n 'price': this.safeNumber (market, 'order_price_round'),\n }", "key" => "precision", "value" => "{\n 'amount': this.parseNumber ('1')" }, %{ "comment" => nil, "key" => "limits", "value" => "{\n 'leverage': {\n 'min': this.safeNumber (market, 'leverage_min'),\n 'max': this.safeNumber (market, 'leverage_max'),\n },\n 'amount': {\n 'min': this.safeNumber (market, 'order_size_min'),\n 'max': this.safeNumber (market, 'order_size_max'),\n },\n 'price': {\n 'min': this.parseNumber (minPrice),\n 'max': this.parseNumber (maxPrice),\n },\n 'cost': {\n 'min': undefined,\n 'max': undefined,\n },\n }" }, %{ "comment" => nil, "key" => "created", "value" => "this.safeIntegerProduct (market, 'create_time', 1000)" }, %{ "comment" => nil, "key" => "info", "value" => "market" }, %{ "comment" => nil, "key" => "leverage", "value" => "{\n 'min': this.safeNumber (market, 'leverage_min'),\n 'max': this.safeNumber (market, 'leverage_max'),\n }" }, %{ "comment" => nil, "key" => "amount", "value" => "{\n 'min': this.safeNumber (market, 'order_size_min'),\n 'max': this.safeNumber (market, 'order_size_max'),\n }" }, %{ "comment" => nil, "key" => "price", "value" => "{\n 'min': this.parseNumber (minPrice),\n 'max': this.parseNumber (maxPrice),\n }" }, %{ "comment" => nil, "key" => "cost", "value" => "{\n 'min': undefined,\n 'max': undefined,\n }" }, %{ "comment" => nil, "key" => "min", "value" => "this.safeNumber (market, 'order_size_min')" }, %{ "comment" => nil, "key" => "max", "value" => "this.safeNumber (market, 'order_size_max')" }, %{ "comment" => nil, "key" => "min", "value" => "this.parseNumber (minPrice)" }, %{ "comment" => nil, "key" => "max", "value" => "this.parseNumber (maxPrice)" } ], "name" => "parseContractMarket", "signature" => "parseContractMarket (market, settleId)", "source" => "parseContractMarket (market, settleId) {\n //\n // Perpetual swap\n //\n // {\n // \"name\": \"BTC_USDT\",\n // \"type\": \"direct\",\n // \"quanto_multiplier\": \"0.0001\",\n // \"ref_discount_rate\": \"0\",\n // \"order_price_deviate\": \"0.5\",\n // \"maintenance_rate\": \"0.005\",\n // \"mark_type\": \"index\",\n // \"last_price\": \"38026\",\n // \"mark_price\": \"37985.6\",\n // \"index_price\": \"37954.92\",\n // \"funding_rate_indicative\": \"0.000219\",\n // \"mark_price_round\": \"0.01\",\n // \"funding_offset\": 0,\n // \"in_delisting\": false,\n // \"risk_limit_base\": \"1000000\",\n // \"interest_rate\": \"0.0003\",\n // \"order_price_round\": \"0.1\",\n // \"order_size_min\": 1,\n // \"ref_rebate_rate\": \"0.2\",\n // \"funding_interval\": 28800,\n // \"risk_limit_step\": \"1000000\",\n // \"leverage_min\": \"1\",\n // \"leverage_max\": \"100\",\n // \"risk_limit_max\": \"8000000\",\n // \"maker_fee_rate\": \"-0.00025\", // not actual value for regular users\n // \"taker_fee_rate\": \"0.00075\", // not actual value for regular users\n // \"funding_rate\": \"0.002053\",\n // \"order_size_max\": 1000000,\n // \"funding_next_apply\": 1610035200,\n // \"short_users\": 977,\n // \"config_change_time\": 1609899548,\n // \"create_time\": 1609800048,\n // \"trade_size\": 28530850594,\n // \"position_size\": 5223816,\n // \"long_users\": 455,\n // \"funding_impact_value\": \"60000\",\n // \"orders_limit\": 50,\n // \"trade_id\": 10851092,\n // \"orderbook_id\": 2129638396\n // }\n //\n // Delivery Futures\n //\n // {\n // \"name\": \"BTC_USDT_20200814\",\n // \"underlying\": \"BTC_USDT\",\n // \"cycle\": \"WEEKLY\",\n // \"type\": \"direct\",\n // \"quanto_multiplier\": \"0.0001\",\n // \"mark_type\": \"index\",\n // \"last_price\": \"9017\",\n // \"mark_price\": \"9019\",\n // \"index_price\": \"9005.3\",\n // \"basis_rate\": \"0.185095\",\n // \"basis_value\": \"13.7\",\n // \"basis_impact_value\": \"100000\",\n // \"settle_price\": \"0\",\n // \"settle_price_interval\": 60,\n // \"settle_price_duration\": 1800,\n // \"settle_fee_rate\": \"0.0015\",\n // \"expire_time\": 1593763200,\n // \"order_price_round\": \"0.1\",\n // \"mark_price_round\": \"0.1\",\n // \"leverage_min\": \"1\",\n // \"leverage_max\": \"100\",\n // \"maintenance_rate\": \"1000000\",\n // \"risk_limit_base\": \"140.726652109199\",\n // \"risk_limit_step\": \"1000000\",\n // \"risk_limit_max\": \"8000000\",\n // \"maker_fee_rate\": \"-0.00025\", // not actual value for regular users\n // \"taker_fee_rate\": \"0.00075\", // not actual value for regular users\n // \"ref_discount_rate\": \"0\",\n // \"ref_rebate_rate\": \"0.2\",\n // \"order_price_deviate\": \"0.5\",\n // \"order_size_min\": 1,\n // \"order_size_max\": 1000000,\n // \"orders_limit\": 50,\n // \"orderbook_id\": 63,\n // \"trade_id\": 26,\n // \"trade_size\": 435,\n // \"position_size\": 130,\n // \"config_change_time\": 1593158867,\n // \"in_delisting\": false\n // }\n //\n const id = this.safeString (market, 'name');\n const parts = id.split ('_');\n const baseId = this.safeString (parts, 0);\n const quoteId = this.safeString (parts, 1);\n const date = this.safeString (parts, 2);\n const base = this.safeCurrencyCode (baseId);\n const quote = this.safeCurrencyCode (quoteId);\n const settle = this.safeCurrencyCode (settleId);\n const expiry = this.safeTimestamp (market, 'expire_time');\n let symbol = '';\n let marketType = 'swap';\n if (date !== undefined) {\n symbol = base + '/' + quote + ':' + settle + '-' + this.yymmdd (expiry, '');\n marketType = 'future';\n } else {\n symbol = base + '/' + quote + ':' + settle;\n }\n const priceDeviate = this.safeString (market, 'order_price_deviate');\n const markPrice = this.safeString (market, 'mark_price');\n const minMultiplier = Precise.stringSub ('1', priceDeviate);\n const maxMultiplier = Precise.stringAdd ('1', priceDeviate);\n const minPrice = Precise.stringMul (minMultiplier, markPrice);\n const maxPrice = Precise.stringMul (maxMultiplier, markPrice);\n const isLinear = quote === settle;\n let contractSize = this.safeString (market, 'quanto_multiplier');\n // exception only for one market: https://api.gateio.ws/api/v4/futures/btc/contracts\n if (contractSize === '0') {\n contractSize = '1'; // 1 USD in WEB: https://i.imgur.com/MBBUI04.png\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': marketType,\n 'spot': false,\n 'margin': false,\n 'swap': marketType === 'swap',\n 'future': marketType === 'future',\n 'option': marketType === 'option',\n 'active': true,\n 'contract': true,\n 'linear': isLinear,\n 'inverse': !isLinear,\n 'taker': this.parseNumber ('0.0005'), // 0.05% vip0\n 'maker': this.parseNumber ('0.0002'), // 0.02% vip0\n 'contractSize': this.parseNumber (contractSize),\n 'expiry': expiry,\n 'expiryDatetime': this.iso8601 (expiry),\n 'strike': undefined,\n 'optionType': undefined,\n 'precision': {\n 'amount': this.parseNumber ('1'), // all contracts have this step size\n 'price': this.safeNumber (market, 'order_price_round'),\n },\n 'limits': {\n 'leverage': {\n 'min': this.safeNumber (market, 'leverage_min'),\n 'max': this.safeNumber (market, 'leverage_max'),\n },\n 'amount': {\n 'min': this.safeNumber (market, 'order_size_min'),\n 'max': this.safeNumber (market, 'order_size_max'),\n },\n 'price': {\n 'min': this.parseNumber (minPrice),\n 'max': this.parseNumber (maxPrice),\n },\n 'cost': {\n 'min': undefined,\n 'max': undefined,\n },\n },\n 'created': this.safeIntegerProduct (market, 'create_time', 1000),\n 'info': market,\n };\n }" }, %{ "comment" => nil, "examples" => [ "{\n chain: \"BTC\",\n address: \"1Nxu.......Ys\",\n payment_id: \"\",\n payment_name: \"\",\n obtain_failed: \"0\",\n }" ], "line_end" => 2364, "line_start" => 2345, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "depositAddress" }, %{ "comment" => nil, "key" => "currency", "value" => "this.safeString (currency, 'code')" }, %{ "comment" => nil, "key" => "address", "value" => "address" }, %{ "comment" => nil, "key" => "tag", "value" => "this.safeString (depositAddress, 'payment_id')" }, %{ "comment" => nil, "key" => "network", "value" => "this.networkIdToCode (this.safeString (depositAddress, 'chain'))" } ], "name" => "parseDepositAddress", "signature" => "parseDepositAddress (depositAddress, currency = undefined)", "source" => "parseDepositAddress (depositAddress, currency = undefined) {\n //\n // {\n // chain: \"BTC\",\n // address: \"1Nxu.......Ys\",\n // payment_id: \"\",\n // payment_name: \"\",\n // obtain_failed: \"0\",\n // }\n //\n const address = this.safeString (depositAddress, 'address');\n this.checkAddress (address);\n return {\n 'info': depositAddress,\n 'currency': this.safeString (currency, 'code'),\n 'address': address,\n 'tag': this.safeString (depositAddress, 'payment_id'),\n 'network': this.networkIdToCode (this.safeString (depositAddress, 'chain')),\n };\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"currency\": \"MTN\",\n \"name\": \"Medicalchain\",\n \"name_cn\": \"Medicalchain\",\n \"deposit\": \"0\",\n \"withdraw_percent\": \"0%\",\n \"withdraw_fix\": \"900\",\n \"withdraw_day_limit\": \"500000\",\n \"withdraw_day_limit_remain\": \"500000\",\n \"withdraw_amount_mini\": \"900.1\",\n \"withdraw_eachtime_limit\": \"90000000000\",\n \"withdraw_fix_on_chains\": {\n \"ETH\": \"900\"\n }\n }" ], "line_end" => 2611, "line_start" => 2562, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "fee" }, %{ "comment" => nil, "key" => "withdraw", "value" => "{\n 'fee': this.safeNumber (fee, 'withdraw_fix'),\n 'percentage': false,\n }" }, %{ "comment" => nil, "key" => "deposit", "value" => "{\n 'fee': this.safeNumber (fee, 'deposit'),\n 'percentage': false,\n }" }, %{ "comment" => nil, "key" => "networks", "value" => "{}" }, %{ "comment" => nil, "key" => "fee", "value" => "this.safeNumber (fee, 'deposit')" }, %{ "comment" => nil, "key" => "percentage", "value" => "false" }, %{ "comment" => nil, "key" => "withdraw", "value" => "{\n 'fee': this.parseNumber (withdrawFixOnChains[chainKey]),\n 'percentage': false,\n }" }, %{ "comment" => nil, "key" => "deposit", "value" => "{\n 'fee': undefined,\n 'percentage': undefined,\n }" } ], "name" => "parseDepositWithdrawFee", "signature" => "parseDepositWithdrawFee (fee, currency: Currency = undefined)", "source" => "parseDepositWithdrawFee (fee, currency: Currency = undefined) {\n //\n // {\n // \"currency\": \"MTN\",\n // \"name\": \"Medicalchain\",\n // \"name_cn\": \"Medicalchain\",\n // \"deposit\": \"0\",\n // \"withdraw_percent\": \"0%\",\n // \"withdraw_fix\": \"900\",\n // \"withdraw_day_limit\": \"500000\",\n // \"withdraw_day_limit_remain\": \"500000\",\n // \"withdraw_amount_mini\": \"900.1\",\n // \"withdraw_eachtime_limit\": \"90000000000\",\n // \"withdraw_fix_on_chains\": {\n // \"ETH\": \"900\"\n // }\n // }\n //\n const withdrawFixOnChains = this.safeValue (fee, 'withdraw_fix_on_chains');\n const result: Dict = {\n 'info': fee,\n 'withdraw': {\n 'fee': this.safeNumber (fee, 'withdraw_fix'),\n 'percentage': false,\n },\n 'deposit': {\n 'fee': this.safeNumber (fee, 'deposit'),\n 'percentage': false,\n },\n 'networks': {},\n };\n if (withdrawFixOnChains !== undefined) {\n const chainKeys = Object.keys (withdrawFixOnChains);\n for (let i = 0; i < chainKeys.length; i++) {\n const chainKey = chainKeys[i];\n const networkCode = this.networkIdToCode (chainKey, this.safeString (fee, 'currency'));\n result['networks'][networkCode] = {\n 'withdraw': {\n 'fee': this.parseNumber (withdrawFixOnChains[chainKey]),\n 'percentage': false,\n },\n 'deposit': {\n 'fee': undefined,\n 'percentage': undefined,\n },\n };\n }\n }\n return result;\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 6524, "line_start" => 6496, "mappings" => [], "name" => "parseEmulatedLeverageTiers", "signature" => "parseEmulatedLeverageTiers (info, market = undefined): LeverageTier[]", "source" => "parseEmulatedLeverageTiers (info, market = undefined): LeverageTier[] {\n const marketId = this.safeString (info, 'name');\n const maintenanceMarginUnit = this.safeString (info, 'maintenance_rate'); // '0.005',\n const leverageMax = this.safeString (info, 'leverage_max'); // '100',\n const riskLimitStep = this.safeString (info, 'risk_limit_step'); // '1000000',\n const riskLimitMax = this.safeString (info, 'risk_limit_max'); // '16000000',\n const initialMarginUnit = Precise.stringDiv ('1', leverageMax);\n let maintenanceMarginRate = maintenanceMarginUnit;\n let initialMarginRatio = initialMarginUnit;\n let floor = '0';\n const tiers = [];\n while (Precise.stringLt (floor, riskLimitMax)) {\n const cap = Precise.stringAdd (floor, riskLimitStep);\n tiers.push ({\n 'tier': this.parseNumber (Precise.stringDiv (cap, riskLimitStep)),\n 'symbol': this.safeSymbol (marketId, market, undefined, 'contract'),\n 'currency': this.safeString (market, 'settle'),\n 'minNotional': this.parseNumber (floor),\n 'maxNotional': this.parseNumber (cap),\n 'maintenanceMarginRate': this.parseNumber (maintenanceMarginRate),\n 'maxLeverage': this.parseNumber (Precise.stringDiv ('1', initialMarginRatio)),\n 'info': info,\n });\n maintenanceMarginRate = Precise.stringAdd (maintenanceMarginRate, maintenanceMarginUnit);\n initialMarginRatio = Precise.stringAdd (initialMarginRatio, initialMarginUnit);\n floor = cap;\n }\n return tiers as LeverageTier[];\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 2675, "line_start" => 2666, "mappings" => [], "name" => "parseFundingHistories", "signature" => "parseFundingHistories (response, symbol, since, limit): FundingHistory[]", "source" => "parseFundingHistories (response, symbol, since, limit): FundingHistory[] {\n const result = [];\n for (let i = 0; i < response.length; i++) {\n const entry = response[i];\n const funding = this.parseFundingHistory (entry);\n result.push (funding);\n }\n const sorted = this.sortBy (result, 'timestamp');\n return this.filterBySymbolSinceLimit (sorted, symbol, since, limit);\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"time\": 1646899200,\n \"change\": \"-0.027722\",\n \"balance\": \"11.653120591841\",\n \"text\": \"XRP_USDT\",\n \"type\": \"fund\"\n }" ], "line_end" => 2699, "line_start" => 2677, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "info" }, %{ "comment" => nil, "key" => "symbol", "value" => "this.safeString (market, 'symbol')" }, %{ "comment" => nil, "key" => "code", "value" => "this.safeString (market, 'settle')" }, %{ "comment" => nil, "key" => "timestamp", "value" => "timestamp" }, %{ "comment" => nil, "key" => "datetime", "value" => "this.iso8601 (timestamp)" }, %{ "comment" => nil, "key" => "id", "value" => "undefined" }, %{ "comment" => nil, "key" => "amount", "value" => "this.safeNumber (info, 'change')" } ], "name" => "parseFundingHistory", "signature" => "parseFundingHistory (info, market: Market = undefined)", "source" => "parseFundingHistory (info, market: Market = undefined) {\n //\n // {\n // \"time\": 1646899200,\n // \"change\": \"-0.027722\",\n // \"balance\": \"11.653120591841\",\n // \"text\": \"XRP_USDT\",\n // \"type\": \"fund\"\n // }\n //\n const timestamp = this.safeTimestamp (info, 'time');\n const marketId = this.safeString (info, 'text');\n market = this.safeMarket (marketId, market, '_', 'swap');\n return {\n 'info': info,\n 'symbol': this.safeString (market, 'symbol'),\n 'code': this.safeString (market, 'settle'),\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n 'id': undefined,\n 'amount': this.safeNumber (info, 'change'),\n };\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 2262, "line_start" => 2253, "mappings" => [], "name" => "parseFundingInterval", "signature" => "parseFundingInterval (interval)", "source" => "parseFundingInterval (interval) {\n const intervals: Dict = {\n '3600000': '1h',\n '14400000': '4h',\n '28800000': '8h',\n '57600000': '16h',\n '86400000': '24h',\n };\n return this.safeString (intervals, interval, interval);\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"name\": \"BTC_USDT\",\n \"type\": \"direct\",\n \"quanto_multiplier\": \"0.0001\",\n \"ref_discount_rate\": \"0\",\n \"order_price_deviate\": \"0.5\",\n \"maintenance_rate\": \"0.005\",\n \"mark_type\": \"index\",\n \"last_price\": \"38026\",\n \"mark_price\": \"37985.6\",\n \"index_price\": \"37954.92\",\n \"funding_rate_indicative\": \"0.000219\",\n \"mark_price_round\": \"0.01\",\n \"funding_offset\": 0,\n \"in_delisting\": false,\n \"risk_limit_base\": \"1000000\",\n \"interest_rate\": \"0.0003\",\n \"order_price_round\": \"0.1\",\n \"order_size_min\": 1,\n \"ref_rebate_rate\": \"0.2\",\n \"funding_interval\": 28800,\n \"risk_limit_step\": \"1000000\",\n \"leverage_min\": \"1\",\n \"leverage_max\": \"100\",\n \"risk_limit_max\": \"8000000\",\n \"maker_fee_rate\": \"-0.00025\",\n \"taker_fee_rate\": \"0.00075\",\n \"funding_rate\": \"0.002053\",\n \"order_size_max\": 1000000,\n \"funding_next_apply\": 1610035200,\n \"short_users\": 977,\n \"config_change_time\": 1609899548,\n \"trade_size\": 28530850594,\n \"position_size\": 5223816,\n \"long_users\": 455,\n \"funding_impact_value\": \"60000\",\n \"orders_limit\": 50,\n \"trade_id\": 10851092,\n \"orderbook_id\": 2129638396\n }" ], "line_end" => 2251, "line_start" => 2179, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "contract" }, %{ "comment" => nil, "key" => "symbol", "value" => "symbol" }, %{ "comment" => nil, "key" => "markPrice", "value" => "markPrice" }, %{ "comment" => nil, "key" => "indexPrice", "value" => "indexPrice" }, %{ "comment" => nil, "key" => "interestRate", "value" => "interestRate" }, %{ "comment" => nil, "key" => "estimatedSettlePrice", "value" => "undefined" }, %{ "comment" => nil, "key" => "timestamp", "value" => "undefined" }, %{ "comment" => nil, "key" => "datetime", "value" => "undefined" }, %{ "comment" => nil, "key" => "fundingRate", "value" => "fundingRate" }, %{ "comment" => nil, "key" => "fundingTimestamp", "value" => "fundingTime" }, %{ "comment" => nil, "key" => "fundingDatetime", "value" => "this.iso8601 (fundingTime)" }, %{ "comment" => nil, "key" => "nextFundingRate", "value" => "fundingRateIndicative" }, %{ "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" => "this.parseFundingInterval (fundingInterval)" } ], "name" => "parseFundingRate", "signature" => "parseFundingRate (contract, market: Market = undefined): FundingRate", "source" => "parseFundingRate (contract, market: Market = undefined): FundingRate {\n //\n // {\n // \"name\": \"BTC_USDT\",\n // \"type\": \"direct\",\n // \"quanto_multiplier\": \"0.0001\",\n // \"ref_discount_rate\": \"0\",\n // \"order_price_deviate\": \"0.5\",\n // \"maintenance_rate\": \"0.005\",\n // \"mark_type\": \"index\",\n // \"last_price\": \"38026\",\n // \"mark_price\": \"37985.6\",\n // \"index_price\": \"37954.92\",\n // \"funding_rate_indicative\": \"0.000219\",\n // \"mark_price_round\": \"0.01\",\n // \"funding_offset\": 0,\n // \"in_delisting\": false,\n // \"risk_limit_base\": \"1000000\",\n // \"interest_rate\": \"0.0003\",\n // \"order_price_round\": \"0.1\",\n // \"order_size_min\": 1,\n // \"ref_rebate_rate\": \"0.2\",\n // \"funding_interval\": 28800,\n // \"risk_limit_step\": \"1000000\",\n // \"leverage_min\": \"1\",\n // \"leverage_max\": \"100\",\n // \"risk_limit_max\": \"8000000\",\n // \"maker_fee_rate\": \"-0.00025\",\n // \"taker_fee_rate\": \"0.00075\",\n // \"funding_rate\": \"0.002053\",\n // \"order_size_max\": 1000000,\n // \"funding_next_apply\": 1610035200,\n // \"short_users\": 977,\n // \"config_change_time\": 1609899548,\n // \"trade_size\": 28530850594,\n // \"position_size\": 5223816,\n // \"long_users\": 455,\n // \"funding_impact_value\": \"60000\",\n // \"orders_limit\": 50,\n // \"trade_id\": 10851092,\n // \"orderbook_id\": 2129638396\n // }\n //\n const marketId = this.safeString (contract, 'name');\n const symbol = this.safeSymbol (marketId, market, '_', 'swap');\n const markPrice = this.safeNumber (contract, 'mark_price');\n const indexPrice = this.safeNumber (contract, 'index_price');\n const interestRate = this.safeNumber (contract, 'interest_rate');\n const fundingRate = this.safeNumber (contract, 'funding_rate');\n const fundingTime = this.safeTimestamp (contract, 'funding_next_apply');\n const fundingRateIndicative = this.safeNumber (contract, 'funding_rate_indicative');\n const fundingInterval = Precise.stringMul ('1000', this.safeString (contract, 'funding_interval'));\n return {\n 'info': contract,\n 'symbol': symbol,\n 'markPrice': markPrice,\n 'indexPrice': indexPrice,\n 'interestRate': interestRate,\n 'estimatedSettlePrice': undefined,\n 'timestamp': undefined,\n 'datetime': undefined,\n 'fundingRate': fundingRate,\n 'fundingTimestamp': fundingTime,\n 'fundingDatetime': this.iso8601 (fundingTime),\n 'nextFundingRate': fundingRateIndicative,\n 'nextFundingTimestamp': undefined,\n 'nextFundingDatetime': undefined,\n 'previousFundingRate': undefined,\n 'previousFundingTimestamp': undefined,\n 'previousFundingDatetime': undefined,\n 'interval': this.parseFundingInterval (fundingInterval),\n } as FundingRate;\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"vega\": \"1.78992\",\n \"leverage\": \"6.2096777055417\",\n \"ask_iv\": \"0.6245\",\n \"delta\": \"-0.69397\",\n \"last_price\": \"0\",\n \"theta\": \"-2.5723\",\n \"bid1_price\": \"222.9\",\n \"mark_iv\": \"0.5909\",\n \"name\": \"ETH_USDT-20231201-2300-P\",\n \"bid_iv\": \"0.5065\",\n \"ask1_price\": \"243.6\",\n \"mark_price\": \"236.57\",\n \"position_size\": 0,\n \"bid1_size\": 368,\n \"ask1_size\": -335,\n \"gamma\": \"0.00116\"\n }" ], "line_end" => 7926, "line_start" => 7882, "mappings" => [ %{ "comment" => nil, "key" => "symbol", "value" => "symbol" }, %{ "comment" => nil, "key" => "timestamp", "value" => "undefined" }, %{ "comment" => nil, "key" => "datetime", "value" => "undefined" }, %{ "comment" => nil, "key" => "delta", "value" => "this.safeNumber (greeks, 'delta')" }, %{ "comment" => nil, "key" => "gamma", "value" => "this.safeNumber (greeks, 'gamma')" }, %{ "comment" => nil, "key" => "theta", "value" => "this.safeNumber (greeks, 'theta')" }, %{ "comment" => nil, "key" => "vega", "value" => "this.safeNumber (greeks, 'vega')" }, %{ "comment" => nil, "key" => "rho", "value" => "undefined" }, %{ "comment" => nil, "key" => "bidSize", "value" => "this.safeNumber (greeks, 'bid1_size')" }, %{ "comment" => nil, "key" => "askSize", "value" => "this.safeNumber (greeks, 'ask1_size')" }, %{ "comment" => nil, "key" => "bidImpliedVolatility", "value" => "this.safeNumber (greeks, 'bid_iv')" }, %{ "comment" => nil, "key" => "askImpliedVolatility", "value" => "this.safeNumber (greeks, 'ask_iv')" }, %{ "comment" => nil, "key" => "markImpliedVolatility", "value" => "this.safeNumber (greeks, 'mark_iv')" }, %{ "comment" => nil, "key" => "bidPrice", "value" => "this.safeNumber (greeks, 'bid1_price')" }, %{ "comment" => nil, "key" => "askPrice", "value" => "this.safeNumber (greeks, 'ask1_price')" }, %{ "comment" => nil, "key" => "markPrice", "value" => "this.safeNumber (greeks, 'mark_price')" }, %{ "comment" => nil, "key" => "lastPrice", "value" => "this.safeNumber (greeks, 'last_price')" }, %{ "comment" => nil, "key" => "underlyingPrice", "value" => "this.parseNumber (market['info']['underlying_price'])" }, %{ "comment" => nil, "key" => "info", "value" => "greeks" } ], "name" => "parseGreeks", "signature" => "parseGreeks (greeks: Dict, market: Market = undefined): Greeks", "source" => "parseGreeks (greeks: Dict, market: Market = undefined): Greeks {\n //\n // {\n // \"vega\": \"1.78992\",\n // \"leverage\": \"6.2096777055417\",\n // \"ask_iv\": \"0.6245\",\n // \"delta\": \"-0.69397\",\n // \"last_price\": \"0\",\n // \"theta\": \"-2.5723\",\n // \"bid1_price\": \"222.9\",\n // \"mark_iv\": \"0.5909\",\n // \"name\": \"ETH_USDT-20231201-2300-P\",\n // \"bid_iv\": \"0.5065\",\n // \"ask1_price\": \"243.6\",\n // \"mark_price\": \"236.57\",\n // \"position_size\": 0,\n // \"bid1_size\": 368,\n // \"ask1_size\": -335,\n // \"gamma\": \"0.00116\"\n // }\n //\n const marketId = this.safeString (greeks, 'name');\n const symbol = this.safeSymbol (marketId, market);\n return {\n 'symbol': symbol,\n 'timestamp': undefined,\n 'datetime': undefined,\n 'delta': this.safeNumber (greeks, 'delta'),\n 'gamma': this.safeNumber (greeks, 'gamma'),\n 'theta': this.safeNumber (greeks, 'theta'),\n 'vega': this.safeNumber (greeks, 'vega'),\n 'rho': undefined,\n 'bidSize': this.safeNumber (greeks, 'bid1_size'),\n 'askSize': this.safeNumber (greeks, 'ask1_size'),\n 'bidImpliedVolatility': this.safeNumber (greeks, 'bid_iv'),\n 'askImpliedVolatility': this.safeNumber (greeks, 'ask_iv'),\n 'markImpliedVolatility': this.safeNumber (greeks, 'mark_iv'),\n 'bidPrice': this.safeNumber (greeks, 'bid1_price'),\n 'askPrice': this.safeNumber (greeks, 'ask1_price'),\n 'markPrice': this.safeNumber (greeks, 'mark_price'),\n 'lastPrice': this.safeNumber (greeks, 'last_price'),\n 'underlyingPrice': this.parseNumber (market['info']['underlying_price']),\n 'info': greeks,\n };\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"id\": \"123456\",\n \"time\": 1547633726123,\n \"currency\": \"BTC\",\n \"change\": \"1.03\",\n \"balance\": \"4.59316525194\",\n \"type\": \"margin_in\"\n }", "{\n \"id\": \"123456\",\n \"time\": \"1547633726\",\n \"time_ms\": 1547633726123,\n \"currency\": \"BTC\",\n \"currency_pair\": \"BTC_USDT\",\n \"change\": \"1.03\",\n \"balance\": \"4.59316525194\"\n }", "{\n \"time\": 1682294400.123456,\n \"change\": \"0.000010152188\",\n \"balance\": \"4.59316525194\",\n \"text\": \"ETH_USD:6086261\",\n \"type\": \"fee\"\n }", "{\n \"time\": 1685594770,\n \"change\": \"3.33\",\n \"balance\": \"29.87911771\",\n \"text\": \"BTC_USDT-20230602-26500-C:2611026125\",\n \"type\": \"prem\"\n }" ], "line_end" => 7522, "line_start" => 7439, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "item" }, %{ "comment" => nil, "key" => "id", "value" => "this.safeString (item, 'id')" }, %{ "comment" => nil, "key" => "direction", "value" => "direction" }, %{ "comment" => nil, "key" => "account", "value" => "undefined" }, %{ "comment" => nil, "key" => "referenceAccount", "value" => "undefined" }, %{ "comment" => nil, "key" => "referenceId", "value" => "undefined" }, %{ "comment" => nil, "key" => "type", "value" => "this.parseLedgerEntryType (type)" }, %{ "comment" => nil, "key" => "currency", "value" => "this.safeCurrencyCode (currencyId, currency)" }, %{ "comment" => nil, "key" => "amount", "value" => "this.parseNumber (amount)" }, %{ "comment" => nil, "key" => "timestamp", "value" => "timestamp" }, %{ "comment" => nil, "key" => "datetime", "value" => "this.iso8601 (timestamp)" }, %{ "comment" => nil, "key" => "before", "value" => "before" }, %{ "comment" => nil, "key" => "after", "value" => "this.safeNumber (item, 'balance')" }, %{ "comment" => nil, "key" => "status", "value" => "undefined" }, %{ "comment" => nil, "key" => "fee", "value" => "undefined" } ], "name" => "parseLedgerEntry", "signature" => "parseLedgerEntry (item: Dict, currency: Currency = undefined): LedgerEntry", "source" => "parseLedgerEntry (item: Dict, currency: Currency = undefined): LedgerEntry {\n //\n // spot\n //\n // {\n // \"id\": \"123456\",\n // \"time\": 1547633726123,\n // \"currency\": \"BTC\",\n // \"change\": \"1.03\",\n // \"balance\": \"4.59316525194\",\n // \"type\": \"margin_in\"\n // }\n //\n // margin\n //\n // {\n // \"id\": \"123456\",\n // \"time\": \"1547633726\",\n // \"time_ms\": 1547633726123,\n // \"currency\": \"BTC\",\n // \"currency_pair\": \"BTC_USDT\",\n // \"change\": \"1.03\",\n // \"balance\": \"4.59316525194\"\n // }\n //\n // swap and future\n //\n // {\n // \"time\": 1682294400.123456,\n // \"change\": \"0.000010152188\",\n // \"balance\": \"4.59316525194\",\n // \"text\": \"ETH_USD:6086261\",\n // \"type\": \"fee\"\n // }\n //\n // option\n //\n // {\n // \"time\": 1685594770,\n // \"change\": \"3.33\",\n // \"balance\": \"29.87911771\",\n // \"text\": \"BTC_USDT-20230602-26500-C:2611026125\",\n // \"type\": \"prem\"\n // }\n //\n let direction = undefined;\n let amount = this.safeString (item, 'change');\n if (Precise.stringLt (amount, '0')) {\n direction = 'out';\n amount = Precise.stringAbs (amount);\n } else {\n direction = 'in';\n }\n const currencyId = this.safeString (item, 'currency');\n currency = this.safeCurrency (currencyId, currency);\n const type = this.safeString (item, 'type');\n const rawTimestamp = this.safeString (item, 'time');\n let timestamp = undefined;\n if (rawTimestamp.length > 10) {\n timestamp = parseInt (rawTimestamp);\n } else {\n timestamp = parseInt (rawTimestamp) * 1000;\n }\n const balanceString = this.safeString (item, 'balance');\n const changeString = this.safeString (item, 'change');\n const before = this.parseNumber (Precise.stringSub (balanceString, changeString));\n return this.safeLedgerEntry ({\n 'info': item,\n 'id': this.safeString (item, 'id'),\n 'direction': direction,\n 'account': undefined,\n 'referenceAccount': undefined,\n 'referenceId': undefined,\n 'type': this.parseLedgerEntryType (type),\n 'currency': this.safeCurrencyCode (currencyId, currency),\n 'amount': this.parseNumber (amount),\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n 'before': before,\n 'after': this.safeNumber (item, 'balance'),\n 'status': undefined,\n 'fee': undefined,\n }, currency) as LedgerEntry;\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 7566, "line_start" => 7524, "mappings" => [], "name" => "parseLedgerEntryType", "signature" => "parseLedgerEntryType (type)", "source" => "parseLedgerEntryType (type) {\n const ledgerType: Dict = {\n 'deposit': 'deposit',\n 'withdraw': 'withdrawal',\n 'sub_account_transfer': 'transfer',\n 'margin_in': 'transfer',\n 'margin_out': 'transfer',\n 'margin_funding_in': 'transfer',\n 'margin_funding_out': 'transfer',\n 'cross_margin_in': 'transfer',\n 'cross_margin_out': 'transfer',\n 'copy_trading_in': 'transfer',\n 'copy_trading_out': 'transfer',\n 'quant_in': 'transfer',\n 'quant_out': 'transfer',\n 'futures_in': 'transfer',\n 'futures_out': 'transfer',\n 'delivery_in': 'transfer',\n 'delivery_out': 'transfer',\n 'new_order': 'trade',\n 'order_fill': 'trade',\n 'referral_fee': 'rebate',\n 'order_fee': 'fee',\n 'interest': 'interest',\n 'lend': 'loan',\n 'redeem': 'loan',\n 'profit': 'interest',\n 'flash_swap_buy': 'trade',\n 'flash_swap_sell': 'trade',\n 'unknown': 'unknown',\n 'set': 'settlement',\n 'prem': 'trade',\n 'point_refr': 'rebate',\n 'point_fee': 'fee',\n 'point_dnw': 'deposit/withdraw',\n 'fund': 'fee',\n 'refr': 'rebate',\n 'fee': 'fee',\n 'pnl': 'trade',\n 'dnw': 'deposit/withdraw',\n };\n return this.safeString (ledgerType, type, type);\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 8120, "line_start" => 8110, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "leverage" }, %{ "comment" => nil, "key" => "symbol", "value" => "this.safeSymbol (marketId, market, '_', 'spot')" }, %{ "comment" => nil, "key" => "marginMode", "value" => "undefined" }, %{ "comment" => nil, "key" => "longLeverage", "value" => "leverageValue" }, %{ "comment" => nil, "key" => "shortLeverage", "value" => "leverageValue" } ], "name" => "parseLeverage", "signature" => "parseLeverage (leverage: Dict, market: Market = undefined): Leverage", "source" => "parseLeverage (leverage: Dict, market: Market = undefined): Leverage {\n const marketId = this.safeString2 (leverage, 'currency_pair', 'id');\n const leverageValue = this.safeInteger (leverage, 'leverage');\n return {\n 'info': leverage,\n 'symbol': this.safeSymbol (marketId, market, '_', 'spot'),\n 'marginMode': undefined,\n 'longLeverage': leverageValue,\n 'shortLeverage': leverageValue,\n } as Leverage;\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"contract\": \"BTC_USDT\",\n \"left\": 0,\n \"size\": -165,\n \"fill_price\": \"28070\",\n \"order_price\": \"28225\",\n \"time\": 1696736132\n }", "{\n \"time\": 1548654951,\n \"contract\": \"BTC_USDT\",\n \"size\": 600,\n \"leverage\": \"25\",\n \"margin\": \"0.006705256878\",\n \"entry_price\": \"3536.123\",\n \"liq_price\": \"3421.54\",\n \"mark_price\": \"3420.27\",\n \"order_id\": 317393847,\n \"order_price\": \"3405\",\n \"fill_price\": \"3424\",\n \"left\": 0\n }", "{\n \"time\": 1631764800,\n \"pnl\": \"-42914.291\",\n \"settle_size\": \"-10001\",\n \"side\": \"short\",\n \"contract\": \"BTC_USDT-20210916-5000-C\",\n \"text\": \"settled\"\n }" ], "line_end" => 7831, "line_start" => 7749, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "liquidation" }, %{ "comment" => nil, "key" => "symbol", "value" => "this.safeSymbol (marketId, market)" }, %{ "comment" => nil, "key" => "contracts", "value" => "this.parseNumber (contractsString)" }, %{ "comment" => nil, "key" => "contractSize", "value" => "this.parseNumber (contractSizeString)" }, %{ "comment" => nil, "key" => "price", "value" => "this.parseNumber (priceString)" }, %{ "comment" => nil, "key" => "side", "value" => "side" }, %{ "comment" => nil, "key" => "baseValue", "value" => "this.parseNumber (baseValueString)" }, %{ "comment" => nil, "key" => "quoteValue", "value" => "this.parseNumber (Precise.stringAbs (quoteValueString))" }, %{ "comment" => nil, "key" => "timestamp", "value" => "timestamp" }, %{ "comment" => nil, "key" => "datetime", "value" => "this.iso8601 (timestamp)" } ], "name" => "parseLiquidation", "signature" => "parseLiquidation (liquidation, market: Market = undefined)", "source" => "parseLiquidation (liquidation, market: Market = undefined) {\n //\n // fetchLiquidations\n //\n // {\n // \"contract\": \"BTC_USDT\",\n // \"left\": 0,\n // \"size\": -165,\n // \"fill_price\": \"28070\",\n // \"order_price\": \"28225\",\n // \"time\": 1696736132\n // }\n //\n // swap and future: fetchMyLiquidations\n //\n // {\n // \"time\": 1548654951,\n // \"contract\": \"BTC_USDT\",\n // \"size\": 600,\n // \"leverage\": \"25\",\n // \"margin\": \"0.006705256878\",\n // \"entry_price\": \"3536.123\",\n // \"liq_price\": \"3421.54\",\n // \"mark_price\": \"3420.27\",\n // \"order_id\": 317393847,\n // \"order_price\": \"3405\",\n // \"fill_price\": \"3424\",\n // \"left\": 0\n // }\n //\n // option: fetchMyLiquidations\n //\n // {\n // \"time\": 1631764800,\n // \"pnl\": \"-42914.291\",\n // \"settle_size\": \"-10001\",\n // \"side\": \"short\",\n // \"contract\": \"BTC_USDT-20210916-5000-C\",\n // \"text\": \"settled\"\n // }\n //\n const marketId = this.safeString (liquidation, 'contract');\n const timestamp = this.safeTimestamp (liquidation, 'time');\n const size = this.safeString2 (liquidation, 'size', 'settle_size');\n const left = this.safeString (liquidation, 'left', '0');\n const contractsString = Precise.stringAbs (Precise.stringSub (size, left));\n const contractSizeString = this.safeString (market, 'contractSize');\n const priceString = this.safeString2 (liquidation, 'liq_price', 'fill_price');\n const baseValueString = Precise.stringMul (contractsString, contractSizeString);\n let quoteValueString = this.safeString (liquidation, 'pnl');\n if (quoteValueString === undefined) {\n quoteValueString = Precise.stringMul (baseValueString, priceString);\n }\n // --- derive side ---\n // 1) options payload has explicit 'side': 'long' | 'short'\n const optPos = this.safeStringLower (liquidation, 'side');\n let side: Str = undefined;\n if (optPos === 'long') {\n side = 'buy';\n } else if (optPos === 'short') {\n side = 'sell';\n } else {\n if (size !== undefined) { // 2) futures/perpetual (and fallback for options): infer from size\n if (Precise.stringGt (size, '0')) {\n side = 'buy';\n } else if (Precise.stringLt (size, '0')) {\n side = 'sell';\n }\n }\n }\n return this.safeLiquidation ({\n 'info': liquidation,\n 'symbol': this.safeSymbol (marketId, market),\n 'contracts': this.parseNumber (contractsString),\n 'contractSize': this.parseNumber (contractSizeString),\n 'price': this.parseNumber (priceString),\n 'side': side,\n 'baseValue': this.parseNumber (baseValueString),\n 'quoteValue': this.parseNumber (Precise.stringAbs (quoteValueString)),\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n });\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"id\": \"17\",\n \"create_time\": 1620381696159,\n \"update_time\": 1620381696159,\n \"currency\": \"EOS\",\n \"amount\": \"110.553635\",\n \"text\": \"web\",\n \"status\": 2,\n \"repaid\": \"110.506649705159\",\n \"repaid_interest\": \"0.046985294841\",\n \"unpaid_interest\": \"0.0000074393366667\"\n }", "{\n \"id\": \"34267567\",\n \"create_time\": \"1656394778\",\n \"expire_time\": \"1657258778\",\n \"status\": \"loaned\",\n \"side\": \"borrow\",\n \"currency\": \"USDT\",\n \"rate\": \"0.0002\",\n \"amount\": \"100\",\n \"days\": 10,\n \"auto_renew\": false,\n \"currency_pair\": \"LTC_USDT\",\n \"left\": \"0\",\n \"repaid\": \"0\",\n \"paid_interest\": \"0\",\n \"unpaid_interest\": \"0.003333333333\"\n }" ], "line_end" => 6788, "line_start" => 6735, "mappings" => [ %{ "comment" => nil, "key" => "id", "value" => "this.safeInteger (info, 'id')" }, %{ "comment" => nil, "key" => "currency", "value" => "this.safeCurrencyCode (currencyId, currency)" }, %{ "comment" => nil, "key" => "amount", "value" => "this.safeNumber (info, 'amount')" }, %{ "comment" => nil, "key" => "symbol", "value" => "this.safeSymbol (marketId, undefined, '_', 'margin')" }, %{ "comment" => nil, "key" => "timestamp", "value" => "timestamp" }, %{ "comment" => nil, "key" => "datetime", "value" => "this.iso8601 (timestamp)" }, %{ "comment" => nil, "key" => "info", "value" => "info" } ], "name" => "parseMarginLoan", "signature" => "parseMarginLoan (info, currency: Currency = undefined)", "source" => "parseMarginLoan (info, currency: Currency = undefined) {\n //\n // Cross\n //\n // {\n // \"id\": \"17\",\n // \"create_time\": 1620381696159,\n // \"update_time\": 1620381696159,\n // \"currency\": \"EOS\",\n // \"amount\": \"110.553635\",\n // \"text\": \"web\",\n // \"status\": 2,\n // \"repaid\": \"110.506649705159\",\n // \"repaid_interest\": \"0.046985294841\",\n // \"unpaid_interest\": \"0.0000074393366667\"\n // }\n //\n // Isolated\n //\n // {\n // \"id\": \"34267567\",\n // \"create_time\": \"1656394778\",\n // \"expire_time\": \"1657258778\",\n // \"status\": \"loaned\",\n // \"side\": \"borrow\",\n // \"currency\": \"USDT\",\n // \"rate\": \"0.0002\",\n // \"amount\": \"100\",\n // \"days\": 10,\n // \"auto_renew\": false,\n // \"currency_pair\": \"LTC_USDT\",\n // \"left\": \"0\",\n // \"repaid\": \"0\",\n // \"paid_interest\": \"0\",\n // \"unpaid_interest\": \"0.003333333333\"\n // }\n //\n const marginMode = this.safeString2 (this.options, 'defaultMarginMode', 'marginMode', 'cross');\n let timestamp = this.safeInteger (info, 'create_time');\n if (marginMode === 'isolated') {\n timestamp = this.safeTimestamp (info, 'create_time');\n }\n const currencyId = this.safeString (info, 'currency');\n const marketId = this.safeString (info, 'currency_pair');\n return {\n 'id': this.safeInteger (info, 'id'),\n 'currency': this.safeCurrencyCode (currencyId, currency),\n 'amount': this.safeNumber (info, 'amount'),\n 'symbol': this.safeSymbol (marketId, undefined, '_', 'margin'),\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n 'info': info,\n };\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"value\": \"11.9257\",\n \"leverage\": \"5\",\n \"mode\": \"single\",\n \"realised_point\": \"0\",\n \"contract\": \"ETH_USDT\",\n \"entry_price\": \"1203.45\",\n \"mark_price\": \"1192.57\",\n \"history_point\": \"0\",\n \"realised_pnl\": \"-0.00577656\",\n \"close_order\": null,\n \"size\": \"1\",\n \"cross_leverage_limit\": \"0\",\n \"pending_orders\": \"0\",\n \"adl_ranking\": \"5\",\n \"maintenance_rate\": \"0.005\",\n \"unrealised_pnl\": \"-0.1088\",\n \"user\": \"1486602\",\n \"leverage_max\": \"100\",\n \"history_pnl\": \"0\",\n \"risk_limit\": \"1000000\",\n \"margin\": \"5.415925875\",\n \"last_close_pnl\": \"0\",\n \"liq_price\": \"665.69\"\n }" ], "line_end" => 7019, "line_start" => 6976, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "data" }, %{ "comment" => nil, "key" => "symbol", "value" => "market['symbol']" }, %{ "comment" => nil, "key" => "type", "value" => "undefined" }, %{ "comment" => nil, "key" => "marginMode", "value" => "'isolated'" }, %{ "comment" => nil, "key" => "amount", "value" => "undefined" }, %{ "comment" => nil, "key" => "total", "value" => "total" }, %{ "comment" => nil, "key" => "code", "value" => "this.safeValue (market, 'quote')" }, %{ "comment" => nil, "key" => "status", "value" => "'ok'" }, %{ "comment" => nil, "key" => "timestamp", "value" => "undefined" }, %{ "comment" => nil, "key" => "datetime", "value" => "undefined" } ], "name" => "parseMarginModification", "signature" => "parseMarginModification (data: Dict, market: Market = undefined): MarginModification", "source" => "parseMarginModification (data: Dict, market: Market = undefined): MarginModification {\n //\n // {\n // \"value\": \"11.9257\",\n // \"leverage\": \"5\",\n // \"mode\": \"single\",\n // \"realised_point\": \"0\",\n // \"contract\": \"ETH_USDT\",\n // \"entry_price\": \"1203.45\",\n // \"mark_price\": \"1192.57\",\n // \"history_point\": \"0\",\n // \"realised_pnl\": \"-0.00577656\",\n // \"close_order\": null,\n // \"size\": \"1\",\n // \"cross_leverage_limit\": \"0\",\n // \"pending_orders\": \"0\",\n // \"adl_ranking\": \"5\",\n // \"maintenance_rate\": \"0.005\",\n // \"unrealised_pnl\": \"-0.1088\",\n // \"user\": \"1486602\",\n // \"leverage_max\": \"100\",\n // \"history_pnl\": \"0\",\n // \"risk_limit\": \"1000000\",\n // \"margin\": \"5.415925875\",\n // \"last_close_pnl\": \"0\",\n // \"liq_price\": \"665.69\"\n // }\n //\n const contract = this.safeString (data, 'contract');\n market = this.safeMarket (contract, market, '_', 'contract');\n const total = this.safeNumber (data, 'margin');\n return {\n 'info': data,\n 'symbol': market['symbol'],\n 'type': undefined,\n 'marginMode': 'isolated',\n 'amount': undefined,\n 'total': total,\n 'code': this.safeValue (market, 'quote'),\n 'status': 'ok',\n 'timestamp': undefined,\n 'datetime': undefined,\n };\n }" }, %{ "comment" => nil, "examples" => [ "[\n {\n \"maintenance_rate\": \"0.004\",\n \"tier\": 1,\n \"initial_rate\": \"0.008\",\n \"leverage_max\": \"125\",\n \"risk_limit\": \"1000000\"\n }\n ]" ], "line_end" => 6559, "line_start" => 6526, "mappings" => [ %{ "comment" => nil, "key" => "tier", "value" => "this.sum (i, 1)" }, %{ "comment" => nil, "key" => "symbol", "value" => "market['symbol']" }, %{ "comment" => nil, "key" => "currency", "value" => "market['base']" }, %{ "comment" => nil, "key" => "minNotional", "value" => "minNotional" }, %{ "comment" => nil, "key" => "maxNotional", "value" => "maxNotional" }, %{ "comment" => nil, "key" => "maintenanceMarginRate", "value" => "this.safeNumber (item, 'maintenance_rate')" }, %{ "comment" => nil, "key" => "maxLeverage", "value" => "this.safeNumber (item, 'leverage_max')" }, %{ "comment" => nil, "key" => "info", "value" => "item" } ], "name" => "parseMarketLeverageTiers", "signature" => "parseMarketLeverageTiers (info, market: Market = undefined): LeverageTier[]", "source" => "parseMarketLeverageTiers (info, market: Market = undefined): LeverageTier[] {\n //\n // [\n // {\n // \"maintenance_rate\": \"0.004\",\n // \"tier\": 1,\n // \"initial_rate\": \"0.008\",\n // \"leverage_max\": \"125\",\n // \"risk_limit\": \"1000000\"\n // }\n // ]\n //\n if (!Array.isArray (info)) {\n return this.parseEmulatedLeverageTiers (info, market);\n }\n let minNotional = 0;\n const tiers = [];\n for (let i = 0; i < info.length; i++) {\n const item = info[i];\n const maxNotional = this.safeNumber (item, 'risk_limit');\n tiers.push ({\n 'tier': this.sum (i, 1),\n 'symbol': market['symbol'],\n 'currency': market['base'],\n 'minNotional': minNotional,\n 'maxNotional': maxNotional,\n 'maintenanceMarginRate': this.safeNumber (item, 'maintenance_rate'),\n 'maxLeverage': this.safeNumber (item, 'leverage_max'),\n 'info': item,\n });\n minNotional = maxNotional;\n }\n return tiers as LeverageTier[];\n }" }, %{ "comment" => nil, "examples" => [ "[\n \"1660957920\", // timestamp\n \"6227.070147198573\", // quote volume\n \"0.0000133485\", // close\n \"0.0000133615\", // high\n \"0.0000133347\", // low\n \"0.0000133468\", // open\n \"466641934.99\" // base volume\n ]", "{\n \"t\":1632873600, // Unix timestamp in seconds\n \"o\": \"41025\", // Open price\n \"h\": \"41882.17\", // Highest price\n \"c\": \"41776.92\", // Close price\n \"l\": \"40783.94\" // Lowest price\n }" ], "line_end" => 3525, "line_start" => 3480, "mappings" => [], "name" => "parseOHLCV", "signature" => "parseOHLCV (ohlcv, market: Market = undefined): OHLCV", "source" => "parseOHLCV (ohlcv, market: Market = undefined): OHLCV {\n //\n // Spot market candles\n //\n // [\n // \"1660957920\", // timestamp\n // \"6227.070147198573\", // quote volume\n // \"0.0000133485\", // close\n // \"0.0000133615\", // high\n // \"0.0000133347\", // low\n // \"0.0000133468\", // open\n // \"466641934.99\" // base volume\n // ]\n //\n //\n // Swap, Future, Option, Mark and Index price candles\n //\n // {\n // \"t\":1632873600, // Unix timestamp in seconds\n // \"o\": \"41025\", // Open price\n // \"h\": \"41882.17\", // Highest price\n // \"c\": \"41776.92\", // Close price\n // \"l\": \"40783.94\" // Lowest price\n // }\n //\n if (Array.isArray (ohlcv)) {\n return [\n this.safeTimestamp (ohlcv, 0), // unix timestamp in seconds\n this.safeNumber (ohlcv, 5), // open price\n this.safeNumber (ohlcv, 3), // highest price\n this.safeNumber (ohlcv, 4), // lowest price\n this.safeNumber (ohlcv, 2), // close price\n this.safeNumber (ohlcv, 6), // trading volume\n ];\n } else {\n // Swap, Future, Option, Mark and Index price candles\n return [\n this.safeTimestamp (ohlcv, 't'), // unix timestamp in seconds\n this.safeNumber (ohlcv, 'o'), // open price\n this.safeNumber (ohlcv, 'h'), // highest price\n this.safeNumber (ohlcv, 'l'), // lowest price\n this.safeNumber (ohlcv, 'c'), // close price\n this.safeNumber (ohlcv, 'v'), // trading volume, undefined for mark or index price\n ];\n }\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"long_liq_size\": \"0\",\n \"short_liq_size\": \"0\",\n \"short_liq_usd\": \"0\",\n \"lsr_account\": \"3.2808988764045\",\n \"mark_price\": \"0.34619\",\n \"top_lsr_size\": \"0\",\n \"time\": \"1674057000\",\n \"short_liq_amount\": \"0\",\n \"long_liq_amount\": \"0\",\n \"open_interest_usd\": \"9872386.7775\",\n \"top_lsr_account\": \"0\",\n \"open_interest\": \"2851725\",\n \"long_liq_usd\": \"0\",\n \"lsr_taker\": \"9.3765153315902\"\n }" ], "line_end" => 7139, "line_start" => 7111, "mappings" => [ %{ "comment" => nil, "key" => "symbol", "value" => "this.safeString (market, 'symbol')" }, %{ "comment" => nil, "key" => "openInterestAmount", "value" => "this.safeNumber (interest, 'open_interest')" }, %{ "comment" => nil, "key" => "openInterestValue", "value" => "this.safeNumber (interest, 'open_interest_usd')" }, %{ "comment" => nil, "key" => "timestamp", "value" => "timestamp" }, %{ "comment" => nil, "key" => "datetime", "value" => "this.iso8601 (timestamp)" }, %{ "comment" => nil, "key" => "info", "value" => "interest" } ], "name" => "parseOpenInterest", "signature" => "parseOpenInterest (interest, market: Market = undefined)", "source" => "parseOpenInterest (interest, market: Market = undefined) {\n //\n // {\n // \"long_liq_size\": \"0\",\n // \"short_liq_size\": \"0\",\n // \"short_liq_usd\": \"0\",\n // \"lsr_account\": \"3.2808988764045\",\n // \"mark_price\": \"0.34619\",\n // \"top_lsr_size\": \"0\",\n // \"time\": \"1674057000\",\n // \"short_liq_amount\": \"0\",\n // \"long_liq_amount\": \"0\",\n // \"open_interest_usd\": \"9872386.7775\",\n // \"top_lsr_account\": \"0\",\n // \"open_interest\": \"2851725\",\n // \"long_liq_usd\": \"0\",\n // \"lsr_taker\": \"9.3765153315902\"\n // }\n //\n const timestamp = this.safeTimestamp (interest, 'time');\n return {\n 'symbol': this.safeString (market, 'symbol'),\n 'openInterestAmount': this.safeNumber (interest, 'open_interest'),\n 'openInterestValue': this.safeNumber (interest, 'open_interest_usd'),\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n 'info': interest,\n };\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"is_active\": true,\n \"mark_price_round\": \"0.1\",\n \"settle_fee_rate\": \"0.00015\",\n \"bid1_size\": 434,\n \"taker_fee_rate\": \"0.0003\",\n \"price_limit_fee_rate\": \"0.1\",\n \"order_price_round\": \"1\",\n \"tag\": \"day\",\n \"ref_rebate_rate\": \"0\",\n \"name\": \"BTC_USDT-20240324-63500-P\",\n \"strike_price\": \"63500\",\n \"ask1_price\": \"387\",\n \"ref_discount_rate\": \"0\",\n \"order_price_deviate\": \"0.15\",\n \"ask1_size\": -454,\n \"mark_price_down\": \"124.3\",\n \"orderbook_id\": 29600,\n \"is_call\": false,\n \"last_price\": \"0\",\n \"mark_price\": \"366.6\",\n \"underlying\": \"BTC_USDT\",\n \"create_time\": 1711118829,\n \"settle_limit_fee_rate\": \"0.1\",\n \"orders_limit\": 10,\n \"mark_price_up\": \"630\",\n \"position_size\": 0,\n \"order_size_max\": 10000,\n \"position_limit\": 10000,\n \"multiplier\": \"0.01\",\n \"order_size_min\": 1,\n \"trade_size\": 0,\n \"underlying_price\": \"64084.65\",\n \"maker_fee_rate\": \"0.0003\",\n \"expiration_time\": 1711267200,\n \"trade_id\": 0,\n \"bid1_price\": \"307\"\n }" ], "line_end" => 8307, "line_start" => 8244, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "chain" }, %{ "comment" => nil, "key" => "currency", "value" => "undefined" }, %{ "comment" => nil, "key" => "symbol", "value" => "market['symbol']" }, %{ "comment" => nil, "key" => "timestamp", "value" => "timestamp" }, %{ "comment" => nil, "key" => "datetime", "value" => "this.iso8601 (timestamp)" }, %{ "comment" => nil, "key" => "impliedVolatility", "value" => "undefined" }, %{ "comment" => nil, "key" => "openInterest", "value" => "undefined" }, %{ "comment" => nil, "key" => "bidPrice", "value" => "this.safeNumber (chain, 'bid1_price')" }, %{ "comment" => nil, "key" => "askPrice", "value" => "this.safeNumber (chain, 'ask1_price')" }, %{ "comment" => nil, "key" => "midPrice", "value" => "undefined" }, %{ "comment" => nil, "key" => "markPrice", "value" => "this.safeNumber (chain, 'mark_price')" }, %{ "comment" => nil, "key" => "lastPrice", "value" => "this.safeNumber (chain, 'last_price')" }, %{ "comment" => nil, "key" => "underlyingPrice", "value" => "this.safeNumber (chain, 'underlying_price')" }, %{ "comment" => nil, "key" => "change", "value" => "undefined" }, %{ "comment" => nil, "key" => "percentage", "value" => "undefined" }, %{ "comment" => nil, "key" => "baseVolume", "value" => "undefined" }, %{ "comment" => nil, "key" => "quoteVolume", "value" => "undefined" } ], "name" => "parseOption", "signature" => "parseOption (chain: Dict, currency: Currency = undefined, market: Market = undefined): Option", "source" => "parseOption (chain: Dict, currency: Currency = undefined, market: Market = undefined): Option {\n //\n // {\n // \"is_active\": true,\n // \"mark_price_round\": \"0.1\",\n // \"settle_fee_rate\": \"0.00015\",\n // \"bid1_size\": 434,\n // \"taker_fee_rate\": \"0.0003\",\n // \"price_limit_fee_rate\": \"0.1\",\n // \"order_price_round\": \"1\",\n // \"tag\": \"day\",\n // \"ref_rebate_rate\": \"0\",\n // \"name\": \"BTC_USDT-20240324-63500-P\",\n // \"strike_price\": \"63500\",\n // \"ask1_price\": \"387\",\n // \"ref_discount_rate\": \"0\",\n // \"order_price_deviate\": \"0.15\",\n // \"ask1_size\": -454,\n // \"mark_price_down\": \"124.3\",\n // \"orderbook_id\": 29600,\n // \"is_call\": false,\n // \"last_price\": \"0\",\n // \"mark_price\": \"366.6\",\n // \"underlying\": \"BTC_USDT\",\n // \"create_time\": 1711118829,\n // \"settle_limit_fee_rate\": \"0.1\",\n // \"orders_limit\": 10,\n // \"mark_price_up\": \"630\",\n // \"position_size\": 0,\n // \"order_size_max\": 10000,\n // \"position_limit\": 10000,\n // \"multiplier\": \"0.01\",\n // \"order_size_min\": 1,\n // \"trade_size\": 0,\n // \"underlying_price\": \"64084.65\",\n // \"maker_fee_rate\": \"0.0003\",\n // \"expiration_time\": 1711267200,\n // \"trade_id\": 0,\n // \"bid1_price\": \"307\"\n // }\n //\n const marketId = this.safeString (chain, 'name');\n market = this.safeMarket (marketId, market);\n const timestamp = this.safeTimestamp (chain, 'create_time');\n return {\n 'info': chain,\n 'currency': undefined,\n 'symbol': market['symbol'],\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n 'impliedVolatility': undefined,\n 'openInterest': undefined,\n 'bidPrice': this.safeNumber (chain, 'bid1_price'),\n 'askPrice': this.safeNumber (chain, 'ask1_price'),\n 'midPrice': undefined,\n 'markPrice': this.safeNumber (chain, 'mark_price'),\n 'lastPrice': this.safeNumber (chain, 'last_price'),\n 'underlyingPrice': this.safeNumber (chain, 'underlying_price'),\n 'change': undefined,\n 'percentage': undefined,\n 'baseVolume': undefined,\n 'quoteVolume': undefined,\n };\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"id\": \"62364648575\",\n \"text\": \"apiv4\",\n \"create_time\": \"1626354834\",\n \"update_time\": \"1626354834\",\n \"create_time_ms\": \"1626354833544\",\n \"update_time_ms\": \"1626354833544\",\n \"status\": \"open\",\n \"currency_pair\": \"BTC_USDT\",\n \"type\": \"limit\",\n \"account\": \"spot\",\n \"side\": \"buy\",\n \"amount\": \"0.0001\",\n \"price\": \"30000\",\n \"time_in_force\": \"gtc\",\n \"iceberg\": \"0\",\n \"left\": \"0.0001\",\n \"fill_price\": \"0\",\n \"filled_total\": \"0\",\n \"fee\": \"0\",\n \"fee_currency\": \"BTC\",\n \"point_fee\": \"0\",\n \"gt_fee\": \"0\",\n \"gt_discount\": true,\n \"rebated_fee\": \"0\",\n \"rebated_fee_currency\": \"USDT\"\n }", "{\n \"id\": 12604556\n }", "{\n \"market\": \"ADA_USDT\",\n \"user\": 6392049,\n \"trigger\": {\n \"price\": \"1.08\", // stopPrice\n \"rule\": \"\\u003e=\",\n \"expiration\": 86400\n },\n \"put\": {\n \"type\": \"limit\",\n \"side\": \"buy\",\n \"price\": \"1.08\", // order price\n \"amount\": \"1.00000000000000000000\",\n \"account\": \"normal\",\n \"time_in_force\": \"gtc\"\n },\n \"id\": 71639298,\n \"ctime\": 1643945985,\n \"status\": \"open\"\n }", "{\n \"id\": 123028481731,\n \"contract\": \"ADA_USDT\",\n \"mkfr\": \"-0.00005\",\n \"tkfr\": \"0.00048\",\n \"tif\": \"ioc\",\n \"is_reduce_only\": false,\n \"create_time\": 1643950262.68,\n \"finish_time\": 1643950262.68,\n \"price\": \"0\",\n \"size\": 1,\n \"refr\": \"0\",\n \"left\":0,\n \"text\": \"api\",\n \"fill_price\": \"1.05273\",\n \"user\":6329238,\n \"finish_as\": \"filled\",\n \"status\": \"finished\",\n \"is_liq\": false,\n \"refu\":0,\n \"is_close\": false,\n \"iceberg\": 0\n }", "{\n \"user\": 6320300,\n \"trigger\": {\n \"strategy_type\": 0,\n \"price_type\": 0,\n \"price\": \"1.03\", // stopPrice\n \"rule\": 2,\n \"expiration\": 0\n },\n \"initial\": {\n \"contract\": \"ADA_USDT\",\n \"size\": -1,\n \"price\": \"1.02\",\n \"tif\": \"gtc\",\n \"text\": \"\",\n \"iceberg\": 0,\n \"is_close\": false,\n \"is_reduce_only\": false,\n \"auto_size\": \"\"\n },\n \"id\": 126393906,\n \"trade_id\": 0,\n \"status\": \"open\",\n \"reason\": \"\",\n \"create_time\": 1643953482,\n \"finish_time\": 1643953482,\n \"is_stop_order\": false,\n \"stop_trigger\": {\n \"rule\": 0,\n \"trigger_price\": \"\",\n \"order_price\": \"\"\n },\n \"me_order_id\": 0,\n \"order_type\": \"\"\n }" ], "line_end" => 5154, "line_start" => 4843, "mappings" => [ %{ "comment" => nil, "key" => "clientOrderId", "value" => "this.safeString (order, 'text')" }, %{ "comment" => nil, "key" => "info", "value" => "order" }, %{ "comment" => nil, "key" => "status", "value" => "'rejected'" }, %{ "comment" => nil, "key" => "id", "value" => "this.safeString (order, 'id')" }, %{ "comment" => nil, "key" => "timestamp", "value" => "timestamp" }, %{ "comment" => nil, "key" => "datetime", "value" => "this.iso8601 (timestamp)" }, %{ "comment" => nil, "key" => "lastTradeTimestamp", "value" => "lastTradeTimestamp" }, %{ "comment" => nil, "key" => "status", "value" => "status" }, %{ "comment" => nil, "key" => "symbol", "value" => "symbol" }, %{ "comment" => nil, "key" => "type", "value" => "type" }, %{ "comment" => nil, "key" => "timeInForce", "value" => "timeInForce" }, %{ "comment" => nil, "key" => "postOnly", "value" => "postOnly" }, %{ "comment" => nil, "key" => "reduceOnly", "value" => "reduceOnly" }, %{ "comment" => nil, "key" => "side", "value" => "side" }, %{ "comment" => nil, "key" => "price", "value" => "price" }, %{ "comment" => nil, "key" => "triggerPrice", "value" => "triggerPrice" }, %{ "comment" => nil, "key" => "average", "value" => "average" }, %{ "comment" => nil, "key" => "amount", "value" => "Precise.stringAbs (amount)" }, %{ "comment" => nil, "key" => "cost", "value" => "Precise.stringAbs (cost)" }, %{ "comment" => nil, "key" => "filled", "value" => "undefined" }, %{ "comment" => nil, "key" => "remaining", "value" => "remaining" }, %{ "comment" => nil, "key" => "fee", "value" => "multipleFeeCurrencies ? undefined : this.safeValue (fees, 0)" }, %{ "comment" => nil, "key" => "fees", "value" => "multipleFeeCurrencies ? fees : []" }, %{ "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 // SPOT\n // createOrder/cancelOrder/fetchOrder/editOrder\n //\n // {\n // \"id\": \"62364648575\",\n // \"text\": \"apiv4\",\n // \"create_time\": \"1626354834\",\n // \"update_time\": \"1626354834\",\n // \"create_time_ms\": \"1626354833544\",\n // \"update_time_ms\": \"1626354833544\",\n // \"status\": \"open\",\n // \"currency_pair\": \"BTC_USDT\",\n // \"type\": \"limit\",\n // \"account\": \"spot\",\n // \"side\": \"buy\",\n // \"amount\": \"0.0001\",\n // \"price\": \"30000\",\n // \"time_in_force\": \"gtc\",\n // \"iceberg\": \"0\",\n // \"left\": \"0.0001\",\n // \"fill_price\": \"0\",\n // \"filled_total\": \"0\",\n // \"fee\": \"0\",\n // \"fee_currency\": \"BTC\",\n // \"point_fee\": \"0\",\n // \"gt_fee\": \"0\",\n // \"gt_discount\": true,\n // \"rebated_fee\": \"0\",\n // \"rebated_fee_currency\": \"USDT\"\n // }\n //\n // SPOT TRIGGER ORDERS\n // createOrder\n //\n // {\n // \"id\": 12604556\n // }\n //\n // fetchOrder/cancelOrder\n //\n // {\n // \"market\": \"ADA_USDT\",\n // \"user\": 6392049,\n // \"trigger\": {\n // \"price\": \"1.08\", // stopPrice\n // \"rule\": \"\\u003e=\",\n // \"expiration\": 86400\n // },\n // \"put\": {\n // \"type\": \"limit\",\n // \"side\": \"buy\",\n // \"price\": \"1.08\", // order price\n // \"amount\": \"1.00000000000000000000\",\n // \"account\": \"normal\",\n // \"time_in_force\": \"gtc\"\n // },\n // \"id\": 71639298,\n // \"ctime\": 1643945985,\n // \"status\": \"open\"\n // }\n //\n // FUTURE, SWAP AND OPTION\n // createOrder/cancelOrder/fetchOrder\n //\n // {\n // \"id\": 123028481731,\n // \"contract\": \"ADA_USDT\",\n // \"mkfr\": \"-0.00005\",\n // \"tkfr\": \"0.00048\",\n // \"tif\": \"ioc\",\n // \"is_reduce_only\": false,\n // \"create_time\": 1643950262.68,\n // \"finish_time\": 1643950262.68,\n // \"price\": \"0\",\n // \"size\": 1,\n // \"refr\": \"0\",\n // \"left\":0,\n // \"text\": \"api\",\n // \"fill_price\": \"1.05273\",\n // \"user\":6329238,\n // \"finish_as\": \"filled\",\n // \"status\": \"finished\",\n // \"is_liq\": false,\n // \"refu\":0,\n // \"is_close\": false,\n // \"iceberg\": 0\n // }\n //\n // TRIGGER ORDERS (FUTURE AND SWAP)\n // createOrder\n //\n // {\n // \"id\": 12604556\n // }\n //\n // fetchOrder/cancelOrder\n //\n // {\n // \"user\": 6320300,\n // \"trigger\": {\n // \"strategy_type\": 0,\n // \"price_type\": 0,\n // \"price\": \"1.03\", // stopPrice\n // \"rule\": 2,\n // \"expiration\": 0\n // },\n // \"initial\": {\n // \"contract\": \"ADA_USDT\",\n // \"size\": -1,\n // \"price\": \"1.02\",\n // \"tif\": \"gtc\",\n // \"text\": \"\",\n // \"iceberg\": 0,\n // \"is_close\": false,\n // \"is_reduce_only\": false,\n // \"auto_size\": \"\"\n // },\n // \"id\": 126393906,\n // \"trade_id\": 0,\n // \"status\": \"open\",\n // \"reason\": \"\",\n // \"create_time\": 1643953482,\n // \"finish_time\": 1643953482,\n // \"is_stop_order\": false,\n // \"stop_trigger\": {\n // \"rule\": 0,\n // \"trigger_price\": \"\",\n // \"order_price\": \"\"\n // },\n // \"me_order_id\": 0,\n // \"order_type\": \"\"\n // }\n //\n // {\n // \"text\": \"t-d18baf9ac44d82e2\",\n // \"succeeded\": false,\n // \"label\": \"BALANCE_NOT_ENOUGH\",\n // \"message\": \"Not enough balance\"\n // }\n //\n // {\"user_id\":10406147,\"id\":\"id\",\"succeeded\":false,\"message\":\"INVALID_PROTOCOL\",\"label\":\"INVALID_PROTOCOL\"}\n //\n // cancel trigger order returns timestamps in ms\n // id: '2007047737421336576',\n // id_string: '2007047737421336576',\n // trigger_time: '0',\n // trade_id: '0',\n // trade_id_string: '',\n // status: 'finished',\n // finish_as: 'cancelled',\n // reason: '',\n // create_time: '1767352444402496'\n // finish_time: '1767352509535790',\n // is_stop_order: false,\n // stop_trigger: { rule: '0', trigger_price: '', order_price: '' },\n // me_order_id: '0',\n // me_order_id_string: '',\n // order_type: '',\n // in_dual_mode: false,\n // parent_id: '0',\n const succeeded = this.safeBool (order, 'succeeded', true);\n if (!succeeded) {\n // cancelOrders response\n return this.safeOrder ({\n 'clientOrderId': this.safeString (order, 'text'),\n 'info': order,\n 'status': 'rejected',\n 'id': this.safeString (order, 'id'),\n });\n }\n const put = this.safeValue2 (order, 'put', 'initial', {});\n const trigger = this.safeValue (order, 'trigger', {});\n let contract = this.safeString (put, 'contract');\n let type = this.safeString (put, 'type');\n let timeInForce = this.safeStringUpper2 (put, 'time_in_force', 'tif');\n let amount = this.safeString2 (put, 'amount', 'size');\n let side = this.safeString (put, 'side');\n let price = this.safeString (put, 'price');\n contract = this.safeString (order, 'contract', contract);\n type = this.safeString (order, 'type', type);\n timeInForce = this.safeStringUpper2 (order, 'time_in_force', 'tif', timeInForce);\n if (timeInForce === 'POC') {\n timeInForce = 'PO';\n }\n const postOnly = (timeInForce === 'PO');\n amount = this.safeString2 (order, 'amount', 'size', amount);\n side = this.safeString (order, 'side', side);\n price = this.safeString (order, 'price', price);\n let remainingString = this.safeString (order, 'left');\n let cost = this.safeString (order, 'filled_total');\n const triggerPrice = this.safeNumber (trigger, 'price');\n let average = this.safeNumber2 (order, 'avg_deal_price', 'fill_price');\n if (triggerPrice) {\n remainingString = amount;\n cost = '0';\n }\n if (contract) {\n const isMarketOrder = Precise.stringEquals (price, '0') && (timeInForce === 'IOC');\n type = isMarketOrder ? 'market' : 'limit';\n side = Precise.stringGt (amount, '0') ? 'buy' : 'sell';\n }\n const rawStatus = this.safeStringN (order, [ 'finish_as', 'status', 'open' ]);\n let timestampStr = this.safeString (order, 'create_time_ms');\n if (timestampStr === undefined) {\n timestampStr = this.safeString2 (order, 'create_time', 'ctime');\n if (timestampStr !== undefined) {\n if (timestampStr.length === 10 || timestampStr.indexOf ('.') >= 0) {\n // ts in seconds, multiply to ms\n timestampStr = Precise.stringMul (timestampStr, '1000');\n } else if (timestampStr.length === 16) {\n // ts in microseconds, divide to ms\n timestampStr = Precise.stringDiv (timestampStr, '1000');\n }\n }\n }\n let lastTradeTimestampStr = this.safeString (order, 'update_time_ms');\n if (lastTradeTimestampStr === undefined) {\n lastTradeTimestampStr = this.safeString2 (order, 'update_time', 'finish_time');\n if (lastTradeTimestampStr !== undefined) {\n if (lastTradeTimestampStr.length === 10 || lastTradeTimestampStr.indexOf ('.') >= 0) {\n // ts in seconds, multiply to ms\n lastTradeTimestampStr = Precise.stringMul (lastTradeTimestampStr, '1000');\n } else if (lastTradeTimestampStr.length === 16) {\n // ts in microseconds, divide to ms\n lastTradeTimestampStr = Precise.stringDiv (lastTradeTimestampStr, '1000');\n }\n }\n }\n let marketType = 'contract';\n if (('currency_pair' in order) || ('market' in order)) {\n marketType = 'spot';\n }\n const exchangeSymbol = this.safeString2 (order, 'currency_pair', 'market', contract);\n const symbol = this.safeSymbol (exchangeSymbol, market, '_', marketType);\n // Everything below this(above return) is related to fees\n const fees = [];\n const gtFee = this.safeString (order, 'gt_fee');\n if (gtFee !== undefined) {\n fees.push ({\n 'currency': 'GT',\n 'cost': gtFee,\n });\n }\n const fee = this.safeString (order, 'fee');\n if (fee !== undefined) {\n fees.push ({\n 'currency': this.safeCurrencyCode (this.safeString (order, 'fee_currency')),\n 'cost': fee,\n });\n }\n const rebate = this.safeString (order, 'rebated_fee');\n if (rebate !== undefined) {\n fees.push ({\n 'currency': this.safeCurrencyCode (this.safeString (order, 'rebated_fee_currency')),\n 'cost': Precise.stringNeg (rebate),\n });\n }\n const numFeeCurrencies = fees.length;\n const multipleFeeCurrencies = numFeeCurrencies > 1;\n const status = this.parseOrderStatus (rawStatus);\n let remaining = Precise.stringAbs (remainingString);\n // handle spot market buy\n const account = this.safeString (order, 'account'); // using this instead of market type because of the conflicting ids\n if (account === 'spot') {\n const averageString = this.safeString (order, 'avg_deal_price');\n average = this.parseNumber (averageString);\n if ((type === 'market') && (side === 'buy')) {\n remaining = Precise.stringDiv (remainingString, averageString);\n price = undefined; // arrives as 0\n cost = amount;\n amount = Precise.stringDiv (amount, averageString);\n }\n }\n let timestamp = undefined;\n let lastTradeTimestamp = undefined;\n if (timestampStr !== undefined) {\n timestamp = this.parseToInt (timestampStr);\n }\n if (lastTradeTimestampStr !== undefined) {\n lastTradeTimestamp = this.parseToInt (lastTradeTimestampStr);\n }\n const initial = this.safeDict (order, 'initial', {});\n const reduceOnlyInitial = this.safeBool (initial, 'is_reduce_only');\n const reduceOnly = this.safeBool (order, 'is_reduce_only', reduceOnlyInitial);\n return this.safeOrder ({\n 'id': this.safeString (order, 'id'),\n 'clientOrderId': this.safeString (order, 'text'),\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n 'lastTradeTimestamp': lastTradeTimestamp,\n 'status': status,\n 'symbol': symbol,\n 'type': type,\n 'timeInForce': timeInForce,\n 'postOnly': postOnly,\n 'reduceOnly': reduceOnly,\n 'side': side,\n 'price': price,\n 'triggerPrice': triggerPrice,\n 'average': average,\n 'amount': Precise.stringAbs (amount),\n 'cost': Precise.stringAbs (cost),\n 'filled': undefined,\n 'remaining': remaining,\n 'fee': multipleFeeCurrencies ? undefined : this.safeValue (fees, 0),\n 'fees': multipleFeeCurrencies ? fees : [],\n 'trades': undefined,\n 'info': order,\n }, market);\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 4841, "line_start" => 4826, "mappings" => [], "name" => "parseOrderStatus", "signature" => "parseOrderStatus (status: Str)", "source" => "parseOrderStatus (status: Str) {\n const statuses: Dict = {\n 'open': 'open',\n '_new': 'open',\n 'filled': 'closed',\n 'cancelled': 'canceled',\n 'liquidated': 'closed',\n 'ioc': 'canceled',\n 'failed': 'canceled',\n 'expired': 'canceled',\n 'finished': 'closed',\n 'finish': 'closed',\n 'succeeded': 'closed',\n };\n return this.safeString (statuses, status, status);\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"value\": \"4.60516\",\n \"leverage\": \"0\",\n \"mode\": \"single\",\n \"realised_point\": \"0\",\n \"contract\": \"BTC_USDT\",\n \"entry_price\": \"46030.3\",\n \"mark_price\": \"46051.6\",\n \"history_point\": \"0\",\n \"realised_pnl\": \"-0.002301515\",\n \"close_order\": null,\n \"size\": 1,\n \"cross_leverage_limit\": \"0\",\n \"pending_orders\": 0,\n \"adl_ranking\": 5,\n \"maintenance_rate\": \"0.004\",\n \"unrealised_pnl\": \"0.00213\",\n \"user\": 5691076,\n \"leverage_max\": \"125\",\n \"history_pnl\": \"0\",\n \"risk_limit\": \"1000000\",\n \"margin\": \"8.997698485\",\n \"last_close_pnl\": \"0\",\n \"liq_price\": \"0\",\n \"update_time\": 1705034246,\n \"update_id\": 1,\n \"initial_margin\": \"0\",\n \"maintenance_margin\": \"0\",\n \"open_time\": 1705034246,\n \"trade_max_size\": \"0\"\n }", "{\n \"close_order\": null,\n \"size\": 1,\n \"vega\": \"5.29756\",\n \"theta\": \"-98.98917\",\n \"gamma\": \"0.00056\",\n \"delta\": \"0.68691\",\n \"contract\": \"BTC_USDT-20230602-26500-C\",\n \"entry_price\": \"529\",\n \"unrealised_pnl\": \"-1.0131\",\n \"user\": 5691076,\n \"mark_price\": \"427.69\",\n \"underlying_price\": \"26810.2\",\n \"underlying\": \"BTC_USDT\",\n \"realised_pnl\": \"-0.08042877\",\n \"mark_iv\": \"0.4224\",\n \"pending_orders\": 0\n }", "{\n \"contract\": \"SLERF_USDT\", // Futures contract\n \"text\": \"web\", // Text of close order\n \"long_price\": \"0.766306\", // When 'side' is 'long,' it indicates the opening average price; when 'side' is 'short,' it indicates the closing average price.\n \"pnl\": \"-23.41702352\", // PNL\n \"pnl_pnl\": \"-22.7187\", // Position P/L\n \"pnl_fee\": \"-0.06527125\", // Transaction Fees\n \"pnl_fund\": \"-0.63305227\", // Funding Fees\n \"accum_size\": \"100\",\n \"time\": 1711279263, // Position close time\n \"short_price\": \"0.539119\", // When 'side' is 'long,' it indicates the opening average price; when 'side' is 'short,' it indicates the closing average price\n \"side\": \"long\", // Position side, long or short\n \"max_size\": \"100\", // Max Trade Size\n \"first_open_time\": 1711037985 // First Open Time\n }" ], "line_end" => 6146, "line_start" => 6006, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "position" }, %{ "comment" => nil, "key" => "id", "value" => "undefined" }, %{ "comment" => nil, "key" => "symbol", "value" => "this.safeString (market, 'symbol')" }, %{ "comment" => nil, "key" => "timestamp", "value" => "timestamp" }, %{ "comment" => nil, "key" => "datetime", "value" => "this.iso8601 (timestamp)" }, %{ "comment" => nil, "key" => "lastUpdateTimestamp", "value" => "this.safeTimestamp2 (position, 'update_time', 'time')" }, %{ "comment" => nil, "key" => "initialMargin", "value" => "this.parseNumber (initialMarginString)" }, %{ "comment" => nil, "key" => "initialMarginPercentage", "value" => "this.parseNumber (Precise.stringDiv (initialMarginString, notional))" }, %{ "comment" => nil, "key" => "maintenanceMargin", "value" => "this.parseNumber (Precise.stringMul (maintenanceRate, notional))" }, %{ "comment" => nil, "key" => "maintenanceMarginPercentage", "value" => "this.parseNumber (maintenanceRate)" }, %{ "comment" => nil, "key" => "entryPrice", "value" => "this.safeNumber (position, 'entry_price')" }, %{ "comment" => nil, "key" => "notional", "value" => "this.parseNumber (notional)" }, %{ "comment" => nil, "key" => "leverage", "value" => "this.safeNumber (position, 'leverage')" }, %{ "comment" => nil, "key" => "unrealizedPnl", "value" => "this.safeNumber (position, 'unrealised_pnl')" }, %{ "comment" => nil, "key" => "realizedPnl", "value" => "this.safeNumber2 (position, 'realised_pnl', 'pnl')" }, %{ "comment" => nil, "key" => "contracts", "value" => "this.parseNumber (Precise.stringAbs (size))" }, %{ "comment" => nil, "key" => "contractSize", "value" => "this.safeNumber (market, 'contractSize')" }, %{ "comment" => nil, "key" => "marginRatio", "value" => "undefined" }, %{ "comment" => nil, "key" => "liquidationPrice", "value" => "this.safeNumber (position, 'liq_price')" }, %{ "comment" => nil, "key" => "markPrice", "value" => "this.safeNumber (position, 'mark_price')" }, %{ "comment" => nil, "key" => "lastPrice", "value" => "undefined" }, %{ "comment" => nil, "key" => "collateral", "value" => "this.safeNumber (position, 'margin')" }, %{ "comment" => nil, "key" => "marginMode", "value" => "marginMode" }, %{ "comment" => nil, "key" => "side", "value" => "side" }, %{ "comment" => nil, "key" => "percentage", "value" => "undefined" }, %{ "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 // swap and future\n //\n // {\n // \"value\": \"4.60516\",\n // \"leverage\": \"0\",\n // \"mode\": \"single\",\n // \"realised_point\": \"0\",\n // \"contract\": \"BTC_USDT\",\n // \"entry_price\": \"46030.3\",\n // \"mark_price\": \"46051.6\",\n // \"history_point\": \"0\",\n // \"realised_pnl\": \"-0.002301515\",\n // \"close_order\": null,\n // \"size\": 1,\n // \"cross_leverage_limit\": \"0\",\n // \"pending_orders\": 0,\n // \"adl_ranking\": 5,\n // \"maintenance_rate\": \"0.004\",\n // \"unrealised_pnl\": \"0.00213\",\n // \"user\": 5691076,\n // \"leverage_max\": \"125\",\n // \"history_pnl\": \"0\",\n // \"risk_limit\": \"1000000\",\n // \"margin\": \"8.997698485\",\n // \"last_close_pnl\": \"0\",\n // \"liq_price\": \"0\",\n // \"update_time\": 1705034246,\n // \"update_id\": 1,\n // \"initial_margin\": \"0\",\n // \"maintenance_margin\": \"0\",\n // \"open_time\": 1705034246,\n // \"trade_max_size\": \"0\"\n // }\n //\n // option\n //\n // {\n // \"close_order\": null,\n // \"size\": 1,\n // \"vega\": \"5.29756\",\n // \"theta\": \"-98.98917\",\n // \"gamma\": \"0.00056\",\n // \"delta\": \"0.68691\",\n // \"contract\": \"BTC_USDT-20230602-26500-C\",\n // \"entry_price\": \"529\",\n // \"unrealised_pnl\": \"-1.0131\",\n // \"user\": 5691076,\n // \"mark_price\": \"427.69\",\n // \"underlying_price\": \"26810.2\",\n // \"underlying\": \"BTC_USDT\",\n // \"realised_pnl\": \"-0.08042877\",\n // \"mark_iv\": \"0.4224\",\n // \"pending_orders\": 0\n // }\n //\n // fetchPositionsHistory (swap and future)\n //\n // {\n // \"contract\": \"SLERF_USDT\", // Futures contract\n // \"text\": \"web\", // Text of close order\n // \"long_price\": \"0.766306\", // When 'side' is 'long,' it indicates the opening average price; when 'side' is 'short,' it indicates the closing average price.\n // \"pnl\": \"-23.41702352\", // PNL\n // \"pnl_pnl\": \"-22.7187\", // Position P/L\n // \"pnl_fee\": \"-0.06527125\", // Transaction Fees\n // \"pnl_fund\": \"-0.63305227\", // Funding Fees\n // \"accum_size\": \"100\",\n // \"time\": 1711279263, // Position close time\n // \"short_price\": \"0.539119\", // When 'side' is 'long,' it indicates the opening average price; when 'side' is 'short,' it indicates the closing average price\n // \"side\": \"long\", // Position side, long or short\n // \"max_size\": \"100\", // Max Trade Size\n // \"first_open_time\": 1711037985 // First Open Time\n // }\n //\n const contract = this.safeString (position, 'contract');\n market = this.safeMarket (contract, market, '_', 'contract');\n const size = this.safeString2 (position, 'size', 'accum_size');\n let side = this.safeString (position, 'side');\n if (side === undefined) {\n if (Precise.stringGt (size, '0')) {\n side = 'long';\n } else if (Precise.stringLt (size, '0')) {\n side = 'short';\n }\n }\n const maintenanceRate = this.safeString (position, 'maintenance_rate');\n const notional = this.safeString (position, 'value');\n const leverage = this.safeString (position, 'leverage');\n let marginMode = undefined;\n if (leverage !== undefined) {\n if (leverage === '0') {\n marginMode = 'cross';\n } else {\n marginMode = 'isolated';\n }\n }\n // Initial Position Margin = ( Position Value / Leverage ) + Close Position Fee\n // *The default leverage under the full position is the highest leverage in the market.\n // *Trading fee is charged as Taker Fee Rate (0.075%).\n let feePaid = this.safeString (position, 'pnl_fee');\n let initialMarginString = undefined;\n if (feePaid === undefined) {\n const takerFee = '0.00075';\n feePaid = Precise.stringMul (takerFee, notional);\n initialMarginString = Precise.stringAdd (Precise.stringDiv (notional, leverage), feePaid);\n }\n let timestamp = this.safeTimestamp2 (position, 'open_time', 'first_open_time');\n if (timestamp === 0) {\n timestamp = undefined;\n }\n return this.safePosition ({\n 'info': position,\n 'id': undefined,\n 'symbol': this.safeString (market, 'symbol'),\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n 'lastUpdateTimestamp': this.safeTimestamp2 (position, 'update_time', 'time'),\n 'initialMargin': this.parseNumber (initialMarginString),\n 'initialMarginPercentage': this.parseNumber (Precise.stringDiv (initialMarginString, notional)),\n 'maintenanceMargin': this.parseNumber (Precise.stringMul (maintenanceRate, notional)),\n 'maintenanceMarginPercentage': this.parseNumber (maintenanceRate),\n 'entryPrice': this.safeNumber (position, 'entry_price'),\n 'notional': this.parseNumber (notional),\n 'leverage': this.safeNumber (position, 'leverage'),\n 'unrealizedPnl': this.safeNumber (position, 'unrealised_pnl'),\n 'realizedPnl': this.safeNumber2 (position, 'realised_pnl', 'pnl'),\n 'contracts': this.parseNumber (Precise.stringAbs (size)),\n 'contractSize': this.safeNumber (market, 'contractSize'),\n 'marginRatio': undefined,\n 'liquidationPrice': this.safeNumber (position, 'liq_price'),\n 'markPrice': this.safeNumber (position, 'mark_price'),\n 'lastPrice': undefined,\n 'collateral': this.safeNumber (position, 'margin'),\n 'marginMode': marginMode,\n 'side': side,\n 'percentage': undefined,\n 'stopLossPrice': undefined,\n 'takeProfitPrice': undefined,\n });\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"time\": 1685952000,\n \"profit\": \"18.266806892718\",\n \"settle_price\": \"26826.68068927182\",\n \"fee\": \"0.040240021034\",\n \"contract\": \"BTC_USDT-20230605-25000-C\",\n \"strike_price\": \"25000\"\n }", "{\n \"size\": -1,\n \"settle_profit\": \"0\",\n \"contract\": \"BTC_USDT-20220624-26000-C\",\n \"strike_price\": \"26000\",\n \"time\": 1656057600,\n \"settle_price\": \"20917.461281337048\",\n \"underlying\": \"BTC_USDT\",\n \"realised_pnl\": \"-0.00116042\",\n \"fee\": \"0\"\n }" ], "line_end" => 7285, "line_start" => 7249, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "settlement" }, %{ "comment" => nil, "key" => "symbol", "value" => "this.safeSymbol (marketId, market)" }, %{ "comment" => nil, "key" => "price", "value" => "this.safeNumber (settlement, 'settle_price')" }, %{ "comment" => nil, "key" => "timestamp", "value" => "timestamp" }, %{ "comment" => nil, "key" => "datetime", "value" => "this.iso8601 (timestamp)" } ], "name" => "parseSettlement", "signature" => "parseSettlement (settlement, market)", "source" => "parseSettlement (settlement, market) {\n //\n // fetchSettlementHistory\n //\n // {\n // \"time\": 1685952000,\n // \"profit\": \"18.266806892718\",\n // \"settle_price\": \"26826.68068927182\",\n // \"fee\": \"0.040240021034\",\n // \"contract\": \"BTC_USDT-20230605-25000-C\",\n // \"strike_price\": \"25000\"\n // }\n //\n // fetchMySettlementHistory\n //\n // {\n // \"size\": -1,\n // \"settle_profit\": \"0\",\n // \"contract\": \"BTC_USDT-20220624-26000-C\",\n // \"strike_price\": \"26000\",\n // \"time\": 1656057600,\n // \"settle_price\": \"20917.461281337048\",\n // \"underlying\": \"BTC_USDT\",\n // \"realised_pnl\": \"-0.00116042\",\n // \"fee\": \"0\"\n // }\n //\n const timestamp = this.safeTimestamp (settlement, 'time');\n const marketId = this.safeString (settlement, 'contract');\n return {\n 'info': settlement,\n 'symbol': this.safeSymbol (marketId, market),\n 'price': this.safeNumber (settlement, 'settle_price'),\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n };\n }" }, %{ "comment" => nil, "examples" => [ "[\n {\n \"time\": 1685952000,\n \"profit\": \"18.266806892718\",\n \"settle_price\": \"26826.68068927182\",\n \"fee\": \"0.040240021034\",\n \"contract\": \"BTC_USDT-20230605-25000-C\",\n \"strike_price\": \"25000\"\n }\n ]", "[\n {\n \"size\": -1,\n \"settle_profit\": \"0\",\n \"contract\": \"BTC_USDT-20220624-26000-C\",\n \"strike_price\": \"26000\",\n \"time\": 1656057600,\n \"settle_price\": \"20917.461281337048\",\n \"underlying\": \"BTC_USDT\",\n \"realised_pnl\": \"-0.00116042\",\n \"fee\": \"0\"\n }\n ]" ], "line_end" => 7323, "line_start" => 7287, "mappings" => [], "name" => "parseSettlements", "signature" => "parseSettlements (settlements, market)", "source" => "parseSettlements (settlements, market) {\n //\n // fetchSettlementHistory\n //\n // [\n // {\n // \"time\": 1685952000,\n // \"profit\": \"18.266806892718\",\n // \"settle_price\": \"26826.68068927182\",\n // \"fee\": \"0.040240021034\",\n // \"contract\": \"BTC_USDT-20230605-25000-C\",\n // \"strike_price\": \"25000\"\n // }\n // ]\n //\n // fetchMySettlementHistory\n //\n // [\n // {\n // \"size\": -1,\n // \"settle_profit\": \"0\",\n // \"contract\": \"BTC_USDT-20220624-26000-C\",\n // \"strike_price\": \"26000\",\n // \"time\": 1656057600,\n // \"settle_price\": \"20917.461281337048\",\n // \"underlying\": \"BTC_USDT\",\n // \"realised_pnl\": \"-0.00116042\",\n // \"fee\": \"0\"\n // }\n // ]\n //\n const result = [];\n for (let i = 0; i < settlements.length; i++) {\n result.push (this.parseSettlement (settlements[i], market));\n }\n return result;\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"currency_pair\": \"KFC_USDT\",\n \"last\": \"7.255\",\n \"lowest_ask\": \"7.298\",\n \"highest_bid\": \"7.218\",\n \"change_percentage\": \"-1.18\",\n \"base_volume\": \"1219.053687865\",\n \"quote_volume\": \"8807.40299875455\",\n \"high_24h\": \"7.262\",\n \"low_24h\": \"7.095\"\n }", "{\n \"contract\": \"BTC_USDT\",\n \"last\": \"6432\",\n \"low_24h\": \"6278\",\n \"high_24h\": \"6790\",\n \"change_percentage\": \"4.43\",\n \"total_size\": \"32323904\",\n \"volume_24h\": \"184040233284\",\n \"volume_24h_btc\": \"28613220\",\n \"volume_24h_usd\": \"184040233284\",\n \"volume_24h_base\": \"28613220\",\n \"volume_24h_quote\": \"184040233284\",\n \"volume_24h_settle\": \"28613220\",\n \"mark_price\": \"6534\",\n \"funding_rate\": \"0.0001\",\n \"funding_rate_indicative\": \"0.0001\",\n \"index_price\": \"6531\"\n }", "{\n \"t\": 1671363004228,\n \"u\": 9793320464,\n \"s\": \"BTC_USDT\",\n \"b\": \"16716.8\", // best bid price\n \"B\": \"0.0134\", // best bid size\n \"a\": \"16716.9\", // best ask price\n \"A\": \"0.0353\" // best ask size\n }", "{\n \"vega\": \"0.00002\",\n \"leverage\": \"12.277188268663\",\n \"ask_iv\": \"0\",\n \"delta\": \"-0.99999\",\n \"last_price\": \"0\",\n \"theta\": \"-0.00661\",\n \"bid1_price\": \"1096\",\n \"mark_iv\": \"0.7799\",\n \"name\": \"BTC_USDT-20230608-28500-P\",\n \"bid_iv\": \"0\",\n \"ask1_price\": \"2935\",\n \"mark_price\": \"2147.3\",\n \"position_size\": 0,\n \"bid1_size\": 12,\n \"ask1_size\": -14,\n \"gamma\": \"0\"\n }" ], "line_end" => 2982, "line_start" => 2869, "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" => "high" }, %{ "comment" => nil, "key" => "low", "value" => "low" }, %{ "comment" => nil, "key" => "bid", "value" => "bid" }, %{ "comment" => nil, "key" => "bidVolume", "value" => "bidVolume" }, %{ "comment" => nil, "key" => "ask", "value" => "ask" }, %{ "comment" => nil, "key" => "askVolume", "value" => "askVolume" }, %{ "comment" => nil, "key" => "vwap", "value" => "undefined" }, %{ "comment" => nil, "key" => "open", "value" => "undefined" }, %{ "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" => "percentage" }, %{ "comment" => nil, "key" => "average", "value" => "undefined" }, %{ "comment" => nil, "key" => "baseVolume", "value" => "baseVolume" }, %{ "comment" => nil, "key" => "quoteVolume", "value" => "quoteVolume" }, %{ "comment" => nil, "key" => "markPrice", "value" => "this.safeString (ticker, 'mark_price')" }, %{ "comment" => nil, "key" => "indexPrice", "value" => "this.safeString (ticker, 'index_price')" }, %{ "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 //\n // SPOT\n //\n // {\n // \"currency_pair\": \"KFC_USDT\",\n // \"last\": \"7.255\",\n // \"lowest_ask\": \"7.298\",\n // \"highest_bid\": \"7.218\",\n // \"change_percentage\": \"-1.18\",\n // \"base_volume\": \"1219.053687865\",\n // \"quote_volume\": \"8807.40299875455\",\n // \"high_24h\": \"7.262\",\n // \"low_24h\": \"7.095\"\n // }\n //\n // LINEAR/DELIVERY\n //\n // {\n // \"contract\": \"BTC_USDT\",\n // \"last\": \"6432\",\n // \"low_24h\": \"6278\",\n // \"high_24h\": \"6790\",\n // \"change_percentage\": \"4.43\",\n // \"total_size\": \"32323904\",\n // \"volume_24h\": \"184040233284\",\n // \"volume_24h_btc\": \"28613220\",\n // \"volume_24h_usd\": \"184040233284\",\n // \"volume_24h_base\": \"28613220\",\n // \"volume_24h_quote\": \"184040233284\",\n // \"volume_24h_settle\": \"28613220\",\n // \"mark_price\": \"6534\",\n // \"funding_rate\": \"0.0001\",\n // \"funding_rate_indicative\": \"0.0001\",\n // \"index_price\": \"6531\"\n // }\n //\n // bookTicker\n // {\n // \"t\": 1671363004228,\n // \"u\": 9793320464,\n // \"s\": \"BTC_USDT\",\n // \"b\": \"16716.8\", // best bid price\n // \"B\": \"0.0134\", // best bid size\n // \"a\": \"16716.9\", // best ask price\n // \"A\": \"0.0353\" // best ask size\n // }\n //\n // option\n //\n // {\n // \"vega\": \"0.00002\",\n // \"leverage\": \"12.277188268663\",\n // \"ask_iv\": \"0\",\n // \"delta\": \"-0.99999\",\n // \"last_price\": \"0\",\n // \"theta\": \"-0.00661\",\n // \"bid1_price\": \"1096\",\n // \"mark_iv\": \"0.7799\",\n // \"name\": \"BTC_USDT-20230608-28500-P\",\n // \"bid_iv\": \"0\",\n // \"ask1_price\": \"2935\",\n // \"mark_price\": \"2147.3\",\n // \"position_size\": 0,\n // \"bid1_size\": 12,\n // \"ask1_size\": -14,\n // \"gamma\": \"0\"\n // }\n //\n const marketId = this.safeStringN (ticker, [ 'currency_pair', 'contract', 'name' ]);\n const marketType = ('mark_price' in ticker) ? 'contract' : 'spot';\n const symbol = this.safeSymbol (marketId, market, '_', marketType);\n const last = this.safeString2 (ticker, 'last', 'last_price');\n const ask = this.safeStringN (ticker, [ 'lowest_ask', 'a', 'ask1_price' ]);\n const bid = this.safeStringN (ticker, [ 'highest_bid', 'b', 'bid1_price' ]);\n const high = this.safeString (ticker, 'high_24h');\n const low = this.safeString (ticker, 'low_24h');\n const bidVolume = this.safeString2 (ticker, 'B', 'bid1_size');\n const askVolume = this.safeString2 (ticker, 'A', 'ask1_size');\n const timestamp = this.safeInteger (ticker, 't');\n let baseVolume = this.safeString2 (ticker, 'base_volume', 'volume_24h_base');\n if (baseVolume === 'nan') {\n baseVolume = '0';\n }\n let quoteVolume = this.safeString2 (ticker, 'quote_volume', 'volume_24h_quote');\n if (quoteVolume === 'nan') {\n quoteVolume = '0';\n }\n const percentage = this.safeString (ticker, 'change_percentage');\n return this.safeTicker ({\n 'symbol': symbol,\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n 'high': high,\n 'low': low,\n 'bid': bid,\n 'bidVolume': bidVolume,\n 'ask': ask,\n 'askVolume': askVolume,\n 'vwap': undefined,\n 'open': undefined,\n 'close': last,\n 'last': last,\n 'previousClose': undefined,\n 'change': undefined,\n 'percentage': percentage,\n 'average': undefined,\n 'baseVolume': baseVolume,\n 'quoteVolume': quoteVolume,\n 'markPrice': this.safeString (ticker, 'mark_price'),\n 'indexPrice': this.safeString (ticker, 'index_price'),\n 'info': ticker,\n }, market);\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"id\": \"1334253759\",\n \"create_time\": \"1626342738\",\n \"create_time_ms\": \"1626342738331.497000\",\n \"currency_pair\": \"BTC_USDT\",\n \"side\": \"sell\",\n \"amount\": \"0.0022\",\n \"price\": \"32452.16\"\n }", "{\n \"id\": \"442288327\",\n \"contract\": \"BTC_USDT\",\n \"create_time\": \"1739814676.707\",\n \"create_time_ms\": \"1739814676.707\",\n \"size\": \"-105\",\n \"price\": \"95594.8\"\n }", "{\n \"id\": 221994511,\n \"time\": 1580311438.618647,\n \"price\": \"9309\",\n \"amount\": \"0.0019\",\n \"type\": \"sell\"\n }", "{\n \"id\": \"2876130500\",\n \"create_time\": \"1645464610\",\n \"create_time_ms\": \"1645464610777.399200\",\n \"currency_pair\": \"DOGE_USDT\",\n \"side\": \"sell\",\n \"role\": \"taker\",\n \"amount\": \"10.97\",\n \"price\": \"0.137384\",\n \"order_id\": \"125924049993\",\n \"fee\": \"0.00301420496\",\n \"fee_currency\": \"USDT\",\n \"point_fee\": \"1.1\",\n \"gt_fee\":\"2.2\"\n }", "{\n \"size\": -5,\n \"order_id\": \"130264979823\",\n \"id\": 26884791,\n \"role\": \"taker\",\n \"create_time\": 1645465199.5472,\n \"contract\": \"DOGE_USDT\",\n \"price\": \"0.136888\"\n }" ], "line_end" => 3988, "line_start" => 3823, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "trade" }, %{ "comment" => nil, "key" => "id", "value" => "id" }, %{ "comment" => nil, "key" => "timestamp", "value" => "timestamp" }, %{ "comment" => nil, "key" => "datetime", "value" => "this.iso8601 (timestamp)" }, %{ "comment" => nil, "key" => "symbol", "value" => "market['symbol']" }, %{ "comment" => nil, "key" => "order", "value" => "orderId" }, %{ "comment" => nil, "key" => "type", "value" => "undefined" }, %{ "comment" => nil, "key" => "side", "value" => "side" }, %{ "comment" => nil, "key" => "takerOrMaker", "value" => "takerOrMaker" }, %{ "comment" => nil, "key" => "price", "value" => "priceString" }, %{ "comment" => nil, "key" => "amount", "value" => "amountString" }, %{ "comment" => nil, "key" => "cost", "value" => "undefined" }, %{ "comment" => nil, "key" => "fee", "value" => "undefined" }, %{ "comment" => nil, "key" => "fees", "value" => "fees" }, %{ "comment" => nil, "key" => "cost", "value" => "feeAmount" }, %{ "comment" => nil, "key" => "currency", "value" => "feeCurrencyCode" } ], "name" => "parseTrade", "signature" => "parseTrade (trade: Dict, market: Market = undefined): Trade", "source" => "parseTrade (trade: Dict, market: Market = undefined): Trade {\n //\n // public\n //\n // spot:\n // {\n // \"id\": \"1334253759\",\n // \"create_time\": \"1626342738\",\n // \"create_time_ms\": \"1626342738331.497000\",\n // \"currency_pair\": \"BTC_USDT\",\n // \"side\": \"sell\",\n // \"amount\": \"0.0022\",\n // \"price\": \"32452.16\"\n // }\n //\n // swap:\n //\n // {\n // \"id\": \"442288327\",\n // \"contract\": \"BTC_USDT\",\n // \"create_time\": \"1739814676.707\",\n // \"create_time_ms\": \"1739814676.707\",\n // \"size\": \"-105\",\n // \"price\": \"95594.8\"\n // }\n //\n //\n // public ws\n //\n // {\n // \"id\": 221994511,\n // \"time\": 1580311438.618647,\n // \"price\": \"9309\",\n // \"amount\": \"0.0019\",\n // \"type\": \"sell\"\n // }\n //\n // spot rest\n //\n // {\n // \"id\": \"2876130500\",\n // \"create_time\": \"1645464610\",\n // \"create_time_ms\": \"1645464610777.399200\",\n // \"currency_pair\": \"DOGE_USDT\",\n // \"side\": \"sell\",\n // \"role\": \"taker\",\n // \"amount\": \"10.97\",\n // \"price\": \"0.137384\",\n // \"order_id\": \"125924049993\",\n // \"fee\": \"0.00301420496\",\n // \"fee_currency\": \"USDT\",\n // \"point_fee\": \"1.1\",\n // \"gt_fee\":\"2.2\"\n // }\n //\n // perpetual swap rest\n //\n // {\n // \"size\": -5,\n // \"order_id\": \"130264979823\",\n // \"id\": 26884791,\n // \"role\": \"taker\",\n // \"create_time\": 1645465199.5472,\n // \"contract\": \"DOGE_USDT\",\n // \"price\": \"0.136888\"\n // }\n //\n // future rest\n //\n // {\n // \"id\": 121234231,\n // \"create_time\": 1514764800.123,\n // \"contract\": \"BTC_USDT\",\n // \"order_id\": \"21893289839\",\n // \"size\": 100,\n // \"price\": \"100.123\",\n // \"role\": \"taker\"\n // }\n //\n // fetchTrades: option\n //\n // {\n // \"size\": -5,\n // \"id\": 25,\n // \"create_time\": 1682378573,\n // \"contract\": \"ETH_USDT-20230526-2000-P\",\n // \"price\": \"209.1\"\n // }\n //\n // fetchMyTrades: option\n //\n // {\n // \"underlying_price\": \"26817.84\",\n // \"size\": -1,\n // \"contract\": \"BTC_USDT-20230602-26500-C\",\n // \"id\": 16,\n // \"role\": \"taker\",\n // \"create_time\": 1685594770,\n // \"order_id\": 2611026125,\n // \"price\": \"333\"\n // }\n //\n const id = this.safeString2 (trade, 'id', 'trade_id');\n let timestamp: Int = undefined;\n let msString = this.safeString (trade, 'create_time_ms');\n if (msString !== undefined) {\n msString = Precise.stringMul (msString, '1000');\n msString = msString.slice (0, 13);\n timestamp = this.parseToInt (msString);\n } else {\n timestamp = this.safeTimestamp2 (trade, 'time', 'create_time');\n }\n const marketId = this.safeString2 (trade, 'currency_pair', 'contract');\n const marketType = ('contract' in trade) ? 'contract' : 'spot';\n market = this.safeMarket (marketId, market, '_', marketType);\n let amountString = this.safeString2 (trade, 'amount', 'size');\n const priceString = this.safeString (trade, 'price');\n const contractSide = Precise.stringLt (amountString, '0') ? 'sell' : 'buy';\n amountString = Precise.stringAbs (amountString);\n const side = this.safeString2 (trade, 'side', 'type', contractSide);\n const orderId = this.safeString (trade, 'order_id');\n const feeAmount = this.safeString (trade, 'fee');\n const gtFee = this.omitZero (this.safeString (trade, 'gt_fee'));\n const pointFee = this.omitZero (this.safeString (trade, 'point_fee'));\n const fees = [];\n if (feeAmount !== undefined) {\n const feeCurrencyId = this.safeString (trade, 'fee_currency');\n let feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId);\n if (feeCurrencyCode === undefined) {\n feeCurrencyCode = this.safeString (market, 'settle');\n }\n fees.push ({\n 'cost': feeAmount,\n 'currency': feeCurrencyCode,\n });\n }\n if (gtFee !== undefined) {\n fees.push ({\n 'cost': gtFee,\n 'currency': 'GT',\n });\n }\n if (pointFee !== undefined) {\n fees.push ({\n 'cost': pointFee,\n 'currency': 'GATEPOINT',\n });\n }\n const takerOrMaker = this.safeString (trade, 'role');\n return this.safeTrade ({\n 'info': trade,\n 'id': id,\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n 'symbol': market['symbol'],\n 'order': orderId,\n 'type': undefined,\n 'side': side,\n 'takerOrMaker': takerOrMaker,\n 'price': priceString,\n 'amount': amountString,\n 'cost': undefined,\n 'fee': undefined,\n 'fees': fees,\n }, market);\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"user_id\": 1486602,\n \"taker_fee\": \"0.002\",\n \"maker_fee\": \"0.002\",\n \"gt_discount\": true,\n \"gt_taker_fee\": \"0.0015\",\n \"gt_maker_fee\": \"0.0015\",\n \"loan_fee\": \"0.18\",\n \"point_type\": \"0\",\n \"futures_taker_fee\": \"0.0005\",\n \"futures_maker_fee\": \"0\"\n }" ], "line_end" => 2466, "line_start" => 2437, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "info" }, %{ "comment" => nil, "key" => "symbol", "value" => "this.safeString (market, 'symbol')" }, %{ "comment" => nil, "key" => "maker", "value" => "this.safeNumber (info, makerKey)" }, %{ "comment" => nil, "key" => "taker", "value" => "this.safeNumber (info, takerKey)" }, %{ "comment" => nil, "key" => "percentage", "value" => "undefined" }, %{ "comment" => nil, "key" => "tierBased", "value" => "undefined" } ], "name" => "parseTradingFee", "signature" => "parseTradingFee (info, market: Market = undefined)", "source" => "parseTradingFee (info, market: Market = undefined) {\n //\n // {\n // \"user_id\": 1486602,\n // \"taker_fee\": \"0.002\",\n // \"maker_fee\": \"0.002\",\n // \"gt_discount\": true,\n // \"gt_taker_fee\": \"0.0015\",\n // \"gt_maker_fee\": \"0.0015\",\n // \"loan_fee\": \"0.18\",\n // \"point_type\": \"0\",\n // \"futures_taker_fee\": \"0.0005\",\n // \"futures_maker_fee\": \"0\"\n // }\n //\n const gtDiscount = this.safeValue (info, 'gt_discount');\n const taker = gtDiscount ? 'gt_taker_fee' : 'taker_fee';\n const maker = gtDiscount ? 'gt_maker_fee' : 'maker_fee';\n const contract = this.safeValue (market, 'contract');\n const takerKey = contract ? 'futures_taker_fee' : taker;\n const makerKey = contract ? 'futures_maker_fee' : maker;\n return {\n 'info': info,\n 'symbol': this.safeString (market, 'symbol'),\n 'maker': this.safeNumber (info, makerKey),\n 'taker': this.safeNumber (info, takerKey),\n 'percentage': undefined,\n 'tierBased': undefined,\n };\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 2435, "line_start" => 2427, "mappings" => [], "name" => "parseTradingFees", "signature" => "parseTradingFees (response)", "source" => "parseTradingFees (response) {\n const result: Dict = {};\n for (let i = 0; i < this.symbols.length; i++) {\n const symbol = this.symbols[i];\n const market = this.market (symbol);\n result[symbol] = this.parseTradingFee (response, market);\n }\n return result;\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"id\": \"d33361395\",\n \"currency\": \"USDT_TRX\",\n \"address\": \"TErdnxenuLtXfnMafLbfappYdHtnXQ5U4z\",\n \"amount\": \"100\",\n \"txid\": \"ae9374de34e558562fe18cbb1bf9ab4d9eb8aa7669d65541c9fa2a532c1474a0\",\n \"timestamp\": \"1626345819\",\n \"status\": \"DONE\",\n \"memo\": \"\"\n }", "{\n \"id\":\"w64413318\",\n \"currency\":\"usdt\",\n \"amount\":\"10150\",\n \"address\":\"0x0ab891497116f7f5532a4c2f4f7b1784488628e1\",\n \"memo\":null,\n \"status\":\"REQUEST\",\n \"chain\":\"eth\",\n \"withdraw_order_id\":\"\",\n \"fee_amount\":\"4.15000000\"\n }", "{\n \"id\": \"210496\",\n \"timestamp\": \"1542000000\",\n \"withdraw_order_id\": \"order_123456\",\n \"currency\": \"USDT\",\n \"address\": \"1HkxtBAMrA3tP5ENnYY2CZortjZvFDH5Cs\",\n \"txid\": \"128988928203223323290\",\n \"block_number\": \"41575382\",\n \"amount\": \"222.61\",\n \"fee\": \"0.01\",\n \"memo\": \"\",\n \"status\": \"DONE\",\n \"chain\": \"TRX\"\n }", "{\n \"id\": \"w13389675\",\n \"currency\": \"USDT\",\n \"amount\": \"50\",\n \"address\": \"TUu2rLFrmzUodiWfYki7QCNtv1akL682p1\",\n \"memo\": null\n }", "{\n \"currency\":\"usdt\",\n \"address\":\"0x01c0A9b7b4CdE774AF0f3E47CB4f1c2CCdBa0806\",\n \"amount\":\"1880\",\n \"chain\":\"eth\"\n }" ], "line_end" => 4249, "line_start" => 4138, "mappings" => [ %{ "comment" => nil, "key" => "info", "value" => "transaction" }, %{ "comment" => nil, "key" => "id", "value" => "id" }, %{ "comment" => nil, "key" => "txid", "value" => "txid" }, %{ "comment" => nil, "key" => "currency", "value" => "code" }, %{ "comment" => nil, "key" => "amount", "value" => "this.parseNumber (amountString)" }, %{ "comment" => nil, "key" => "network", "value" => "this.networkIdToCode (networkId)" }, %{ "comment" => nil, "key" => "address", "value" => "address" }, %{ "comment" => nil, "key" => "addressTo", "value" => "undefined" }, %{ "comment" => nil, "key" => "addressFrom", "value" => "undefined" }, %{ "comment" => nil, "key" => "tag", "value" => "tag" }, %{ "comment" => nil, "key" => "tagTo", "value" => "undefined" }, %{ "comment" => nil, "key" => "tagFrom", "value" => "undefined" }, %{ "comment" => nil, "key" => "status", "value" => "status" }, %{ "comment" => nil, "key" => "type", "value" => "type" }, %{ "comment" => nil, "key" => "timestamp", "value" => "timestamp" }, %{ "comment" => nil, "key" => "datetime", "value" => "this.iso8601 (timestamp)" }, %{ "comment" => nil, "key" => "updated", "value" => "undefined" }, %{ "comment" => nil, "key" => "internal", "value" => "undefined" }, %{ "comment" => nil, "key" => "comment", "value" => "undefined" }, %{ "comment" => nil, "key" => "fee", "value" => "{\n 'currency': code,\n 'cost': this.parseNumber (feeCostString),\n }" } ], "name" => "parseTransaction", "signature" => "parseTransaction (transaction: Dict, currency: Currency = undefined): Transaction", "source" => "parseTransaction (transaction: Dict, currency: Currency = undefined): Transaction {\n //\n // fetchDeposits\n //\n // {\n // \"id\": \"d33361395\",\n // \"currency\": \"USDT_TRX\",\n // \"address\": \"TErdnxenuLtXfnMafLbfappYdHtnXQ5U4z\",\n // \"amount\": \"100\",\n // \"txid\": \"ae9374de34e558562fe18cbb1bf9ab4d9eb8aa7669d65541c9fa2a532c1474a0\",\n // \"timestamp\": \"1626345819\",\n // \"status\": \"DONE\",\n // \"memo\": \"\"\n // }\n //\n // withdraw\n //\n // {\n // \"id\":\"w64413318\",\n // \"currency\":\"usdt\",\n // \"amount\":\"10150\",\n // \"address\":\"0x0ab891497116f7f5532a4c2f4f7b1784488628e1\",\n // \"memo\":null,\n // \"status\":\"REQUEST\",\n // \"chain\":\"eth\",\n // \"withdraw_order_id\":\"\",\n // \"fee_amount\":\"4.15000000\"\n // }\n //\n // fetchWithdrawals\n //\n // {\n // \"id\": \"210496\",\n // \"timestamp\": \"1542000000\",\n // \"withdraw_order_id\": \"order_123456\",\n // \"currency\": \"USDT\",\n // \"address\": \"1HkxtBAMrA3tP5ENnYY2CZortjZvFDH5Cs\",\n // \"txid\": \"128988928203223323290\",\n // \"block_number\": \"41575382\",\n // \"amount\": \"222.61\",\n // \"fee\": \"0.01\",\n // \"memo\": \"\",\n // \"status\": \"DONE\",\n // \"chain\": \"TRX\"\n // }\n //\n // {\n // \"id\": \"w13389675\",\n // \"currency\": \"USDT\",\n // \"amount\": \"50\",\n // \"address\": \"TUu2rLFrmzUodiWfYki7QCNtv1akL682p1\",\n // \"memo\": null\n // }\n //\n // {\n // \"currency\":\"usdt\",\n // \"address\":\"0x01c0A9b7b4CdE774AF0f3E47CB4f1c2CCdBa0806\",\n // \"amount\":\"1880\",\n // \"chain\":\"eth\"\n // }\n //\n const id = this.safeString (transaction, 'id');\n let type = undefined;\n let amountString = this.safeString (transaction, 'amount');\n if (id !== undefined) {\n if (id[0] === 'b') {\n // GateCode handling\n type = Precise.stringGt (amountString, '0') ? 'deposit' : 'withdrawal';\n amountString = Precise.stringAbs (amountString);\n } else {\n type = this.parseTransactionType (id[0]);\n }\n }\n const feeCostString = this.safeString2 (transaction, 'fee', 'fee_amount');\n if (type === 'withdrawal') {\n amountString = Precise.stringSub (amountString, feeCostString);\n }\n const networkId = this.safeStringUpper (transaction, 'chain');\n const currencyId = this.safeString (transaction, 'currency');\n const code = this.safeCurrencyCode (currencyId);\n const txid = this.safeString (transaction, 'txid');\n const rawStatus = this.safeString (transaction, 'status');\n const status = this.parseTransactionStatus (rawStatus);\n const address = this.safeString (transaction, 'address');\n const tag = this.safeString (transaction, 'memo');\n const timestamp = this.safeTimestamp (transaction, 'timestamp');\n return {\n 'info': transaction,\n 'id': id,\n 'txid': txid,\n 'currency': code,\n 'amount': this.parseNumber (amountString),\n 'network': this.networkIdToCode (networkId),\n 'address': address,\n 'addressTo': undefined,\n 'addressFrom': undefined,\n 'tag': tag,\n 'tagTo': undefined,\n 'tagFrom': undefined,\n 'status': status,\n 'type': type,\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n 'updated': undefined,\n 'internal': undefined,\n 'comment': undefined,\n 'fee': {\n 'currency': code,\n 'cost': this.parseNumber (feeCostString),\n },\n } as Transaction;\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 4128, "line_start" => 4111, "mappings" => [], "name" => "parseTransactionStatus", "signature" => "parseTransactionStatus (status: Str)", "source" => "parseTransactionStatus (status: Str) {\n const statuses: Dict = {\n 'PEND': 'pending',\n 'REQUEST': 'pending',\n 'DMOVE': 'pending',\n 'MANUAL': 'pending',\n 'VERIFY': 'pending',\n 'PROCES': 'pending',\n 'EXTPEND': 'pending',\n 'SPLITPEND': 'pending',\n 'CANCEL': 'canceled',\n 'FAIL': 'failed',\n 'INVALID': 'failed',\n 'DONE': 'ok',\n 'BCODE': 'ok', // GateCode withdrawal\n };\n return this.safeString (statuses, status, status);\n }" }, %{ "comment" => nil, "examples" => [], "line_end" => 4136, "line_start" => 4130, "mappings" => [], "name" => "parseTransactionType", "signature" => "parseTransactionType (type)", "source" => "parseTransactionType (type) {\n const types: Dict = {\n 'd': 'deposit',\n 'w': 'withdrawal',\n };\n return this.safeString (types, type, type);\n }" }, %{ "comment" => nil, "examples" => [ "{\n \"currency\": \"BTC\",\n \"from\": \"spot\",\n \"to\": \"margin\",\n \"amount\": \"1\",\n \"currency_pair\": \"BTC_USDT\"\n }" ], "line_end" => 5929, "line_start" => 5908, "mappings" => [ %{ "comment" => nil, "key" => "id", "value" => "this.safeString (transfer, 'tx_id')" }, %{ "comment" => nil, "key" => "timestamp", "value" => "undefined" }, %{ "comment" => nil, "key" => "datetime", "value" => "undefined" }, %{ "comment" => nil, "key" => "currency", "value" => "this.safeCurrencyCode (undefined, currency)" }, %{ "comment" => nil, "key" => "amount", "value" => "undefined" }, %{ "comment" => nil, "key" => "fromAccount", "value" => "undefined" }, %{ "comment" => nil, "key" => "toAccount", "value" => "undefined" }, %{ "comment" => nil, "key" => "status", "value" => "undefined" }, %{ "comment" => nil, "key" => "info", "value" => "transfer" } ], "name" => "parseTransfer", "signature" => "parseTransfer (transfer: Dict, currency: Currency = undefined): TransferEntry", "source" => "parseTransfer (transfer: Dict, currency: Currency = undefined): TransferEntry {\n //\n // {\n // \"currency\": \"BTC\",\n // \"from\": \"spot\",\n // \"to\": \"margin\",\n // \"amount\": \"1\",\n // \"currency_pair\": \"BTC_USDT\"\n // }\n //\n return {\n 'id': this.safeString (transfer, 'tx_id'),\n 'timestamp': undefined,\n 'datetime': undefined,\n 'currency': this.safeCurrencyCode (undefined, currency),\n 'amount': undefined,\n 'fromAccount': undefined,\n 'toAccount': undefined,\n 'status': undefined,\n 'info': transfer,\n };\n }" } ], path_prefix: "", pro: true, quote_json_numbers: nil, rate_limits: %{ interval_ms: 50, period: 1000, requests: 20, rolling_window_size: 60000 }, raw_endpoints: %{ private: [], public: [] }, required_credentials: %{ api_key: true, password: false, secret: true, uid: false }, requires_eddsa: false, response_error: %{ code_field: "label", field: "label", message_field: "message", success_values: nil, type: :error_present }, signing: %{ api_key_header: "KEY", confidence: :high, pattern: :hmac_sha512_gate, signature_header: "SIGN", timestamp_header: "Timestamp" }, spec_format_version: 2, status: %{ "eta" => nil, "status" => "ok", "updated" => nil, "url" => nil }, symbol_format: nil, symbol_formats: %{ future: %{ base: "ORDI", base_id: "ORDI", case: :upper, contract: true, contract_size: 0.1, expiry: 1773388800000, expiry_datetime: "2026-03-13T08:00:00.000Z", id: "ORDI_USDT_20260313", inverse: false, limits: %{ "amount" => %{ "max" => 1000000, "min" => 1 }, "cost" => %{}, "leverage" => %{ "max" => 20, "min" => 1 }, "price" => %{ "max" => 3.6495, "min" => 1.2165 } }, linear: true, maker: 0.0002, precision: %{ "amount" => 1, "price" => 0.001 }, quote: "USDT", quote_id: "USDT", separator: "_", settle: "USDT", settle_id: "usdt", symbol: "ORDI/USDT:USDT-260313", taker: 0.0005 }, option: %{ base: "BTC", base_id: "BTC", case: :upper, contract: true, contract_size: 1, expiry: 1773302400000, expiry_datetime: "2026-03-12T08:00:00.000Z", id: "BTC_USDT-20260312-74000-P", inverse: false, limits: %{ "amount" => %{ "max" => 10000, "min" => 1 }, "cost" => %{}, "leverage" => %{}, "price" => %{ "max" => 4153.685, "min" => 3070.115 } }, linear: true, maker: 0.0003, precision: %{ "amount" => 1, "price" => 1 }, quote: "USDT", quote_id: "USDT", separator: "-", settle: "USDT", settle_id: "USDT", symbol: "BTC/USDT:USDT-260312-74000-P", taker: 0.0003 }, precision_mode: 4, sample_limits: %{ "amount" => %{ "min" => 0.01 }, "cost" => %{ "min" => 3 }, "price" => %{} }, sample_precision: %{ "amount" => 0.01, "price" => 1.0e-5 }, spot: %{ base: "ALEPH", base_id: "ALEPH", case: :upper, contract: false, id: "ALEPH_USDT", limits: %{ "amount" => %{ "min" => 0.01 }, "cost" => %{ "min" => 3 }, "leverage" => %{ "max" => 1, "min" => 1 }, "price" => %{} }, maker: 0.002, precision: %{ "amount" => 0.01, "price" => 1.0e-5 }, quote: "USDT", quote_id: "USDT", separator: "_", symbol: "ALEPH/USDT", taker: 0.002 }, swap: %{ base: "BABA", base_id: "BABA", case: :upper, contract: true, contract_size: 0.01, id: "BABA_USDT", inverse: false, limits: %{ "amount" => %{ "max" => 32000, "min" => 1 }, "cost" => %{}, "leverage" => %{ "max" => 25, "min" => 1 }, "price" => %{ "max" => 148.797, "min" => 121.743 } }, linear: true, maker: 0.0002, precision: %{ "amount" => 1, "price" => 0.01 }, quote: "USDT", quote_id: "USDT", separator: "_", settle: "USDT", settle_id: "usdt", symbol: "BABA/USDT:USDT", taker: 0.0005 } }, symbol_patterns: %{ future: %{ case: :upper, component_order: [ :base, :quote, :date ], date_format: :yyyymmdd, pattern: :future_yyyymmdd, prefix: nil, separator: "_", suffix: nil }, option: %{ case: :upper, component_order: [ :base, :date, :strike, :type ], date_format: :yyyymmdd, pattern: :option_unknown, prefix: nil, separator: "-", suffix: nil }, spot: %{ case: :upper, component_order: nil, date_format: nil, pattern: :underscore_upper, prefix: nil, separator: "_", suffix: nil }, swap: %{ case: :upper, component_order: nil, date_format: nil, pattern: :implicit, prefix: nil, separator: "_", suffix: nil } }, timeframes: %{ "10s" => "10s", "15m" => "15m", "1d" => "1d", "1h" => "1h", "1m" => "1m", "1w" => "7d", "2h" => "2h", "30m" => "30m", "4h" => "4h", "5m" => "5m", "7d" => "7d", "8h" => "8h" }, url_strategy: %{ detected_from: "url_structure", note: "market_type_in_path", pattern: :nested_market_type_urls, prefix: nil }, urls: %{ api: "https://api.gateio.ws/api/v4", api_sections: nil, doc: "https://www.gate.com/docs/developers/apiv4/en/", other: nil, sandbox: %{ "private" => %{ "account" => "https://api-testnet.gateapi.io/api/v4", "delivery" => "https://api-testnet.gateapi.io/api/v4", "futures" => "https://api-testnet.gateapi.io/api/v4", "margin" => "https://api-testnet.gateapi.io/api/v4", "options" => "https://api-testnet.gateapi.io/api/v4", "spot" => "https://api-testnet.gateapi.io/api/v4", "sub_accounts" => "https://api-testnet.gateapi.io/api/v4", "wallet" => "https://api-testnet.gateapi.io/api/v4" }, "public" => %{ "account" => "https://api-testnet.gateapi.io/api/v4", "delivery" => "https://api-testnet.gateapi.io/api/v4", "futures" => "https://api-testnet.gateapi.io/api/v4", "margin" => "https://api-testnet.gateapi.io/api/v4", "options" => "https://api-testnet.gateapi.io/api/v4", "spot" => "https://api-testnet.gateapi.io/api/v4", "sub_accounts" => "https://api-testnet.gateapi.io/api/v4", "wallet" => "https://api-testnet.gateapi.io/api/v4" } }, www: "https://gate.com" }, version: "v4", ws: %{ channel_templates: %{ watch_balance: %{ market_id_format: :native, params: [], pattern: :event_based }, watch_bids_asks: %{ market_id_format: :native, params: [], pattern: :event_based }, watch_my_liquidations: %{ market_id_format: :native, params: [ %{ "default" => nil, "name" => "limit" } ], pattern: :event_based }, watch_my_liquidations_for_symbols: %{ market_id_format: :native, params: [ %{ "default" => nil, "name" => "limit" } ], pattern: :event_based }, watch_my_trades: %{ market_id_format: :native, params: [ %{ "default" => nil, "name" => "limit" } ], pattern: :event_based }, watch_ohlcv: %{ market_id_format: :native, params: [ %{ "default" => nil, "name" => "interval" }, %{ "default" => nil, "name" => "limit" } ], pattern: :event_based }, watch_order_book: %{ channel_name: "100ms", market_id_format: :native, params: [ %{ "default" => "100ms", "name" => "interval" }, %{ "default" => nil, "name" => "limit" } ], pattern: :event_based }, watch_orders: %{ market_id_format: :native, params: [ %{ "default" => nil, "name" => "limit" } ], pattern: :event_based }, watch_positions: %{ market_id_format: :native, params: [ %{ "default" => nil, "name" => "limit" } ], pattern: :event_based }, watch_ticker: %{ market_id_format: :native, params: [], pattern: :event_based }, watch_tickers: %{ market_id_format: :native, params: [], pattern: :event_based }, watch_trades: %{ market_id_format: :native, params: [ %{ "default" => nil, "name" => "limit" } ], pattern: :event_based }, watch_trades_for_symbols: %{ market_id_format: :native, params: [ %{ "default" => nil, "name" => "limit" } ], pattern: :event_based } }, has: %{ watch_balance: true, watch_bids_asks: true, watch_liquidations: false, watch_liquidations_for_symbols: false, watch_my_liquidations: true, watch_my_liquidations_for_symbols: true, watch_my_trades: true, watch_ohlcv: true, watch_ohlcv_for_symbols: nil, watch_order_book: true, watch_order_book_for_symbols: nil, watch_orders: true, watch_orders_for_symbols: nil, watch_position: nil, watch_positions: true, watch_status: nil, watch_ticker: true, watch_tickers: true, watch_trades: true, watch_trades_for_symbols: true }, message_patterns: [ %{ args_field: "channel", format: :event, id_field: "id", keys: [ "auth", "channel", "event", "id", "payload", "time" ], kind_field: "event", kind_value: "subscribe", sources: [ :send, :watch ] }, %{ args_field: "channel", format: :event, id_field: "id", keys: [ "auth", "channel", "event", "id", "time" ], kind_field: "event", kind_value: "subscribe", sources: [ :send, :watch ] }, %{ args_field: "channel", format: :event, id_field: "id", keys: [ "channel", "event", "id", "payload", "time" ], kind_field: "event", kind_value: "subscribe", sources: [ :send, :watch, :watch_multiple ] } ], options: %{ "watchBalance" => %{ "settle" => "usdt", "spot" => "spot.balances" }, "watchOrderBook" => %{ "checksum" => true, "interval" => "100ms", "snapshotDelay" => 10, "snapshotMaxRetries" => 3 }, "watchOrderBookSubscriptions" => %{}, "watchPositions" => %{ "awaitPositionsSnapshot" => true, "fetchPositionsSnapshot" => true }, "watchTicker" => %{ "name" => "tickers" }, "watchTickerSubscriptions" => %{}, "watchTradesSubscriptions" => %{} }, subscription_config: %{ args_field: "payload", args_format: :object_list, market_id_format: :native, op_field: "event" }, subscription_pattern: :event_subscribe, urls: "wss://ws.gate.io/v4", watch_methods: [ "watchBalance", "watchBidsAsks", "watchMyLiquidations", "watchMyLiquidationsForSymbols", "watchMyTrades", "watchOHLCV", "watchOrderBook", "watchOrders", "watchPositions", "watchTicker", "watchTickers", "watchTrades", "watchTradesForSymbols" ] } }