Skip to content

Commit

Permalink
round pos size to qty_step
Browse files Browse the repository at this point in the history
  • Loading branch information
enarjord authored Dec 5, 2021
1 parent 9eee8c6 commit e2f0516
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bybit.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import traceback

from pure_funcs import ts_to_date, sort_dict_keys, date_to_ts
from njit_funcs import round_
from procedures import print_async_exception, print_, utc_ms
from passivbot import Bot

Expand Down Expand Up @@ -195,10 +196,10 @@ async def fetch_position(self) -> dict:
else:
raise Exception('unknown market type')

position['long'] = {'size': float(long_pos['size']),
position['long'] = {'size': round_(float(long_pos['size']), self.qty_step),
'price': float(long_pos['entry_price']),
'liquidation_price': float(long_pos['liq_price'])}
position['shrt'] = {'size': -float(shrt_pos['size']),
position['shrt'] = {'size': -round_(float(shrt_pos['size']), self.qty_step),
'price': float(shrt_pos['entry_price']),
'liquidation_price': float(shrt_pos['liq_price'])}
return position
Expand Down Expand Up @@ -520,10 +521,10 @@ def standardize_user_stream_event(self, event: Union[List[Dict], Dict]) -> Union
if elm['symbol'] == self.symbol:
standardized = {}
if elm['side'] == 'Buy':
standardized['long_psize'] = float(elm['size'])
standardized['long_psize'] = round_(float(elm['size']), self.qty_step)
standardized['long_pprice'] = float(elm['entry_price'])
elif elm['side'] == 'Sell':
standardized['shrt_psize'] = -abs(float(elm['size']))
standardized['shrt_psize'] = -round_(abs(float(elm['size'])), self.qty_step)
standardized['shrt_pprice'] = float(elm['entry_price'])

events.append(standardized)
Expand Down

0 comments on commit e2f0516

Please sign in to comment.