pwb-toolbox 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl
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/datasets/__init__.py +40 -0
- {pwb_toolbox-0.1.1.dist-info → pwb_toolbox-0.1.3.dist-info}/METADATA +13 -9
- pwb_toolbox-0.1.3.dist-info/RECORD +7 -0
- {pwb_toolbox-0.1.1.dist-info → pwb_toolbox-0.1.3.dist-info}/WHEEL +1 -1
- pwb_toolbox-0.1.1.dist-info/RECORD +0 -7
- {pwb_toolbox-0.1.1.dist-info → pwb_toolbox-0.1.3.dist-info/licenses}/LICENSE.txt +0 -0
- {pwb_toolbox-0.1.1.dist-info → pwb_toolbox-0.1.3.dist-info}/top_level.txt +0 -0
pwb_toolbox/datasets/__init__.py
CHANGED
@@ -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
|
|
@@ -852,6 +853,45 @@ def __extend_etfs(df_etfs):
|
|
852
853
|
combined_data = pd.concat([index_data_before_common, etf_data])
|
853
854
|
frames.append(combined_data)
|
854
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
|
+
|
855
859
|
# Concatenate all frames to form the final dataframe
|
856
860
|
df = pd.concat(frames).sort_values(by=["date", "symbol"]).reset_index(drop=True)
|
857
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
|
+
extend=False,
|
870
|
+
):
|
871
|
+
"""
|
872
|
+
Get pricing data for a list of symbols
|
873
|
+
"""
|
874
|
+
if isinstance(symbol_list, str):
|
875
|
+
symbol_list = [symbol_list]
|
876
|
+
if len(fields) != 1:
|
877
|
+
raise ValueError("Only one field is allowed")
|
878
|
+
if fields[0] not in ["open", "high", "low", "close"]:
|
879
|
+
raise ValueError("Invalid field")
|
880
|
+
df = pd.concat(
|
881
|
+
[
|
882
|
+
load_dataset("Stocks-Daily-Price", symbol_list, extend=extend),
|
883
|
+
load_dataset("ETFs-Daily-Price", symbol_list, extend=extend),
|
884
|
+
load_dataset("Cryptocurrencies-Daily-Price", symbol_list, extend=extend),
|
885
|
+
load_dataset("Bonds-Daily-Price", symbol_list, extend=extend),
|
886
|
+
load_dataset("Commodities-Daily-Price", symbol_list, extend=extend),
|
887
|
+
]
|
888
|
+
)
|
889
|
+
df["date"] = pd.to_datetime(df["date"])
|
890
|
+
df.set_index("date", inplace=True)
|
891
|
+
df.sort_index(inplace=True)
|
892
|
+
df_filtered = df.loc[start_date:end_date]
|
893
|
+
prices_df = df_filtered.pivot_table(
|
894
|
+
values="close", index=df_filtered.index, columns="symbol"
|
895
|
+
)
|
896
|
+
prices_df.columns = list(prices_df.columns)
|
897
|
+
return prices_df
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: pwb-toolbox
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.3
|
4
4
|
Summary: A toolbox library for quant traders
|
5
5
|
Home-page: https://github.com/paperswithbacktest/pwb-toolbox
|
6
6
|
Author: Your Name
|
@@ -14,6 +14,7 @@ Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE.txt
|
15
15
|
Requires-Dist: datasets
|
16
16
|
Requires-Dist: pandas
|
17
|
+
Dynamic: license-file
|
17
18
|
|
18
19
|
<div align="center">
|
19
20
|
<img src="static/images/systematic-trading.jpeg" height=200 alt=""/>
|
@@ -46,13 +47,15 @@ The `pwb-toolbox` package offers a range of functionalities for systematic tradi
|
|
46
47
|
```python
|
47
48
|
import pwb_toolbox.datasets as pwb_ds
|
48
49
|
|
49
|
-
df =
|
50
|
-
df =
|
51
|
-
df =
|
52
|
-
df =
|
53
|
-
df =
|
54
|
-
df =
|
55
|
-
df =
|
50
|
+
df = pwb_ds.get_pricing(["AAPL", "MSFT", "GOOGL"])
|
51
|
+
df = pwb_ds.load_dataset("Bonds-Daily-Price")
|
52
|
+
df = pwb_ds.load_dataset("Commodities-Daily-Price")
|
53
|
+
df = pwb_ds.load_dataset("Cryptocurrencies-Daily-Price")
|
54
|
+
df = pwb_ds.load_dataset("ETFs-Daily-Price")
|
55
|
+
df = pwb_ds.load_dataset("Forex-Daily-Price")
|
56
|
+
df = pwb_ds.load_dataset("Indices-Daily-Price")
|
57
|
+
df = pwb_ds.load_dataset("Stocks-Daily-Price")
|
58
|
+
|
56
59
|
```
|
57
60
|
|
58
61
|
- 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 +133,7 @@ To build the package, run:
|
|
130
133
|
|
131
134
|
```bash
|
132
135
|
python -m pip install --upgrade build
|
136
|
+
rm -r dist
|
133
137
|
python -m build
|
134
138
|
```
|
135
139
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
pwb_toolbox/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
pwb_toolbox/datasets/__init__.py,sha256=n-Ir_9y6b9GqvLq050dmrdxunlObcVMmWxuIujNJ-s8,19906
|
3
|
+
pwb_toolbox-0.1.3.dist-info/licenses/LICENSE.txt,sha256=_Wjz7o7St3iVSPBRzE0keS8XSqSJ03A3NZ6cMlTaSK8,1079
|
4
|
+
pwb_toolbox-0.1.3.dist-info/METADATA,sha256=AF5Kr9xx34_kEjdhuQCkgncQSCTN1zT5K7nlJMHC6KI,4617
|
5
|
+
pwb_toolbox-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
+
pwb_toolbox-0.1.3.dist-info/top_level.txt,sha256=TZcXcF2AMkKkibZOuq6AYsHjajPgddHAGjQUT64OYGY,12
|
7
|
+
pwb_toolbox-0.1.3.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
pwb_toolbox/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
pwb_toolbox/datasets/__init__.py,sha256=YGupxmXGcM_Q6QjFEvaQO_RwLSFrN46WhBfVDa-uF7c,18501
|
3
|
-
pwb_toolbox-0.1.1.dist-info/LICENSE.txt,sha256=_Wjz7o7St3iVSPBRzE0keS8XSqSJ03A3NZ6cMlTaSK8,1079
|
4
|
-
pwb_toolbox-0.1.1.dist-info/METADATA,sha256=Jl53c7wl36Cog8UQANNBHJsrAMemcyJjVwauIbU5D3w,4504
|
5
|
-
pwb_toolbox-0.1.1.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
6
|
-
pwb_toolbox-0.1.1.dist-info/top_level.txt,sha256=TZcXcF2AMkKkibZOuq6AYsHjajPgddHAGjQUT64OYGY,12
|
7
|
-
pwb_toolbox-0.1.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|