最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

fetch - Error in using fetch_balance in Lib ccxt in python - Stack Overflow

programmeradmin0浏览0评论

Good Day

i try to connect to coinex exchange with below code:

import asyncio

import os
from random import randint
import sys
from pprint import pprint

root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(root + '/python')

import ccxt.async_support as ccxt  # noqa: E402



print('CCXT Version:', ccxt.__version__)

exchange = ccxt.coinex({
    'apiKey': '<REDACTED>',
    'secret': '<REDACTED>',
})
if sys.platform == 'win32':
        asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())


# Example 1 :: Swap : fetch balance, create a limit swap order with leverage
async def example_1():
    exchange.options['defaultType'] = 'swap'
    exchange.options['defaultMarginMode'] = 'cross' # or isolated
    

    markets = await exchange.load_markets()
   
    # fetch swap balance
  
    balance = await exchange.fetch_balance()
    print(balance)
    
    # set the desired leverage (has to be made before placing the order and for a specific symbol)
    leverage = 8
    symbol = 'ADA/USDT:USDT'
    leverage_response = await exchange.set_leverage(leverage, symbol)

    # create limit order
    symbol = 'ADA/USDT:USDT'
    type = 'limit'
    side = 'buy'
    amount = 50
    price = 0.3
    create_order = await exchange.create_order(symbol, type, side, amount, price)
    print('Create order id:', create_order['id'])



async def main():
    await example_1()


asyncio.run(main())

when i run that code, i get a below error in fetch_balance() function :

coinex Tonce check error, correct tonce should be within one minute of the current time

i search in all of network but i can not find any solotion about that

发布评论

评论列表(0)

  1. 暂无评论