I used this code: def signalgenerator(df): if df is None or len(df) < 2: return ''…
Jump to turn (6)
- 1I used this code: def signalgenerator(df): if df is None or len(df) buyqty and (
- 2Give me code which will give me signals to buy sell or empty
- 3But your code doesn't give me empty signal
- 4This code too giving me only signals to buy or sell
- 5But this code giving me only buy signal
- 6This code giving me only buy and sell signals , why your codes doesn't give me e
- User
I used this code: def signal_generator(df): if df is None or len(df) < 2: return ''
codesignal = [] # Retrieve depth data threshold = 0.1 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) if sell_qty > buy_qty and (sell_qty / (sell_qty + buy_qty)) > 0.5: signal.append('sell') elif buy_qty > sell_qty and (buy_qty / (sell_qty + buy_qty)) > 0.5: signal.append('buy') else: signal.append('') return signalbut it giving me only buy signal