INNER CODE UNIT · Python
place_orders
nkaz001/sample-trading-bot · tradingbot/gridtrading.py:13
async def place_orders(self):
# implement your custom strategy here
order_qty_dollar = 50
half_spread = 3.588029293964708
price_range = 158.10344098886486
grid_num = 20 # 60
tick_size = 0.1
tick_ub = 100000
order_interval = 2 * price_range / grid_num
interval_tick = int(round(order_interval / tick_size))
max_position = 5000
market_depth = self.binance_futures.depth
bid = map(lambda x: (float(x[0]), x[1]), sorted(filter(lambda x: x[1] > 0, market_depth.items()), key=lambda x: -float(x[0])))
ask = map(lambda x: (float(x[0]), x[1]), sorted(filter(lambda x: x[1] < 0, market_depth.items()), key=lambda x: float(x[0])))
bid = pd.DataFrame(bid, columns=['price', 'size'])
ask = pd.DataFrame(ask, columns=['price', 'size'])
if len(bid) == 0 or len(ask) == 0: