Automated Python Based Trading Bot

kimber_da

New member
VIP
First of all: PLEASE PLEASE PLEASE be careful with automated trading. It is not for everyone and takes a lot of work to keep running and to make money. Don't jump into this without experience trading manually. Depending on your strategy, your may run out of day trades pretty quickly and should probably should have a cash account. Use this art your own risk with the understanding that if you use it the consequences are on you.

Attached is a link to a git repo for those that want to utilize and automated trading bot through TOS. My partner and I made the program and strategies and when I say my partner and I, I mean he did 99.999% of the work. I think I have mainly just been there for moral (and demoralized) support.

We both thought we would share this with the community that has helped us with some successful strategies.

I will say this: If you have questions, I will forward them to my partner because all I know about coding is that I can't put white out on the screen when I make a mistake.

Other than that I politely ask two things:

1: If you make the code better, please "fork" it in github so we can make it better for all of us. Also, I don't know what fork means.

2: My partner (who is like Rain Man with a laptop) has worked upwords of a 1000 hours on this program. If you could donate a dollar or two to him on buymecoffee at the bottom of the github, I know he would appreciate it. I don't get, want, or deserve any of the money.

Without further ado:

https://github.com/TreyThomas93/python-trading-bot-with-thinkorswim
 
Last edited:

rad14733

Well-known member
VIP
@kimber_da Could you please edit your first post to include a warning about the extreme risks of automated trading... We are getting a lot of new members signing up who could potentially get in way over their heads should they try automated trading... While it may be a great concept, automated trading is nothing to play with if you don't fully understand the risks as well as the code involved... Better safe than sorry... 💡

Edited to add: After fully reviewing the GitHub documentation it would probably be well beyond most traders ability to implement this system anyway... I've been doing IT work for 30+ years, working in too many programming languages (including low level assembly language) and environments to count, and probably wouldn't invest the time and effort required myself... Adding in overhead of monthly expenses would push even more members out of the realm... Neat concept just the same... A lot of thought and effort has gone into this... Just a bit on the geeky side...
 
Last edited:

tradecombine

New member
@kimber_da I like it. I've seen other respositories leveraging the TD API, but this is the first version I've seen that attempts to leverage the user-side of ThinkOrSwim. (There are reports that TD had a prior platform that allowed full automation, so this feature is intentionally missing from ThinkOrSwim, as best as I can tell.)
 

Ryguy

New member
Thank you so much for sharing this with us. I have a question and I apologize if this sounds extremely basic but, how do I create another "Database" with in the cluster? Im very excited to see what this does and analyze it for myself whether it works in my trading that or not. I know there is something to learn :). I am an experienced trader. Nonetheless, I am not a coder. I understand some of the functions and am open to learning how to code. For now, I just need that basic info. Maybe there is something Im not seeing. Thanks for taking a second to answer my post.
 

TreyThomas673

New member
Thank you so much for sharing this with us. I have a question and I apologize if this sounds extremely basic but, how do I create another "Database" with in the cluster? Im very excited to see what this does and analyze it for myself whether it works in my trading that or not. I know there is something to learn :). I am an experienced trader. Nonetheless, I am not a coder. I understand some of the functions and am open to learning how to code. For now, I just need that basic info. Maybe there is something Im not seeing. Thanks for taking a second to answer my post.
I am the creator of this program, and let me tell you, if you are not familiar with programming, then you should not attempt to implement this until you have a good foundation in programming. This is an intermediate to advanced level program.

That being said, I can at least advise you on database creation for your cluster.

When you create a cluster in Mongo using the GUI, you need to click on the cluster name within your projects. Once in your cluster, there is a button that says Create Database. Click that, give your database a name, and insert some data just to temporarily fill it, and your good.
 

kimber_da

New member
VIP
Thank you so much for sharing this with us. I have a question and I apologize if this sounds extremely basic but, how do I create another "Database" with in the cluster? Im very excited to see what this does and analyze it for myself whether it works in my trading that or not. I know there is something to learn :). I am an experienced trader. Nonetheless, I am not a coder. I understand some of the functions and am open to learning how to code. For now, I just need that basic info. Maybe there is something Im not seeing. Thanks for taking a second to answer my post.
I will ask my partner and see what he says. Like I said, I know next to nothing about code.
 

barbaros

Well-known member
VIP
I have banged my head against the wall with TD Ameritrade API for a while. It works most of the time, but reliability is not perfect.

What I don't like the most is that they don't allow trades for Futures.
 

codydog

Active member
As an aside, if you want to have exposure to HFTs without all the massive headaches that come with running APIs etc, you can just trade VIRT and read their public docs.

Before jumping into the deep end of this stuff, googling RenTec's results in recent market turmoil is interesting as well.
 

Ryguy

New member
I am the creator of this program, and let me tell you, if you are not familiar with programming, then you should not attempt to implement this until you have a good foundation in programming. This is an intermediate to advanced level program.

That being said, I can at least advise you on database creation for your cluster.

When you create a cluster in Mongo using the GUI, you need to click on the cluster name within your projects. Once in your cluster, there is a button that says Create Database. Click that, give your database a name, and insert some data just to temporarily fill it, and your good.
Well, even though Im not experienced in coding I can learn. Nonetheless, if its carelessness you are worried about, then you dont have to worry because I am an experienced trader. (not that you would be worried). I just want to be able to implement this and try it out. Im sure I can adjust some things here and there. Ill ask for help if need be.

Are you basically saying the code you provided requires additional code input to complete? If so, thats fine. I just want to be able to get something going that I can come back to and build upon, If that makes any sense.
 

TreyThomas673

New member
Well, even though Im not experienced in coding I can learn. Nonetheless, if its carelessness you are worried about, then you dont have to worry because I am an experienced trader. (not that you would be worried). I just want to be able to implement this and try it out. Im sure I can adjust some things here and there. Ill ask for help if need be.

Are you basically saying the code you provided requires additional code input to complete? If so, thats fine. I just want to be able to get something going that I can come back to and build upon, If that makes any sense.
It's more of a plug and play type of program. The code is already written. You just have to handle the third party API's and configure them to your personal settings. If you follow the docs in the repo, they will guide you in the right direction. It's quite complex of a program, and only makes sense to the one who wrote it. That being said, don't hesitate to ask me questions throughout.
 

Ryguy

New member
It's more of a plug and play type of program. The code is already written. You just have to handle the third party API's and configure them to your personal settings. If you follow the docs in the repo, they will guide you in the right direction. It's quite complex of a program, and only makes sense to the one who wrote it. That being said, don't hesitate to ask me questions throughout.
Thats perfect. If the structure is there I can fill in the rest. I appreciate you taking some time to answer my questions thank you. And thanks again for sharing your code with the community. :)
 

fishstick1229

New member
VIP
@kimber_da @TreyThomas673 - this is awesome, nice work.

one issue i found was that the sim_trader runTrader has conditions to check if side is BUY or SELL, but not checking for BUY_TO_OPEN or SELL_TO_CLOSE.

And one question. As far as i can tell, this is designed for a user to have only one Asset_Type, EQUITY or OPTION. So if i want to trade both Asset_Type I can not unless I use two separate TD accounts, and create two users, is it correct?
 

Picard

Member
kimber_da,

Do you have a video that will explain how to use your trading bot? That would help me and maybe some others too.

Thanks.
 

Similar threads

Top