This is the most common comment you could ever read on web courses. I’m sure your teacher explained well, you were just bored and didn’t pay attention. Here you have 4 hours for everything you need to know and you can stop and start whenever you want. It’s easier. But don’t discredit other people because you have not been able to keep up with them.
I wonder why almost everyone feels the same about the schools.they kepp u 4 years in a box and u act like a piggy bank to them.it is realy sad .I am already in that box.this guy deserves a ton of money not my teachers.
to whom it can be of use: if you're stuck because of a KeyError 'DISCA', that is because the original stock list has had some change. You can solve it by using a try/except block when doing the the iteration for the final_dataframe = final_datafrme.append(.....) . Just put all of that inside the try block, and then do an except KeyError, and handle the eroor
haven't used a try/except before, can you please elaborate on how to use the except? I have the same issue Edit: I just put everything in the try block like you said and put except KeyError: break, is this what you did?
50min in and am already in love with the style of teaching. Errors are left in the vid as well as the logical process of debugging them, everything he mentions are backed up by examples. Superb content
@2:09:00 you can use the code below to ensure you have a valid number by looping until the user has inputted a numerical value. Thanks for the great video! while True: try: portfolio_size = float(input("Enter the size of your portfolio: $")) break except ValueError: print("Please enter a valid numerical value in $")
thank you so much for this course!!! I started my coding journey with Free Code Camp, I now work full time as a developer. This topic is on my to do list!!!
I don't comment often but this guy is an amazing teacher. He explained everything in such good detail. It helped me as I need a deep understanding of a topic to grasp it completely. Keep up the great work.
Thank you that you didn't edit video, these debugging/looking for error processes actually make things more clear. And teach how to deal with such cases. And thank you for this video at all, it's great!
Rather than counting zeros, an easier way to input large numbers with many zeros is to use e-notation: 3e3 (which equals 3 * 10^3, or 3000) 10e6 (equals 10 * 10^6, or 10000000) 8e100 (equals 8 * 10^100, or 80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)
Amazing video! Thank you so much for sharing this! Still going through it, but there's an observation I need to make for any beginners that might stumble upon this video: To create a new column with values based on another column(s), using a for loop to iterate through rows and make calculations (as shown in 2:31:11) will be EXTREMELY inefficient on larger datasets. It is better to use Pandas' `apply()` method paired with a `lambda` function, as follows: ``` # create list with time periods time_period = ['One-Year', 'Six-Month', 'Three-Month', 'One-Month'] # create new fields (or update existing ones) based on previous list # and calculate percentile based on Price Return for i in time_period: change_col = f'{i} Price Return' percentile_col = f'{i} Return Percentile' hqm_dataframe[percentile_col] = hqm_dataframe.apply( lambda x: score(hqm_dataframe[change_col], x[change_col]), axis=1) ``` Same method can be applied to calculate HQM Score using Pandas' `mean()` method: ``` hqm_dataframe['HQM Score'] = hqm_dataframe.apply( lambda x: pd.Series([x[f'{time_period[0]} Return Percentile'], x[f'{time_period[1]} Return Percentile'], x[f'{time_period[2]} Return Percentile'], x[f'{time_period[3]} Return Percentile'] ]).mean(), axis=1) ```
@@Jon-bk2bw I had the same question and I think they did on 21st August 2021 but I'm not sure how come users were able to work with it until a couple of months ago.
Just as a safety precaution since you never want to trust someone to know what to do you can use a while loop for the input validation: invalid_input = True while invalid_input: try: portfolio_size = input("Enter the value of our portfolio:") val = float(portfolio_size) print(val) invalid_input = False except Exception as exception: print("You must enter an integer")
I worked on it for a full month using the Interactive Brokers API in python and watched a bunch of videos focusing on day trading indicators etc to try and code the bot. In the end, I hadn't accounted for the commission the brokerages take (about $5 per trade which adds up especially if you're not trading with a lot) and this eventually started discouraging me a little. If anyone does run into the same problem, I would look into leverage which is riskier but easier to overcome tis problem. Risk analysis is also crucial (setting stop losses, take profits).
Loving the materials! I might add that Pandas and Numpy actually has builtin methods better suited than math and scipy libraries for some operations. For example, numpy.floor() can be used instead of math.floor() final_dataframe['Number of Shares to Buy'] = np.floor(position_size/final_dataframe['Price']) or df.rank() can be used instead of scipy.stats.percentileofscore() for time_period in time_periods: hqm_dataframe[f'{time_period} Return Percentile'] = hqm_dataframe[f'{time_period} Price Return'].rank(method='max', pct=True).mul(100)
@@adiletdaniyarov5737 HQM Scores from momentum strategy, momentum_percentiles = [f'{time_period} Return Percentile' for time_period in time_periods] hqm_dataframe['HQM Score'] = hqm_dataframe[momentum_percentiles].mean(axis=1) RV Score from valuations: rv_dataframe['RV Score'] = rv_dataframe[[i for i in metrics.values()]].mean(axis=1) :)
In 58:05 for anyone don't want to use yield, you can use list concatenation for both symbol_groups and symbol_strings symbol_groups = [list(stocks.Ticker)[x:x+100] for x in range(0, len(list(stocks.Ticker)), 100)] symbol_strings = [(',').join(i) for i in symbol_groups]
do u have any tips on how to learn and improve my ability in this area after I complete this video? Tryna prepare myself for work in this field was wondering if you have tips!
There were a few questions I had while watching (I am a noob so sorry if any of them sound dumb): - How do you deploy that? I imagine you wouldn't want it running in Jupyter Notebook. - Is the accuracy-loss of floats safe to ignore? - While the concept of high-quality vs low-quality momentum makes sense, why is momentum a good metric? Isn't it likely that since you rely on data from a year ago, your model identify stocks that have already seen their growth and won't grow more? (Like making you buy at high, instead of low) - Would it be sensible instead of calculating a score to sort all the columns based on different return_percentiles? - Also, when do you know to sell? I know the premise was that we have a team of traders to whom we send our excel files, but while they'd be able to know how many stocks to buy based on our position and the filtering we did, how do they know when to sell?
this is very useful, you show what needs to be done, how to do it, how to fix errors, what things mean in real life situation. great job and thank you !!!
So far I have only used my python knowledge to program basic games, automation widgets and a few data scrappers but this... My head just exploded with curiosity!🤯 Thank you so much!
Excellent course for someone new to Algo Trading. It’s precise and well designed course. I would like to see something more along lines of simulating real time strategies like VWAP, TWAP. This one is more of pre-trade analytics. Nonetheless I liked it and strongly suggest to anyone new to Algo trading space!
52:39 If you stuck with appending series to a dataframe like me, this method(.append) returns a new object, so if you want to see the result, you should assign final_dataframe to new variable and then print it. new_dataframe = final_dataframe.append(pd.Series( [ symbol, price, market_cap, 'N/A' ], index=my_columns ), ignore_index=True ) print(new_dataframe.to_markdown())
Easy way to add a cost column to your pandas df: final_dataframe = final_dataframe.apply(lambda x: x['Stock Price'] * x['Number of Shares to Buy'], 1) *** don't forget the ',1', it specifies the axis :)
I have a few tips for people that may be struggling with setup & other things: As an alternative to setting up & using a local Jupyter notebook, you can use a Google Colab Notebook (colab.research.google.com) with the following imports: import numpy as np import pandas as pd import requests import math !pip install xlsxwriter If any of you are confused about how to get secrets.py, click on the link & press 'Ctrl/Command + S' to save the file. Upload it into your Google Colab, go to the 'Runtime' menu tab, and click 'Restart & Run All' Note that if you use Google Colabs, you may have to re-upload the stocks csv & IEX token file after you leave the browser & come back.
Still watching and learning the topics, so far so good, thanks a lot for generous offering this great course and I look forward to seeing this extended topic with advanced techniques and link to specific brokers' API like IB, Futu, etc. Thanks again for your great teaching!!
A great detailed starter course to learn some Python. As a licensed commodity trading advisor (and a software engineer), I would never advise someone to trade this though.
Hello, for people getting to the Key Error for the stocks, the solve is to delete the 4 stocks that have been delisted from the S&P 500: code example: stocks = stocks[~stocks['Ticker'].isin(['DISCA', 'HFC','VIAC','WLTW'])]
The fun thing about pandas, is that you can work with whole columns without loops, e.g: final_dataframe['Number of Shares to Buy'] = final_dataframe.apply( lambda row: math.floor(position_size / row.Price), axis=1)
@@irvin1241 Im sure most colleges that have a business school within them will have a course or two on python or R that’s centered around finance. The course Im taking next semester is a minicourse to fill out my credit requirement so it’s probably not as in depth as youre looking for. The best place to start would probably be just googling the “python finance college course” and seeing what colleges offer that you’d be willing to pay for. Of course, if youre good at learning things on your own I cant recommend Kaggle enough. Its free and has alot of stuff that you can pull from. Good luck!
@@gomes8335 I dont think its a waste of time, as Im not looking to be a full time programmer. I pay for 18 credits per semester, and using a few of them to focus on my interests outside of my major seems pretty worthwhile to me. I’m not a good self-learner like some people and my background in coding isnt that strong. I think it’ll be a cool way to combine a minor interest with my other education and see if I can really take it anywhere. As always, the internet is truely the best teacher when it comes to programming, but not everyone is suited to that path :)
Mrs harriet dixson service is a talk of the town in North Holland Netherlands , I started with a little amount of 1ETH, and she made huge returns, and I have been constantly investing with her
Tell her I referred you I can't hide her contact information from anyone who is interested in investing with her because she has really helped me a lot with my trade, today I am smiling
I know absolutely nothing about Python… But this is the first video that seems to clearly explain what my brain just can’t seem to wrap itself around. When I designed the investment strategy that I use, it was simple math, well, it was math… But to suddenly take the algo and transfer it into a language that I am not familiar with, seems like the worst possible prostitution of my time… I get it, learn Python then write code and be happy ever after but, but, but, why can’t I do that in English? I can read medical journals on just about any topics, all I need is a dictionary and some extra time, I don’t need to mortgage a significant portion of my time on this planet just to learn something that will be old info by the time I’m done learning it… There’s gotta be a practical way to do that in English! Heck in French or Spanish or Russian or any languages! Geese this is so frustrating!!!!!!!
I am really enjoying learning these techniques and am impressed with your style. Thank you for encouraging others to learn! I'm running into an error in the momentum calculations around percentileofscore implementation, around 2h 30m mark in your video. I am executing the following: for row in hqm_dataframe.index: for time_period in time_periods: change_col = f'{time_period} Price Return' percentile_col = f'{time_period} Return Percentile' hqm_dataframe.loc[row, percentile_col] = score(hqm_dataframe[change_col], hqm_dataframe.loc[row, change_col]) and get the error: TypeError: '
I found a solution to this question in one of the comments. Another user had the same issue and they resolved it by adding this line before the for loops I mentioned: hqm_dataframe.dropna(inplace=True) This drops any rows/columns that return N/A as part of f''{time_period} Price Return' column in the hqm_dataframe
People have to remember the point of these videos is to teach you to code a trading algo. He isnt saying that algo will be profitable. That requires some really complex mathematical models like what Jim Simmons and Renaissance do. But these videos are still valuable to learn to build something for its own sake nevertheless.
Just stumbled on this. Thank goodness I got took my trading seriously. Getting into the market surely led to many open doors for me as I've gone to make quadruple of what I put in.
@Raul Guzmann For me, I lost money repeatedly because I didn’t know how to go about it till I came across recommendations of Levi Clemans, a seasoned trade analyst and reached out. It’s been a great journey ever since. You can also get across
I have not written this sort of comment before but I feel compelled to. Just wanted to let you know that you’re doing a great job Clemans. You have made a difference in my understanding of the market.
Great course. Thank you for all the work you put in and your thorough explanation of how it all works together while coding. I haven't been coding python for more than a year and this was a great refresher course into data science and api use
Another way to skin the cat... You can put inputs in while loops such that the user is repeatedly queried for input until he gives it correctly (i.e. until he gives numeric input). For example: portfolio_size = '' while not isinstance(portfolio_size, float): portfolio_size = input('Enter the numeric value of your portfolio') try: portfolio_size = float(portfolio_size) except ValueError: print('Entry must be numeric') I go this route because assertions, try-except blocks, etc. generally halt execution on errors, requiring you to run the code again. This keeps it going.
Excellent course, NIck!! I enjoyed very much the "real life" approach that included the footage of tracking down bugs. Thanks for not editing that out!
i cant find this Needd Heeellppp!!! Section 2: Course Configuration & API Basics How to Install Python Cloning The Repository & Installing Our Dependencies Jupyter Notebook Basics The Basics of API Requests
@@tiandeqiang Thanks and it worked! My steps are a little different 1) I downloaded "Anaconda" and 2) In the Anaconda Prompt I type "pip install panda" "pip install numpy" "pip install jupyterlab".
Yeah, its very unfortunate and discouraging to those who are learning the fact that section 2 is missing from the actual video even thou it is mentioned on all the syllabus for this course that I came across. Several people on the comments are complaining about this and I mean... You could at least edit the video description with basic instructions or with a link to where we can find the missing part of the video. After all that is critical information for those who wants to follow along with your course. Thanks anyway
You can use a while loop with the input: def portfolio_size(): global portfolio_size while True: try: portfolio_size = input('What is your portfolio size?') if isinstance(float(portfolio_size), float): break except ValueError: print('This is not a number')
awesome!Fix some problems:Before Calculating Momentum Percentiles,Execute the statement first to clean up invalid data.hqm_dataframe.fillna(value=0, inplace=True)
I just started learning python, it's only been days, but this is my end goal. So I'll be saving this video for later, hopefully it won't be too long before I'm ready for this course.
bro i too want to start with python nd my end goal is gonna be this video. Can you help me where to begin with nd when i will be ready to go with this one
@@zeroXmlbb if you're new to coding, I would start at the basics. Learning functions and variables are a good place to start. If you're like me, and this is your first programming language, I would give myself 3 to 6 months before getting to this level.
Just coming across this video now. Make sure, for the first project, you get an up to date list of all stocks found on the S&P 500. At this time there were 4 stocks that no longer are under the listed tickers with the provided csv file.
great video, what I really liked is that you showed in a super clear way how to use the requests library in Python and now I do not need to depend on 3rd party wrappers that might not have all functionality! thanks!
BONUS: In this course a free addictive Python course for beginners / intermediate programmers is included, with clear clarifications about everything you may need ♥
Самое важное в рынке -это понять межбанковский алгоритм поставки цены, далее уже углубляться в микро конъюнктуру рынка, чтобы стоп был коротким и тейк 1к3 минимум. Тогда и математика начинает работать и депозит растет в пропорциях в целостности и гармоничности!
This is a great course. I learned so much from it. One suggestion: the robust value trading program should exclude the negative PE Ratio stocks first before sorting for the low 50 stocks.
I don't know much about these or it works, when it comes to trading I have learnt to have an open mind as there are different trading strategies out there.
Some stocks have been delisted, to make the tutorial work you must delete the following stocks from either the stocks dataframe or the original sp_500_stocks.csv file: 'DISCA', 'HFC', 'VIAC', 'WLTW'
This course is the best on RUclips and it is better than University degrees. Thank you so much for your contribution to us. Is there any way to contribute to you and paying for a certificate after finishing this course?
this was awesome and though I've just finished the first part only, I cannot thank you enough for how well you explained each portion of the project. Now only, if I could build up from here!
Awesome video, I have learned a lot from watching it untill the end, the only thing is that when I tried to replicate the last project with a real production IEX cloud API it returned error during the module Building a Better Quantative Value Strategy : JSONDecodeError: Expecting value: line 1 column 1 (char 0)
What I like about your tutorial is that one doesn’t miss out if they start with the third section. Also than you didn’t cut out the bugs and struggle helps people to understand that these stuff belong to a programmers life. Another positive point is that you try to clarify specific financial terms. Overall you did a great job here. One point of improvement is your face cam position on the screen.
First, I'd like to thank the presenter Nick. Here's my thought about this course. I was following this course during the first project then fast-forwarded the rest of it. I can confirm it provides an ok depth of alg trading to the audiences who have no knowledge of alg trading. But seriously it would be great if the presenter is able to introduce some more trading algorithms even though just conceptually. I personally feel the presenter focuses too much on the implementation itself and most of the content is to demonstrate how to gather data from idx cloud. I know getting data is crucial but it has very little to do with trading. I don't see the point repeating data collection in all of the three projects. Overall, it is good but not great. Also, the presenter is rushing hard in speaking so if you have little exp in data science or python, you easily get lost.
I'm puzzled by your comment about data's having little to do with trading. You can be a successful trader without looking at prospectuses, without keeping up with the news, etc. Many traders look at nothing but data.
@@CalebDiT I agree with what you said but what I mean is that ppl here are more interested in algorithmic part not data processing part. The whole series can reduced to within an hour tbh.
Awesome tutorial, watched the whole thing through to the end. For the next video tutorial, do you want to show us how to write a trading bot that will automate day trading based on these algorithms?
at 2:28:12 While implementing the percentiles, I noticed that the data I am receiving has None type in it. So the scipy.stats module throws an error as it cant compare the None type instances. For now I am replacing it with 0. Just for people who face this error you can just add this right before you assign your return percentiles for row in hqm_dataframe.index: for time_period in time_periods: if hqm_dataframe.loc[row,f'{time_period} return'] == None: hqm_dataframe.loc[row,f'{time_period} return']=0
Only reason for extensive comment that you are receiving great reviews, takes effort to create course like it. Utilizing for example chatgpt is very useful in creating an extensive course like this.
@@goober-ll1wx If you can place order 100 times a minute, it's still not illegal. They place 1000 times a min. It's not illegal. It's calculus of day trading, more like minute or even seconds trading.
When you take the user input this could be an option so that it will keep asking until they provide anportfolio_size = input('Enter the value of your Portfolio : ') while True: try: val = float(portfolio_size) print(portfolio_size) break except ValueError as e: print('That"s not a number, please try again') portfolio_size = input('Enter the value of your Portfolio : ') print(portfolio_size)
This video provides a great way of analyzing stocks using Python but it definitely isn't trading. We can call it quantitative analytical methods but these are definitely not algorithm-based trading because we don't have a clear strategy here (By strategy I mean the Entry/Exit signal, order type, etc). Good for learning but not at all practical
Really liked the tutorial! There are a few places where you're working on code that's blocked by the video of your face. I could generally extrapolate from what you were saying, but wanted to let you know
people think if they are coding it already makes them sophisticated and they are going to win the market. In fact, if you can't make a lot of money doing it manually, you can't do this with python, unless its a high frequency trading which you can't do anyway from home. Don't mistakenly think if you write code you are some sort of sophisticated trader, you still need THE MATH. Most people do not have the math, and never will. The strategies presented here all can be easily proven to be wrong using a simple good python backtest.
I was getting error at DISCA symbol, which is now gone from the new S&P 500 list. Also you have to change .append() with .concat() You can look how on googling -> StackOverflow: Add Pandas Series as a Row to Pandas DataFrame
I like how the errors were made without editing them out from the clip. Thanks for including all those in.
Sir, you clearly explained both financial and coding keywords better than my professors did in 4 years of schooling. You're a great teacher!!
So ageee!!!!
This is the most common comment you could ever read on web courses. I’m sure your teacher explained well, you were just bored and didn’t pay attention. Here you have 4 hours for everything you need to know and you can stop and start whenever you want. It’s easier. But don’t discredit other people because you have not been able to keep up with them.
@@AlbyTheMovieCreator the school system is just fcked and you know it
I wonder why almost everyone feels the same about the schools.they kepp u 4 years in a box and u act like a piggy bank to them.it is realy sad .I am already in that box.this guy deserves a ton of money not my teachers.
Everything covered in this video is extremely basic. If you didn't understand it in 4 years of college, that is 100% on you.
to whom it can be of use: if you're stuck because of a KeyError 'DISCA', that is because the original stock list has had some change. You can solve it by using a try/except block when doing the the iteration for the final_dataframe = final_datafrme.append(.....) . Just put all of that inside the try block, and then do an except KeyError, and handle the eroor
haven't used a try/except before, can you please elaborate on how to use the except? I have the same issue
Edit: I just put everything in the try block like you said and put except KeyError: break, is this what you did?
50min in and am already in love with the style of teaching. Errors are left in the vid as well as the logical process of debugging them, everything he mentions are backed up by examples. Superb content
where did he has shown how to install dependencies and cloning plz help
@2:09:00 you can use the code below to ensure you have a valid number by looping until the user has inputted a numerical value. Thanks for the great video!
while True:
try:
portfolio_size = float(input("Enter the size of your portfolio: $"))
break
except ValueError:
print("Please enter a valid numerical value in $")
Hey thanks bro you saved the day :)
Bro, which software is used to run this script?
@@ameeraarif Jupyter Notebook provided by IPython, pip library, numpy, pandas, xlsxwriter
thank you so much for this course!!! I started my coding journey with Free Code Camp, I now work full time as a developer. This topic is on my to do list!!!
Which road map did you take for fulltime job?
Cap af
I don't comment often but this guy is an amazing teacher. He explained everything in such good detail. It helped me as I need a deep understanding of a topic to grasp it completely. Keep up the great work.
Thank you that you didn't edit video, these debugging/looking for error processes actually make things more clear. And teach how to deal with such cases.
And thank you for this video at all, it's great!
finished the entire thing in one sitting. Loved it! its an amazing course if you are starting out algo trading!
Worth hai kya?
Rather than counting zeros, an easier way to input large numbers with many zeros is to use e-notation:
3e3 (which equals 3 * 10^3, or 3000)
10e6 (equals 10 * 10^6, or 10000000)
8e100 (equals 8 * 10^100, or 80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)
Also an easy way to input small numbers, e.g. 3e-3
Are you trying to input my bank accout balance?
@@Zaenil Yes, for a withdrawal, but all I keep getting from your bank are 🤣emojis. What's up with that?
I LOVE how you go through your own process of debugging. It really helps me.
Amazing video! Thank you so much for sharing this! Still going through it, but there's an observation I need to make for any beginners that might stumble upon this video:
To create a new column with values based on another column(s), using a for loop to iterate through rows and make calculations (as shown in 2:31:11) will be EXTREMELY inefficient on larger datasets. It is better to use Pandas' `apply()` method paired with a `lambda` function, as follows:
```
# create list with time periods
time_period = ['One-Year', 'Six-Month', 'Three-Month', 'One-Month']
# create new fields (or update existing ones) based on previous list
# and calculate percentile based on Price Return
for i in time_period:
change_col = f'{i} Price Return'
percentile_col = f'{i} Return Percentile'
hqm_dataframe[percentile_col] = hqm_dataframe.apply(
lambda x: score(hqm_dataframe[change_col], x[change_col]), axis=1)
```
Same method can be applied to calculate HQM Score using Pandas' `mean()` method:
```
hqm_dataframe['HQM Score'] = hqm_dataframe.apply(
lambda x:
pd.Series([x[f'{time_period[0]} Return Percentile'], x[f'{time_period[1]} Return Percentile'],
x[f'{time_period[2]} Return Percentile'], x[f'{time_period[3]} Return Percentile']
]).mean(), axis=1)
```
Hey Alex! just checking, are you still able to use it? Did they deprecate the sandbox api?
@@Jon-bk2bw Not sure if it's working at the moment, but it did a few weeks ago when I tested it! If anything, you can use Yahoo Finance API instead
@@Jon-bk2bw I had the same question and I think they did on 21st August 2021 but I'm not sure how come users were able to work with it until a couple of months ago.
29:41 Thanks for showing debugging when hitting errors. That adds a lot to real world training!
that is not debugging lmao, it's like turning your phone off and on
Reloadi g this thing is like off and on but how do you know if you should restart it? This is debugging
Its still showing error importing from secrets.py file. Did nothing for me
hey guys, even after restarting kernel, I am still getting same error for importing secrets, any solution?
@@koushikdey7778 same here please do suggest
Furthermore, you could try to
1) follow the approach of Ang (2009) and exclude firms with the lowest 5% of market valuation (and not only prices
Just as a safety precaution since you never want to trust someone to know what to do you can use a while loop for the input validation:
invalid_input = True
while invalid_input:
try:
portfolio_size = input("Enter the value of our portfolio:")
val = float(portfolio_size)
print(val)
invalid_input = False
except Exception as exception:
print("You must enter an integer")
Literally just started building a trading bot, timing couldn't have been any better, thanks!
RUclipss algorithm is your friend.
You should thank the cookies for that
I’m also curious how your trading is going
I worked on it for a full month using the Interactive Brokers API in python and watched a bunch of videos focusing on day trading indicators etc to try and code the bot. In the end, I hadn't accounted for the commission the brokerages take (about $5 per trade which adds up especially if you're not trading with a lot) and this eventually started discouraging me a little. If anyone does run into the same problem, I would look into leverage which is riskier but easier to overcome tis problem. Risk analysis is also crucial (setting stop losses, take profits).
@@kenjohnson512 so how is it going bigboy?
Loving the materials!
I might add that Pandas and Numpy actually has builtin methods better suited than math and scipy libraries for some operations.
For example, numpy.floor() can be used instead of math.floor()
final_dataframe['Number of Shares to Buy'] = np.floor(position_size/final_dataframe['Price'])
or df.rank() can be used instead of scipy.stats.percentileofscore()
for time_period in time_periods:
hqm_dataframe[f'{time_period} Return Percentile'] = hqm_dataframe[f'{time_period} Price Return'].rank(method='max', pct=True).mul(100)
Oh, man have a nice day, u made mine easier
thanks for .rank
@@adiletdaniyarov5737 HQM Scores from momentum strategy,
momentum_percentiles = [f'{time_period} Return Percentile' for time_period in time_periods]
hqm_dataframe['HQM Score'] = hqm_dataframe[momentum_percentiles].mean(axis=1)
RV Score from valuations:
rv_dataframe['RV Score'] = rv_dataframe[[i for i in metrics.values()]].mean(axis=1)
:)
That's awesome, thanks you
Bro thank you so much I was getting float errors.
In 58:05 for anyone don't want to use yield, you can use list concatenation for both symbol_groups and symbol_strings
symbol_groups = [list(stocks.Ticker)[x:x+100] for x in range(0, len(list(stocks.Ticker)), 100)]
symbol_strings = [(',').join(i) for i in symbol_groups]
do u have any tips on how to learn and improve my ability in this area after I complete this video? Tryna prepare myself for work in this field was wondering if you have tips!
There were a few questions I had while watching (I am a noob so sorry if any of them sound dumb):
- How do you deploy that? I imagine you wouldn't want it running in Jupyter Notebook.
- Is the accuracy-loss of floats safe to ignore?
- While the concept of high-quality vs low-quality momentum makes sense, why is momentum a good metric? Isn't it likely that since you rely on data from a year ago, your model identify stocks that have already seen their growth and won't grow more? (Like making you buy at high, instead of low)
- Would it be sensible instead of calculating a score to sort all the columns based on different return_percentiles?
- Also, when do you know to sell? I know the premise was that we have a team of traders to whom we send our excel files, but while they'd be able to know how many stocks to buy based on our position and the filtering we did, how do they know when to sell?
this is very useful, you show what needs to be done, how to do it, how to fix errors, what things mean in real life situation. great job and thank you !!!
So far I have only used my python knowledge to program basic games, automation widgets and a few data scrappers but this... My head just exploded with curiosity!🤯 Thank you so much!
@Arid Sohan *paid
@@Mmmkay.. I don’t think that was a typo
@Arid Sohan tf
ya maybe program to teach a bot to give head , we can control the speed
Excellent course for someone new to Algo Trading. It’s precise and well designed course. I would like to see something more along lines of simulating real time strategies like VWAP, TWAP. This one is more of pre-trade analytics. Nonetheless I liked it and strongly suggest to anyone new to Algo trading space!
52:39 If you stuck with appending series to a dataframe like me, this method(.append) returns a new object, so if you want to see the result, you should assign final_dataframe to new variable and then print it.
new_dataframe = final_dataframe.append(pd.Series(
[
symbol,
price,
market_cap,
'N/A'
],
index=my_columns
),
ignore_index=True
)
print(new_dataframe.to_markdown())
TY! assigning the new variable got it to print and installing tabulate
Perfect! Exactly what I got stuck on.
Easy way to add a cost column to your pandas df:
final_dataframe = final_dataframe.apply(lambda x: x['Stock Price'] * x['Number of Shares to Buy'], 1)
*** don't forget the ',1', it specifies the axis :)
I have a few tips for people that may be struggling with setup & other things:
As an alternative to setting up & using a local Jupyter notebook, you can use a Google Colab Notebook (colab.research.google.com) with the following imports:
import numpy as np
import pandas as pd
import requests
import math
!pip install xlsxwriter
If any of you are confused about how to get secrets.py, click on the link & press 'Ctrl/Command + S' to save the file. Upload it into your Google Colab, go to the 'Runtime' menu tab, and click 'Restart & Run All'
Note that if you use Google Colabs, you may have to re-upload the stocks csv & IEX token file after you leave the browser & come back.
Still watching and learning the topics, so far so good, thanks a lot for generous offering this great course and I look forward to seeing this extended topic with advanced techniques and link to specific brokers' API like IB, Futu, etc. Thanks again for your great teaching!!
Note that there are a few pops in Nick's sound at the beginning, but these go away completely once he starts building projects at the 17:20 mark.
great, was worried it was my system 😅
Hi, I am still a beginner, where do we go to install the dependencies... the video skips that part.. thanks
@@blockdisney3676 I think you can start with this anaconda
ruclips.net/video/YJC6ldI3hWk/видео.html
@@contantino_mm Thank you so much!
@@contantino_mm And where to start without this anaconda?
A great detailed starter course to learn some Python. As a licensed commodity trading advisor (and a software engineer), I would never advise someone to trade this though.
?
Could you explain your opinion or suggest anything?
Hello, for people getting to the Key Error for the stocks, the solve is to delete the 4 stocks that have been delisted from the S&P 500:
code example:
stocks = stocks[~stocks['Ticker'].isin(['DISCA', 'HFC','VIAC','WLTW'])]
thanks!
Thanks!
The fun thing about pandas, is that you can work with whole columns without loops, e.g:
final_dataframe['Number of Shares to Buy'] = final_dataframe.apply(
lambda row: math.floor(position_size / row.Price), axis=1)
Oh my god, again, you are doing god work. From dynamic programming now this.
About to take a college course on this topic next semester, so glad this exists!
which course and college? could you please refer to a link?
Waste of time.
@@irvin1241 Im sure most colleges that have a business school within them will have a course or two on python or R that’s centered around finance. The course Im taking next semester is a minicourse to fill out my credit requirement so it’s probably not as in depth as youre looking for. The best place to start would probably be just googling the “python finance college course” and seeing what colleges offer that you’d be willing to pay for. Of course, if youre good at learning things on your own I cant recommend Kaggle enough. Its free and has alot of stuff that you can pull from. Good luck!
@@gomes8335 I dont think its a waste of time, as Im not looking to be a full time programmer. I pay for 18 credits per semester, and using a few of them to focus on my interests outside of my major seems pretty worthwhile to me. I’m not a good self-learner like some people and my background in coding isnt that strong. I think it’ll be a cool way to combine a minor interest with my other education and see if I can really take it anywhere. As always, the internet is truely the best teacher when it comes to programming, but not everyone is suited to that path :)
@@VERY_TALL_MAN Good on you. I wish you luck :)
Hit 200k today. I'm really grateful for all the knowledge and nuggets you had thrown my way over the last months. Started with 14k in June 2022
How please? Am a newbie in crypto investment, please can you guide me through on how you made
Mrs harriet dixson service is a talk of the town in North Holland Netherlands , I started with a little amount of 1ETH, and she made huge returns, and I have been constantly investing with her
@AgbamucheRichardshe often interacts on Telegrams, using the user below
@Harrietdixson12
Tell her I referred you
I can't hide her contact information from anyone who is interested in investing with her because she has really helped me a lot with my trade, today I am smiling
I know absolutely nothing about Python… But this is the first video that seems to clearly explain what my brain just can’t seem to wrap itself around. When I designed the investment strategy that I use, it was simple math, well, it was math… But to suddenly take the algo and transfer it into a language that I am not familiar with, seems like the worst possible prostitution of my time…
I get it, learn Python then write code and be happy ever after but, but, but, why can’t I do that in English? I can read medical journals on just about any topics, all I need is a dictionary and some extra time, I don’t need to mortgage a significant portion of my time on this planet just to learn something that will be old info by the time I’m done learning it… There’s gotta be a practical way to do that in English! Heck in French or Spanish or Russian or any languages! Geese this is so frustrating!!!!!!!
One of the most challenging courses on flying helicopter, preflight. Checking some of these instruction will benefit you greatly. Former Airforce.
Not only application specific, he goes through very comprehensive instruction on Python. Huge kudo!
I'm 12 minutes into this course and I already feel like I'm getting a firm grasp of this stuff. Thank you so much
Stop picking low hanging apples. Go deeper into the subject.
@@panhuragan4388 😂😂
Never wrote one line of code in my life and I feel ready to go work for google. Amazing!
I am really enjoying learning these techniques and am impressed with your style. Thank you for encouraging others to learn!
I'm running into an error in the momentum calculations around percentileofscore implementation, around 2h 30m mark in your video. I am executing the following:
for row in hqm_dataframe.index:
for time_period in time_periods:
change_col = f'{time_period} Price Return'
percentile_col = f'{time_period} Return Percentile'
hqm_dataframe.loc[row, percentile_col] = score(hqm_dataframe[change_col], hqm_dataframe.loc[row, change_col])
and get the error:
TypeError: '
I found a solution to this question in one of the comments. Another user had the same issue and they resolved it by adding this line before the for loops I mentioned:
hqm_dataframe.dropna(inplace=True)
This drops any rows/columns that return N/A as part of f''{time_period} Price Return' column in the hqm_dataframe
People have to remember the point of these videos is to teach you to code a trading algo. He isnt saying that algo will be profitable. That requires some really complex mathematical models like what Jim Simmons and Renaissance do. But these videos are still valuable to learn to build something for its own sake nevertheless.
Just stumbled on this. Thank goodness I got took my trading seriously. Getting into the market surely led to many open doors for me as I've gone to make quadruple of what I put in.
@Raul Guzmann For me, I lost money repeatedly because I didn’t know how to go about it till I came across recommendations of Levi Clemans, a seasoned trade analyst and reached out. It’s been a great journey ever since. You can also get across
Levi clemans(a)Gmai
Lcom...Is he taking commissions for trades? Yes, I’m I still making money in the process? Hell yes!
I have not written this sort of comment before but I feel compelled to. Just wanted to let you know that you’re doing a great job Clemans. You have made a difference in my understanding of the market.
Does Mr Clemans really help people trade?
@@alexpavarde8698 its a scam never listen or join courses about the stock market, they're all a scam.
Thank you for this video but I think everybody is feeling the absence of the second section. Any updates would be greatly appreciated.
Great course. Thank you for all the work you put in and your thorough explanation of how it all works together while coding. I haven't been coding python for more than a year and this was a great refresher course into data science and api use
where did he has shown how to install dependencies and cloning plz help
Another way to skin the cat...
You can put inputs in while loops such that the user is repeatedly queried for input until he gives it correctly (i.e. until he gives numeric input). For example:
portfolio_size = ''
while not isinstance(portfolio_size, float):
portfolio_size = input('Enter the numeric value of your portfolio')
try:
portfolio_size = float(portfolio_size)
except ValueError:
print('Entry must be numeric')
I go this route because assertions, try-except blocks, etc. generally halt execution on errors, requiring you to run the code again. This keeps it going.
Excellent course, NIck!! I enjoyed very much the "real life" approach that included the footage of tracking down bugs. Thanks for not editing that out!
i agree ,especial racking bugs setion i like it
i cant find this Needd Heeellppp!!!
Section 2: Course Configuration & API Basics
How to Install Python
Cloning The Repository & Installing Our Dependencies
Jupyter Notebook Basics
The Basics of API Requests
1.you visit website www.python.org/downloads/
2.open cmd type
"pip install panda"
"pip install numpy"
"pip install jupyterlab"
@@tiandeqiang Thanks and it worked! My steps are a little different 1) I downloaded "Anaconda" and 2) In the Anaconda Prompt I type "pip install panda"
"pip install numpy"
"pip install jupyterlab".
Yeah, its very unfortunate and discouraging to those who are learning the fact that section 2 is missing from the actual video even thou it is mentioned on all the syllabus for this course that I came across. Several people on the comments are complaining about this and I mean... You could at least edit the video description with basic instructions or with a link to where we can find the missing part of the video. After all that is critical information for those who wants to follow along with your course. Thanks anyway
You can use a while loop with the input:
def portfolio_size():
global portfolio_size
while True:
try:
portfolio_size = input('What is your portfolio size?')
if isinstance(float(portfolio_size), float):
break
except ValueError:
print('This is not a number')
awesome!Fix some problems:Before Calculating Momentum Percentiles,Execute the statement first to clean up invalid data.hqm_dataframe.fillna(value=0, inplace=True)
Finished the entire course in 3 days with the new API version ! Feels good!
@duke_adi, which API version did you use? I'm getting the 403 error when using the one mentioned in the video
yahh me to i get the same error@@andrewhenderson593
same, did you find a solution?@@andrewhenderson593
Trading algorithm
1. Mean Reversion
2. Statistical Arbitrage
3. Momentum
4. Trend following
5. Market making & Order execution
6. Sentiment
I just started learning python, it's only been days, but this is my end goal. So I'll be saving this video for later, hopefully it won't be too long before I'm ready for this course.
bro i too want to start with python nd my end goal is gonna be this video. Can you help me where to begin with nd when i will be ready to go with this one
@@zeroXmlbb if you're new to coding, I would start at the basics. Learning functions and variables are a good place to start. If you're like me, and this is your first programming language, I would give myself 3 to 6 months before getting to this level.
Just coming across this video now. Make sure, for the first project, you get an up to date list of all stocks found on the S&P 500. At this time there were 4 stocks that no longer are under the listed tickers with the provided csv file.
I like how you face problems and fix them, thanks for not cutting those parts out of the final video
great video, what I really liked is that you showed in a super clear way how to use the requests library in Python and now I do not need to depend on 3rd party wrappers that might not have all functionality! thanks!
BONUS: In this course a free addictive Python course for beginners / intermediate programmers is included, with clear clarifications about everything you may need ♥
Самое важное в рынке -это понять межбанковский алгоритм поставки цены, далее уже углубляться в микро конъюнктуру рынка, чтобы стоп был коротким и тейк 1к3 минимум. Тогда и математика начинает работать и депозит растет в пропорциях в целостности и гармоничности!
And the fact that this is free re establishes my belief in humanity
There is no such thing as free
Not free for long
This is a great course. I learned so much from it. One suggestion: the robust value trading program should exclude the negative PE Ratio stocks first before sorting for the low 50 stocks.
very nice, thx. the IEX cloud testing sandbox is deprecated but able to workaround using other data provider. e.g. yfinance works fine for me.
Hi, can you walk me through the API part? How do use yfinance for this project?
I don't know much about these or it works, when it comes to trading I have learnt to have an open mind as there are different trading strategies out there.
Do you trade stocks with this?
@@michealvaughan8089 I don't use these but would like to know if it guarantee a 100% win ratio when trading.
Congrats Nick McCullum for creating this. Good that the debugging parts are left in, so we can understand in more details how various parts work.
The API token is not valid anymore, kindly correct it or suggest any other token that we can use
Some stocks have been delisted, to make the tutorial work you must delete the following stocks from either the stocks dataframe or the original sp_500_stocks.csv file:
'DISCA', 'HFC', 'VIAC', 'WLTW'
in fact u can just use 'try:... except:...' structure to avoid the error but don't change the original file
Hi. Do you know how to get the CSV file, I dont find it.
OMG. He talks so fast, but explains concepts so darn clearly..... 👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍
playback 0.75 might help a bit
@@omgitzcoola I love fast speakers:) just amazed by him.
This course is the best on RUclips and it is better than University degrees. Thank you so much for your contribution to us. Is there any way to contribute to you and paying for a certificate after finishing this course?
Coursera
Thank you for this amazing tutorial! I wish there was more of this information 4-5 years ago.
I knew free code camp would have a legit course on this.
this was awesome and though I've just finished the first part only, I cannot thank you enough for how well you explained each portion of the project. Now only, if I could build up from here!
I am from Winnipeg, and I am astounded by your "aboot", I feel like I have been saying it wrong my whole life. Great Video!!
Best definition of an API
Unbelievable! Yall doing sucha great! Thank you very much! God bless yah family!
Great respect from Kazakhstan!
Awesome video, I have learned a lot from watching it untill the end, the only thing is that when I tried to replicate the last project with a real production IEX cloud API it returned error during the module Building a Better Quantative Value Strategy : JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Thanks u soo much sir
U provide free education
❤️❤️ Love from india
What I like about your tutorial is that one doesn’t miss out if they start with the third section.
Also than you didn’t cut out the bugs and struggle helps people to understand that these stuff belong to a programmers life.
Another positive point is that you try to clarify specific financial terms.
Overall you did a great job here.
One point of improvement is your face cam position on the screen.
where did he has shown how to install dependencies and cloning plz help
This guy is awesome, the best thing I liked that he was debugging things in video. Debugging is actually most important part that takes time to learn.
First, I'd like to thank the presenter Nick. Here's my thought about this course.
I was following this course during the first project then fast-forwarded the rest of it. I can confirm it provides an ok depth of alg trading to the audiences who have no knowledge of alg trading. But seriously it would be great if the presenter is able to introduce some more trading algorithms even though just conceptually. I personally feel the presenter focuses too much on the implementation itself and most of the content is to demonstrate how to gather data from idx cloud. I know getting data is crucial but it has very little to do with trading. I don't see the point repeating data collection in all of the three projects. Overall, it is good but not great. Also, the presenter is rushing hard in speaking so if you have little exp in data science or python, you easily get lost.
I'm puzzled by your comment about data's having little to do with trading. You can be a successful trader without looking at prospectuses, without keeping up with the news, etc. Many traders look at nothing but data.
@@CalebDiT I agree with what you said but what I mean is that ppl here are more interested in algorithmic part not data processing part. The whole series can reduced to within an hour tbh.
Great coding tutorial here. Perhaps next time reduce the mugshot size so we can actually seem the code as it goes out of sight at times.
It seems IEX has closed access to the sandbox mode unless you have an account which starts at $49/mth. (30 day free trial).
Best tutorial. New in python and Stock is foreign to me. I actually can have stock conversation, now. Thanks
You clicked on so many lightbulbs for me with this video. Thank you so much.
Awesome tutorial, watched the whole thing through to the end. For the next video tutorial, do you want to show us how to write a trading bot that will automate day trading based on these algorithms?
Bro u intrested to learn more about algo trading?
at 2:28:12 While implementing the percentiles, I noticed that the data I am receiving has None type in it. So the scipy.stats module throws an error as it cant compare the None type instances. For now I am replacing it with 0. Just for people who face this error you can just add this right before you assign your return percentiles
for row in hqm_dataframe.index:
for time_period in time_periods:
if hqm_dataframe.loc[row,f'{time_period} return'] == None:
hqm_dataframe.loc[row,f'{time_period} return']=0
I actually did a hqm_dataframe.dropna(inplace=True), as this values are from stocks that are probably not available anymore using the API
Hey thans guys, you all saved the day :)
@@fcoreas Thank You this fixed it for me
@@fcoreas This worked perfect for me! thank you.
@@fcoreas eyvallah francisco
Notes for myself:
7:06 Quant investing strategy steps.
10:33 what's an API
Useful to me as well, thanks
Only reason for extensive comment that you are receiving great reviews, takes effort to create course like it. Utilizing for example chatgpt is very useful in creating an extensive course like this.
Algo Trading - List of algo trading & backtesting softwares
- (Tradetron) algo and backtest
- (Robomatic) algo and backtest
- (Quntsman) algo and backtest
- (Quantiply) algo
- (Stockmoxk) backtest
- (Algotest) backtest
freakin hell! how good is this! Lockdown boredom solved. Thanks!
if yall getting a modulenotfound error with the secrets.py u can either hardcode the string or import import_ipynb after doing a pip install
Thanks
Hello, I am getting Key Error: Ticker. How can i solve this problem.
you know, Renaissance technologies is something I pass by on my way to almost anywhere and I never knew what they were until now. That's pretty cool
they dnt use python
@@pajeetsingh What do they use?
@@ayansamal2440 A quick Google shows C++
@@goober-ll1wx If you can place order 100 times a minute, it's still not illegal. They place 1000 times a min. It's not illegal. It's calculus of day trading, more like minute or even seconds trading.
@@goober-ll1wx Well he worked for CIA. That should settle your doubt.
When you take the user input this could be an option so that it will keep asking until they provide anportfolio_size = input('Enter the value of your Portfolio : ')
while True:
try:
val = float(portfolio_size)
print(portfolio_size)
break
except ValueError as e:
print('That"s not a number,
please try again')
portfolio_size = input('Enter the value of your Portfolio : ')
print(portfolio_size)
Success is about focusing Your energy on what creates results and using what you already know
'Citadel'- Cue in Fortunate Son and flashbacks of Vietnam with my WSB brothers.
As sandbox is discontinued I'm using the public key provided by IEX within the test period. I'm still getting 403 error. Any ideas?
Thank you very much for this course!!! You've done a wonderful job!
This video provides a great way of analyzing stocks using Python but it definitely isn't trading. We can call it quantitative analytical methods but these are definitely not algorithm-based trading because we don't have a clear strategy here (By strategy I mean the Entry/Exit signal, order type, etc). Good for learning but not at all practical
Really liked the tutorial! There are a few places where you're working on code that's blocked by the video of your face. I could generally extrapolate from what you were saying, but wanted to let you know
Great video, thanks! but very sad ,no way to test myself...indeed, seems api token doesnt work anymore :/
Sandbox testing has been deprecated. Is there any alternate free data api that we can use in this project?
people think if they are coding it already makes them sophisticated and they are going to win the market. In fact, if you can't make a lot of money doing it manually, you can't do this with python, unless its a high frequency trading which you can't do anyway from home.
Don't mistakenly think if you write code you are some sort of sophisticated trader, you still need THE MATH.
Most people do not have the math, and never will.
The strategies presented here all can be easily proven to be wrong using a simple good python backtest.
after 15 mins, i already know this is a very good course
In S&P 500, KSU is replaced by EPAM on December 14th. You will have to revise the sp500 csv file to run successfully.
came here to write exact same comment lol thanks ! was getting json decode error.
How do i revise the CS1 file?
I was getting error at DISCA symbol, which is now gone from the new S&P 500 list.
Also you have to change .append() with .concat()
You can look how on googling -> StackOverflow: Add Pandas Series as a Row to Pandas DataFrame