Skip to main content

トレーディング戦略のためのPythonバックテストライブラリ

Project description

BackcastPro Logo BackcastPro

トレーディング戦略のためのPythonバックテストライブラリ。 リプレイ型シミュレーターで、1バーずつ時間を進めながらチャートと売買を可視化できます。

インストール(Windows)

PyPIから(エンドユーザー向け)

python -m pip install BackcastPro

開発用インストール

git clone <repository-url>
cd BackcastPro
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -e .
python -m pip install -r requirements.txt

使用方法

基本的な使い方

from BackcastPro import Backtest
import pandas as pd

# データ準備
df = pd.read_csv("AAPL.csv", index_col=0, parse_dates=True)
bt = Backtest(data={"AAPL": df}, cash=100000)

# 戦略関数
def my_strategy(bt):
    if bt.position == 0:
        bt.buy(tag="entry")
    elif bt.position > 0:
        bt.sell(tag="exit")

# ステップ実行
while not bt.is_finished:
    my_strategy(bt)
    bt.step()

# 結果を取得
results = bt.finalize()
print(results)

一括実行

bt = Backtest(data={"AAPL": df}, cash=100000)
results = bt.run_with_strategy(my_strategy)

marimo連携(リプレイ型シミュレーター)

import marimo as mo

slider = mo.ui.slider(start=1, stop=len(bt.index), value=1, label="時間")
bt.goto(slider.value, strategy=my_strategy)
chart = bt.make_chart()  # plotlyローソク足 + 売買マーカー

mo.vstack([slider, chart])

ドキュメント

バグ報告 / サポート

  • バグ報告や要望は GitHub Issues へ
  • 質問は Discord コミュニティへ(招待リンク
  • 使い方はドキュメントをご参照ください

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

backcastpro-0.3.0.tar.gz (363.7 kB view details)

Uploaded Source

Built Distribution

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

backcastpro-0.3.0-py3-none-any.whl (70.5 kB view details)

Uploaded Python 3

File details

Details for the file backcastpro-0.3.0.tar.gz.

File metadata

  • Download URL: backcastpro-0.3.0.tar.gz
  • Upload date:
  • Size: 363.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for backcastpro-0.3.0.tar.gz
Algorithm Hash digest
SHA256 627da6c1feab8a87c469143f34a39037f9f09225272340ba2ebff7d742baa649
MD5 bc55bf6d126af8f4476456e7f2d7f18a
BLAKE2b-256 d9b1d64c4f639bb6596978eccd51e4bfcd22c4174b7213533d9bfe20b4e7dc78

See more details on using hashes here.

File details

Details for the file backcastpro-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: backcastpro-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 70.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for backcastpro-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 629aa8e39cbb38812e36099a260cb9252ad2a1ced1a65f6d1a306c5441ce2de2
MD5 d76c8c0c182b324b943988188c32bd05
BLAKE2b-256 c71605014c024d1e73528b302517e591358d351948abb947cb98091a169ddaad

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