EzyQuant: Powerful Python backtesting for Thai stocks
Features
- Backtest
- Signal Creator
- Data Reader
Installation
pip install ezyquant
or
pip install git+https://github.com/ezyquant/ezyquant
Quick Example
import pandas as pd
import ezyquant as ez
from ezyquant import SETDataReader, backtest
from ezyquant.backtest import Context
ez.connect_sqlite("ezyquant.db")
start_date = "2020-01-01"
end_date = "2020-12-31"
initial_cash = 1e6
# Signal
sdr = SETDataReader()
trade_date_list = sdr.get_trading_dates(start_date, end_date)
signal_df = pd.DataFrame(index=pd.DatetimeIndex(trade_date_list), columns=["AOT"])
def backtest_algorithm(ctx: Context) -> float:
return 100
# Backtest
report = backtest(
signal_df=signal_df,
backtest_algorithm=backtest_algorithm,
start_date=start_date,
end_date=end_date,
initial_cash=initial_cash,
pct_commission=0.25,
)
Backtest report:
port_value port_value_with_dividend
pct_net_profit 0.024916 0.024916
cagr 0.025055 0.025055
pct_maximum_drawdown -0.223604 -0.223604
cagr_divided_maxdd 0.112052 0.112052
pct_win_per_trade 1.0 1.0
std 0.32582 0.32582
cagr_divided_std 0.076899 0.076899
pct_exposure 0.665873 0.665873
total_commission 2483.75 2483.75
initial_capital 1000000.0 1000000.0
ending_capital 1024916.25 1024916.25
net_profit 24916.25 24916.25
maximum_drawdown -235340.125 -235340.125
all_trades 1 1
avg_profit_loss 24916.25 24916.25
pct_avg_profit_loss NaN NaN
avg_bar_held 120.0 120.0
win_trades 1 1
total_profit 22364.0 22364.0
avg_profit 22364.0 22364.0
pct_avg_profit 0.02251 0.02251
avg_win_bar_held 120.0 120.0
max_win_consecutive 1 1
loss_trades 0 0
total_loss 0.0 0.0
avg_loss NaN NaN
pct_avg_loss NaN NaN
avg_lose_bar_held NaN NaN
max_lose_consecutive 0 0
start_date 2020-01-02 00:00:00 2020-01-02 00:00:00
end_date 2020-12-30 00:00:00 2020-12-30 00:00:00
pct_commission 0.25 0.25
pct_buy_slip 0.0 0.0
pct_sell_slip 0.0 0.0
You can find more examples in the examples directory.
Metadata
Release files for ezyquant 0.9.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ezyquant-0.9.6.tar.gz | 14.5 MB | Without provenance | Details for ezyquant-0.9.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ezyquant-0.9.6-py3-none-any.whl | Python 3 | none | any | Details for ezyquant-0.9.6-py3-none-any.whl |
Total release size: 14.5 MB
Release files / ezyquant-0.9.6.tar.gz
| Download URL | ezyquant-0.9.6.tar.gz |
|---|---|
| Size | 14.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bf0819881fb24747681e5ac03150e9e00428311a8e303d48d25ef07f577237a9
|
|
BLAKE2b-256 checksum How to use checksums |
0f4c9198ae5d0580ea5e26fd1f15a56197a0ce598dfb52844c49c3b820b8986b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / ezyquant-0.9.6-py3-none-any.whl
| Download URL | ezyquant-0.9.6-py3-none-any.whl |
|---|---|
| Size | 54.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9957ab0f5628c9c99c72fae9855e3cac1215b1edd1afe63186ab584860aa1413
|
|
BLAKE2b-256 checksum How to use checksums |
8a4a1391e410e1463ae6f8f692172b5881365fd6362366386b6892f3e659d0d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Security for ezyquant 0.9.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.