Skip to content

Turtle Quant 1

All hail the turt. Modular technical-indicator strategies, parallel backtesting and one-click cloud deployment — built for systematic trading.

Tech stack

Technical indicators

A widely varied collection of modular, hand-selected momentum and candlestick pattern indicators that provide early detection of changes in the direction of price trends.

Support / resistance

Support and resistance algorithms combined through a fair voting mechanism for high accuracy and confidence.

Parallelisation

Multiprocessing and multithreading run strategy calculations in parallel, increasing throughput.

Memoization

Thread-safe, file-based caches for expensive indicator calculations speed up backtesting and live predictions.

Cloud orchestration

Google Cloud Run Jobs execute long-running tasks in parallel for better throughput and responsiveness.

DevOps

A one-click push-to-main CI/CD pipeline builds and deploys Docker images and Cloud Run Jobs with GitHub Actions and Terraform.

Software design

Loosely-coupled, cohesive classes with plug-and-play multi-vendor support (e.g. Yahoo Finance, Alpha Vantage).

Get started with development

  1. Clone the repository.
git clone https://github.com/jyjulianwong/Turtle-Quant-1.git
  1. Verify that you have a compatible Python version installed on your machine.

    python --version
    

  2. Install uv (used as the package manager for this project).

  3. Install the development dependencies.

    cd Turtle-Quant-1/
    uv sync --all-groups
    uv run pre-commit install
    

Get started with Jupyter notebooks

  1. Once the above setup is complete, set up a Python kernel.

    source .venv/bin/activate
    python -m ipykernel install --user --name=turtle-quant-1
    

  2. Refer to the following common commands.

    jupyter kernelspec list
    jupyter kernelspec uninstall turtle-quant-1
    

  3. Start the Jupyter server.

    jupyter lab
    

Common entry points

Backtesting

Run the following script to run all custom backtesting test cases.

uv run turtle_quant_1/backtesting/main.py

Hyperparameter tuning

Run the following script to run hyperparameter tuning across all strategies.

uv run turtle_quant_1/backtesting/hyperparameters.py

Deployment

For naming conventions, refer to https://stepan.wtf/cloud-naming-convention/.

Continuous deployment

Deployment is fully automated and handled by GitHub Actions. Refer to: - .github/workflows/main-deploy.yaml - .github/workflows/main-docs.yaml - .github/workflows/dev-test.yaml

Google Cloud administration

Setting IAM permissions and roles

export GOOGLE_CLOUD_PROJECT=$(gcloud config get-value core/project)
gcloud iam service-accounts create svc-usea1-tf
gcloud iam service-accounts keys create ~/key.json --iam-account svc-usea1-tf@${GOOGLE_CLOUD_PROJECT}.iam.gserviceaccount.com
gcloud projects add-iam-policy-binding ${GOOGLE_CLOUD_PROJECT} --member "serviceAccount:svc-usea1-tf@${GOOGLE_CLOUD_PROJECT}.iam.gserviceaccount.com" --role "roles/bigquery.user"
gcloud projects get-iam-policy $GOOGLE_CLOUD_PROJECT