You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I have an issue or 2. Please, if someone could look into this for me. Not a Python Savvy here.
Trades.txt is recording everything twice
When an order is sent, it records the buy/sell price at the price the order is sent but by the time the order is executed by binance, the price is different. for example: lets take SOL. The bot sends the order for 2 SOL for 65.476 and records the coin buy with bouth at price in coins.json and trades.txt at 65.476. However, by the time the trade was received and executed by binance, it was actually purchased at 66.774 which actually is a problem because bot is thinking it was bought at 65.476 and calculates the take profit percentage at recorded price which is not the actual price at which the order was actually exacuted
The text was updated successfully, but these errors were encountered:
`def update_portfolio(orders):
for coin in orders:
if orders[coin]['status'] == 'FILLED' and float(orders[coin]['executedQty']) > 0:
buy_price = float(orders[coin]['cummulativeQuoteQty']) / float(orders[coin]['executedQty'])
else:
buy_price = 0 # En caso de que no se ejecute ninguna parte de la orden
volume = float(orders[coin]['executedQty'])
coins_bought[coin] = {
'symbol': orders[coin]['symbol'],
'orderid': orders[coin]['orderId'],
'timestamp': orders[coin]['time'],
'bought_at': buy_price,
'volume': volume,
'stop_loss': -STOP_LOSS,
'take_profit': TAKE_PROFIT,
'buy_price': buy_price,
}
with open(coins_bought_file_path, 'w') as file:
json.dump(coins_bought, file, indent=4)
print(f'Orden con id {orders[coin]["orderId"]} actualizada y guardada en el archivo')`
Hi,
I have an issue or 2. Please, if someone could look into this for me. Not a Python Savvy here.
The text was updated successfully, but these errors were encountered: