Skip to content

Commit b8bf145

Browse files
committed
feat: migration of data fetching method to pwb-toolbox
1 parent e5d0ee0 commit b8bf145

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1183
-269
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
__pycache__
44
ssrn-abstract-classifier
55
wandb
6-
systematic_trading/datasets/logfile.log
6+
pwb_toolbox/datasets/logfile.log

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Current file",
6+
"type": "debugpy",
7+
"request": "launch",
8+
"program": "${file}",
9+
"args": [],
10+
"console": "integratedTerminal",
11+
"python": "${userHome}/miniconda3/bin/python",
12+
"justMyCode": false
13+
}
14+
]
15+
}

.vscode/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"python.linting.lintOnSave": true,
4+
"python.linting.pylintArgs": [
5+
"--disable=relative-beyond-top-level"
6+
],
7+
"python.linting.pylintEnabled": true,
8+
"python.formatting.provider": "black",
9+
"python.defaultInterpreterPath": "${env:HOME}/miniconda3/bin/python",
10+
"yaml.schemas": {
11+
"https://squidfunk.github.io/mkdocs-material/schema.json": "mkdocs.yml"
12+
}
13+
}

README.md

Lines changed: 87 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,17 @@
11
<div align="center">
22
<img src="static/images/systematic-trading.jpeg" height=200 alt=""/>
3-
<h1>Systematic Trading</h1>
3+
<h1>Papers With Backtest Toolbox</h1>
44
</div>
55

6-
The `systematic-trading` 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/.
6+
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/.
77

88

99
## Installation
1010

11-
To install the systematic-trading package, follow these steps:
11+
To install the pwb-toolbox package:
1212

1313
```bash
14-
# Install python and its dependencies
15-
sudo apt install python3 python3-pip python3-venv
16-
# Clone the repository or download the package from the official source
17-
git clone https://github.com/paperswithbacktest/systematic-trading.git
18-
# Navigate to the package directory
19-
cd systematic-trading/
20-
# Create a virtual environment
21-
python3 -m venv ~/myenv
22-
# Activate it
23-
source ~/myenv/bin/activate
24-
# Install the required dependencies by running
25-
pip install -r requirements.txt
14+
pip install pwb-toolbox
2615
```
2716

2817
To login to Huggingface Hub with Access Token
@@ -33,42 +22,83 @@ huggingface-cli login
3322

3423
## Usage
3524

36-
The `systematic-trading` package offers a range of functionalities for systematic trading analysis. Here are some examples of how to utilize the package:
25+
The `pwb-toolbox` package offers a range of functionalities for systematic trading analysis. Here are some examples of how to utilize the package:
3726

38-
- Crawling Datasets:
27+
- 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:
3928

4029
```python
41-
HF_USERNAME= PYTHONPATH=$PYTHONPATH:. TWILIO_ACCOUNT_SID= TWILIO_AUTH_TOKEN= TWILIO_FROM= TWILIO_TO= python pwb_toolbox/datasets \
42-
--username [YOUR_HUGGINGFACE_USERNAME]
30+
import pwb_toolbox.datasets as pwb_ds
31+
32+
df = ds.load_dataset("Bonds-Daily-Price")
33+
df = ds.load_dataset("Commodities-Daily-Price")
34+
df = ds.load_dataset("Cryptocurrencies-Daily-Price")
35+
df = ds.load_dataset("ETFs-Daily-Price")
36+
df = ds.load_dataset("Forex-Daily-Price")
37+
df = ds.load_dataset("Indices-Daily-Price")
38+
df = ds.load_dataset("Stocks-Daily-Price")
4339
```
4440

45-
- Crawling Strategy Ideas:
41+
- 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:
4642

4743
```python
48-
# Download SSRN paper abtract to a Kili project of id YOUR_KILI_PROJECT_ID
49-
PYTHONPATH=$PYTHONPATH:. python pwb_toolbox/strategy_ideas \
50-
--mode abstract \
51-
--jel-code G14 \
52-
--from-page 1 \
53-
--kili-project-id [YOUR_KILI_PROJECT_ID]
54-
55-
# Use the abtracts labeled in YOUR_SOURCE_KILI_PROJECT_ID to download SSRN paper PDF
56-
# into another Kili project YOUR_TARGET_KILI_PROJECT_ID
57-
PYTHONPATH=$PYTHONPATH:. python pwb_toolbox/strategy_ideas \
58-
--mode paper \
59-
--src-kili-project-id [YOUR_SOURCE_KILI_PROJECT_ID] \
60-
--tgt-kili-project-id [YOUR_TARGET_KILI_PROJECT_ID]
61-
62-
# Transform the annotations of YOUR_KILI_PROJECT_ID into markdown strategy ID cards
63-
PYTHONPATH=$PYTHONPATH:. python pwb_toolbox/strategy_ideas \
64-
--mode summary \
65-
--kili-project-id [YOUR_KILI_PROJECT_ID] \
66-
--tgt-folder [YOUR_TARGET_FOLDER]
44+
import pwb_toolbox.datasets as pwb_ds
45+
46+
df = pwb_ds.load_dataset(
47+
"Stocks-Daily-Price",
48+
["AAPL", "MSFT"],
49+
)
50+
51+
df = pwb_ds.load_dataset(
52+
"Stocks-Daily-Price",
53+
["AAPL", "MSFT"],
54+
adjust=False,
55+
)
56+
57+
df = pwb_ds.load_dataset(
58+
"Stocks-Daily-Price",
59+
["sp500"],
60+
)
61+
```
62+
63+
- The `extend=True` argument instructs the function to return an extended historical data using indices, commodities, and bonds data.
64+
65+
```python
66+
import pwb_toolbox.datasets as pwb_ds
67+
68+
df = pwb_ds.load_dataset(
69+
"ETFs-Daily-Price",
70+
["SPY", "IEF"],
71+
extend=True,
72+
)
73+
```
74+
75+
- The argument `rate_to_price=False` specifies that bond yield rates should not be converted to price values in the returned data:
76+
77+
```python
78+
import pwb_toolbox.datasets as pwb_ds
79+
80+
df = pwb_ds.load_dataset(
81+
"Bonds-Daily-Price",
82+
["US10Y"],
83+
rate_to_price=False,
84+
)
85+
```
86+
87+
- 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.
88+
89+
```python
90+
import pwb_toolbox.datasets as pwb_ds
91+
92+
df = pwb_ds.load_dataset(
93+
"Indices-Daily-Price",
94+
["US10Y"],
95+
to_usd=False,
96+
)
6797
```
6898

6999
## Contributing
70100

71-
Contributions to the `systematic-trading` package are welcome! If you have any improvements, new datasets, or strategy ideas to share, please follow these guidelines:
101+
Contributions to the `pwb-toolbox` package are welcome! If you have any improvements, new datasets, or strategy ideas to share, please follow these guidelines:
72102

73103
1. Fork the repository and create a new branch for your feature.
74104
2. Make your changes and ensure they adhere to the package's coding style.
@@ -77,12 +107,27 @@ Contributions to the `systematic-trading` package are welcome! If you have any i
77107

78108
Please note that all contributions are subject to review and approval by the maintainers.
79109

110+
## Build the Package
111+
112+
To build the package, run:
113+
114+
```bash
115+
python -m pip install --upgrade build
116+
python -m build
117+
```
118+
119+
To upload the package to PyPI, run:
120+
121+
```bash
122+
twine upload dist/*
123+
```
124+
80125
## License
81126

82-
The `systematic-trading` package is released under the MIT license. See the LICENSE file for more details.
127+
The `pwb-toolbox` package is released under the MIT license. See the LICENSE file for more details.
83128

84129
## Contact
85130

86-
For any questions, issues, or suggestions regarding the `systematic-trading` package, please contact the maintainers or create an issue on the repository. We appreciate your feedback and involvement in improving the package.
131+
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.
87132

88133
Happy trading!

data/stocks.page.pkl

-42.6 MB
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8.85 KB
Binary file not shown.

dist/pwb_backtest-0.1.0.tar.gz

8.76 KB
Binary file not shown.

pwb_backtest.egg-info/PKG-INFO

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
Metadata-Version: 2.1
2+
Name: pwb-backtest
3+
Version: 0.1.0
4+
Summary: A toolbox library for quant traders
5+
Home-page: https://github.com/paperswithbacktest/pwb-backtest
6+
Author: Your Name
7+
Author-email: [email protected]
8+
License: MIT
9+
Classifier: Programming Language :: Python :: 3
10+
Classifier: License :: OSI Approved :: MIT License
11+
Classifier: Operating System :: OS Independent
12+
Requires-Python: >=3.7
13+
Description-Content-Type: text/markdown
14+
License-File: LICENSE.txt
15+
Requires-Dist: datasets
16+
Requires-Dist: pandas
17+
18+
<div align="center">
19+
<img src="static/images/systematic-trading.jpeg" height=200 alt=""/>
20+
<h1>Papers With Backtest Toolbox</h1>
21+
</div>
22+
23+
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/.
24+
25+
26+
## Installation
27+
28+
To install the pwb-toolbox package:
29+
30+
```bash
31+
pip install pwb-toolbox
32+
```
33+
34+
To login to Huggingface Hub with Access Token
35+
36+
```bash
37+
huggingface-cli login
38+
```
39+
40+
## Usage
41+
42+
The `pwb-toolbox` package offers a range of functionalities for systematic trading analysis. Here are some examples of how to utilize the package:
43+
44+
- 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:
45+
46+
```python
47+
import pwb_toolbox.datasets as pwb_ds
48+
49+
df = ds.load_dataset("Bonds-Daily-Price")
50+
df = ds.load_dataset("Commodities-Daily-Price")
51+
df = ds.load_dataset("Cryptocurrencies-Daily-Price")
52+
df = ds.load_dataset("ETFs-Daily-Price")
53+
df = ds.load_dataset("Forex-Daily-Price")
54+
df = ds.load_dataset("Indices-Daily-Price")
55+
df = ds.load_dataset("Stocks-Daily-Price")
56+
```
57+
58+
- 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:
59+
60+
```python
61+
import pwb_toolbox.datasets as pwb_ds
62+
63+
df = pwb_ds.load_dataset(
64+
"Stocks-Daily-Price",
65+
["AAPL", "MSFT"],
66+
)
67+
68+
df = pwb_ds.load_dataset(
69+
"Stocks-Daily-Price",
70+
["AAPL", "MSFT"],
71+
adjust=False,
72+
)
73+
74+
df = pwb_ds.load_dataset(
75+
"Stocks-Daily-Price",
76+
["sp500"],
77+
)
78+
```
79+
80+
- The `extend=True` argument instructs the function to return an extended historical data using indices, commodities, and bonds data.
81+
82+
```python
83+
import pwb_toolbox.datasets as pwb_ds
84+
85+
df = pwb_ds.load_dataset(
86+
"ETFs-Daily-Price",
87+
["SPY", "IEF"],
88+
extend=True,
89+
)
90+
```
91+
92+
- The argument `rate_to_price=False` specifies that bond yield rates should not be converted to price values in the returned data:
93+
94+
```python
95+
import pwb_toolbox.datasets as pwb_ds
96+
97+
df = pwb_ds.load_dataset(
98+
"Bonds-Daily-Price",
99+
["US10Y"],
100+
rate_to_price=False,
101+
)
102+
```
103+
104+
- 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.
105+
106+
```python
107+
import pwb_toolbox.datasets as pwb_ds
108+
109+
df = pwb_ds.load_dataset(
110+
"Indices-Daily-Price",
111+
["US10Y"],
112+
to_usd=False,
113+
)
114+
```
115+
116+
## Contributing
117+
118+
Contributions to the `pwb-toolbox` package are welcome! If you have any improvements, new datasets, or strategy ideas to share, please follow these guidelines:
119+
120+
1. Fork the repository and create a new branch for your feature.
121+
2. Make your changes and ensure they adhere to the package's coding style.
122+
3. Write tests to validate the functionality or provide sample usage examples.
123+
4. Submit a pull request, clearly explaining the purpose and benefits of your contribution.
124+
125+
Please note that all contributions are subject to review and approval by the maintainers.
126+
127+
## Build the Package
128+
129+
To build your package, run:
130+
131+
```bash
132+
python -m pip install --upgrade build
133+
python -m build
134+
```
135+
136+
## License
137+
138+
The `pwb-toolbox` package is released under the MIT license. See the LICENSE file for more details.
139+
140+
## Contact
141+
142+
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.
143+
144+
Happy trading!

pwb_backtest.egg-info/SOURCES.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
LICENSE.txt
2+
README.md
3+
pyproject.toml
4+
setup.cfg
5+
pwb_backtest.egg-info/PKG-INFO
6+
pwb_backtest.egg-info/SOURCES.txt
7+
pwb_backtest.egg-info/dependency_links.txt
8+
pwb_backtest.egg-info/requires.txt
9+
pwb_backtest.egg-info/top_level.txt
10+
pwb_toolbox/__init__.py
11+
pwb_toolbox/datasets/__init__.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

pwb_backtest.egg-info/requires.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
datasets
2+
pandas

pwb_backtest.egg-info/top_level.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pwb_toolbox

pwb_toolbox/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)