pwb-toolbox 0.1.0__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pwb_toolbox-0.1.0 → pwb_toolbox-0.1.2}/PKG-INFO +12 -9
- {pwb_toolbox-0.1.0 → pwb_toolbox-0.1.2}/README.md +10 -7
- {pwb_toolbox-0.1.0 → pwb_toolbox-0.1.2}/pwb_toolbox/datasets/__init__.py +60 -0
- {pwb_toolbox-0.1.0 → pwb_toolbox-0.1.2}/pwb_toolbox.egg-info/PKG-INFO +12 -9
- {pwb_toolbox-0.1.0 → pwb_toolbox-0.1.2}/setup.cfg +1 -1
- {pwb_toolbox-0.1.0 → pwb_toolbox-0.1.2}/LICENSE.txt +0 -0
- {pwb_toolbox-0.1.0 → pwb_toolbox-0.1.2}/pwb_toolbox/__init__.py +0 -0
- {pwb_toolbox-0.1.0 → pwb_toolbox-0.1.2}/pwb_toolbox.egg-info/SOURCES.txt +0 -0
- {pwb_toolbox-0.1.0 → pwb_toolbox-0.1.2}/pwb_toolbox.egg-info/dependency_links.txt +0 -0
- {pwb_toolbox-0.1.0 → pwb_toolbox-0.1.2}/pwb_toolbox.egg-info/requires.txt +0 -0
- {pwb_toolbox-0.1.0 → pwb_toolbox-0.1.2}/pwb_toolbox.egg-info/top_level.txt +0 -0
- {pwb_toolbox-0.1.0 → pwb_toolbox-0.1.2}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: pwb-toolbox
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.2
|
4
4
|
Summary: A toolbox library for quant traders
|
5
5
|
Home-page: https://github.com/paperswithbacktest/pwb-toolbox
|
6
6
|
Author: Your Name
|
@@ -46,13 +46,15 @@ The `pwb-toolbox` package offers a range of functionalities for systematic tradi
|
|
46
46
|
```python
|
47
47
|
import pwb_toolbox.datasets as pwb_ds
|
48
48
|
|
49
|
-
df =
|
50
|
-
df =
|
51
|
-
df =
|
52
|
-
df =
|
53
|
-
df =
|
54
|
-
df =
|
55
|
-
df =
|
49
|
+
df = pwb_ds.get_pricing(["AAPL", "MSFT", "GOOGL"])
|
50
|
+
df = pwb_ds.load_dataset("Bonds-Daily-Price")
|
51
|
+
df = pwb_ds.load_dataset("Commodities-Daily-Price")
|
52
|
+
df = pwb_ds.load_dataset("Cryptocurrencies-Daily-Price")
|
53
|
+
df = pwb_ds.load_dataset("ETFs-Daily-Price")
|
54
|
+
df = pwb_ds.load_dataset("Forex-Daily-Price")
|
55
|
+
df = pwb_ds.load_dataset("Indices-Daily-Price")
|
56
|
+
df = pwb_ds.load_dataset("Stocks-Daily-Price")
|
57
|
+
|
56
58
|
```
|
57
59
|
|
58
60
|
- 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:
|
@@ -130,6 +132,7 @@ To build the package, run:
|
|
130
132
|
|
131
133
|
```bash
|
132
134
|
python -m pip install --upgrade build
|
135
|
+
rm -r dist
|
133
136
|
python -m build
|
134
137
|
```
|
135
138
|
|
@@ -29,13 +29,15 @@ The `pwb-toolbox` package offers a range of functionalities for systematic tradi
|
|
29
29
|
```python
|
30
30
|
import pwb_toolbox.datasets as pwb_ds
|
31
31
|
|
32
|
-
df =
|
33
|
-
df =
|
34
|
-
df =
|
35
|
-
df =
|
36
|
-
df =
|
37
|
-
df =
|
38
|
-
df =
|
32
|
+
df = pwb_ds.get_pricing(["AAPL", "MSFT", "GOOGL"])
|
33
|
+
df = pwb_ds.load_dataset("Bonds-Daily-Price")
|
34
|
+
df = pwb_ds.load_dataset("Commodities-Daily-Price")
|
35
|
+
df = pwb_ds.load_dataset("Cryptocurrencies-Daily-Price")
|
36
|
+
df = pwb_ds.load_dataset("ETFs-Daily-Price")
|
37
|
+
df = pwb_ds.load_dataset("Forex-Daily-Price")
|
38
|
+
df = pwb_ds.load_dataset("Indices-Daily-Price")
|
39
|
+
df = pwb_ds.load_dataset("Stocks-Daily-Price")
|
40
|
+
|
39
41
|
```
|
40
42
|
|
41
43
|
- 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:
|
@@ -113,6 +115,7 @@ To build the package, run:
|
|
113
115
|
|
114
116
|
```bash
|
115
117
|
python -m pip install --upgrade build
|
118
|
+
rm -r dist
|
116
119
|
python -m build
|
117
120
|
```
|
118
121
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
from collections import defaultdict
|
2
|
+
from datetime import date
|
2
3
|
import os
|
3
4
|
import re
|
4
5
|
|
@@ -770,13 +771,34 @@ def __extend_etfs(df_etfs):
|
|
770
771
|
mapping = {
|
771
772
|
"AGG": ["Bonds-Daily-Price", "US10Y"],
|
772
773
|
"EPP": ["Indices-Daily-Price", "HSI"],
|
774
|
+
"EWA": ["Indices-Daily-Price", "AS30"], # Australia
|
775
|
+
"EWO": ["Indices-Daily-Price", "ATX"], # Austria
|
776
|
+
"EWK": ["Indices-Daily-Price", "BEL20"], # Belgium
|
777
|
+
"EWZ": ["Indices-Daily-Price", "IBOV"], # Brazil
|
778
|
+
"EWC": ["Indices-Daily-Price", "SPTSX"], # Canada
|
779
|
+
"FXI": ["Indices-Daily-Price", "SSE50"], # China
|
780
|
+
"EWQ": ["Indices-Daily-Price", "CAC"], # France
|
781
|
+
"EWG": ["Indices-Daily-Price", "DAX"], # Germany
|
782
|
+
"EWH": ["Indices-Daily-Price", "HSI"], # Hong Kong
|
783
|
+
"EWI": ["Indices-Daily-Price", "FTSEMIB"], # Italy
|
773
784
|
"EWJ": ["Indices-Daily-Price", "NKY"],
|
785
|
+
"EWM": ["Indices-Daily-Price", "FBMKLCI"], # Malaysia
|
786
|
+
"EWW": ["Indices-Daily-Price", "MEXBOL"], # Mexico
|
787
|
+
"EWN": ["Indices-Daily-Price", "AEX"], # Netherlands
|
788
|
+
"EWS": ["Indices-Daily-Price", "FSSTI"], # Singapore
|
789
|
+
"EZA": ["Indices-Daily-Price", "TOP40"], # South Africa
|
790
|
+
"EWP": ["Indices-Daily-Price", "IBEX"], # Spain
|
791
|
+
"EWD": ["Indices-Daily-Price", "OMX"], # Sweden
|
792
|
+
"EWL": ["Indices-Daily-Price", "SMI"], # Switzerland
|
793
|
+
"EWT": ["Indices-Daily-Price", "TWSE"], # Taiwan
|
794
|
+
"EWU": ["Indices-Daily-Price", "UKX"], # United Kingdom
|
774
795
|
"GLD": ["Commodities-Daily-Price", "GC1"],
|
775
796
|
"IEF": ["Bonds-Daily-Price", "US10Y"],
|
776
797
|
"IEV": ["Indices-Daily-Price", "SX5E"],
|
777
798
|
"IWB": ["Indices-Daily-Price", "SPX"],
|
778
799
|
"SHY": ["Bonds-Daily-Price", "US1Y"],
|
779
800
|
"SPY": ["Indices-Daily-Price", "SPX"],
|
801
|
+
"THD": ["Indices-Daily-Price", "SET50"], # Thailand
|
780
802
|
}
|
781
803
|
symbols = df_etfs.symbol.unique()
|
782
804
|
mapping = {k: v for k, v in mapping.items() if k in symbols}
|
@@ -831,6 +853,44 @@ def __extend_etfs(df_etfs):
|
|
831
853
|
combined_data = pd.concat([index_data_before_common, etf_data])
|
832
854
|
frames.append(combined_data)
|
833
855
|
|
856
|
+
symbols_not_in_mapping = set(symbols) - set(mapping.keys())
|
857
|
+
frames.append(df_etfs[df_etfs["symbol"].isin(symbols_not_in_mapping)])
|
858
|
+
|
834
859
|
# Concatenate all frames to form the final dataframe
|
835
860
|
df = pd.concat(frames).sort_values(by=["date", "symbol"]).reset_index(drop=True)
|
836
861
|
return df
|
862
|
+
|
863
|
+
|
864
|
+
def get_pricing(
|
865
|
+
symbol_list,
|
866
|
+
fields=["close"],
|
867
|
+
start_date="1980-01-01",
|
868
|
+
end_date=date.today().isoformat(),
|
869
|
+
):
|
870
|
+
"""
|
871
|
+
Get pricing data for a list of symbols
|
872
|
+
"""
|
873
|
+
if isinstance(symbol_list, str):
|
874
|
+
symbol_list = [symbol_list]
|
875
|
+
if len(fields) != 1:
|
876
|
+
raise ValueError("Only one field is allowed")
|
877
|
+
if fields[0] not in ["open", "high", "low", "close"]:
|
878
|
+
raise ValueError("Invalid field")
|
879
|
+
df = pd.concat(
|
880
|
+
[
|
881
|
+
load_dataset("Stocks-Daily-Price", symbol_list),
|
882
|
+
load_dataset("ETFs-Daily-Price", symbol_list),
|
883
|
+
load_dataset("Cryptocurrencies-Daily-Price", symbol_list),
|
884
|
+
load_dataset("Bonds-Daily-Price", symbol_list),
|
885
|
+
load_dataset("Commodities-Daily-Price", symbol_list),
|
886
|
+
]
|
887
|
+
)
|
888
|
+
df["date"] = pd.to_datetime(df["date"])
|
889
|
+
df.set_index("date", inplace=True)
|
890
|
+
df.sort_index(inplace=True)
|
891
|
+
df_filtered = df.loc[start_date:end_date]
|
892
|
+
prices_df = df_filtered.pivot_table(
|
893
|
+
values="close", index=df_filtered.index, columns="symbol"
|
894
|
+
)
|
895
|
+
prices_df.columns = list(prices_df.columns)
|
896
|
+
return prices_df
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: pwb-toolbox
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.2
|
4
4
|
Summary: A toolbox library for quant traders
|
5
5
|
Home-page: https://github.com/paperswithbacktest/pwb-toolbox
|
6
6
|
Author: Your Name
|
@@ -46,13 +46,15 @@ The `pwb-toolbox` package offers a range of functionalities for systematic tradi
|
|
46
46
|
```python
|
47
47
|
import pwb_toolbox.datasets as pwb_ds
|
48
48
|
|
49
|
-
df =
|
50
|
-
df =
|
51
|
-
df =
|
52
|
-
df =
|
53
|
-
df =
|
54
|
-
df =
|
55
|
-
df =
|
49
|
+
df = pwb_ds.get_pricing(["AAPL", "MSFT", "GOOGL"])
|
50
|
+
df = pwb_ds.load_dataset("Bonds-Daily-Price")
|
51
|
+
df = pwb_ds.load_dataset("Commodities-Daily-Price")
|
52
|
+
df = pwb_ds.load_dataset("Cryptocurrencies-Daily-Price")
|
53
|
+
df = pwb_ds.load_dataset("ETFs-Daily-Price")
|
54
|
+
df = pwb_ds.load_dataset("Forex-Daily-Price")
|
55
|
+
df = pwb_ds.load_dataset("Indices-Daily-Price")
|
56
|
+
df = pwb_ds.load_dataset("Stocks-Daily-Price")
|
57
|
+
|
56
58
|
```
|
57
59
|
|
58
60
|
- 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:
|
@@ -130,6 +132,7 @@ To build the package, run:
|
|
130
132
|
|
131
133
|
```bash
|
132
134
|
python -m pip install --upgrade build
|
135
|
+
rm -r dist
|
133
136
|
python -m build
|
134
137
|
```
|
135
138
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|