トレーディング戦略のためのPythonバックテストライブラリ
Project description
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
Release history Release notifications | RSS feed
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.2.tar.gz
(363.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file backcastpro-0.3.2.tar.gz.
File metadata
- Download URL: backcastpro-0.3.2.tar.gz
- Upload date:
- Size: 363.1 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":{"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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdf1047d973371b8eb4e581f4a3097613358aabb5fb2bfe75a95c368254a3f88
|
|
| MD5 |
e1a337e1d7c33cdab047dd9eb040e644
|
|
| BLAKE2b-256 |
94355edffecfa104b3385dbe996c01ed4553b8e0894e06a660557da0f8c10589
|
File details
Details for the file backcastpro-0.3.2-py3-none-any.whl.
File metadata
- Download URL: backcastpro-0.3.2-py3-none-any.whl
- Upload date:
- Size: 70.2 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":{"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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9053883ce27055ef9a2a733f67ea7e3fa619d80b58c59968dc52efc5473f463e
|
|
| MD5 |
d27127597ac995b4d29b812c6bdd1cb3
|
|
| BLAKE2b-256 |
33561452bc30b479a7ba2f394f1923ba98211acbb0425bf538d4dfa161087d4d
|