Hephyrius / binance_futures_bot

A bot that trades leveraged USDT futures markets on binance.
299 stars 123 forks source link

`side` doesn't change in handle signal #11

Closed IlyasDeckers closed 3 years ago

IlyasDeckers commented 3 years ago

https://github.com/Hephyrius/binance_futures_bot/blob/41f6d354f9b383dda32ea927e893d074e8130f07/bot_functions.py#L222

I could be wrong, but is it possible side does not get set to 1 in case of a long position in handle_signal on line 274? I noticed this after trades exited very fast in most situations.

Possible solution:

...
    market_price = get_market_price(client, _market=market)
    in_position = True

    if order_side == "BUY":
        side = 1
    else:
        side = -1

    singlePrint(f"{order_side}: {qty} ${market_price} using x{leverage} leverage", std)
...
Hephyrius commented 3 years ago

I think you're right, I must have messed this up at some point, will insert the suggested code