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 .

使用方法

基本的な使い方

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)
bt.set_strategy(my_strategy)
results = bt.run()

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)

state = bt.get_state_snapshot()
info = mo.md(f"資産: ¥{state['equity']:,.0f} / 進捗: {state['progress'] * 100:.1f}%")

mo.vstack([slider, info])

ドキュメント

バグ報告 / サポート

  • バグ報告や要望は 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.6.4.tar.gz (422.0 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.6.4-py3-none-any.whl (71.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: backcastpro-0.6.4.tar.gz
  • Upload date:
  • Size: 422.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for backcastpro-0.6.4.tar.gz
Algorithm Hash digest
SHA256 6e3d7f029742e367e8c92ef1e95ff4c27a0d4283782b8b66069cafd8a878db13
MD5 cb31f2bd0aa116205d8aed6ae87e5ed4
BLAKE2b-256 1ca81e8a20bb5231a28bfdc23df7f942a7f5aef29326ee4777b36130254aef3b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for backcastpro-0.6.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5b3d1f0de6dccb104f6fd73bcc53eea2fc26a60f33c455ed95818ad108b97b57
MD5 05d6d298c56bb9e7aae93da6bec43d20
BLAKE2b-256 f2eb2b63a62e61b4288b3d3414b618f4bd2237eb6cb8d41ccc701edb1a58a293

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