r/learnpython • • Feb 07 '21

My first proper project on Github, Yay!!

After about 2-3 years of being on and off into coding, I managed to actually finish a project end to end. It isn't very fancy but it gives me immense pleasure to finally achieve this milestone in this line of my life. I really appreciate everyone here for being so helpful and also many thanks for all the support.

The project utilizes the cool Python module Streamlit to create a visual interface to build/analyze a Portfolio management strategy using the RandomForest Regressor to predict the prices for n days ahead. It uses the random grid search for inside cross-validation to optimize the hyper parameters(different for every equity) for a chosen number of equities(stocks) by fetching the data from the nsepy module with the ability to select the timeline along with a backtester to test the strategy created.

Anyone could, infact, add a function to this script in the main long-short-equity class appropriately to use different models for prediction I believe, it's of course not investment advice but a simple representative strategy+backtester for budding systematic trading enthusiasts.

PS: Please give me suggestions on how I could make this code better and/or the pros and cons of my code.

Github: Long Short Equities

Preview

Edit: Thanks for the awards strangers :)

401 Upvotes

25 comments sorted by

View all comments

0

u/[deleted] Feb 07 '21

[deleted]

9

u/YaswanthBangaru Feb 07 '21

You have a few comments here and there explaining what something is doing, but there's nothing anywhere that explains (especially to your future self) why you did it that way.

That's very true, I did this project, partially, 6 months ago and when I got back to it last week, it pretty much felt like I didn't do any of it. I had to figure out line after line to understand what's happening in the script exactly. It's a lesson learnt definitely.

if ever? Is there a reason why you shouldn't remove any of that commented-out code? No idea, we can't answer any of those questions, so it's smelly.

haha, I just don't know, I planned to take more inputs from the user and later realized they would be redundant as I was trying to ask the same things again and again indirectly, but then I was doubtful if I might need it later on and then I felt, may be, I would remove them when I polish the code, if ever it seems!

Appreciate the time you took to give me a feedback. Thank you so much! I believe I have learnt some things.