1

I got an interest about ccxt these days, especially futures trade

i tried to make a logic and it was fun

but I've got a problem to "Setting amount"

def binance_long():
    order = binance.create_market_buy_order(
        symbol = symbol,
        amount=0.001
    )

def binance_short():
    order = binance.create_market_sell_order(
        symbol=symbol,
        amount=0.001
    )

this is my buy/sell function

In that codes, I want to put my whole usdt dollars

but i don't know how to change amount

because that 0.001 position is based on btc not usdt

how can i put my whole usdt dollars in my position?

ex)729.8 usdt -> put that whole thing

also using leverage too (1~50)

and also how can i close my position with my whole usdt?

because In order, I understood that I had to write this function and then use this function.

  1. binance_long() <- buy long position
  2. binance_short() <- close long position

like this

schedule.every().monday.at("00:00:00").do(binance_long)

schedule.every().monday.at("00:00:30").do(binance_short)

To Open position and Close position in Long position

  • I solved amount problem but i don't know where am i have to multiply the leverage in this logic. this is my amount function. `def cal_amount(usdt_balance, cur_price): #usde based portion = 1 #100% in my wallet usdt_trade = usdt_balance * portion amount = math.floor((usdt_trade * 1000000)/cur_price) / 1000000 return amount ` – Byungheon Lee Feb 15 '22 at 16:24
  • Also what if market price changes meanwhile? – dorien Apr 10 '23 at 09:12

0 Answers0