nkaz001 / sample-trading-bot

Binance Futures Sample Trading Bot
46 stars 14 forks source link

Traceback (most recent call last): #2

Closed ceppos-cell closed 2 years ago

ceppos-cell commented 2 years ago

Hey, I get this when I try to run it:

Traceback (most recent call last):
  File "C:\Users\Nutzer\Desktop\coding\binance\mm\tradingbot\ordermanager.py", line 149, in run_loop
    ioloop.add_signal_handler(signal.SIGTERM, signal_handler)
  File "C:\Users\Nutzer\AppData\Local\Programs\Python\Python39\lib\asyncio\events.py", line 539, in add_signal_handler
    raise NotImplementedError
NotImplementedError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Nutzer\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Nutzer\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\Nutzer\Desktop\coding\binance\mm\tradingbot\custom_strategy.py", line 57, in <module>
    run()
  File "C:\Users\Nutzer\Desktop\coding\binance\mm\tradingbot\custom_strategy.py", line 53, in run
    order_manager.run_loop()
  File "C:\Users\Nutzer\Desktop\coding\binance\mm\tradingbot\ordermanager.py", line 153, in run_loop
    if e.args[0] != 'Event loop stopped before Future completed.':
IndexError: tuple index out of range
ERROR:asyncio:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x000001DCEEEE1A00>

do you maybe know why? Regards

nkaz001 commented 2 years ago

I think you try to run this on Windows and add_signal_handler method only supports Linux compatible OS. It would be okay to comment out these two lines(https://github.com/nkaz001/sample-trading-bot/blob/master/tradingbot/ordermanager.py#L149). I will update it, too.

ceppos-cell commented 2 years ago

Worked, thanks!

ceppos-cell commented 2 years ago

Do you also know why it only places buy orders? Looked through the code and when threshold is achieved it should post short orders. When I start it, only buy orders are posted and executed. Do I need to change some settings on binance?

nkaz001 commented 2 years ago

Did you check the buy - sell value with the threshold? I don't see any problem posting a sell order. You have to set the parameters in custom_strategy.py and settings.py. It's just a sample trading bot based on an order book imbalance strategy. I highly recommend you review the code first. By the way, I added logging the values that matter.

ceppos-cell commented 2 years ago

I wanted to test it with those strategies: https://github.com/nkaz001/algotrading-example Is that possible?

Am Do., 7. Okt. 2021 um 17:10 Uhr schrieb nkaz001 @.***

:

Did you check the buy - sell value with the threshold? I don't see any problem posting a sell order. You have to set the parameters in custom_strategy.py and settings.py. It's just a sample trading bot based on an order book imbalance strategy. I highly recommend you review the code first. By the way, I added logging the values that matter.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nkaz001/sample-trading-bot/issues/2#issuecomment-937887184, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQSRPEUFCIEZDQ6BCZJWKILUFWZ7RANCNFSM5FMMOE6A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

nkaz001 commented 2 years ago

Yes, it's possible but algotrading-example is backtested on BitMEX. There is my modified version of BitMEX's official sample market maker bot. https://github.com/nkaz001/sample-market-maker
You have to put in proper parameters and might need to modify the code according to the strategies. The modified version is implementing a simple order book imbalance strategy.
If you want to run a Binance bot, you need to find proper parameters by backtesting. Also still I strongly recommend you to backtest by yourself and review the code before you test it live. Testnet gives totally different data and execution results so it can be used only for checking if a bot functionally works.

ceppos-cell commented 2 years ago

Can I please get your email? Regards

nkaz001 commented 2 years ago

Please leave your email then I will get in touch with you.

ceppos-cell commented 2 years ago

Sure, turioncep@gmail.com