I Day Traded $1000 Using Reinforcement Learning and Bayesian Statistics

  Рет қаралды 9,116

ritvikmath

ritvikmath

Күн бұрын

Пікірлер: 24
@steveetches6013
@steveetches6013 Жыл бұрын
I don't think what you are doing here is a reinforcement learning process, it is just a Bayesian approach that you are updating with each days data. Reinforcement Learning would involve the algorithm learning the optimal policy for traders given a specific state of the tickers. To train such a model you would probably use historic ticker data and let the model learning by simulating a week/month/quarter and repeating so the algorithm learnings.
@ritvikmath
@ritvikmath Жыл бұрын
Thanks for your comment; I thought about it a bit from first-principles and wanted to share my thoughts. An RL problem consists of: an agent taking actions in an environment, various states of the agent/environment as a result of those actions, rewards associated to each state. I think for a reinforcement learning stock trading algorithm: - the actions would be choices of which stocks to buy and how much to buy - the rewards would be the returns of those stocks the next day, week, month, etc. - the states, as you mention, would be the specific state of the tickers which I'm taking to mean any and all information about the market So if the goal of an RL problem is to learn an optimal policy which is P(action | state) that means P(choice of stocks to buy | specific state of the tickers) in our problem. I think the method I've presented here does work in that way; given the specific state of tickers A and B, we use their history of returns (and the prior) to decide which action to next take (which stocks to next buy). However, I think there are definitely key components missing in the approach I've presented which you'd see in a usual RL problem. For example, there's no notion of exploration in this method. I simply use the means of the posteriors (exploitation only) and that is likely a big problem with this method. How do we know if the mean of a posterior is trustworthy without including its variance? Overall, I think you're right that this doesn't fit as cleanly into the mold of a usual RL problem and we could probably benefit from a future video where I present an RL method starting from actions, states, and rewards as I've tried to do in this comment.
@nelsonjesus8906
@nelsonjesus8906 Жыл бұрын
Well, its a RL problem with a more frequent update of the historical content, instead of learning from previous (long) experiences (which is a legitimate process), it's learning from a more narrow time frame, updating the environment with more regularity (i'm not sure if the learning process is as fast or as accurate as with the historical data) but, we must agree that has all the components and expected behaviour of an RL problem. My only question for @ritvikmath is the assumption of normality, real data rarely behaves normally.
@bin4ry_d3struct0r
@bin4ry_d3struct0r Жыл бұрын
Your summary at the end perfectly explains why I personally don't use trading bots. I don't see these trend chasing methods working out in the long run. The way you make money off the stock market is to buy low and sell high, and the cons listed mean these methods fail in that regard. 9/10 traders cannot beat the S&P, so the easier and more reliable thing to do is to set it and forget it. Appreciate the math, though!
@sharks1349
@sharks1349 Жыл бұрын
I always get so excited about the next stock trading strategy you're gonna show us
@sigma_z
@sigma_z Жыл бұрын
Just started watching, can already see it's going to be a brilliant video. Thank you. 🙏🏼
@ritvikmath
@ritvikmath Жыл бұрын
Hope you enjoy it!
@cornagojar
@cornagojar Жыл бұрын
Try this for the next video, it's super simple: - Download a bunch of backadjusted futures data (or backadjust it yourself). The more futures the better (with 100 you are done). - Calculate the running recent annualized volatility, something like Vol = sqrt(EMA(Returns^2, 30)) * sqrt(252) - Choose a target volatility, let's say 20% - Apply a trend following strategy, something slow like Forecast = (EMA(Price, 20) - EMA(Price, 80)) / (Price * Vol * sqrt(252)) - Calculate excess returns: ER = lag(Forecast * 0.20/Vol) * Returns - Merge all the future contracts results together by averaging the excess returns, calculate sharpe ratio etc... And...surprise! 🤗
@find2hard
@find2hard Жыл бұрын
Aren't daily returns a brownian motion/wiener process? Also the mean would have to be consistently higher than 0 otherwise you would still lose money because of negative % bias (or whatever it's called: if you make 5%, then lose 5% you are in the negative overall, even without counting trading costs).
@djpremier333
@djpremier333 Жыл бұрын
Very nice video again, which software do you use for bayesian inference, pymc or tensorflow prob?
@mistermiyagi4570
@mistermiyagi4570 Жыл бұрын
I would love to see you put out some videos on chaos mathematics applied to stock trading
@ritvikmath
@ritvikmath Жыл бұрын
Great suggestion!
@deadalnix
@deadalnix 6 ай бұрын
It's be good if you could compare sharpe ratio or any other risk adjusted return metric and whatnot. Because if the method has significantly less volatility, it might still be worth doing with leverage. I doubt so, but nevertheless, this is how one shoudl evaluate the trading strategy.
@6Ligma
@6Ligma Жыл бұрын
Can you put a link to the notebook you coded?
@AB-zv6dz
@AB-zv6dz 9 ай бұрын
Fair enough but there is so much in your results which is unexplained. I am sure you know that just measuring absolute returns over a period is a nonsense. I cant be bothered to go into all the unknowns. But if you have a strat that can make 0.6% a week, and goes long and short to trade momentum in a bayesian manner, you have a system that makes 30% a year, which is very respectable. So does your system beat risk adjusted return of the market? Big fat UNKNOWN. It was sad after all that effort to publish only a week of your results and not think about them for more than 2 seconds. You even compared your strat to a week in which the S&P returned 1.6% which is miles from average. The average return is about .2% a week. So even at .6 youre beating the average S&P week. As I say, it was a shame to do all that work then do your work dirty by not competently analysing the results.
@christusrex334
@christusrex334 7 ай бұрын
Could this method be feasible using weekly price changes instead of daily, where you use historic data for each weekly price change and update weekly?
@ritvikmath
@ritvikmath 7 ай бұрын
It certainly could, we’d have to run it and see if this gives usually better performance than daily
@ntesla66
@ntesla66 11 ай бұрын
You have a sample space 7 wide and yet you said in the video that the returns were calculated over 5 days... I'm confused.
@juanfa98
@juanfa98 Жыл бұрын
Great video, new subscriber here Could you link the notebook you coded or show it in another video?
@Hellotherewhtsup
@Hellotherewhtsup 11 ай бұрын
PLEASE CAN WE GET A SIMPLE GUIDE ON HOW TO DO IT?? I MEAN ALL THE STEPS AND APPS , THANKS
@appliedstatistics2043
@appliedstatistics2043 10 ай бұрын
Hi I also have another idea about Bayesian trading, and I have applied in the back testing, the strategy is like using beta binomial conjugation, we set the theta the probability of the stock raising up as the prior which follows beta distribution, and then we use binomial likelihood to compute the posterior. The prior theta is set by observing the data in hours bar, and the likelihood is computed by 5 min bar, the idea is that small change and affect the whole trend , if you would like to know more I would love to discuss with u . I like ur videos !
@nanthawatanancharoenpakorn6649
@nanthawatanancharoenpakorn6649 Жыл бұрын
I learned so many things from your vdo and it is very helpful since you explain the story (context) of the concept. I am working on buidling on quantitative trading strategies. I some guildence. Please let me know if you are happy to be my mentor or someone who I can get advice. :)
@cornagojar
@cornagojar Жыл бұрын
Assuming that trading is mostly a zero-sum game, so that every time you make money somebody else loses it: Why do you think that a strategy like this systematically makes money? In order words, why is somebody else constantly losing money to you?
@ApiolJoe
@ApiolJoe Жыл бұрын
> Why do you think that a strategy like this systematically makes money? I don't think he thinks that. I hope he doesn't.
I Used Data Science to Buy the Dip
19:32
ritvikmath
Рет қаралды 8 М.
What the Heck is Bayesian Stats ?? : Data Science Basics
20:30
ritvikmath
Рет қаралды 67 М.
Wait for the last one 🤣🤣 #shorts #minecraft
00:28
Cosmo Guy
Рет қаралды 9 МЛН
Smart Sigma Kid #funny #sigma
00:14
CRAZY GREAPA
Рет қаралды 49 МЛН
黑的奸计得逞 #古风
00:24
Black and white double fury
Рет қаралды 25 МЛН
龟兔赛跑:好可爱的小乌龟#short #angel #clown
01:00
Super Beauty team
Рет қаралды 67 МЛН
The Unreasonable Effectiveness of Bayesian Prediction
15:03
ritvikmath
Рет қаралды 21 М.
t-SNE Simply Explained
25:49
ritvikmath
Рет қаралды 13 М.
I Day Traded $1000 with the Hidden Markov Model
12:33
ritvikmath
Рет қаралды 19 М.
I Traded $1000 with Every Tree-Based Machine Learning Model
15:44
The Key Equation Behind Probability
26:24
Artem Kirsanov
Рет қаралды 127 М.
Reinforcement Learning Series: Overview of Methods
21:37
Steve Brunton
Рет қаралды 99 М.
Reinforcement Learning, by the Book
18:19
Mutual Information
Рет қаралды 100 М.
An introduction to Reinforcement Learning
16:27
Arxiv Insights
Рет қаралды 657 М.
Wait for the last one 🤣🤣 #shorts #minecraft
00:28
Cosmo Guy
Рет қаралды 9 МЛН