无法从ccxt获取币安期货数据

问题描述 投票:0回答:2

我需要从币安获取资金利率历史数据,但即使我输入:

它也只显示现货市场:
binance = ccxt.binance({'option': {'defaultType': 'future'}})

binance.fetch_markets()

如何修复?

binance binance-api-client ccxt
2个回答
1
投票

希望这有帮助:

import ccxt

exchange = ccxt.binance()

exchange.options = {'defaultType': 'future',
                    'adjustForTimeDifference': True}

symbol = 'BTC/USDT'
funding = exchange.fetchFundingRate(symbol)
print(funding)

0
投票

这就是我们使用 ccxt 获取交易所信息的方式

用您的替换 API 密钥和密码

import ccxt from 'ccxt';

const exchangeClass = ccxt['binanceusdm'];
    const exchange = new exchangeClass({
        'apiKey': "apiKey",
        'secret': "secret",
        'options': {
            'defaultType': 'future',
        }
    });
    // console.log(symbol, type, side, quantity,  price,  param ,"spam" )
    
    exchange.setSandboxMode(false)
    
    //get exchange information
    const exchangeInfo = await exchange.fetchMarkets();
© www.soinside.com 2019 - 2024. All rights reserved.