<div align="center">
<img src="static/images/systematic-trading.jpeg" height=200 alt=""/>
<h1>Papers With Backtest Toolbox</h1>
</div>
The `pwb-toolbox` package is designed to provide tools and resources for systematic trading strategies. It includes datasets and strategy ideas to assist in developing and backtesting trading algorithms. For detailed instructions on how to use this package effectively, please refer to the associated Substack publication by visiting: https://blog.paperswithbacktest.com/.
## Installation
To install the pwb-toolbox package:
```bash
pip install pwb-toolbox
```
This package requires Python 3.10 or higher.
To login to Huggingface Hub (where PWB datasets are hosted) with Access Token
```bash
huggingface-cli login
```
## Usage
The `pwb-toolbox` package offers a range of functionalities for systematic trading analysis. Here are some examples of how to utilize the package:
### Datasets
- Import `pwb_toolbox.datasets` and sequentially loads datasets for different asset classes, such as bonds, commodities, cryptocurrencies, ETFs, forex, indices, and stocks, using the `load_dataset` function:
```python
import pwb_toolbox.datasets as pwb_ds
df = pwb_ds.get_pricing(["AAPL", "MSFT", "GOOGL"])
df = pwb_ds.load_dataset("Bonds-Daily-Price")
df = pwb_ds.load_dataset("Commodities-Daily-Price")
df = pwb_ds.load_dataset("Cryptocurrencies-Daily-Price")
df = pwb_ds.load_dataset("ETFs-Daily-Price")
df = pwb_ds.load_dataset("Forex-Daily-Price")
df = pwb_ds.load_dataset("Indices-Daily-Price")
df = pwb_ds.load_dataset("Stocks-Daily-Price")
```
- Load daily stock price data for specific symbols using the load_dataset function. The first call retrieves data for Apple and Microsoft. The second call retrieves the same stocks but without price adjustments (`adjust=False`). The third call loads daily price data for the S&P 500 index:
```python
import pwb_toolbox.datasets as pwb_ds
df = pwb_ds.load_dataset(
"Stocks-Daily-Price",
["AAPL", "MSFT"],
)
df = pwb_ds.load_dataset(
"Stocks-Daily-Price",
["AAPL", "MSFT"],
adjust=False,
)
df = pwb_ds.load_dataset(
"Stocks-Daily-Price",
["sp500"],
)
```
- The `extend=True` argument instructs the function to return an extended historical data using indices, commodities, and bonds data.
```python
import pwb_toolbox.datasets as pwb_ds
df = pwb_ds.load_dataset(
"ETFs-Daily-Price",
["SPY", "IEF"],
extend=True,
)
```
- The argument `rate_to_price=False` specifies that bond yield rates should not be converted to price values in the returned data:
```python
import pwb_toolbox.datasets as pwb_ds
df = pwb_ds.load_dataset(
"Bonds-Daily-Price",
["US10Y"],
rate_to_price=False,
)
```
- The argument `to_usd=False` indicates that the data should not be converted to U.S. dollars, implying that it might be available in another currency.
```python
import pwb_toolbox.datasets as pwb_ds
df = pwb_ds.load_dataset(
"Indices-Daily-Price",
["US10Y"],
to_usd=False,
)
```
### Backtest engine
The `pwb_toolbox.backtesting` module offers simple building blocks for running
Backtrader simulations. Alpha models generate insights which are turned
into portfolio weights and executed via Backtrader orders.
```python
from pwb_toolbox.backtesting.examples import GoldenCrossAlpha, EqualWeightPortfolio
from pwb_toolbox.backtesting import run_backtest
from pwb_toolbox.backtesting.execution_models import ImmediateExecutionModel
from pwb_toolbox.backtesting.risk_models import MaximumTotalPortfolioExposure
from pwb_toolbox.backtesting.universe_models import ManualUniverseSelectionModel
run_backtest(
ManualUniverseSelectionModel(["SPY", "QQQ"]),
GoldenCrossAlpha(),
EqualWeightPortfolio(),
execution=ImmediateExecutionModel(),
risk=MaximumTotalPortfolioExposure(max_exposure=1.0),
start="2015-01-01",
)
```
The backtesting package is composed of a few focused modules:
- `backtest_engine` – glue code that wires together universe selection,
alpha models, portfolio construction and execution into a Backtrader run.
- `base_strategy` – common bookkeeping and helpers used by all provided
strategies.
- `commission` – cost models for simulating broker commissions and spreads.
- `indicators` – reusable signal and technical indicator implementations.
- `optimization_engine` – genetic‑algorithm tooling for parameter searches.
- `portfolio` – utilities for combining the results of several strategies and
producing performance reports.
- `strategies` – ready‑to‑use Backtrader `Strategy` subclasses.
- `universe` – helpers for building trading universes (e.g. most liquid symbols).
`pwb_toolbox.backtesting.strategies` ships a collection of portfolio templates
with different rebalancing rules and signal expectations:
- **DailyEqualWeightPortfolio** – holds all assets with a long signal and
allocates equal weight each day.
- **DailyLeveragePortfolio** – goes long with fixed leverage when the signal is
1 and is otherwise flat.
- **EqualWeightEntryExitPortfolio** – opens equally‑weighted positions when an
entry condition triggers and leaves existing winners untouched.
- **DynamicEqualWeightPortfolio** – event‑driven equal‑weight portfolio that can
rebalance on any signal change or only when the set of long assets changes.
- **MonthlyLongShortPortfolio** – once per month allocates half of the leverage
to longs and half to shorts based on a universe‑aware signal.
- **MonthlyLongShortQuantilePortfolio** – monthly rebalance that ranks assets
by a per‑asset signal and goes long the strongest and short the weakest.
- **MonthlyRankedEqualWeightPortfolio** – monthly equal‑weight portfolio with an
optional ranking step and support for keeping only the top *N* assets.
- **QuarterlyTopMomentumPortfolio** – every quarter concentrates exposure in the
single asset with the strongest recent momentum.
- **RollingSemesterLongShortPortfolio** – semi‑annual rebalancing template that
accumulates long/short signals over six‑month windows.
- **WeeklyLongShortDecilePortfolio** – rebalances weekly and trades the top and
bottom deciles of a signal distribution.
- **WeightedAllocationPortfolio** – turns user‑provided weights into integer
share positions under a leverage constraint.
### Optimal Limit Order Execution
The module `pwb_toolbox.execution.optimal_limit_order` implements the optimal
limit‑order placement framework described in *Optimal Portfolio Liquidation with Limit Orders* by Guéant, Lehalle, and Tapia.
Given a target quantity and time horizon, `get_optimal_quote` solves the associated system of
differential equations to return the price offset from the mid‑price that
maximises the expected utility of execution. Market parameters such as
volatility (`sigma`), arrival rate of market orders (`A`), liquidity impact
(`k`), trader risk aversion (`gamma`) and liquidation penalty (`b`) can be
supplied to model different scenarios. Setting `is_plot=True` visualises the
optimal quote path over time.
### Live Strategy Execution
The execution helpers in `pwb_toolbox.execution` can connect to brokers to run
strategies in real time. A typical session collects account information,
computes target positions and submits the necessary orders.
#### Interactive Brokers
```python
from pathlib import Path
import pandas as pd
from pwb_toolbox import execution as pwb_exec
STRATEGIES = {"my_strategy": {"path": "my_package.my_strategy", "weight": 1.0}}
logs_dir = Path("logs")
ACCOUNT_REFERENCE_NAV_VALUE = 100_000
ACCOUNT_REFERENCE_NAV_DATE = pd.Timestamp("2023-01-01")
LEVERAGE = 1.0
MARKET_DATA_TYPE = 1
ibc = pwb_exec.IBConnector(market_data_type=MARKET_DATA_TYPE)
ibc.connect()
account_nav_value = ibc.get_account_nav()
account_nav_date = pd.Timestamp.today().normalize()
nav_entry = pwb_exec.append_nav_history(logs_dir, account_nav_value)
nav_series, raw_positions = pwb_exec.run_strategies(STRATEGIES)
strategies_positions, theoretical_positions = pwb_exec.scale_positions(
STRATEGIES,
raw_positions,
nav_series,
ACCOUNT_REFERENCE_NAV_VALUE,
LEVERAGE,
ACCOUNT_REFERENCE_NAV_DATE,
)
ib_positions = ibc.get_positions()
orders = pwb_exec.compute_orders(theoretical_positions, ib_positions)
execution_time = 5 * 60 # five minutes
trades = pwb_exec.execute_and_log_orders(ibc, orders, execution_time)
pwb_exec.log_current_state(
logs_dir,
account_nav_value,
strategies_positions,
theoretical_positions,
ib_positions,
orders,
account_nav_date,
trades=trades,
nav_history_entry=nav_entry,
)
ibc.disconnect()
```
#### CCXT Exchanges
```python
from pathlib import Path
import pandas as pd
from pwb_toolbox import execution as pwb_exec
STRATEGIES = {"my_strategy": {"path": "my_package.my_strategy", "weight": 1.0}}
logs_dir = Path("logs")
ACCOUNT_REFERENCE_NAV_VALUE = 100_000
ACCOUNT_REFERENCE_NAV_DATE = pd.Timestamp("2023-01-01")
LEVERAGE = 1.0
cc = pwb_exec.CCXTConnector(
exchange="binance",
api_key="YOUR_API_KEY",
api_secret="YOUR_API_SECRET",
)
cc.connect()
account_nav_value = cc.get_account_nav()
account_nav_date = pd.Timestamp.today().normalize()
nav_entry = pwb_exec.append_nav_history(logs_dir, account_nav_value)
nav_series, raw_positions = pwb_exec.run_strategies(STRATEGIES)
strategies_positions, theoretical_positions = pwb_exec.scale_positions(
STRATEGIES,
raw_positions,
nav_series,
ACCOUNT_REFERENCE_NAV_VALUE,
LEVERAGE,
ACCOUNT_REFERENCE_NAV_DATE,
)
cc_positions = cc.get_positions()
orders = pwb_exec.compute_orders(theoretical_positions, cc_positions)
execution_time = 5 * 60
trades = pwb_exec.execute_and_log_orders(cc, orders, execution_time)
pwb_exec.log_current_state(
logs_dir,
account_nav_value,
strategies_positions,
theoretical_positions,
cc_positions,
orders,
account_nav_date,
trades=trades,
nav_history_entry=nav_entry,
)
cc.disconnect()
```
### Performance Analysis
After running a live trading session, you can analyze the returned equity series using the
`pwb_toolbox.performance` module.
```python
from pwb_toolbox.backtesting.examples import GoldenCrossAlpha, EqualWeightPortfolio
from pwb_toolbox.backtesting import run_backtest
from pwb_toolbox.backtesting.execution_models import ImmediateExecutionModel
from pwb_toolbox.performance import total_return, cagr
from pwb_toolbox.performance.plots import plot_equity_curve
result, equity = run_backtest(
ManualUniverseSelectionModel(["SPY", "QQQ"]),
GoldenCrossAlpha(),
EqualWeightPortfolio(),
execution=ImmediateExecutionModel(),
start="2015-01-01",
)
print("Total return:", total_return(equity))
print("CAGR:", cagr(equity))
plot_equity_curve(equity)
```
## Contributing
Contributions to the `pwb-toolbox` package are welcome! If you have any improvements, new datasets, or strategy ideas to share, please follow these guidelines:
1. Fork the repository and create a new branch for your feature.
2. Make your changes and ensure they adhere to the package's coding style.
3. Write tests to validate the functionality or provide sample usage examples.
4. Submit a pull request, clearly explaining the purpose and benefits of your contribution.
Please note that all contributions are subject to review and approval by the maintainers.
### Build the Package
To build the package, run:
```bash
python -m pip install --upgrade build
rm -r dist
python -m build
```
To upload the package to PyPI, run:
```bash
twine upload dist/*
```
## Contact
For any questions, issues, or suggestions regarding the `pwb-toolbox` package, please contact the maintainers or create an issue on the repository. We appreciate your feedback and involvement in improving the package.
Happy trading!
Raw data
{
"_id": null,
"home_page": "https://github.com/paperswithbacktest/pwb-toolbox",
"name": "pwb-toolbox",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Your Name",
"author_email": "hello@paperswithbacktest.com",
"download_url": "https://files.pythonhosted.org/packages/0b/98/cbd2e73941bd1cf714c64055954e7242ce5ec61029c9c52d9a2ee0bb035c/pwb_toolbox-0.1.22.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n <img src=\"static/images/systematic-trading.jpeg\" height=200 alt=\"\"/>\n <h1>Papers With Backtest Toolbox</h1>\n</div>\n\nThe `pwb-toolbox` package is designed to provide tools and resources for systematic trading strategies. It includes datasets and strategy ideas to assist in developing and backtesting trading algorithms. For detailed instructions on how to use this package effectively, please refer to the associated Substack publication by visiting: https://blog.paperswithbacktest.com/.\n\n\n## Installation\n\nTo install the pwb-toolbox package:\n\n```bash\npip install pwb-toolbox\n```\nThis package requires Python 3.10 or higher.\n\nTo login to Huggingface Hub (where PWB datasets are hosted) with Access Token\n\n```bash\nhuggingface-cli login\n```\n\n## Usage\n\nThe `pwb-toolbox` package offers a range of functionalities for systematic trading analysis. Here are some examples of how to utilize the package:\n\n### Datasets\n\n- Import `pwb_toolbox.datasets` and sequentially loads datasets for different asset classes, such as bonds, commodities, cryptocurrencies, ETFs, forex, indices, and stocks, using the `load_dataset` function:\n\n```python\nimport pwb_toolbox.datasets as pwb_ds\n\ndf = pwb_ds.get_pricing([\"AAPL\", \"MSFT\", \"GOOGL\"])\ndf = pwb_ds.load_dataset(\"Bonds-Daily-Price\")\ndf = pwb_ds.load_dataset(\"Commodities-Daily-Price\")\ndf = pwb_ds.load_dataset(\"Cryptocurrencies-Daily-Price\")\ndf = pwb_ds.load_dataset(\"ETFs-Daily-Price\")\ndf = pwb_ds.load_dataset(\"Forex-Daily-Price\")\ndf = pwb_ds.load_dataset(\"Indices-Daily-Price\")\ndf = pwb_ds.load_dataset(\"Stocks-Daily-Price\")\n\n```\n\n- Load daily stock price data for specific symbols using the load_dataset function. The first call retrieves data for Apple and Microsoft. The second call retrieves the same stocks but without price adjustments (`adjust=False`). The third call loads daily price data for the S&P 500 index:\n\n```python\nimport pwb_toolbox.datasets as pwb_ds\n\ndf = pwb_ds.load_dataset(\n \"Stocks-Daily-Price\",\n [\"AAPL\", \"MSFT\"],\n)\n\ndf = pwb_ds.load_dataset(\n \"Stocks-Daily-Price\",\n [\"AAPL\", \"MSFT\"],\n adjust=False,\n)\n\ndf = pwb_ds.load_dataset(\n \"Stocks-Daily-Price\",\n [\"sp500\"],\n)\n```\n\n- The `extend=True` argument instructs the function to return an extended historical data using indices, commodities, and bonds data.\n\n```python\nimport pwb_toolbox.datasets as pwb_ds\n\ndf = pwb_ds.load_dataset(\n \"ETFs-Daily-Price\",\n [\"SPY\", \"IEF\"],\n extend=True,\n)\n```\n\n- The argument `rate_to_price=False` specifies that bond yield rates should not be converted to price values in the returned data:\n\n```python\nimport pwb_toolbox.datasets as pwb_ds\n\ndf = pwb_ds.load_dataset(\n \"Bonds-Daily-Price\",\n [\"US10Y\"],\n rate_to_price=False,\n)\n```\n\n- The argument `to_usd=False` indicates that the data should not be converted to U.S. dollars, implying that it might be available in another currency.\n\n```python\nimport pwb_toolbox.datasets as pwb_ds\n\ndf = pwb_ds.load_dataset(\n \"Indices-Daily-Price\",\n [\"US10Y\"],\n to_usd=False,\n)\n```\n\n### Backtest engine\n\nThe `pwb_toolbox.backtesting` module offers simple building blocks for running\nBacktrader simulations. Alpha models generate insights which are turned\ninto portfolio weights and executed via Backtrader orders.\n\n```python\nfrom pwb_toolbox.backtesting.examples import GoldenCrossAlpha, EqualWeightPortfolio\nfrom pwb_toolbox.backtesting import run_backtest\nfrom pwb_toolbox.backtesting.execution_models import ImmediateExecutionModel\nfrom pwb_toolbox.backtesting.risk_models import MaximumTotalPortfolioExposure\nfrom pwb_toolbox.backtesting.universe_models import ManualUniverseSelectionModel\n\nrun_backtest(\n ManualUniverseSelectionModel([\"SPY\", \"QQQ\"]),\n GoldenCrossAlpha(),\n EqualWeightPortfolio(),\n execution=ImmediateExecutionModel(),\n risk=MaximumTotalPortfolioExposure(max_exposure=1.0),\n start=\"2015-01-01\",\n)\n```\n\nThe backtesting package is composed of a few focused modules:\n\n- `backtest_engine` \u2013 glue code that wires together universe selection,\n alpha models, portfolio construction and execution into a Backtrader run.\n- `base_strategy` \u2013 common bookkeeping and helpers used by all provided\n strategies.\n- `commission` \u2013 cost models for simulating broker commissions and spreads.\n- `indicators` \u2013 reusable signal and technical indicator implementations.\n- `optimization_engine` \u2013 genetic\u2011algorithm tooling for parameter searches.\n- `portfolio` \u2013 utilities for combining the results of several strategies and\n producing performance reports.\n- `strategies` \u2013 ready\u2011to\u2011use Backtrader `Strategy` subclasses.\n- `universe` \u2013 helpers for building trading universes (e.g. most liquid symbols).\n\n\n`pwb_toolbox.backtesting.strategies` ships a collection of portfolio templates\nwith different rebalancing rules and signal expectations:\n\n- **DailyEqualWeightPortfolio** \u2013 holds all assets with a long signal and\n allocates equal weight each day.\n- **DailyLeveragePortfolio** \u2013 goes long with fixed leverage when the signal is\n 1 and is otherwise flat.\n- **EqualWeightEntryExitPortfolio** \u2013 opens equally\u2011weighted positions when an\n entry condition triggers and leaves existing winners untouched.\n- **DynamicEqualWeightPortfolio** \u2013 event\u2011driven equal\u2011weight portfolio that can\n rebalance on any signal change or only when the set of long assets changes.\n- **MonthlyLongShortPortfolio** \u2013 once per month allocates half of the leverage\n to longs and half to shorts based on a universe\u2011aware signal.\n- **MonthlyLongShortQuantilePortfolio** \u2013 monthly rebalance that ranks assets\n by a per\u2011asset signal and goes long the strongest and short the weakest.\n- **MonthlyRankedEqualWeightPortfolio** \u2013 monthly equal\u2011weight portfolio with an\n optional ranking step and support for keeping only the top *N* assets.\n- **QuarterlyTopMomentumPortfolio** \u2013 every quarter concentrates exposure in the\n single asset with the strongest recent momentum.\n- **RollingSemesterLongShortPortfolio** \u2013 semi\u2011annual rebalancing template that\n accumulates long/short signals over six\u2011month windows.\n- **WeeklyLongShortDecilePortfolio** \u2013 rebalances weekly and trades the top and\n bottom deciles of a signal distribution.\n- **WeightedAllocationPortfolio** \u2013 turns user\u2011provided weights into integer\n share positions under a leverage constraint.\n\n### Optimal Limit Order Execution\n\nThe module `pwb_toolbox.execution.optimal_limit_order` implements the optimal\nlimit\u2011order placement framework described in *Optimal Portfolio Liquidation with Limit Orders* by Gu\u00e9ant, Lehalle, and Tapia.\nGiven a target quantity and time horizon, `get_optimal_quote` solves the associated system of\ndifferential equations to return the price offset from the mid\u2011price that\nmaximises the expected utility of execution. Market parameters such as\nvolatility (`sigma`), arrival rate of market orders (`A`), liquidity impact\n(`k`), trader risk aversion (`gamma`) and liquidation penalty (`b`) can be\nsupplied to model different scenarios. Setting `is_plot=True` visualises the\noptimal quote path over time.\n\n### Live Strategy Execution\n\nThe execution helpers in `pwb_toolbox.execution` can connect to brokers to run\nstrategies in real time. A typical session collects account information,\ncomputes target positions and submits the necessary orders.\n\n#### Interactive Brokers\n\n```python\nfrom pathlib import Path\nimport pandas as pd\nfrom pwb_toolbox import execution as pwb_exec\n\nSTRATEGIES = {\"my_strategy\": {\"path\": \"my_package.my_strategy\", \"weight\": 1.0}}\nlogs_dir = Path(\"logs\")\nACCOUNT_REFERENCE_NAV_VALUE = 100_000\nACCOUNT_REFERENCE_NAV_DATE = pd.Timestamp(\"2023-01-01\")\nLEVERAGE = 1.0\nMARKET_DATA_TYPE = 1\n\nibc = pwb_exec.IBConnector(market_data_type=MARKET_DATA_TYPE)\nibc.connect()\n\naccount_nav_value = ibc.get_account_nav()\naccount_nav_date = pd.Timestamp.today().normalize()\n\nnav_entry = pwb_exec.append_nav_history(logs_dir, account_nav_value)\nnav_series, raw_positions = pwb_exec.run_strategies(STRATEGIES)\nstrategies_positions, theoretical_positions = pwb_exec.scale_positions(\n STRATEGIES,\n raw_positions,\n nav_series,\n ACCOUNT_REFERENCE_NAV_VALUE,\n LEVERAGE,\n ACCOUNT_REFERENCE_NAV_DATE,\n)\n\nib_positions = ibc.get_positions()\norders = pwb_exec.compute_orders(theoretical_positions, ib_positions)\n\nexecution_time = 5 * 60 # five minutes\ntrades = pwb_exec.execute_and_log_orders(ibc, orders, execution_time)\n\npwb_exec.log_current_state(\n logs_dir,\n account_nav_value,\n strategies_positions,\n theoretical_positions,\n ib_positions,\n orders,\n account_nav_date,\n trades=trades,\n nav_history_entry=nav_entry,\n)\n\nibc.disconnect()\n```\n\n#### CCXT Exchanges\n\n```python\nfrom pathlib import Path\nimport pandas as pd\nfrom pwb_toolbox import execution as pwb_exec\n\nSTRATEGIES = {\"my_strategy\": {\"path\": \"my_package.my_strategy\", \"weight\": 1.0}}\nlogs_dir = Path(\"logs\")\nACCOUNT_REFERENCE_NAV_VALUE = 100_000\nACCOUNT_REFERENCE_NAV_DATE = pd.Timestamp(\"2023-01-01\")\nLEVERAGE = 1.0\n\ncc = pwb_exec.CCXTConnector(\n exchange=\"binance\",\n api_key=\"YOUR_API_KEY\",\n api_secret=\"YOUR_API_SECRET\",\n)\ncc.connect()\n\naccount_nav_value = cc.get_account_nav()\naccount_nav_date = pd.Timestamp.today().normalize()\n\nnav_entry = pwb_exec.append_nav_history(logs_dir, account_nav_value)\nnav_series, raw_positions = pwb_exec.run_strategies(STRATEGIES)\nstrategies_positions, theoretical_positions = pwb_exec.scale_positions(\n STRATEGIES,\n raw_positions,\n nav_series,\n ACCOUNT_REFERENCE_NAV_VALUE,\n LEVERAGE,\n ACCOUNT_REFERENCE_NAV_DATE,\n)\n\ncc_positions = cc.get_positions()\norders = pwb_exec.compute_orders(theoretical_positions, cc_positions)\n\nexecution_time = 5 * 60\ntrades = pwb_exec.execute_and_log_orders(cc, orders, execution_time)\n\npwb_exec.log_current_state(\n logs_dir,\n account_nav_value,\n strategies_positions,\n theoretical_positions,\n cc_positions,\n orders,\n account_nav_date,\n trades=trades,\n nav_history_entry=nav_entry,\n)\n\ncc.disconnect()\n```\n\n### Performance Analysis\n\nAfter running a live trading session, you can analyze the returned equity series using the\n`pwb_toolbox.performance` module.\n\n```python\nfrom pwb_toolbox.backtesting.examples import GoldenCrossAlpha, EqualWeightPortfolio\nfrom pwb_toolbox.backtesting import run_backtest\nfrom pwb_toolbox.backtesting.execution_models import ImmediateExecutionModel\nfrom pwb_toolbox.performance import total_return, cagr\nfrom pwb_toolbox.performance.plots import plot_equity_curve\n\nresult, equity = run_backtest(\n ManualUniverseSelectionModel([\"SPY\", \"QQQ\"]),\n GoldenCrossAlpha(),\n EqualWeightPortfolio(),\n execution=ImmediateExecutionModel(),\n start=\"2015-01-01\",\n)\n\nprint(\"Total return:\", total_return(equity))\nprint(\"CAGR:\", cagr(equity))\n\nplot_equity_curve(equity)\n```\n\n## Contributing\n\nContributions to the `pwb-toolbox` package are welcome! If you have any improvements, new datasets, or strategy ideas to share, please follow these guidelines:\n\n1. Fork the repository and create a new branch for your feature.\n2. Make your changes and ensure they adhere to the package's coding style.\n3. Write tests to validate the functionality or provide sample usage examples.\n4. Submit a pull request, clearly explaining the purpose and benefits of your contribution.\n\nPlease note that all contributions are subject to review and approval by the maintainers.\n\n### Build the Package\n\nTo build the package, run:\n\n```bash\npython -m pip install --upgrade build\nrm -r dist\npython -m build\n```\n\nTo upload the package to PyPI, run:\n\n```bash\ntwine upload dist/*\n```\n\n## Contact\n\nFor any questions, issues, or suggestions regarding the `pwb-toolbox` package, please contact the maintainers or create an issue on the repository. We appreciate your feedback and involvement in improving the package.\nHappy trading!\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A toolbox library for quant traders",
"version": "0.1.22",
"project_urls": {
"Homepage": "https://github.com/paperswithbacktest/pwb-toolbox"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "330ed8a4bf1d3455fce06d1dcceb27a6209ab47ef5faff3d099437d82a16bbc6",
"md5": "23160b80321e2f42ad3727730047f566",
"sha256": "c2dd0fadd94f3106efd4e5d8e5e92af74106e5433cb0718109e029d75c91151f"
},
"downloads": -1,
"filename": "pwb_toolbox-0.1.22-py3-none-any.whl",
"has_sig": false,
"md5_digest": "23160b80321e2f42ad3727730047f566",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 53788,
"upload_time": "2025-08-28T08:46:40",
"upload_time_iso_8601": "2025-08-28T08:46:40.875994Z",
"url": "https://files.pythonhosted.org/packages/33/0e/d8a4bf1d3455fce06d1dcceb27a6209ab47ef5faff3d099437d82a16bbc6/pwb_toolbox-0.1.22-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "0b98cbd2e73941bd1cf714c64055954e7242ce5ec61029c9c52d9a2ee0bb035c",
"md5": "63f215e899716b8839b21195f750b0c6",
"sha256": "5df2af8d46f01d39181deaae021541059893c7ef3e58f258372152e5f585520a"
},
"downloads": -1,
"filename": "pwb_toolbox-0.1.22.tar.gz",
"has_sig": false,
"md5_digest": "63f215e899716b8839b21195f750b0c6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 49473,
"upload_time": "2025-08-28T08:46:42",
"upload_time_iso_8601": "2025-08-28T08:46:42.315221Z",
"url": "https://files.pythonhosted.org/packages/0b/98/cbd2e73941bd1cf714c64055954e7242ce5ec61029c9c52d9a2ee0bb035c/pwb_toolbox-0.1.22.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-28 08:46:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "paperswithbacktest",
"github_project": "pwb-toolbox",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "backtrader",
"specs": []
},
{
"name": "beautifulsoup4",
"specs": []
},
{
"name": "ccxt",
"specs": []
},
{
"name": "click",
"specs": []
},
{
"name": "datasets",
"specs": []
},
{
"name": "deap",
"specs": []
},
{
"name": "ffn",
"specs": []
},
{
"name": "huggingface_hub",
"specs": []
},
{
"name": "ib_insync",
"specs": []
},
{
"name": "matplotlib",
"specs": []
},
{
"name": "numpy",
"specs": []
},
{
"name": "pandas",
"specs": []
},
{
"name": "python-dateutil",
"specs": []
},
{
"name": "requests",
"specs": []
},
{
"name": "scikit-learn",
"specs": []
},
{
"name": "scipy",
"specs": []
},
{
"name": "tqdm",
"specs": []
},
{
"name": "transformers",
"specs": []
},
{
"name": "webdriver_manager",
"specs": []
}
],
"lcname": "pwb-toolbox"
}