ccxt / ccxt

A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading API with support for more than 100 bitcoin/altcoin exchanges
https://docs.ccxt.com
MIT License
32.53k stars 7.47k forks source link

Bitget futures fetch balance exception: bitget future does not have a value in mapping. #13901

Closed teslatrader closed 2 years ago

teslatrader commented 2 years ago

Hi there. Got some bugs when was trying to fetch futures balance or futures tickets on Bitget (spot section works fine). Here are the details:

SOURCE CODE:

import ccxt
from pprint import pprint

api = ''
secret = ''

exchange = ccxt.bitget({
    "apiKey":api,
    "secret":secret,
    "options": {'defaultType': 'future', 'adjustForTimeDifference' : True},
    "timeout": 60000,
    "enableRateLimit": True,
})

exchange.verbose = True

try:
    balance = exchange.fetch_balance()
    pprint(balance)    

except Exception as e:
    print(f'Exception: \n{e}')

OUTPUT

fetch Request: bitget GET https://api.bitget.com/api/spot/v1/public/currencies RequestHeaders: {'User-Agent': 'python-requests/2.25.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} RequestBody: None

fetch Response: bitget GET https://api.bitget.com/api/spot/v1/public/currencies 200 ResponseHeaders: {'Date': 'Thu, 16 Jun 2022 18:04:25 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Vary': 'Origin, Access-Control-Request-Method, Access-Control-Request-Headers', 'X-Request-ID': 'e9606d028f32478a8629eb44c420fb58', 'Set-Cookie': 'locale=en-US; Max-Age=604800; Expires=Thu, 23-Jun-2022 18:04:25 GMT; Path=/', 'X-Content-Type-Options': 'nosniff, nosniff', 'X-XSS-Protection': '1; mode=block, 1; mode=block', 'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Frame-Options': 'DENY, SAMEORIGIN', 'Content-Encoding': 'gzip', 'Strict-Transport-Security': 'max-age=15768000;includeSubDomains;preload', 'CF-Cache-Status': 'DYNAMIC', 'Expect-CT': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'Server': 'cloudflare', 'CF-RAY': '71c577bf2d069d8c-DME'} ResponseBody: {"code":"00000","msg":"success","requestTime":1655402665009,"data":[{"coinId":"350","coinName":"BEND","transfer":"false","chains":[{"chain":"ERC20","needTag":"false","withdrawable":"true","rechargeable":"true","withdrawFee":"5581.25","depositConfirm":"12","withdrawConfirm":"12","minDepositAmount":"10","minWithdrawAmount":"350","browserUrl":"https://etherscan.io/tx/"}]},

// cut off verbose log //

fetch Request: bitget GET https://api.bitget.com/api/mix/v1/market/contracts?productType=dmcbl RequestHeaders: {'User-Agent': 'python-requests/2.25.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} RequestBody: None

fetch Response: bitget GET https://api.bitget.com/api/mix/v1/market/contracts?productType=dmcbl 200 ResponseHeaders: {'Date': 'Thu, 16 Jun 2022 18:04:26 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Vary': 'Origin, Access-Control-Request-Method, Access-Control-Request-Headers', 'X-Request-ID': '3ae424f87e9f46918adef9b46d9084e4', 'Set-Cookie': 'locale=en-US; Max-Age=604800; Expires=Thu, 23-Jun-2022 18:04:26 GMT; Path=/', 'X-Content-Type-Options': 'nosniff, nosniff', 'X-XSS-Protection': '1; mode=block, 1; mode=block', 'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Frame-Options': 'DENY, SAMEORIGIN', 'Content-Encoding': 'gzip', 'Strict-Transport-Security': 'max-age=15768000;includeSubDomains;preload', 'CF-Cache-Status': 'DYNAMIC', 'Expect-CT': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'Server': 'cloudflare', 'CF-RAY': '71c577c63b529d8c-DME'} ResponseBody: {"code":"00000","msg":"success","requestTime":1655402666082,"data":[{"symbol":"BTCUSD_DMCBL","makerFeeRate":"0.0002","takerFeeRate":"0.0006","feeRateUpRatio":"0.005","openCostUpRatio":"0.01","quoteCoin":"USD","baseCoin":"BTC","buyLimitPriceRatio":"0.01","sellLimitPriceRatio":"0.01","supportMarginCoins":["BTC","ETH","USDC","XRP","BGB"],"minTradeNum":"0.001","priceEndStep":"5","volumePlace":"3","pricePlace":"1"},{"symbol":"ETHUSD_DMCBL","makerFeeRate":"0.0002","takerFeeRate":"0.0006","feeRateUpRatio":"0.005","openCostUpRatio":"0.01","quoteCoin":"USD","baseCoin":"ETH","buyLimitPriceRatio":"0.01","sellLimitPriceRatio":"0.01","supportMarginCoins":["ETH","BTC","USDC","XRP","BGB"],"minTradeNum":"0.1","priceEndStep":"1","volumePlace":"1","pricePlace":"2"},{"symbol":"XRPUSD_DMCBL","makerFeeRate":"0.0002","takerFeeRate":"0.0006","feeRateUpRatio":"0.005","openCostUpRatio":"0.01","quoteCoin":"USD","baseCoin":"XRP","buyLimitPriceRatio":"0.02","sellLimitPriceRatio":"0.02","supportMarginCoins":["XRP","BTC","ETH","USDC","BGB"],"minTradeNum":"1","priceEndStep":"1","volumePlace":"0","pricePlace":"4"},{"symbol":"EOSUSD_DMCBL","makerFeeRate":"0.0002","takerFeeRate":"0.0006","feeRateUpRatio":"0.005","openCostUpRatio":"0.01","quoteCoin":"USD","baseCoin":"EOS","buyLimitPriceRatio":"0.02","sellLimitPriceRatio":"0.02","supportMarginCoins":["EOS","BTC","ETH","USDC","XRP","BGB"],"minTradeNum":"1","priceEndStep":"1","volumePlace":"0","pricePlace":"3"},{"symbol":"BCHUSD_DMCBL","makerFeeRate":"0.0002","takerFeeRate":"0.0006","feeRateUpRatio":"0.005","openCostUpRatio":"0.01","quoteCoin":"USD","baseCoin":"BCH","buyLimitPriceRatio":"0.02","sellLimitPriceRatio":"0.02","supportMarginCoins":["BCH","BTC","ETH","USDC","XRP","BGB"],"minTradeNum":"0.01","priceEndStep":"1","volumePlace":"2","pricePlace":"2"},{"symbol":"LTCUSD_DMCBL","makerFeeRate":"0.0002","takerFeeRate":"0.0006","feeRateUpRatio":"0.005","openCostUpRatio":"0.01","quoteCoin":"USD","baseCoin":"LTC","buyLimitPriceRatio":"0.02","sellLimitPriceRatio":"0.02","supportMarginCoins":["LTC","BTC","ETH","USDC","XRP","BGB"],"minTradeNum":"0.1","priceEndStep":"1","volumePlace":"1","pricePlace":"2"},{"symbol":"UNIUSD_DMCBL","makerFeeRate":"0.0002","takerFeeRate":"0.0006","feeRateUpRatio":"0.005","openCostUpRatio":"0.01","quoteCoin":"USD","baseCoin":"UNI","buyLimitPriceRatio":"0.02","sellLimitPriceRatio":"0.02","supportMarginCoins":["UNI","BTC","ETH","XRP","USDC","BGB"],"minTradeNum":"1","priceEndStep":"1","volumePlace":"0","pricePlace":"3"},{"symbol":"LINKUSD_DMCBL","makerFeeRate":"0.0002","takerFeeRate":"0.0006","feeRateUpRatio":"0.005","openCostUpRatio":"0.01","quoteCoin":"USD","baseCoin":"LINK","buyLimitPriceRatio":"0.02","sellLimitPriceRatio":"0.02","supportMarginCoins":["LINK","BTC","ETH","XRP","USDC","BGB"],"minTradeNum":"1","priceEndStep":"1","volumePlace":"0","pricePlace":"3"}]}
Exception: 
bitget future does not have a value in mapping

Thanks in advance!

samgermain commented 2 years ago

Use 'defaultType': 'swap' instead.

teslatrader commented 2 years ago

Thanks, will try and let you know if it works for me.

samgermain commented 2 years ago

@teslatrader I'm going to close this issue, feel free to reopen it if you have any more questions