Skip to main content

Algorithmic trading research utilities for quant teams

Project description

hqg-algorithms

Interfaces and helper types for writing HQG trading strategies.

Install

python3 -m pip install --upgrade pip setuptools wheel
pip install hqg-algorithms

Implement a strategy

Subclass Strategy and implement the three abstract methods the backtester calls.

Example:

from datetime import timedelta
from hqg_algorithms import Strategy, Cadence, Slice, PortfolioView


class BuyAndRebalanceSpyIef(Strategy):
    def universe(self) -> list[str]:
        return ["SPY", "IEF"]

    def cadence(self) -> Cadence:
        return Cadence( 
            bar_size=timedelta(days=1), # default
            call_phase="on_bar_close", # default
            exec_lag_bars=1, # default
        )

    def on_data(self, data: Slice, portfolio: PortfolioView) -> dict[str, float] | None:
        # Rebalance daily
        return {"SPY": 0.6, "IEF": 0.4}

Key lifecycle methods:

  • universe() tells the platform which symbols to load.
  • cadence() specifies call frequency, trigger phase, and execution lag.
  • on_data(data, portfolio) returns target portfolio weights, {} for all cash, or None to skip an update.

Slice exposes helper methods like slice.close(symbol) to inspect prices, while PortfolioView gives read-only access to current holdings and weights.

Additional docs

  • Publishing workflow and release checklist: docs/publishing.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hqg_algorithms-0.1.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hqg_algorithms-0.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file hqg_algorithms-0.1.0.tar.gz.

File metadata

  • Download URL: hqg_algorithms-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for hqg_algorithms-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6d148a2c62698913b97029b711ba0fec0636eea9c301cb4009325b0a336cb44b
MD5 cd0e81d2610ca196008f431faa5d8f8d
BLAKE2b-256 fd97ed72a03892990fbd2446f9573b446d2f29f943aa461d1db7cbc6cbf7867d

See more details on using hashes here.

File details

Details for the file hqg_algorithms-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hqg_algorithms-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for hqg_algorithms-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 62b0a4d74e9faa8ac0d07edf1928759acb3c397c68f27f473c94abf72eb5f630
MD5 81153cc55915d46dc332786ff66fa8c8
BLAKE2b-256 f11f5186f2c4ec7d742bebc9b0a2439865264612c2322e64d7001aaef70431cc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page