nickmccullum / algorithmic-trading-python

The repository for freeCodeCamp's YouTube course, Algorithmic Trading in Python
2.35k stars 2.37k forks source link

Number of Shares to Buy is extremely low on my recommended_trades.xlsx #24

Open dekacypher opened 2 years ago

dekacypher commented 2 years ago

The Number of Shares to Buy i get when my code has run is extremely low compared to what is displayed on the algorithmic trading video. I dont understand why?

My recommended_trades.xlsx file:

Screen Shot 2022-01-26 at 18 44 03

And my code: `portfolio_size = input("Enter the value of your portfolio:") try: val = float(portfolio_size)

print(val)

except ValueError: print("That's not a number \nPlease try again:") portfolio_size = input("Enter the value of your portfolio:") val = float(portfolio_size)

position_size = val/len(final_dataframe.index)

for i in range(0, len(final_dataframe.index)): final_dataframe.loc[i,'Number of Shares to Buy'] = math.floor(position_size/final_dataframe.loc[i,"Stock Price"]) final_dataframe`

My output: Screen Shot 2022-01-26 at 19 00 32

The Algorithmic Trading in Python video by nickmcullum:

Screen Shot 2022-01-26 at 18 45 09