8000 GitHub - akapet00/algotrading-in-python: Algorithmic trading with Python
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

akapet00/algotrading-in-python

Repository files navigation

Algorithmic Trading Using Python

Python 3.10 License: MIT Jupyter yfinance freeCodeCamp

This repository is a modernized version of the popular Algorithmic Trading Course by freeCodeCamp.org.

What's new?

  • Replaced deprecated IEX Cloud API with yfinance
  • Optimized data fetching using multithreading
  • Added portfolio optimization and backtesting for momentum- and value-based strategies

📊 Strategy Overview

This project covers and enhances the three original strategy modules:

Equal-weight S&P 500 index fund

  • Replicates an S&P 500 ETF by equally weighting all constituents
  • Automatically rebalances the portfolio using live price data

Quantitative momentum strategy (Extended)

  • Ranks S&P 500 stocks based on their 12-month price performance
  • Selects top performers to construct a momentum-based portfolio
  • Includes a full backtest comparing performance vs. SPY

Quantitative value strategy (Extended)

  • Identifies undervalued stocks using multiple valuation metrics:
    • Price-to-Earnings (P/E)
    • Price-to-Book (P/B)
    • Price-to-Sales (P/S)
    • EV/EBITDA
    • EV/Gross Profit
  • Computes a composite score using percentiles of valuation metrics
  • Applies mean-variance optimization to construct a long-only portfolio
  • Includes a full backtest comparing performance vs. SPY

Each project generates an Excel file containing the recommended trades based on the strategy logic.

⚙️ Environment Setup

This project uses uv, a superfast Python package manager to setup the environment.

Install uv

Download and install:

curl -Ls https://astral.sh/uv/install.sh | sh

Initialize the environment

Inside the directory run:

uv init .

and you're ready to go.

Start Jupyter Lab

Run

uv run --with jupyter jupyter lab

to start the server at http://localhost:8888/lab.

Alternatively, to use in VS Code, create a Jupyter kernel:

uv add --dev ipykernel

Inside the VS Code hit Ctrl+Shift+PPython: Select Interpreter → choose .venv (created by uv).

📦 Dependencies

Main libraries used:

  • yfinance for financial data
  • pandas, numpy, scipy for data analysis
  • cvxpy for portfolio optimization
  • matplotlib, seaborn for visualization
  • concurrent.futures for multithreading

🙌 Credits

Releases

No releases published

Packages

No packages published
0