r/learnpython • • Mar 20 '24

Creating an AI trading bot in python, is it possible?

I have enough programming knowledge to work on the bot and make the algorithm, only issue is, I don't know how to go about finding a good strategy that will be profitable and implementing in in python, I know its extremely hard I know that, I just want to know how realistic it is to make one in 1-2 months and if there is any open source or known algorithms like this that I can make something similar to, any help will be appreciated.

requirements

" well-known stocks from the S&P 500, NASDAQ, etc. The algorithm for the Bot will be based on historical events, news articles, graphs, and other important factors affecting the stock market. I understand there's always a risk in trading, especially in AI-trading. However, I do occasionally come across bots of this kind that guarantee a minimum of 80% success. Therefore, I'm open to other suggestions regarding the input side of the AI.
Functions:
The user will choose between X amount of versatility (low-medium-high-very high)
The bot will then do trades based in the versatility. Buy at lows and sell at highs.
The more versatile the more risky trades it will execute.
You would also be able to give the bot a threshold. For example: Sell if below X prosent loss/profit"

2 Upvotes

39 comments sorted by

13

u/SirTwitchALot Mar 20 '24

Banks hate this one trick!

0

u/_extremely_smart_ Mar 20 '24

I know its not going to be extremely profitable like its a life hack or something, I just want it to be not negative at least.

3

u/nathie5432 Mar 20 '24

You could build an RNN or LSTM for it, there’s plenty of tutorials on YouTube. I don’t believe they perform very well tho. Behaviour of stock market can’t, really, be learnt

1

u/_extremely_smart_ Mar 20 '24

yep, I think so too, but again there are multiple strategies out there and algorithms too, I was just wondering what can I find to make something similar to

3

u/twitch_and_shock Mar 20 '24

Strategy is very different than programming anything like this. And it sounds like you don't know what you want your strategy to be. Wading into programming a bot without a clear idea on how it will trade isn't going to lead you to some magical discovery, unfortunately. The approach I've used it honing my strategy, first, for months, but following it on paper by hand. Then once I could clearly define my strategy, it was almost trivial to implement it in code.

0

u/_extremely_smart_ Mar 20 '24

yes, thats why im here, im looking for a strategy

1

u/LeftShark Mar 20 '24

It would be mathematicians and research analysts that have the strategies, not python coders.

1

u/twitch_and_shock Mar 20 '24

Yea, that's not a programming question, that's a trading question. I'd head over to one of the stock market subs or even r/algotrading

10

u/jhojnac2 Mar 20 '24

ML models are terrible at predicting the stock market. I thought the same thing and tried to train different models off of historical data to paper trade.

It all boils down to your TA strategy and what signals you want your bot to trade off. AI is not helpful in this context. TradingView has their own language in the pine editor where you can set up a bot and test your strategy. Doesn't even require python.

I suggest looking into r/algotrading sub as well. Probably more helpful.

3

u/MovingObjective Mar 20 '24

There is no such thing as profitable trading. This has been disproven time and time again. Best thing your trading bot could do is buy and hold index funds long term 😅

1

u/Shot-Pension-9119 Apr 25 '24

Not true man. Had the same mindset but was I wrong.

2

u/Playful-Coffee7692 Dec 21 '24

reddit is full of angsty weenies who love to dump on everyone for being interested in learning something

2

u/m0us3_rat Mar 20 '24

there is a magic formula they discovered in the 80s that did some decent prediction where ppl made a lot of money.

here is a video made about it

https://www.youtube.com/watch?v=A5w-dEgIU1M

you will probably not make any money.

i'd argue is such a bad investment you would save money if you donated half and then play the rest in a casino.

i was going to ridicule this situation but i was afraid that my rude sarcasm might fly over so ..just dropped the facts.

i'm 100% you will blissfully ignore this and push ahead in this ridiculous narrative.. so godspeed to you good sir.

2

u/[deleted] Mar 20 '24 edited Mar 20 '24

SDEs model the stock market better than any AI bot would.   

 I know its extremely hard I know that, I just want to know how realistic it is to make one in 1-2 months and if there is any open source or known algorithms like this that I can make something similar to, any help will be appreciated.   

I think you need to do a bit more research in stochastic calculus. Oskendal is a good start. I'd recommend Shreve if you're into financial derivatives.

2

u/Shot-Pension-9119 Apr 25 '24

You can make 200% a year with a 1.5rr and risking 1.6% capital strat. Fee rate at 0.05 for market Nd 0.02 for limit. My bot averages 1.8 trades per day and doubles about every 4 months. 

1

u/Lukhs Jul 29 '25

How :0 Where can i Learn? Thanks in advance :)

1

u/maverickf11 Mar 20 '24

It sounds like you are talking about quantitative analysis

1

u/shiftybyte Mar 20 '24

Some previous attempts at this before generative ai are called sentiment analysis.

Google that for more reading...

Also:

https://medium.com/@chedy.smaoui/using-sentiment-analysis-as-a-trading-signal-beat-the-market-with-transformers-54c65641bec8

1

u/territrades Mar 20 '24

Normally CS is so free and open source, but let me tell you, trading algorithms are extremely valuable and a closely guarded secret. The thing is, as soon as people figure out what you are doing, they are copying you, and the strategy stops working. Therefore algorithms can only work if they are kept secret.

1

u/niehle Mar 20 '24

If you have to ask the question then it’s not

1

u/InterestingCredit245 Mar 24 '24

I have been daytrading trading btc for 5 years. Got over 50000% return in a certain period. I have trading statements from exchange and was actually thinking of training Ai on that as well as the strategy and books I used and know it works. The only thing I miss is a deep understanding of programming and python, but already started to learn.

1

u/Aggressive-Pack4623 Sep 03 '24

Have you made your ai? I am a trader with basic coding knowledge so I am in the same boat. I can provide datasets and strategies.

1

u/Fabulous_Respond1999 Feb 04 '25

COme posso contattarti , vorrei trovare una persona esperta ho alcune strategie che vorrei provare

1

u/Leather-Ant7120 Dec 31 '24

Where can I start 

1

u/Trading_Twice Mar 05 '25

Io ho le strategie e uno scanner che mi manda I segnali, vorrei fare un bot ai che le utilizzi in automatico. Hai più fatto nulla?

1

u/AcceptableAd6653 May 04 '25

Se vuoi creare un bot personale è automatico io sono un programmatore posso creartene uno su misura in base alle tue richieste è basato su gli indicatori che vuoi quindi contattami

1

u/henryzhangpku Apr 01 '25

I've been down this rabbit hole! Building an AI trading bot in Python is definitely doable, especially with libraries like pandas, scikit-learn, and backtrader. But making something that consistently works in live markets is a whole different game. 🤖📉

One thing I’ve found helpful is separating signal generation from execution—let AI handle the info crunching, but keep risk management and actual trading rules simple and transparent.

If you're interested in seeing how AI-generated signals can look in practice (without building the whole system from scratch), check out QuantSignals. It gives plain-English trading insights daily based on AI models—kinda like a shortcut to seeing AI in action before going full dev mode.

Good luck and happy coding!

1

u/AcceptableAd6653 May 04 '25

Salve a tutti io sono un programmatore e per chi volesse io creo bot su misura quindi personalizzati per che ne volesse uno basato sugli indicatori scelti dal cliente ad un prezzo di 200€ quindi accessibile a tutti il bot una volta creato apre e chiude in maniera automatica le operazioni. Contattatemi se volete.

1

u/Weekly_Basket8907 Sep 23 '25

For what it's worth, I used a somewhat peculiar way of doing it. First I made an outline of what I wanted, and then I went step by step with gpt+. My project was like this:

-1° I created a script for tradingview with the conditions of the strategy I had designed

-2° I created a code in python which connected to the bitget through the api, selecting pair, leverage, timing and more things

-3° configure tradingview so that the alerts reach an email

-4° I modified the python code so that it would access the inbox of said email and every 5 seconds it would review the new messages (open long, open short, close long...), so that depending on the message read it would perform the operation

In this way I managed to have a personalized indicator, thanks to which I can operate automatically. Buuut, due to work I had to put the next phase of the project aside and I still haven't been able to verify profitability.

I can assure you that the tradingview-> email-> phyton-> exchange method is functional.

To finish, I must also say that with the paid gpt the error correction was much faster but to get a functional code I had to spend hours

Currently, between correcting and testing until what I have done works, I think it took me approximately 150 hours (without having any idea about programming)

When I have time I hope I can continue polishing it.

I hope my case can be of some use to you.

Greetings