How to build a Stock Recommendation System with Python - Part II: MACD, Golden Cross and RSI Signals

Поделиться
HTML-код
  • Опубликовано: 10 ноя 2024

Комментарии • 65

  • @nguyenduyta7136
    @nguyenduyta7136 2 года назад +3

    Yeah awesome 👏 , keep going on better and better ❤🎉. I’m just a newbie’s and self study so my path of learning programming seem to be not a good order but I found many useful things from your videos. I’m just an electrical engineer but I love programming for algo trade , finding stocks and for further may be a nice jobs of programming although now I’m 42 years old. Thank so much

    • @Algovibes
      @Algovibes  2 года назад +1

      Thank you so much for your comment Nguyen! Appreciate your positivity and your drive :-) Be kindly invited to check out my other stuff. Cheers!

  • @GabrielGonzalez-xf8xp
    @GabrielGonzalez-xf8xp 3 года назад +2

    Keep up the good work my friend, I'm following closely most of your videos and miniprojects. It's an outstanding job what you are doing, my congrats. Greetings from Spain

    • @Algovibes
      @Algovibes  3 года назад +1

      Thank you buddy :-) Recently have been to 🇪🇸 Check out my community post 2 months ago, maybe you recognize where it is :D

  • @azrulfyz1162
    @azrulfyz1162 3 года назад +1

    Thanks, this was very helpful to see how you apply all the methods into a class objects... much appreciated

    • @Algovibes
      @Algovibes  3 года назад

      Awesome :-) Thanks a lot for your feedback mate.

  • @hiteshsutariya475
    @hiteshsutariya475 Год назад

    @Algovibes, Trying to run the code but getting an error at the end of recommendation stage. Can you pls help me with below error.
    'str' object has no attributes called 'TABLE_NAME'
    I'm using the same code, all the stages are working fine except last recommendation.

  • @bryan-9742
    @bryan-9742 2 года назад +1

    Just to be clear in OOP when you want to use another method within a method like you do in getprices, I don't need to do anything in the constructor. The method gettables(self): method allows me to create an attribute in the getprices(self): module?
    Said differently ,why does the for loop in getprices work? for table, schema in zip(self.gettables().TABLE_NAME, self.gettables().Schema): In fact, it seems that the attributes "work" because in the gettables(self): method we created a dataframe that has columns TABLE_NAME and Schema thus the .TABLE_NAME and .Schema ending for the attribute in getprices(self): method for loop it seems.
    Could you expand on this perhaps?

    • @Algovibes
      @Algovibes  2 года назад

      I probably wouldn't code it like that anymore but rather call the method creating a necessary object in the constructor and define it. But it also works this way.

  • @AbduhakimAliMohamed
    @AbduhakimAliMohamed Год назад

    I would like to get a code that recommends stocks in the NASDAQ under $5 that have just experienced MACD crossover and 10 stocks at a time but where is best to run such python codes

  • @chiragpalan9780
    @chiragpalan9780 2 года назад +1

    @19.22 MACDdecision function and Goldencrossdecision function is not returning anything!!!

    • @Algovibes
      @Algovibes  2 года назад

      That's correct and that is intended. Reason behind that is, those functions are doing data manipulations to a provided frame. There is no need to return anything.

  • @ageens
    @ageens 3 года назад +1

    Hi, sorry I am late, but can you use ISIN code instead of tickers for yfinance?

    • @Algovibes
      @Algovibes  3 года назад +1

      Unfortunately not. But there are libraries which do the transformation for you.

  • @mehtapun80
    @mehtapun80 2 года назад +1

    Hi, many thanks for making this extremely useful video. I have a qs - when you say you updated the database to most recent date - can you show how do you it - is it a recurring code from python everyday to add price data or how can you avoid downloading same data time and time again. Many thanks

    • @Algovibes
      @Algovibes  2 года назад +1

      Hi Puneet,
      I did exactly that in Part III, didn't I?

  • @azamat_kalam
    @azamat_kalam 2 года назад +1

    Hey, great video once again!
    Can you please tell how to program for usual case where there is no "." in stock price? You touch on at 8:21, but don't elaborate the exact steps.
    Thank you

    • @Algovibes
      @Algovibes  2 года назад

      Thanks mate, what exactly do you need to know?

    • @azamat_kalam
      @azamat_kalam 2 года назад

      @@Algovibes Basically I downloaded data for NASDAQ stocks but cannot properly adjust your code to it as Symbols of US stocks usually do not have “.” inside like Nifty, Bovespa, and RTSI stocks. Therefore can you say the adjustments to the code in such case starting from 8:21 of your video. I think this line that you describe at 8:21 is the ONLY thing I need to change.
      Thank you!

  • @assafcohen3173
    @assafcohen3173 3 года назад +1

    Thank you for the video!
    When you run the applytechnicals function in 23:22 I get an error message saying "numpy boolean subtract, the `-` operator, is deprecated, use the bitwise_xor, the `^` operator, or the logical_xor function instead.", have you come across this before? I believe the lines "df['Decision GC'] = df.Signal.diff()" generates that error.

    • @Algovibes
      @Algovibes  3 года назад

      Welcome :-)
      No, I don't get this error. Can you post the full error message? It should include the line which is causing the error.

    • @assafcohen3173
      @assafcohen3173 3 года назад

      @@Algovibes here, I could really use some help to resolve this:
      ---------------------------------------------------------------------------
      TypeError Traceback (most recent call last)
      in
      ----> 1 applytechnicals(nifty)
      in applytechnicals(which)
      3 for frame in prices:
      4 MACDdecision(frame)
      ----> 5 Goldencrossdecision(frame)
      6 RSI_SMAdecision(frame)
      7 return prices
      in Goldencrossdecision(df)
      4 # The indicator triggers when the short term SMA is above the long term SMA
      5 df['Signal'] = np.where(df['SMA20'] > df['SMA50'], True, False)
      ----> 6 df['Decision GC'] = df.Signal.diff()
      7
      ~\Anaconda3\lib\site-packages\pandas\core\series.py in diff(self, periods)
      2549 dtype: float64
      2550 """
      -> 2551 result = algorithms.diff(com.values_from_object(self), periods)
      2552 return self._constructor(result, index=self.index).__finalize__(self)
      2553
      ~\Anaconda3\lib\site-packages\pandas\core\algorithms.py in diff(arr, n, axis)
      1975 out_arr[res_indexer] = result
      1976 else:
      -> 1977 out_arr[res_indexer] = arr[res_indexer] - arr[lag_indexer]
      1978
      1979 if is_timedelta:
      TypeError: numpy boolean subtract, the `-` operator, is deprecated, use the bitwise_xor, the `^` operator, or the logical_xor function instead.

    • @prashantlawhatre7007
      @prashantlawhatre7007 2 года назад

      can you try 1/0 instead of true/false in the np.where statement?

  • @smitkumarsuryawanshi3608
    @smitkumarsuryawanshi3608 3 года назад +2

    Thank you so much , it's very helpful.

    • @Algovibes
      @Algovibes  3 года назад

      Thank you mate, truly appreciate your feedback :-)

  • @harshadbhirud
    @harshadbhirud 3 года назад +1

    hi I am using strptime function on last date column and gives error for remaining zeros. Is there any efficient way to compare dates?

    • @harshadbhirud
      @harshadbhirud 3 года назад

      "df1=yf.download(name, start=date)[1:].reset_index()
      "
      this expression is updating rather than
      "df1=yf.download(name, start=date)[2:].reset_index()
      "
      not sure this could you look in this ....

    • @Algovibes
      @Algovibes  3 года назад +1

      Hi, thanks for watching and your comment. Can you elaborate your question? I am not quite sure what you want to compare.
      Thanks for clarifying in advance.

    • @harshadbhirud
      @harshadbhirud 3 года назад +1

      I am comparing current date with last record date and records are stored in string format, so I was getting an error however I that issue is clear. New issue comes with the download function.

    • @Algovibes
      @Algovibes  3 года назад

      @@harshadbhirud Can you elaborate? Thanks in advance!

  • @AbduhakimAliMohamed
    @AbduhakimAliMohamed Год назад

    brother I asked chatgpt to provide a code that screens for stocks under $5 which the MACD has just crossed over meaning the just experienced the crossover at that time and the stocks shouldn't be more that 10 could you do that for me and where is the to run this types of python codes

  • @maciekpaciarski9343
    @maciekpaciarski9343 3 года назад +1

    a piece of good work.Thanks

    • @Algovibes
      @Algovibes  3 года назад

      Thanks mate, appreciate your comment :-)

  • @tiagocolin
    @tiagocolin 3 года назад +1

    I'm implementing this in a different kind of way and also sending an email to myself EoD with the recommendations using smtplib and email.mime libs. Would be helpful to get some backtesting into this, so we could test new strategies or modify existing ones... nice vid.

    • @Algovibes
      @Algovibes  3 года назад +1

      Awesome man! Really good ideas, thanks a lot for sharing your thoughts and tools! Appreciate it a lot.
      Not quite sure if I am doing a backtest (which doesn't mean I will not but it is not on my priority list). I got some content on my channel where I am running some backtests (e.g. MACD), maybe you find something useful for you.

    • @tiagocolin
      @tiagocolin 3 года назад +1

      @@Algovibes Yeah, I watched it all hehe. But I was thinking on something more abstract, I know there's a lot of libs of backtesting but I always thought it could be better. The best way for me would be a function that receives a df with 3 columns (timestamp, closing price, volume, signals) and just return avg return (%) and accuracy (%), so it's decoupled of the strategy.
      Also, another suggestion which I think it's relevant content: a cronjob that executes everyday at EoD and updates your local db, applies strategies to get signals and send all the info on a e-mail (some other info might be helpful like highest/lowest daily return of all stocks you're watching or on your db). I got that already working if you'd like to take a look :)
      Cheers.

  • @naeemhussain5993
    @naeemhussain5993 3 года назад +1

    good vid...

    • @Algovibes
      @Algovibes  3 года назад

      Happy you like it! Thanks for watching and your comment :-)

  • @imthepvpnoob
    @imthepvpnoob 3 года назад +1

    Extremely helpful and informative thank you!
    I was curious:
    Do you have any sources or further info for updating the mysql database using yfinance or any other method really? I have watched your previous video:
    "Simple Stock Recommendation System based on Technical Trading Indicators (ta) using Python & SQL"
    covering your method to update; however, I am still a bit lost. When I check the schema through mysql, I cannot find any updated new days added.
    Thank you so much!

    • @Algovibes
      @Algovibes  3 года назад

      Thanks for watching and your feedback. Truly appreciate it :-)
      Regarding the update I will probably add how to update the database on a regular base.
      Until then the easy way: you can just get rid of the created schemas and run the code from Part I from the starting point or any time horizon again.
      The hard way: Find out what is the last date in the database and update the DB accordingly.

    • @grizthegriffdog9939
      @grizthegriffdog9939 3 года назад +1

      @@Algovibes nice, I was also wondering about this. Would you go about it using crontab, or perhaps the schedule pip package?? regardless I would love to see an update on it at some point! keep up the great work!

  • @neerajrangwani7830
    @neerajrangwani7830 3 года назад +1

    It would be great if you could make a video on how to build a GUI/web-app for this recommendation system

    • @sherlock27
      @sherlock27 3 года назад +2

      You can use streamlit.

    • @neerajrangwani7830
      @neerajrangwani7830 3 года назад +1

      @@sherlock27 Yess a video on Streamlit would be helpful. Haven't used it till now

    • @Algovibes
      @Algovibes  3 года назад +1

      Thanks for the suggestion and also thanks Golden Swan for sharing your thoughts. Really appreciate it.
      I will see if a streamlit deployment will make sense. It might be included in the next part.

    • @neerajrangwani7830
      @neerajrangwani7830 3 года назад

      @@Algovibes Thanks a lot. Waiting for the third part!

    • @harshadbhirud
      @harshadbhirud 3 года назад +1

      @@Algovibes we can try to add functionalities in Django Webapp to build fully functional bot. It could open lots of probabilities if we can get live streaming data to play. Also database handling is simpler too. I am planning for this project. any guidance?

  • @vamsiakula9860
    @vamsiakula9860 3 года назад +1

    Please do the deployment video also!!!!!!

    • @Algovibes
      @Algovibes  3 года назад

      Will see what I can do, thanks for your feedback again!

  • @prashantlawhatre7007
    @prashantlawhatre7007 2 года назад +1

    29:05, this result is very interesting. Despite having no know bias, it predicted really good stocks.
    Does anybody have any comment on bovespa and RTSI ? Are these recommendations good or bad? I know this is just a tutorial but still !!!

  • @Sagar_Tachtode_777
    @Sagar_Tachtode_777 3 года назад +1

    Great content 👏👏👏👏

  • @behdad0979
    @behdad0979 2 года назад +1

    hi thanks for your great contents 😍
    but your Golden Cross function is incorrect!!!
    because if for example df.signal for today is False and for previouse was True , then False minuse True = True
    and you get a wrong Signal!!!😱😱😱
    do you agree with me?

    • @Algovibes
      @Algovibes  2 года назад +1

      Hi, very welcome! Can you pass me a timestamp please. Been quite a long time since I recorded this. Will have a look then. Thanks a lot!

    • @prashantlawhatre7007
      @prashantlawhatre7007 2 года назад

      What version of python are you using ? It seems to be that you py version is converting int back to bools. I'm using version=3.8.10, so if do "False-True" i get "-1". However, if i do "bool(False-True)" I get "True". BTW, you are not using using any explicit type conversion, right???

  • @sherlock27
    @sherlock27 3 года назад +1

    Thanks a lot for this update!

    • @Algovibes
      @Algovibes  3 года назад

      Thank YOU for watching and your comment :-)

  • @lucksimi3320
    @lucksimi3320 3 года назад

    Hi
    Can you share the code in github? Thanks

    • @Algovibes
      @Algovibes  3 года назад

      Sorry for my late reply!
      Didn't publish the code somewhere yet. If I do, it probably won't be on GitHub.

  • @ihebbibani7122
    @ihebbibani7122 3 года назад

    Other way to explain GoldenCross more clearly is to write :
    df['Decision GC'] = np.where((df['SMA20'] > df["SMA50"] ) & df['SMA20'].shift(1) < df["SMA50"] .shift(1), True,False)
    right ?

    • @Algovibes
      @Algovibes  3 года назад

      Also a good way to do that!
      (BTW I didn't check the syntax but the idea should also work)