eupston / MrHedgy

An Application for trading Stocks with TDAmeritrade
2 stars 4 forks source link

Wow, I just found this awesome Backtrader & TDA app #1

Open jhaoq opened 3 years ago

jhaoq commented 3 years ago

Dear eupston/Sir,

I just discovered your app and wonder if this is a productive or working combination with TDA and Backtrader?

if possible could you please provide some more info in form of a README or real life backtesting exmples?

Can't express how happy that I am to find something that is somewhat in the same direction of mine and I really appreciate your effort and help in advance!

Best wishes, JHAOQ

eupston commented 3 years ago

hi @jhaoq

Thanks for your interest! Yeah it's a bit of a hodgepodge of a few different ideas, and really is quite unfinished. Originally was meant for scanning and parsing trading emails and triggering trades within TD Ameritrade.

I then kept the UI and morphed it into more of testing trading strategies via Backtrader. Once I was happy with a strategy I could put it into production via the LiveTrader.py which basically takes a data feed of the Stock Market Index from services like IEX and runs them through BackTrader against the strategy in near real time. If you look at the SMAStrategy class in TradingStrategies.py you'll see that i've added a Buy and Sell callback which is called during the strategy if an indictor determines a transaction should be made. These callbacks are where it actually hooks into the TD Ameritrade API and executes the order.

I never put this into production for my own personal trading, but think it could be possible with some more work. Some challenges I faced were having inconsistent datastreams from Stock Market data providers like IEX, dropouts with WIFI, hitting the rate limit of external APIs. All are possibly to overcome with some tweaking or different architecture.

I'll see if I can update the ReadMe in the next few days though.

jhaoq commented 3 years ago

hi @eupston

Thanks a lot for your reply. Re the IEX data feed it can be easily fixed methinks by other service provider like polygon.io & co, with which you could deploy into a server environment with much resilient network connection.

What you do is really/nearly what I need, and you should definitely check out if not already the alpaca-backtrader-api, which does the same thing officially/semi-officially for ALPACA markets (futhermore, an unit-test of this is provided here:https://github.com/KlausGlueckert/alpaca_backtrader_test) . If your work is tested and confirmed working with live trading, it opens another door for algo-traders to do their strategy development end2end, design, develop, backtrade & go-live.

I am looking forward to your pushing forward your "unfinished yet very advanced" work to a future version. I understand that you also would like to do some strategy concerning the daily gap-up with low float stocks, in which case some breakout strategy like turtle- which I think it is great!, however, with email notification it is not much time efficient, is it? if you/we can somehow automate the process (which I know it will work w/o email notification) directly in python, it will give more oppotunities to find out more intra-day trading strategies.

Again, thanks a lot for the great work. and if you could advance your coding towards seamlessly automate "TDA watchlist or scan" and indicators -> backtest/live trading, it is hugely appreciated!

Best wishes, JHAOQ