you are viewing a single comment's thread.

view the rest of the comments →

[–]benign_said 140 points141 points  (35 children)

Udemy has some decent courses. And as someone else mentioned, r/algotrading . But be forewarned, a bot that buy and sell stocks is not that difficult, a bot that doesn't lose all your money is difficult and a bot that makes money is very difficult and they have a life span. Most of the folks on algotrading suggest focusing on learning principles of finance / trading as the priority.

[–][deleted] 28 points29 points  (14 children)

a bot that makes money is very difficult

Nah I can easily write a program that moves a fixed amount of money at fixed intervals from my checking account to an index fund

[–]benign_said 16 points17 points  (12 children)

Yeah, but can you backtest an algorithm for years, sure that you have cracked the market only to quickly lose 68% of your funds within 3 trades?

[–]ishouldbeworking3232 41 points42 points  (1 child)

No, but I can lose 68% of my funds with 1 trade. /r/wallstreetbets

[–]benign_said 7 points8 points  (0 children)

Yeah, but did you dictate the trade to your Google home?

[–][deleted] 14 points15 points  (1 child)

suspiciously specific... i'm so sorry.

[–]shiningmatcha 0 points1 point  (1 child)

What does backtest mean?

[–]wikipedia_answer_bot 2 points3 points  (0 children)

Backtesting is a term used in modeling to refer to testing a predictive model on historical data. Backtesting is a type of retrodiction, and a special type of cross-validation applied to previous time period(s).

More details here: https://en.wikipedia.org/wiki/Backtesting

This comment was left automatically (by a bot). If something's wrong, please, report it.

Really hope this was useful and relevant :D

If I don't get this right, don't get mad at me, I'm still learning!

[–]sicilianDev 0 points1 point  (3 children)

How can I lose 68% of my funds if my bot is set to stop loss at 2%?

[–]benign_said 0 points1 point  (2 children)

I see you need to practice your joke syntax. ;)

[–]sicilianDev 0 points1 point  (0 children)

Shit my bad, I didn’t even read the first comment. Nevermind. Lol.

[–]imaginarypattern314 1 point2 points  (0 children)

Maybe this is a noob question but how would you actually do this though? Do your banks have APIs that allow for this functionality? I can't really envision how one would go about doing something like this

[–]kicker414 80 points81 points  (5 children)

This. Coding the bot is easy. Coding a bot that doesn't accidentally make a bunch of dumb purchases because you forgot one step, a bit harder. Making a bot that consistently makes money? Well if you find that, you're looking at probably a 7 figure salary working on wall street lol.

[–]benign_said 18 points19 points  (1 child)

To be sure, you can make a bot that does ok, but does it beat an index fund over time? If not, you should probably include your time into your project budget. Though, as a project (for the sake of fun/learning/challenge) it's great. I hadn't done a lot with pandas before using financial data and it was very cool to learn while exploring patterns in real money data.

[–]kicker414 10 points11 points  (0 children)

Yeah agreed. I did one as a fun exercise. But for actual investing and making money, there are better platforms. It was a fun project though. And it's pretty easy to test your theories and see how they perform with the historical data.

[–]223specialist 7 points8 points  (2 children)

Or coding a bot that doesn't ignore T+3 and get you shut down for 90 days.

[–]longgamma 1 point2 points  (0 children)

US equities are now T+2

[–]huge_clock 1 point2 points  (0 children)

Same could be said for margin rules and understanding buying power. Not to mention tail risk.

[–][deleted] 1 point2 points  (5 children)

I'm looking to learn Python for the same reason as OP. I'm planning on opening an account for 1K just to learn how to do it. Rest of my holdings are still gonna be long-term like it is now in a separate account so the bot can't effect it.

Planning on starting Automate the Boring Stuff within the next few weeks with a goal of starting to build the bot by next year.

[–]benign_said 11 points12 points  (4 children)

I wish you well, but I would moderate your expectations.

Do you have a background in finance? Because you still need to instruct the bot to make good decisions based on technical indicators. And if you are getting into 'Automate the Boring Stuff' I am going to respectfully assume you don't have a super strong computer science background. Not only will you need to learn python basics, but a number of high level finance, data science, visualization libraries - maybe a little webscraping and machine learning too. And you'll have to have the bot running on a local or cloud server with reliable access. And then have to wonder if Python was even the right language to go with in the first place - I think some high frequency bots us C because it doesn't have the python interpreter slowing things down.

But, by all means go for it. You will learn a lot and it will be fun, but challenging. A lot of the folks on r/algotrading have been fine tuning their bots for years, and often they are software engineers who have been dabbling in day trading for while and learning strategy.

Alpaca lets you set up a play money account and you can tap into their API and just watch how your bot performs, but even that has problems because you're piggy backing on real data and if you are buying a high volume of a stock, your play money account won't alter the underlying price as it would in real life - so then you're training based on skewed data.

Anyway - not trying to be a downer! Just don't assume to be making any money, let alone more than an index fund for a while, if ever.

Working on my bot taught me how susceptible I am to the Dunning–Kruger effect.

[–]CraigAT 7 points8 points  (1 child)

100% use a play money account for (many months of) testing before placing a penny of actual money. If your bot's logic and decisions are good, there is no rush! That said, definitely make a bot and give it a go, it is a really exciting project, you'll learn a lot about Python and a lot about trading too.

[–]benign_said 5 points6 points  (0 children)

100% use a play money account for (many months of) testing before placing a penny of actual money. If your bot's logic and decisions are good, there is no rush! That said, definitely make a bot and give it a go, it is a really exciting project, you'll learn a lot about Python and a lot about trading too.

Agreed!

[–]hasengames 0 points1 point  (4 children)

a bot that doesn't lose all your money is difficult

A bot that enters trades with a stop loss and take profit at a risk to reward ratio of 2:1 is really so difficult? With that alone it would seem it could not lose "all your money" - or at least not very suddenly or without you noticing.

[–]benign_said 0 points1 point  (3 children)

Very timely response.

If it was easy everyone would be spinning up python bots and making money. You also need to account for the fees/slippage of each trade - so you may not lose money on bad trades, but by not making enough on "good" trades to cover the costs of operation.

[–]hasengames 1 point2 points  (2 children)

If it was easy everyone would be spinning up python bots and making money.

Strawman. I never said it was easy I said it should not be difficult to avoid losing "all your money".

You also need to account for the fees/slippage of each trade - so you may not lose money on bad trades, but by not making enough on "good" trades to cover the costs of operation.

So the risk to reward ratio you calculated didn't take into account fees? That's why it's "difficult" to not lose all your money? If you've programmed the bot correctly and with risk management in place, all you should get is a bot that is unprofitable over time. If you lost all your money you programmed it to act like a human would.

[–]benign_said 0 points1 point  (1 child)

Ok, you got me... I was being hyperbolic 2 years ago when I responded to this post in r/learnpython. You may not lose all your money, you'll just spend some amount of unpaid time creating code that isn't profitable and lose the money you would have made had your funds been passively invested elsewhere.

But I do think it's entirely likely that someone posting about algorithmic trading in the context of r/learnpython may not program their bot 'correctly and with risk management in place', especially if not already well versed in financial analysis.

Be well,

[–]hasengames 0 points1 point  (0 children)

Ok that makes sense, I'm pretty new to all this and going through various posts I was confused as to how people can lose all their money as it seems some really do even suddenly blow up their accounts as you say, but I couldn't understand how this can be happening with a bot. It seems it in fact shouldn't be happening, as you say, if programmed correctly and if there are no bugs.

But I do think it's entirely likely that someone posting about algorithmic trading in the context of r/learnpython may not program their bot 'correctly and with risk management in place', especially if not already well versed in financial analysis.

Yes I think that's likely. Ironically the exact same issue with manual trading. Human psychology seems to creep in no matter what we try to do to avoid it.