I used your code: def signalgenerator(df): if df is None or len(df) < 2: return ''…
- User
I used your code: def signal_generator(df): if df is None or len(df) < 2: return ''
codesignal = [] # Retrieve depth data 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 buy_qty > sell_qty: signal.append('buy') elif sell_qty > buy_qty: signal.append('sell') else: signal.append('') return signalBut it giving me only sell signal
- Assistant
The code you provided only checks if the total quantity of buy orders is greater than the total quantity of sell orders. If it is, it appends 'buy' to the signal list. If the sell quantity is greater, it appends 'sell' to the signal list. Otherwise, it appends an empty string.
If you are only seeing 'sell' in the output, it means that the sell quantity is greater than the buy quantity. This could be due to the specific data you are using for the depth and ticker price.
Make sure you have valid and up-to-date data for the depth and ticker price, and check if there are any issues with the data retrieval from the client.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.