I used your code : def signalgenerator(df): if df is None or len(df) < 2: return ''…
Jump to turn (6)
- 1I used your code : def signalgenerator(df): if df is None or len(df) buyqty and
- 2Tell me shortly will this code give me signal to sell ?
- 3But it giving me only buy signal !!!
- 4Why it giving me only buy signal
- 5But it too giving only buy signal !!!!
- 6This code too giving me only buy signal !!! Give me code which will give me sign
- User
I used your code : def signal_generator(df): if df is None or len(df) < 2: return ''
codesignal = [] # Retrieve depth data threshold = 0.16 depth_data = client.depth(symbol=symbol) bid_depth = depth_data['bids'] ask_depth = depth_data['asks'] buy_price = float(bid_depth[0][0]) if bid_depth else 0.0 sell_price = float(ask_depth[0][0]) if ask_depth else 0.0 mark_price_data = client.ticker_price(symbol=symbol) mark_price = float(mark_price_data['price']) if 'price' in mark_price_data else 0.0 buy_qty = sum(float(bid[1]) for bid in bid_depth) sell_qty = sum(float(ask[1]) for ask in ask_depth) sell_qty_ratio = sell_qty / buy_qty buy_qty_ratio = buy_qty / sell_qty if sell_qty > buy_qty and sell_qty > (buy_qty * (1 + threshold)): signal.append('sell') elif buy_qty > sell_qty and buy_qty > (sell_qty * (1 + threshold)): signal.append('buy') else: signal.append('') # Append an empty string when no signal conditions met return signal