0

I'm using bybit-api to create a conditional order but don't know how do I calculate quantity. Is it based on leveraged amount or original?

for example

I have balance of 50 USDT and want to use 100% per trade with following conditions.

  1. BTC at price 44,089.50 with 50x leverage.
  2. SHIB at price 0.030810 with 50x leverage.

How do I calculate the qty parameter?

https://bybit-exchange.github.io/docs/linear/#t-placecond

Rohit
  • 1
  • 2

2 Answers2

0

I trade Bitcoin through USDT Perpetuals (BTCUSDT). I've setup my own python API and created my own function to calculate quantity for cross margin:

def order_quantity(self, price:float, currency:str='USDT', leverage:float=50.0):
    margin = self.get_wallet_balance(currency)
    instrument = Instrument(self.query_instrument()[0], 'bybit')
    if not price: # Market orders
         last_trade = self.ws_get_last_trade() # private function to get last trade
         lastprice = float(last_trade[-1]['price'])
    else: # Limit orders
         lastprice = price
    


    totalbtc = float(margin[currency]['available_balance']) * (1 - instrument.maker_fee * leverage)
    rawbtc = totalbtc / lastprice 
    btc = math.floor(rawbtc / instrument.lot_size) * instrument.lot_size

    return min(btc,instrument.max_lot_size) 
overdrive1x
  • 1
  • 1
  • 1
0

It is based on the leverage amount.
Your quantity should be :
qty = 50 USDT * 50 (leverage) / 44089 (BTC price) = 0.0567 BTC

G.Lebret
  • 2,826
  • 2
  • 16
  • 27