For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Trade-along with backtrader



  • Would it be a good idea to create a trade-along app with backtrader?

    Since available brokers on the exchange I'm in are so low-tech, it would be impossible to develop automated trading for me. The best idea I can think of is to create an app with Django and backtrader which will notify me if there will be new orders and I will manually do so on my broker's site. I will just trade on the daily time frame, it shouldn't be hectic to input orders on a daily basis before the market opens.

    Any tips on what I should create/customize to do this? I'm still trying to figure out which class handles the Order and Trade objects.



  • Code the strategy, run the script every day after market close, print size, ticker and direction for orders bt issued after current bar, manually put these orders to your broker account next morning. Next time you run your bt code, it will execute orders and you will have synced bt and real broker accounts.

    As a result you should have backtest performed in parallel with real trading.

    I doubt that you need Django for this, but it is your choice to add more complexity than it requires. :)



  • @ab_trader Yeah, that's the plan. I just want it to have some kind of interface available via web (but still only for personal use). I think this project would make it easier to analyze the trades and enhance the strategy.

    Would it be possible to save the instance of the backtest in some way so you wont have to rerun the strategy back from the start? Something like a pause -> append data -> resume?



  • For "pause > append data > resume mode" you will need to come up with some kind of live data feed. It is possible but depends on how low-tech you are. I just re-run the test. It is much simpler and can be done much faster compare to developing all bells and whistles.



  • @ab_trader I see. I'll try to play around with the available Store classes for now. Thanks!


  • administrators

    @josephjospeh said in Trade-along with backtrader:

    backtrader which will notify me if there will be new orders

    You probably didn't mean this, but to be sure: backtrader doesn't notify you if there are new orders. Your logic determines if you want to issue an order. If you issue it inside backtrader the default broker will send you a notification internally about the current status of your order in the simulation, but that's because you have decided to issue the order.

    Obviously, your logic can write something to a file, to a socket, to a database

    I believe @ab_trader has tackled the rest.



  • @backtrader Yes, notification is meant to be created by a broker subclass that will work together with a django app I'm working on. Sort of a listener or something. I'm still thinking about it.

    I have a question regarding Order and Trade subclass. Currently I'm using an Analyzer to save the object activity in a database. I think my code would be cleaner if I can subclass those classes. Is it possible?
    https://community.backtrader.com/topic/1441/subclass-order-and-trade-classes

    If I were to create a custom live feed and live broker instances for a trade-along, is there some docs aside from the code that I can refer to?

    Thanks for your responses!


  • administrators

    @josephjospeh said in Trade-along with backtrader:

    Yes, notification is meant to be created by a broker subclass that will work together with a django app I'm working on.

    Overkill.

    @josephjospeh said in Trade-along with backtrader:

    Is it possible?

    You can do it in your own broker

    @josephjospeh said in Trade-along with backtrader:

    If I were to create a custom live feed and live broker instances for a trade-along, is there some docs aside from the code that I can refer to?

    No.



  • @backtrader

    Overkill.

    It is? I was just imagining a webapp that will display new orders to be manually inputted, display historical trades with some charting app (hopefully tradingview) for analysis and portfolio analysis with pyfolio. Good luck to me then.

    You can do it in your own broker

    Thought so..

    Thanks guys! Great Community.


  • administrators

    @josephjospeh said in Trade-along with backtrader:

    It is? I was just imagining a webapp that will display new orders to be manually inputted, display historical trades with some charting app (hopefully tradingview) for analysis and portfolio analysis with pyfolio. Good luck to me then.

    You still don't need a broker.



  • @backtrader

    I see, I guess using the analyzer as the listener will suffice. Then as @ab_trader said rerun cerebro everyday starting from when the last buy order was created.



  • @josephjospeh said in Trade-along with backtrader:

    I was just imagining a webapp that will display new orders to be manually inputted,

    Print corresponding message while issuing order within the next()

    display historical trades with some charting app (hopefully tradingview) for analysis and

    bt can do this by standard means

    portfolio analysis with pyfolio. Good luck to me then.

    bt can do this with older version of pyfolio



  • @ab_trader I see. Do you rerun your strategy back from the very beginning of your data or will running it on the date of the last trade minus necessary bars the strategy indicators need do? And maybe just set the current cash of the broker if necessary.

    Thanks for your response!



  • @josephjospeh I run the full test from the strategy start, but it is traded less than a year. Helps me also to keep comparison between test equity and real equity to understand if test was made correctly.



  • @ab_trader I see. I'll figure out what's best for me. Thanks!


Log in to reply
 

});