Skip to main content

A tiny & lightweight quantitative trading framework for learning

Project description

quant-tiny

A tiny & lightweight quantitative trading framework for learning.

Installation

pip install quant-tiny

Quick Start

from quant_tiny import Backtest, Bar, Strategy


class MyStrategy(Strategy):
    def on_bar(self, bar: Bar, portfolio):
        if portfolio.position.is_flat and bar.close > 100:
            return [self.buy(bar.timestamp, 10, bar.close)]
        return []

data = [
    Bar("2024-01-01", 100, 105, 95, 102, 1000),
    Bar("2024-01-02", 102, 108, 100, 106, 1200),
]

backtest = Backtest(data, MyStrategy())
result = backtest.run()
print(f"Final value: ${result['final_value']:.2f}")
print(f"Total trades: {result['total_trades']}")

Run Tests

This project keeps example strategies in pytest tests instead of a separate examples/ directory.

pytest -q

You can find the demo strategy and regression tests in tests/test_core.py.

Features

  • Core Components: Strategy, Bar, Order, Portfolio, Position
  • Backtesting: Simple event-driven backtest engine
  • Indicators: sma(), ema(), rsi()

License

MIT

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

quant_tiny-0.2.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

quant_tiny-0.2.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file quant_tiny-0.2.0.tar.gz.

File metadata

  • Download URL: quant_tiny-0.2.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for quant_tiny-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f66e825c30dbf4b6f97f12be3124555f0a2abc324be4ab4ffa940b78ec076947
MD5 578fcab92b89ff2a623041b553be6a52
BLAKE2b-256 815886a67f61646b8e45d08f5e8a9bfe6bc8932d3a683faa3bc5f09e7c22acd1

See more details on using hashes here.

File details

Details for the file quant_tiny-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: quant_tiny-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for quant_tiny-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4680d0ab00164cd55b8aebf753b01880a4f5c00bb5c6d75f754d7e31e990427c
MD5 51885114609436e308e8041f5e760a88
BLAKE2b-256 c7903e2c2910c8e44563092fd2a9f3aa41d0ac5ca92a4d1b40f29f87e448d575

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