I used your code: def signalgenerator(df): if df is None or len(df) < 2: return ''…
Jump to turn (8)
- 1I used your code: def signalgenerator(df): if df is None or len(df) buyqty and (
- 2Give me code which will give me signal to buy sell or empty
- 3Where is else which will give me empty signals ?
- 4It need to be signal.append
- 5With else
- 6Will it give me signal to sell ?
- 7I used your code, but it gave me only signal to buy I was need to take a loss !
- 8I need to code which will give me signals to buy sell and empty
- User
I used your 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 / 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('') return signal