Skip to content

galen-f/Algorithmic-Backtester

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📈 Trading Strategy Backtester

This is a python-based backtesting engine for evaluating stock trading strategies, using historical price data from Yahoo Finance and displaying it in user-friendly graphs. Additionally presents metrics like the % of days in a trade, the Buy and Hold returns of the period, how many trades were made, etc.


🛠️ Features

  • Fetches historical data from Yahoo Finance
  • Implements various algorithmic trading strategies
  • Simulates capital growth and calculates total returns
  • Visualizes signals and price action
  • CLI Interaction for selecting strategies and stocks

🧪 Strategies

Buy-and-Hold

A simple strategy which buys a stock at a specific date (the start date) and sells it at another specified date (the end date). It's useful for testing other strategies.

Moving Average Crossover

This strategy combines a short-term moving average with a long-term moving average. If the short-term moving average is greater than the long-term moving average, this indicates a bullish market, so we buy. If the short-term average is less, we sell.

Moving Average Convergence Divergence (MACD)

This is a widley used trading strategy. We once again take two moving averages, a long and a short, and take the moving average of those two moving averages, this gives us the MACD line. Then we take a moving average of the MACD line, this is the signal line.

We can measure if the MACD line is above the Signal line, we want to be in a buy position, if the opposite is true, we want to be in a sell position.

MACD+

An adjustment of the MACD strategy which includes more trend indicators, such as only buying if the MACD line is negative (undervalued) and the stock is above a 200 day EMA (Uptrend). Often too cautious to be profitable, but good at reducing losses in downtrending markets.

Agressive MACD

A further adjustment of the cautious MACD which attempts in increase the agressivness of the algorithm. Very profitable in bull markets but very vulnerable in bear markets. Increases the aggression by only selling when the downwards momentum is significant and below the 200 day EMA.


🚀 Running

pip install yfinance pandas matplotlib python main.py
Then follow the terminal prompts to input a strategy and run the backtest.


Skills

Technical Skills

  • Python
  • Pandas
  • Matplotlib
  • Algorithmic trading strategy implementation
  • Backtesting Methodologies

Financial Skills

  • Technical Indicators (MA, EMA, MACD, ETC.)
  • Historical Market Analysis
  • Quantitative Research Methods
  • Portfolio Simulation and Capital Compounding
  • Signal Generation and Position Management
  • Trading Strategies

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages