Skip to main content

Backtest

Python version PyPI version Test Build Coverage Docs License: GPL v3

A backtest engine for developing algorithmic trading strategy.

Table of Contents

Installation

$ pip install backtest

Preparation

Fetching symbols of KOSPI and KOSDAQ exchanges:

$ python -m backtest.utils.symbols_krx symbols.json
Fetched 2,820 symbols
Saved in symbols.json

Usage

The following will execute the backtest after loading configuration file, config.json in same directory.

python -m backtest

Sample content of config.json

{
  "cash": 1000000,
  "ticks_dir": "ticks",
  "ledger_dir": "ledger",
  "symbols_file": "symbols.json",
  "strategy": "strategy",
  "exchanges": [
    "backtest.exchanges.kospi",
    "backtest.exchanges.kosdaq"
  ]
}

Support

Please open an issue for support.

Contributing

Please contribute using Github Flow. Create a branch, add commits, and open a pull request.

Testing

Test codes are prepared in tests/ based on PyTest framework.

Release files for backtest 0.7.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for backtest 0.7.8
File Size Uploaded
backtest-0.7.8.tar.gz 17.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for backtest 0.7.8
File Interpreter ABI Platform
backtest-0.7.8-py3-none-any.whl Python 3 none any Details

Total release size: 55.8 kB

Release files / backtest-0.7.8.tar.gz

Download URL backtest-0.7.8.tar.gz
Size 17.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b36da3489fb0b67299cc21584fb5ade706a3c488fb212e527e92c98d608e7fef
BLAKE2b-256 checksum
How to use checksums
5a1bcd174c6a3bce465e8f10370bc7af165c9f5fee4e6407900c6fdaeff5ac67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.9.0b4

Release files / backtest-0.7.8-py3-none-any.whl

Download URL backtest-0.7.8-py3-none-any.whl
Size 38.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
738ffb215347a378bec43aa5d43e7ff3d6a8ed5f8a3a0c7094529b8eced12022
BLAKE2b-256 checksum
How to use checksums
a289a265896ac06bc39365554fbb888ba6053a1e0014e5c021de40ce84b61afe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.9.0b4
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page