mattygyo / stock_portfolio_analysis

Provide a CSV of stock transactions and measure performance against a Benchmark
MIT License
41 stars 31 forks source link

Not showing data during period #1

Open giorgiooriani opened 4 years ago

giorgiooriani commented 4 years ago

Hi, when I insert my own stock portfolio csv, and change the stocks_start and stocks_end period, it only plots stocks bought before the stocks_start date. Any stocks bought within the time period are not graphed or calculated.

Thanks for the great work!

mattygyo commented 4 years ago

Good find, I modified the logic slightly and it should be working now, let me know if you still have issues!

giorgiooriani commented 4 years ago

Thanks! I am a complete novice at coding, how can I export the results in csv format? (stuff like portfolio returns and benchmark returns etc?) Also is it possible to have foreign stocks and have their gain converted to USD or vice versa? (taking into account the exchange rate at purchase and sale)

giorgiooriani commented 4 years ago

Good find, I modified the logic slightly and it should be working now, let me know if you still have issues!

Apologies, I just tried with your fix and it's still not displaying stocks added within the specified time period. It still only takes stocks purchased before stocks_start.

mattygyo commented 4 years ago

Thanks! I am a complete novice at coding, how can I export the results in csv format? (stuff like portfolio returns and benchmark returns etc?) Yup using the pandas library you can do combined_df.to_csv('<whatever_you_want_the_final_name_as>.csv')

Also is it possible to have foreign stocks and have their gain converted to USD or vice versa? (taking into account the exchange rate at purchase and sale) This would need to be added. It would need to account for trading calendars in different markets and you'd need to merge historical currency exchange data for FX using a library like https://github.com/MicroPyramid/forex-python

mattygyo commented 4 years ago

Apologies, I just tried with your fix and it's still not displaying stocks added within the specified time period. It still only takes stocks purchased before stocks_start.

Could you send me 2 symbols and the start/end date you're using?

giorgiooriani commented 4 years ago

I have BA and AMD as two of the symbols I am using. The dates I am using are 16/03/2020 (or 2020, 03, 16 for your code) to yesterday.

edit: if it helps, if I move the start date forward to beyond the date I purchased the stock, it includes it. If the start date is before the purchase, it includes it

mattygyo commented 4 years ago

what were the purchase dates of BA and AMD??

giorgiooriani commented 4 years ago

Boeing was 24/04 and AMD was 14/04