Inspiration
We built this project to better understand how trading signals are created from real market data. As students interested in maths, finance, and programming, we wanted to take concepts we were learning and apply them to something practical and hands-on.
Instead of just reading about trading strategies, we wanted to actually build one from scratch.
What the project does
Our project pulls historical price data from Yahoo Finance and generates two types of trading signals:
1) Moving Average Crossover
We calculate a fast and slow moving average of the stock price.
- When the fast average crosses above the slow average, we generate a BUY signal.
- When the fast average crosses below the slow average, we generate a SELL signal.
This is a simple and widely used trend-following strategy.
2) Markov Chain Model
We also built a probability-based model using a Markov chain.
- We convert daily price changes into different “states” (large drop, small rise, etc.).
- We calculate how often the market moves from one state to another.
- Using the most recent state, we estimate the most likely next move.
This gives us a probabilistic bias rather than a fixed signal.
How we built it
We structured the project into clear sections:
- A SymbolCollector class to fetch, validate, and clean data from Yahoo Finance
- Moving average calculations using pandas
- A Markov model using numpy to calculate transition probabilities
- Clear printed outputs showing signals and predictions
We focused on writing readable, beginner-friendly code that could be extended later.
Challenges we faced
Some of the main challenges were:
- Handling missing or invalid data
- Debugging errors caused by passing the wrong objects between functions
- Making sure crossover signals only trigger once (and not repeatedly)
- Structuring the Markov model correctly outside of loops
These debugging steps helped us better understand both Python and financial data.
What we learned
Through this project, we learned:
- How to work with real financial time series data
- How to structure a Python project properly
- How to implement both rule-based and probability-based models
- How small coding mistakes can completely change results
Future Improvements
If we continue developing this project, we would like to:
- Add a backtesting system to measure performance
- Plot price charts with signals visually displayed
- Improve the Markov model using better binning methods
- Experiment with different timeframes and parameter settings
Built With
- appwizzy
- python
Log in or sign up for Devpost to join the conversation.