Stock Trading AI 101: How to Build Your Own Reinforcement Learning Model

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 ม.ค. 2023
  • Hey, thanks for clicking on the video.
    CONSIDER JOINING THE NEWSLETTER
    witty-motivator-1414.ck.page/...
    I talk about coding, python, technology, education, data science, deep learning, etc. If you enjoyed the video please like or subscribe. It is one of the best ways to let TH-cam share similar content with you and others interested in this topic. Many thanks
    GET THE CODE
    colab.research.google.com/dri...
    CHAPTERS
    Install Dependencies - 0:28
    Source Stock Data - 1:30
    Reinforcement Learning Explanation - 2:50
    Create Gym - 3:50
    Random Results - 5:23
    Creating Agent - 6:40
    First Results - 9:44
    Second Results - 12:03
    Future Improvements - 13:07
    My goal is to create a community of like-minded people for a mastermind group where we can help each other succeed, so browse around and let me know what you think. Cheers!
    Keyword for the algorithm: Creating an AI with reinforcement learning with OpenAI and stablebaselines3 along with Tensorflow I successfully trained an agent to trade apple stocks with deep learning and machine learning code with python. I took financial time-series data from Alpha Vantage API. Data science and python coding

ความคิดเห็น • 34

  • @dtwizzledante
    @dtwizzledante ปีที่แล้ว +7

    Thank you for making this video! I feel like there is a lack of machine learning for trading videos out there on TH-cam. This is just enough to get me started which I find is the hardest part. Please make the second part to this video

    • @eminsh
      @eminsh  ปีที่แล้ว

      Thank you for the support! Stay tuned for part two coming out in a few weeks

  • @athanasrenti4535
    @athanasrenti4535 ปีที่แล้ว +4

    Excellent work! Can't wait for the next video...👏

    • @eminsh
      @eminsh  ปีที่แล้ว +2

      Thank you so much for the support. I'm planning on having part 2 out in a couple of weeks

    • @ohseafoodhk
      @ohseafoodhk ปีที่แล้ว +1

      Can't wait for the next video too!

  • @ttc1867
    @ttc1867 ปีที่แล้ว +4

    Loved the Video love that you get to the point with your explanations I find it so much easier to just learn a concept by doing then researching further on my own and your video was great for that

    • @eminsh
      @eminsh  ปีที่แล้ว

      Thank you so much for the kind words. I'm glad you found it useful. If you have suggestions for other topics you'd like me to cover please share!

  • @peralser
    @peralser ปีที่แล้ว +3

    Thanks for the video. So detailed.

    • @eminsh
      @eminsh  ปีที่แล้ว

      Appreciate the comment Sergio! Thank you

  • @panos93
    @panos93 ปีที่แล้ว +4

    Thanks for sharing! Waiting to see how to implement custom indicators inside the gym!

    • @eminsh
      @eminsh  ปีที่แล้ว +1

      Thanks for watching! Should have a video ready in a couple of weeks

    • @alice20001
      @alice20001 9 หลายเดือนก่อน

      It is hard to tell, because I am used to Keras and not stable-baseline, but it seems to somehow feed OHLC data into the network/agent. If you add the indicator output into the data file as a new column, it should use that in the training.

  • @abdouseck4894
    @abdouseck4894 6 หลายเดือนก่อน +1

    thank you 🙌

    • @eminsh
      @eminsh  6 หลายเดือนก่อน

      My pleasure, thanks for watching

  • @alice20001
    @alice20001 9 หลายเดือนก่อน +1

    How would I go about saving/loading models? Let's say I want to implement a callback that saves the model with the highest explained variance and then load it and serve it new data as it comes in through the terminal?
    Is there a way to do this without using stable-baselines, and use keras instead?

    • @alice20001
      @alice20001 9 หลายเดือนก่อน +2

      Also, @2:25 the time data is backwards. You can fix that with data.sort_index()

    • @eminsh
      @eminsh  8 หลายเดือนก่อน +1

      Yeah good catch, I implement the sorting in a different video. The stable baseline callback was a bit confusing for me. I looked into it at the time but eventually gave up after finding FinRL which seemed more intuitive.

  • @eagledaniel1760
    @eagledaniel1760 ปีที่แล้ว +1

    I have been following you video and learning g greatly from you sir. But I want to know how can we connect this learning agent to trading platform like binance in order to execute a trade

    • @eminsh
      @eminsh  ปีที่แล้ว

      That’s a great question, it’s in the pipeline we’ll likely connect the model to Alpaca. First gotta figure out how lol. Hoping to release a video about it late August.

  • @MrRahul15937
    @MrRahul15937 ปีที่แล้ว +1

    Keep going

    • @eminsh
      @eminsh  ปีที่แล้ว

      Thank you my man

  • @MOTIONbyMOMO
    @MOTIONbyMOMO ปีที่แล้ว +1

    Is this a lstm model? Or Arima?

    • @eminsh
      @eminsh  ปีที่แล้ว +2

      To be honest, my knowledge on reinforcement learning is basic at best-- I think the model is A2C which is Advantage Actor Critic which uses an MLPpolicy, which I don't think is recurrent. You can kind of think of it as two algorithms. One takes in inputs > calculates an action. The other calculates performance and reward vs what was predicted and helps the first model out. If anyone more knowledgeable about the subject comes across this, please add clarification. Hope this helps.

  • @bmarroc
    @bmarroc 8 หลายเดือนก่อน

    Very nice!...what's the closing song?

    • @eminsh
      @eminsh  6 หลายเดือนก่อน

      I don't really remember, I got it off TH-cam's Creator Music catalogue

  • @bongkem2723
    @bongkem2723 10 หลายเดือนก่อน +2

    got damn, superman use AI to trade now =)))

    • @eminsh
      @eminsh  10 หลายเดือนก่อน +1

      haha journalism and fighting crime weren't keeping up with inflation

  • @yugio5991
    @yugio5991 9 หลายเดือนก่อน +1

    I am wondering the data should be in reverse order. It seems the alphavantage reversed the order. It gives you 100 rows of the stock price changes. However, the newest data row is at the beginning of the dataframe. I'm wondering if you miss data.iloc[::-1]. Thx for the work BTW!

    • @eminsh
      @eminsh  9 หลายเดือนก่อน +1

      This is something I catch in a later video, but you're 100% correct. It's important to sort the data to move from earliest period to most-recent period!

    • @elomp3s
      @elomp3s 6 หลายเดือนก่อน

      @@eminsh how many months or days of data is suitable to train the model for shorterm (intraday) trading?

  • @muely6322
    @muely6322 ปีที่แล้ว +2

    I am getting a runtime error when I try and run the line of code which says "model = A2C('MlpPolicy', env, verbose=1)". Could you please help me resolve this? , Here is the error summary: RuntimeError: Calling torch.geqrf on a CPU tensor requires compiling PyTorch with LAPACK. Please use PyTorch built with LAPACK support.

    • @eminsh
      @eminsh  ปีที่แล้ว

      There isn't much information out there about this... Are you using Jupyter Labs with Anaconda as your development environment?

    • @swiss_crypto6596
      @swiss_crypto6596 ปีที่แล้ว

      I got the same error and am also using Jupyter Labs with Anaconda..... Cannot find the reason / solution for this, pls help