pfeed 0.0.2.dev1__tar.gz → 0.0.2.dev3__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.
Files changed (52) hide show
  1. pfeed-0.0.2.dev3/PKG-INFO +213 -0
  2. pfeed-0.0.2.dev3/README.md +158 -0
  3. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/__init__.py +6 -6
  4. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/cli/commands/config.py +8 -11
  5. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/cli/commands/download.py +4 -4
  6. pfeed-0.0.2.dev3/pfeed/cli/commands/stream.py +0 -0
  7. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/cli/main.py +3 -1
  8. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/config_handler.py +13 -13
  9. pfeed-0.0.2.dev3/pfeed/const/common.py +32 -0
  10. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/feeds/base_feed.py +19 -25
  11. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/feeds/yahoo_finance_feed.py +17 -9
  12. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/sources/binance/download.py +1 -1
  13. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/sources/bybit/const.py +1 -0
  14. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/sources/bybit/download.py +6 -6
  15. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/types/common_literals.py +3 -1
  16. pfeed-0.0.2.dev3/pfeed/types/core.py +11 -0
  17. pfeed-0.0.2.dev3/pyproject.toml +93 -0
  18. pfeed-0.0.2.dev1/PKG-INFO +0 -267
  19. pfeed-0.0.2.dev1/README.md +0 -231
  20. pfeed-0.0.2.dev1/pfeed/const/common.py +0 -15
  21. pfeed-0.0.2.dev1/pyproject.toml +0 -64
  22. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/LICENSE +0 -0
  23. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/cli/__init__.py +0 -0
  24. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/cli/commands/__init__.py +0 -0
  25. /pfeed-0.0.2.dev1/pfeed/cli/commands/stream.py → /pfeed-0.0.2.dev3/pfeed/cli/commands/doc.py +0 -0
  26. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/cli/commands/docker_compose.py +0 -0
  27. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/cli/commands/open.py +0 -0
  28. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/const/paths.py +0 -0
  29. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/data_tools/data_tool_pandas.py +0 -0
  30. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/data_tools/data_tool_polars.py +0 -0
  31. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/datastore.py +0 -0
  32. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/etl.py +0 -0
  33. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/feeds/__init__.py +0 -0
  34. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/feeds/binance_feed.py +0 -0
  35. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/feeds/bybit_feed.py +0 -0
  36. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/feeds/custom_csv_feed.py +0 -0
  37. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/filepath.py +0 -0
  38. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/main.py +0 -0
  39. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/resolution.py +0 -0
  40. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/sources/binance/__init__.py +0 -0
  41. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/sources/binance/api.py +0 -0
  42. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/sources/binance/const.py +0 -0
  43. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/sources/binance/stream.py +0 -0
  44. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/sources/bybit/__init__.py +0 -0
  45. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/sources/bybit/api.py +0 -0
  46. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/sources/bybit/stream.py +0 -0
  47. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/sources/bybit/types.py +0 -0
  48. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/sources/bybit/utils.py +0 -0
  49. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/utils/file_formats.py +0 -0
  50. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/utils/monitor.py +0 -0
  51. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/utils/utils.py +0 -0
  52. {pfeed-0.0.2.dev1 → pfeed-0.0.2.dev3}/pfeed/utils/validate.py +0 -0
@@ -0,0 +1,213 @@
1
+ Metadata-Version: 2.1
2
+ Name: pfeed
3
+ Version: 0.0.2.dev3
4
+ Summary: Data pipeline for algo-trading, getting and storing both real-time and historical data made easy.
5
+ Home-page: https://pfund.ai
6
+ License: Apache-2.0
7
+ Keywords: trading,algo-trading,data pipeline,ETL,data lake,data warehouse,data integration,historical data,live data,data streaming
8
+ Author: Stephen Yau
9
+ Author-email: softwareentrepreneer+pfeed@gmail.com
10
+ Requires-Python: >=3.10,<4.0
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Provides-Extra: all
17
+ Provides-Extra: core
18
+ Provides-Extra: dask
19
+ Provides-Extra: dataops
20
+ Provides-Extra: dfs
21
+ Provides-Extra: polars
22
+ Provides-Extra: spark
23
+ Provides-Extra: storage
24
+ Requires-Dist: adlfs (>=2024.7.0,<2025.0.0) ; extra == "storage" or extra == "all"
25
+ Requires-Dist: beautifulsoup4 (>=4.12.3,<5.0.0)
26
+ Requires-Dist: bytewax (>=0.21.0,<0.22.0) ; extra == "dataops" or extra == "all"
27
+ Requires-Dist: coiled (>=1.54.0,<2.0.0) ; extra == "dask" or extra == "dfs" or extra == "all"
28
+ Requires-Dist: confluent-kafka (>=2.5.3,<3.0.0) ; extra == "dataops" or extra == "all"
29
+ Requires-Dist: connectorx (>=0.3.3,<0.4.0) ; extra == "storage" or extra == "all"
30
+ Requires-Dist: dask[complete] (>=2024.9.1,<2025.0.0) ; extra == "dask" or extra == "dfs" or extra == "all"
31
+ Requires-Dist: databento (>=0.42.0,<0.43.0) ; extra == "core" or extra == "all"
32
+ Requires-Dist: databricks-connect (>=15.4.2,<16.0.0) ; extra == "spark" or extra == "dfs" or extra == "all"
33
+ Requires-Dist: fastparquet (>=2024.2.0,<2025.0.0)
34
+ Requires-Dist: gcsfs (>=2024.9.0,<2025.0.0) ; extra == "storage" or extra == "all"
35
+ Requires-Dist: minio (>=7.2.8,<8.0.0) ; extra == "core" or extra == "all"
36
+ Requires-Dist: modin[all] (>=0.32.0,<0.33.0) ; extra == "core" or extra == "all"
37
+ Requires-Dist: pandas (>=2.2.0,<3.0.0)
38
+ Requires-Dist: pfund (>=0.0.2.dev2,<0.0.3)
39
+ Requires-Dist: polars (>=1.7.1,<2.0.0) ; extra == "polars" or extra == "dfs" or extra == "all"
40
+ Requires-Dist: polars-xdt (>=0.16.0,<0.17.0) ; extra == "polars" or extra == "dfs" or extra == "all"
41
+ Requires-Dist: polygon-api-client (>=1.14.2,<2.0.0) ; extra == "core" or extra == "all"
42
+ Requires-Dist: prefect (>=3.0.5,<4.0.0) ; extra == "dataops" or extra == "all"
43
+ Requires-Dist: psutil (>=6.0.0,<7.0.0) ; extra == "core" or extra == "all"
44
+ Requires-Dist: psycopg2 (>=2.9.9,<3.0.0) ; extra == "storage" or extra == "all"
45
+ Requires-Dist: pyarrow (>=17.0.0,<18.0.0) ; extra == "core" or extra == "all"
46
+ Requires-Dist: pydantic (>=2.7.0,<3.0.0)
47
+ Requires-Dist: pyspark (>=3.5.3,<4.0.0) ; extra == "spark" or extra == "dfs" or extra == "all"
48
+ Requires-Dist: ray (>=2.35.0,<3.0.0) ; extra == "core" or extra == "all"
49
+ Requires-Dist: s3fs (>=2024.9.0,<2025.0.0) ; extra == "storage" or extra == "all"
50
+ Requires-Dist: yfinance (>=0.2.43,<0.3.0)
51
+ Project-URL: Documentation, https://pfeed-docs.pfund.ai
52
+ Project-URL: Repository, https://github.com/PFund-Software-Ltd/pfeed
53
+ Description-Content-Type: text/markdown
54
+
55
+ # PFeed: Data Pipeline for Algo-Trading, Getting and Storing Real-Time and Historical Data Made Easy.
56
+
57
+ [![Twitter Follow](https://img.shields.io/twitter/follow/pfund_ai?style=social)](https://x.com/pfund_ai)
58
+ ![GitHub stars](https://img.shields.io/github/stars/PFund-Software-Ltd/pfeed?style=social)
59
+ ![PyPI downloads](https://img.shields.io/pypi/dm/pfeed?label=downloads)
60
+ [![PyPI](https://img.shields.io/pypi/v/pfeed.svg)](https://pypi.org/project/pfeed)
61
+ ![PyPI - Support Python Versions](https://img.shields.io/pypi/pyversions/pfeed)
62
+ <!-- [![Jupyter Book Badge](https://raw.githubusercontent.com/PFund-Software-Ltd/pfeed/main/docs/images/jupyterbook.svg)](https://jupyterbook.org) -->
63
+ [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
64
+
65
+ [MinIO]: https://min.io/
66
+ [PFund]: https://github.com/PFund-Software-Ltd/pfund
67
+ [Polars]: https://github.com/pola-rs/polars
68
+ [Dask]: https://www.dask.org/
69
+ [Spark]: https://spark.apache.org/docs/latest/api/python/index.html
70
+ [PyTrade.org]: https://pytrade.org
71
+ [Yahoo Finance]: https://github.com/ranaroussi/yfinance
72
+ [Bybit]: https://public.bybit.com
73
+ [Binance]: https://data.binance.vision
74
+ [OKX]: https://www.okx.com/data-download
75
+ [Databento]: https://databento.com/
76
+ [Polygon]: https://polygon.io/
77
+ [FirstRate Data]: https://firstratedata.com
78
+
79
+ ## Problem
80
+ Starting algo-trading requires reliable, clean data. However, the time-consuming and mundane tasks of data cleaning and storage often discourage traders from embarking on their algo-trading journey.
81
+
82
+ ## Solution
83
+ By leveraging modern data engineering tools, `pfeed` handles the tedious data work and **outputs backtesting-ready data**, allowing traders to focus on strategy development.
84
+
85
+ ---
86
+ PFeed (/piː fiːd/) is a data pipeline for algorithmic trading, serving as a bridge between raw data sources and traders. It enables you to **download historical data**, **stream real-time data**, and **store cleaned data** in a **local data lake for quantitative analysis**, by automating the processes of data collection, cleaning, transformation, and storage.
87
+
88
+ ## Core Features
89
+ - [x] Download or stream reliable, validated and **clean data** for research, backtesting, or live trading
90
+ - [x] Get historical data (**dataframe**) or live data in standardized formats by just calling a **single** function
91
+ - [x] **Own your data** by storing them locally using [MinIO], with the option to connect to the cloud
92
+ - [x] Interact with different kinds of data (including TradFi, CeFi and DeFi) using a **unified interface**
93
+
94
+ ---
95
+
96
+ <details>
97
+ <summary>Table of Contents</summary>
98
+
99
+ - [Installation](#installation)
100
+ - [Quick Start](#quick-start)
101
+ - [Get Historical Data in Dataframe](#1-get-historical-data-in-dataframe-no-storage)
102
+ - [Download Historical Data on Command Line](#2-download-historical-data-on-the-command-line-interface-cli)
103
+ - [Download Historical Data in Python](#3-download-historical-data-in-python)
104
+ - [Supported Data Sources](#supported-data-sources)
105
+ - [Related Projects](#related-projects)
106
+ - [Disclaimer](#disclaimer)
107
+
108
+ </details>
109
+
110
+
111
+
112
+ ## Installation
113
+ > For more installation options, please refer to the [documentation](https://pfeed-docs.pfund.ai/installation).
114
+ ```bash
115
+ # [RECOMMENDED]: Full Features, choose this if you do not care about the package size
116
+ pip install -U "pfeed[all]"
117
+
118
+ # Minimal Features, only supports getting, downloading and streaming data
119
+ pip install -U "pfeed[core]"
120
+ ```
121
+
122
+
123
+
124
+ ## Quick Start
125
+ ### 1. Get Historical Data in Dataframe (No storage)
126
+ Get [Bybit]'s data in dataframe, e.g. 1-minute data (data is downloaded on the fly if not stored locally)
127
+
128
+ ```python
129
+ import pfeed as pe
130
+
131
+ feed = pe.BybitFeed(data_tool='polars')
132
+
133
+ df = feed.get_historical_data(
134
+ 'BTC_USDT_PERP',
135
+ resolution='1minute', # 'raw' or '1tick'/'1t' or '2second'/'2s' etc.
136
+ start_date='2024-03-01',
137
+ end_date='2024-03-01',
138
+ )
139
+ ```
140
+
141
+ Printing the first few rows of `df`:
142
+ | | ts | product | resolution | open | high | low | close | volume |
143
+ |---:|:--------------------|:--------------|:-------------|--------:|--------:|--------:|--------:|---------:|
144
+ | 0 | 2024-03-01 00:00:00 | BTC_USDT_PERP | 1m | 61184.1 | 61244.5 | 61175.8 | 61244.5 | 159.142 |
145
+ | 1 | 2024-03-01 00:01:00 | BTC_USDT_PERP | 1m | 61245.3 | 61276.5 | 61200.7 | 61232.2 | 227.242 |
146
+ | 2 | 2024-03-01 00:02:00 | BTC_USDT_PERP | 1m | 61232.2 | 61249 | 61180 | 61184.2 | 91.446 |
147
+
148
+ > By using pfeed, you are just a few lines of code away from getting a standardized dataframe, how convenient!
149
+
150
+ ### 2. Download Historical Data on the Command Line Interface (CLI)
151
+ > For more CLI commands, please refer to the [documentation](https://pfeed-docs.pfund.ai/cli-commands).
152
+ ```bash
153
+ # download data, default data type (dtype) is 'raw' data
154
+ pfeed download -d BYBIT -p BTC_USDT_PERP --start-date 2024-03-01 --end-date 2024-03-08
155
+
156
+ # download multiple products BTC_USDT_PERP and ETH_USDT_PERP as minute data and store them locally
157
+ pfeed download -d BYBIT -p BTC_USDT_PERP -p ETH_USDT_PERP --dtypes minute --use-minio
158
+ ```
159
+
160
+ ### 3. Download Historical Data in Python
161
+ ```python
162
+ import pfeed as pe
163
+
164
+ # compared to the CLI approach, this approach is more convenient for downloading multiple products
165
+ pe.download(
166
+ data_source='bybit',
167
+ pdts=[
168
+ 'BTC_USDT_PERP',
169
+ 'ETH_USDT_PERP',
170
+ 'BCH_USDT_PERP',
171
+ ],
172
+ dtypes=['raw'], # data types, e.g. 'raw', 'tick', 'second', 'minute' etc.
173
+ start_date='2024-03-01',
174
+ end_date='2024-03-08',
175
+ use_minio=False,
176
+ )
177
+ ```
178
+
179
+
180
+
181
+ ## Supported Data Sources
182
+ | Data Source | Get Historical Data | Download Historical Data | Get Live Data | Stream Live Data |
183
+ | -------------------- | ------------------- | ------------------------ | --------------| ---------------- |
184
+ | [Yahoo Finance] | 🟢 | ⚪ | ⚪ | ⚪ |
185
+ | [Bybit] | 🟢 | 🟢 | 🟡 | 🔴 |
186
+ | *Interactive Brokers | 🔴 | ⚪ | 🔴 | 🔴 |
187
+ | *[FirstRate Data] | 🔴 | 🔴 | ⚪ | ⚪ |
188
+ | *[Databento] | 🔴 | 🔴 | 🔴 | 🔴 |
189
+ | *[Polygon] | 🔴 | 🔴 | 🔴 | 🔴 |
190
+ | [Binance] | 🔴 | 🔴 | 🔴 | 🔴 |
191
+ | [OKX] | 🔴 | 🔴 | 🔴 | 🔴 |
192
+
193
+ 🟢 = finished \
194
+ 🟡 = in progress \
195
+ 🔴 = todo \
196
+ ⚪ = not applicable \
197
+ \* = paid data
198
+
199
+
200
+
201
+ ## Related Projects
202
+ - [PFund] — A Complete Algo-Trading Framework for Machine Learning, TradFi, CeFi and DeFi ready. Supports Vectorized and Event-Driven Backtesting, Paper and Live Trading
203
+ - [PyTrade.org] - A curated list of Python libraries and resources for algorithmic trading.
204
+
205
+
206
+
207
+ ## Disclaimer
208
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
209
+
210
+ This framework is intended for educational and research purposes only. It should not be used for real trading without understanding the risks involved. Trading in financial markets involves significant risk, and there is always the potential for loss. Your trading results may vary. No representation is being made that any account will or is likely to achieve profits or losses similar to those discussed on this platform.
211
+
212
+ The developers of this framework are not responsible for any financial losses incurred from using this software. This includes but not limited to losses resulting from inaccuracies in any financial data output by PFeed. Users should conduct their due diligence, verify the accuracy of any data produced by PFeed, and consult with a professional financial advisor before engaging in real trading activities.
213
+
@@ -0,0 +1,158 @@
1
+ # PFeed: Data Pipeline for Algo-Trading, Getting and Storing Real-Time and Historical Data Made Easy.
2
+
3
+ [![Twitter Follow](https://img.shields.io/twitter/follow/pfund_ai?style=social)](https://x.com/pfund_ai)
4
+ ![GitHub stars](https://img.shields.io/github/stars/PFund-Software-Ltd/pfeed?style=social)
5
+ ![PyPI downloads](https://img.shields.io/pypi/dm/pfeed?label=downloads)
6
+ [![PyPI](https://img.shields.io/pypi/v/pfeed.svg)](https://pypi.org/project/pfeed)
7
+ ![PyPI - Support Python Versions](https://img.shields.io/pypi/pyversions/pfeed)
8
+ <!-- [![Jupyter Book Badge](https://raw.githubusercontent.com/PFund-Software-Ltd/pfeed/main/docs/images/jupyterbook.svg)](https://jupyterbook.org) -->
9
+ [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
10
+
11
+ [MinIO]: https://min.io/
12
+ [PFund]: https://github.com/PFund-Software-Ltd/pfund
13
+ [Polars]: https://github.com/pola-rs/polars
14
+ [Dask]: https://www.dask.org/
15
+ [Spark]: https://spark.apache.org/docs/latest/api/python/index.html
16
+ [PyTrade.org]: https://pytrade.org
17
+ [Yahoo Finance]: https://github.com/ranaroussi/yfinance
18
+ [Bybit]: https://public.bybit.com
19
+ [Binance]: https://data.binance.vision
20
+ [OKX]: https://www.okx.com/data-download
21
+ [Databento]: https://databento.com/
22
+ [Polygon]: https://polygon.io/
23
+ [FirstRate Data]: https://firstratedata.com
24
+
25
+ ## Problem
26
+ Starting algo-trading requires reliable, clean data. However, the time-consuming and mundane tasks of data cleaning and storage often discourage traders from embarking on their algo-trading journey.
27
+
28
+ ## Solution
29
+ By leveraging modern data engineering tools, `pfeed` handles the tedious data work and **outputs backtesting-ready data**, allowing traders to focus on strategy development.
30
+
31
+ ---
32
+ PFeed (/piː fiːd/) is a data pipeline for algorithmic trading, serving as a bridge between raw data sources and traders. It enables you to **download historical data**, **stream real-time data**, and **store cleaned data** in a **local data lake for quantitative analysis**, by automating the processes of data collection, cleaning, transformation, and storage.
33
+
34
+ ## Core Features
35
+ - [x] Download or stream reliable, validated and **clean data** for research, backtesting, or live trading
36
+ - [x] Get historical data (**dataframe**) or live data in standardized formats by just calling a **single** function
37
+ - [x] **Own your data** by storing them locally using [MinIO], with the option to connect to the cloud
38
+ - [x] Interact with different kinds of data (including TradFi, CeFi and DeFi) using a **unified interface**
39
+
40
+ ---
41
+
42
+ <details>
43
+ <summary>Table of Contents</summary>
44
+
45
+ - [Installation](#installation)
46
+ - [Quick Start](#quick-start)
47
+ - [Get Historical Data in Dataframe](#1-get-historical-data-in-dataframe-no-storage)
48
+ - [Download Historical Data on Command Line](#2-download-historical-data-on-the-command-line-interface-cli)
49
+ - [Download Historical Data in Python](#3-download-historical-data-in-python)
50
+ - [Supported Data Sources](#supported-data-sources)
51
+ - [Related Projects](#related-projects)
52
+ - [Disclaimer](#disclaimer)
53
+
54
+ </details>
55
+
56
+
57
+
58
+ ## Installation
59
+ > For more installation options, please refer to the [documentation](https://pfeed-docs.pfund.ai/installation).
60
+ ```bash
61
+ # [RECOMMENDED]: Full Features, choose this if you do not care about the package size
62
+ pip install -U "pfeed[all]"
63
+
64
+ # Minimal Features, only supports getting, downloading and streaming data
65
+ pip install -U "pfeed[core]"
66
+ ```
67
+
68
+
69
+
70
+ ## Quick Start
71
+ ### 1. Get Historical Data in Dataframe (No storage)
72
+ Get [Bybit]'s data in dataframe, e.g. 1-minute data (data is downloaded on the fly if not stored locally)
73
+
74
+ ```python
75
+ import pfeed as pe
76
+
77
+ feed = pe.BybitFeed(data_tool='polars')
78
+
79
+ df = feed.get_historical_data(
80
+ 'BTC_USDT_PERP',
81
+ resolution='1minute', # 'raw' or '1tick'/'1t' or '2second'/'2s' etc.
82
+ start_date='2024-03-01',
83
+ end_date='2024-03-01',
84
+ )
85
+ ```
86
+
87
+ Printing the first few rows of `df`:
88
+ | | ts | product | resolution | open | high | low | close | volume |
89
+ |---:|:--------------------|:--------------|:-------------|--------:|--------:|--------:|--------:|---------:|
90
+ | 0 | 2024-03-01 00:00:00 | BTC_USDT_PERP | 1m | 61184.1 | 61244.5 | 61175.8 | 61244.5 | 159.142 |
91
+ | 1 | 2024-03-01 00:01:00 | BTC_USDT_PERP | 1m | 61245.3 | 61276.5 | 61200.7 | 61232.2 | 227.242 |
92
+ | 2 | 2024-03-01 00:02:00 | BTC_USDT_PERP | 1m | 61232.2 | 61249 | 61180 | 61184.2 | 91.446 |
93
+
94
+ > By using pfeed, you are just a few lines of code away from getting a standardized dataframe, how convenient!
95
+
96
+ ### 2. Download Historical Data on the Command Line Interface (CLI)
97
+ > For more CLI commands, please refer to the [documentation](https://pfeed-docs.pfund.ai/cli-commands).
98
+ ```bash
99
+ # download data, default data type (dtype) is 'raw' data
100
+ pfeed download -d BYBIT -p BTC_USDT_PERP --start-date 2024-03-01 --end-date 2024-03-08
101
+
102
+ # download multiple products BTC_USDT_PERP and ETH_USDT_PERP as minute data and store them locally
103
+ pfeed download -d BYBIT -p BTC_USDT_PERP -p ETH_USDT_PERP --dtypes minute --use-minio
104
+ ```
105
+
106
+ ### 3. Download Historical Data in Python
107
+ ```python
108
+ import pfeed as pe
109
+
110
+ # compared to the CLI approach, this approach is more convenient for downloading multiple products
111
+ pe.download(
112
+ data_source='bybit',
113
+ pdts=[
114
+ 'BTC_USDT_PERP',
115
+ 'ETH_USDT_PERP',
116
+ 'BCH_USDT_PERP',
117
+ ],
118
+ dtypes=['raw'], # data types, e.g. 'raw', 'tick', 'second', 'minute' etc.
119
+ start_date='2024-03-01',
120
+ end_date='2024-03-08',
121
+ use_minio=False,
122
+ )
123
+ ```
124
+
125
+
126
+
127
+ ## Supported Data Sources
128
+ | Data Source | Get Historical Data | Download Historical Data | Get Live Data | Stream Live Data |
129
+ | -------------------- | ------------------- | ------------------------ | --------------| ---------------- |
130
+ | [Yahoo Finance] | 🟢 | ⚪ | ⚪ | ⚪ |
131
+ | [Bybit] | 🟢 | 🟢 | 🟡 | 🔴 |
132
+ | *Interactive Brokers | 🔴 | ⚪ | 🔴 | 🔴 |
133
+ | *[FirstRate Data] | 🔴 | 🔴 | ⚪ | ⚪ |
134
+ | *[Databento] | 🔴 | 🔴 | 🔴 | 🔴 |
135
+ | *[Polygon] | 🔴 | 🔴 | 🔴 | 🔴 |
136
+ | [Binance] | 🔴 | 🔴 | 🔴 | 🔴 |
137
+ | [OKX] | 🔴 | 🔴 | 🔴 | 🔴 |
138
+
139
+ 🟢 = finished \
140
+ 🟡 = in progress \
141
+ 🔴 = todo \
142
+ ⚪ = not applicable \
143
+ \* = paid data
144
+
145
+
146
+
147
+ ## Related Projects
148
+ - [PFund] — A Complete Algo-Trading Framework for Machine Learning, TradFi, CeFi and DeFi ready. Supports Vectorized and Event-Driven Backtesting, Paper and Live Trading
149
+ - [PyTrade.org] - A curated list of Python libraries and resources for algorithmic trading.
150
+
151
+
152
+
153
+ ## Disclaimer
154
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
155
+
156
+ This framework is intended for educational and research purposes only. It should not be used for real trading without understanding the risks involved. Trading in financial markets involves significant risk, and there is always the potential for loss. Your trading results may vary. No representation is being made that any account will or is likely to achieve profits or losses similar to those discussed on this platform.
157
+
158
+ The developers of this framework are not responsible for any financial losses incurred from using this software. This includes but not limited to losses resulting from inaccuracies in any financial data output by PFeed. Users should conduct their due diligence, verify the accuracy of any data produced by PFeed, and consult with a professional financial advisor before engaging in real trading activities.
@@ -8,32 +8,32 @@ import importlib
8
8
  from importlib.metadata import version
9
9
 
10
10
  from pfeed.config_handler import configure, get_config
11
- from pfeed.const.common import ALIASES
11
+ from pfeed.const.common import ALIASES as aliases
12
12
  from pfeed.sources import bybit
13
13
  from pfeed.feeds import BybitFeed, YahooFinanceFeed
14
14
 
15
15
 
16
16
  def download_historical_data(
17
17
  data_source: tSUPPORTED_DOWNLOAD_DATA_SOURCES,
18
- pdts: str | list[str] | None = None,
18
+ products: str | list[str] | None = None,
19
19
  dtypes: tSUPPORTED_DATA_TYPES | list[tSUPPORTED_DATA_TYPES] | None = None,
20
20
  ptypes: str | list[str] | None = None,
21
21
  start_date: str | None = None,
22
22
  end_date: str | None = None,
23
23
  use_minio: bool = False,
24
24
  use_ray: bool = True,
25
- ray_num_cpus: int = 8,
25
+ num_cpus: int = 8,
26
26
  ):
27
27
  data_source = importlib.import_module(f"pfeed.sources.{data_source.lower()}")
28
28
  return data_source.download_historical_data(
29
- pdts=pdts,
29
+ products=products,
30
30
  dtypes=dtypes,
31
31
  ptypes=ptypes,
32
32
  start_date=start_date,
33
33
  end_date=end_date,
34
34
  use_minio=use_minio,
35
35
  use_ray=use_ray,
36
- ray_num_cpus=ray_num_cpus,
36
+ num_cpus=num_cpus,
37
37
  )
38
38
 
39
39
 
@@ -53,7 +53,7 @@ __all__ = (
53
53
  "__version__",
54
54
  "configure",
55
55
  "get_config",
56
- "ALIASES",
56
+ "aliases",
57
57
  "bybit",
58
58
  "binance",
59
59
  "YahooFinanceFeed",
@@ -32,33 +32,30 @@ def remove_config(config_file_path: str | Path):
32
32
  @click.option('--use-fork-process', type=bool, help='If True, multiprocessing.set_start_method("fork")')
33
33
  @click.option('--use-custom-excepthook', type=bool, help='If True, log uncaught exceptions to file')
34
34
  @click.option('--env-file', 'env_file_path', type=click.Path(resolve_path=True, exists=True), help='Path to the .env file')
35
- @click.option('--debug', is_flag=True, help='if enabled, debug mode will be enabled where logs at DEBUG level will be printed')
36
- @click.option('--list', '-l', is_flag=True, is_eager=True, help='List all available options')
37
- @click.option('--reset', is_flag=True, is_eager=True, help='Reset the configuration to defaults')
38
- def config(ctx, **kwargs):
35
+ @click.option('--debug', '-d', type=bool, help='If True, enable debug mode where logs at DEBUG level will be printed')
36
+ @click.option('--list', '-l', 'is_list', is_flag=True, is_eager=True, help='List all available options')
37
+ @click.option('--reset', 'is_reset', is_flag=True, is_eager=True, help='Reset the configuration to defaults')
38
+ def config(ctx, is_list, is_reset, **kwargs):
39
39
  """Configures pfeed settings."""
40
40
  config: ConfigHandler = ctx.obj['config']
41
41
 
42
42
  # Filter out options that were not provided by the user
43
- provided_options = {k: v for k, v in kwargs.items() if v is not None and v is not False}
43
+ provided_options = {k: v for k, v in kwargs.items() if v is not None}
44
44
 
45
- if kwargs.get('list'): # Check if --list was used
46
- del provided_options['list']
45
+ if is_list: # Check if --list was used
47
46
  assert not provided_options, "No options should be provided with --list"
48
47
  config_dict = config.__dict__
49
48
  config_dict.update({'config_file_path': USER_CONFIG_FILE_PATH})
50
49
  click.echo(f"PFeed's config:\n{pformat(config_dict)}")
51
50
  return
52
51
 
53
- if kwargs.get('reset'): # Check if --reset was used
54
- del provided_options['reset']
52
+ if is_reset: # Check if --reset was used
55
53
  assert not provided_options, "No options should be provided with --reset"
56
54
  remove_config(USER_CONFIG_FILE_PATH)
57
55
  click.echo("PFeed's config successfully reset.")
58
- return
59
56
 
60
57
  # prints out current config if no options are provided
61
- if not provided_options:
58
+ if not provided_options and not is_list and not is_reset:
62
59
  raise click.UsageError("No options provided. Use --list to see all available options.")
63
60
  else:
64
61
  for option, value in provided_options.items():
@@ -21,7 +21,7 @@ SUPPORTED_DATA_TYPES_IMPLICIT_RAW_ALLOWED = SUPPORTED_DATA_TYPES + ['raw']
21
21
 
22
22
  @click.command()
23
23
  @click.option('--data-source', '-d', required=True, type=click.Choice(SUPPORTED_DOWNLOAD_DATA_SOURCES_ALIASES_INCLUDED, case_sensitive=False), help='Data source')
24
- @click.option('--pdts', '-p', 'pdts', multiple=True, default=[], help='List of trading products')
24
+ @click.option('--products', '-p', 'products', multiple=True, default=[], help='List of trading products')
25
25
  @click.option('--dtypes', '--dt', 'dtypes', multiple=True, default=['raw'], type=click.Choice(SUPPORTED_DATA_TYPES_IMPLICIT_RAW_ALLOWED, case_sensitive=False), help=f'{SUPPORTED_DATA_TYPES=}. How to pass in multiple values: --dt raw --dt tick')
26
26
  @click.option('--ptypes', '--pt', 'ptypes', multiple=True, default=[], type=click.Choice(SUPPORTED_PRODUCT_TYPES, case_sensitive=False), help='List of product types, e.g. PERP = get all perpetuals')
27
27
  @click.option('--start-date', '-s', type=click.DateTime(formats=["%Y-%m-%d"]), help='Start date in YYYY-MM-DD format')
@@ -31,17 +31,17 @@ SUPPORTED_DATA_TYPES_IMPLICIT_RAW_ALLOWED = SUPPORTED_DATA_TYPES + ['raw']
31
31
  @click.option('--no-ray', is_flag=True, help='if enabled, Ray will not be used')
32
32
  @click.option('--env-file', 'env_file_path', type=click.Path(exists=True), help='Path to the .env file')
33
33
  @click.option('--debug', is_flag=True, help='if enabled, debug mode will be enabled where logs at DEBUG level will be printed')
34
- def download(data_source, pdts, dtypes, ptypes, start_date, end_date, num_cpus, no_ray, use_minio, env_file_path, debug):
34
+ def download(data_source, products, dtypes, ptypes, start_date, end_date, num_cpus, no_ray, use_minio, env_file_path, debug):
35
35
  pe.configure(env_file_path=env_file_path, debug=debug)
36
36
  data_source = ALIASES.get(data_source, data_source)
37
37
  pipeline = importlib.import_module(f'pfeed.sources.{data_source.lower()}.download')
38
38
  pipeline.download_historical_data(
39
- pdts=pdts,
39
+ products=products,
40
40
  dtypes=dtypes,
41
41
  ptypes=ptypes,
42
42
  start_date=start_date.date().strftime('%Y-%m-%d') if start_date else start_date,
43
43
  end_date=end_date.date().strftime('%Y-%m-%d') if end_date else end_date,
44
44
  use_ray=not no_ray,
45
- ray_num_cpus=num_cpus,
45
+ num_cpus=num_cpus,
46
46
  use_minio=use_minio,
47
47
  )
File without changes
@@ -6,6 +6,7 @@ from pfeed.cli.commands.config import config
6
6
  from pfeed.cli.commands.download import download
7
7
  # from pfeed.cli.commands.stream import stream
8
8
  from pfeed.cli.commands.open import open
9
+ from pfeed.cli.commands.doc import doc
9
10
 
10
11
 
11
12
  @click.group(context_settings={"help_option_names": ["-h", "--help"]})
@@ -21,4 +22,5 @@ pfeed_group.add_command(docker_compose)
21
22
  pfeed_group.add_command(config)
22
23
  pfeed_group.add_command(download)
23
24
  # pfeed_group.add_command(stream)
24
- pfeed_group.add_command(open)
25
+ pfeed_group.add_command(open)
26
+ pfeed_group.add_command(doc)
@@ -33,7 +33,7 @@ class ConfigHandler:
33
33
  logging_config: dict | None = None
34
34
  use_fork_process: bool = True
35
35
  use_custom_excepthook: bool = False
36
- env_file_path: str | None=None
36
+ env_file_path: str = ''
37
37
  debug: bool = False
38
38
 
39
39
  @classmethod
@@ -57,9 +57,9 @@ class ConfigHandler:
57
57
  return cls(**config)
58
58
 
59
59
  def __post_init__(self):
60
- self.initialize()
60
+ self._initialize()
61
61
 
62
- def initialize(self):
62
+ def _initialize(self):
63
63
  self.logging_config = self.logging_config or {}
64
64
 
65
65
  for path in [self.data_path]:
@@ -76,19 +76,15 @@ class ConfigHandler:
76
76
  self.load_env_file(self.env_file_path)
77
77
 
78
78
  if self.debug:
79
- is_loggers_set_up = bool(logging.getLogger('pfeed').handlers)
80
- if is_loggers_set_up:
81
- print('loggers are already set up, ignoring enabling debug mode')
82
- else:
83
- self.enable_debug_mode()
79
+ self.enable_debug_mode()
84
80
 
85
- def load_env_file(self, env_file_path: str | None):
81
+ def load_env_file(self, env_file_path: str=''):
86
82
  from dotenv import find_dotenv, load_dotenv
87
83
 
88
84
  if not env_file_path:
89
- found_env_file_path = find_dotenv(usecwd=True, raise_error_if_not_found=False)
90
- if found_env_file_path:
91
- print(f'.env file path is not specified, using env file in "{found_env_file_path}"')
85
+ env_file_path = find_dotenv(usecwd=True, raise_error_if_not_found=False)
86
+ if env_file_path:
87
+ print(f'.env file path is not specified, using env file in "{env_file_path}"')
92
88
  else:
93
89
  # print('.env file is not found')
94
90
  return
@@ -96,6 +92,10 @@ class ConfigHandler:
96
92
 
97
93
  def enable_debug_mode(self):
98
94
  '''Enables debug mode by setting the log level to DEBUG for all stream handlers'''
95
+ is_loggers_set_up = bool(logging.getLogger('pfeed').handlers)
96
+ if is_loggers_set_up:
97
+ print('loggers are already set up, ignoring debug mode')
98
+ return
99
99
  if 'handlers' not in self.logging_config:
100
100
  self.logging_config['handlers'] = {}
101
101
  for handler in ['stream_handler', 'stream_path_handler']:
@@ -145,7 +145,7 @@ def configure(
145
145
  else:
146
146
  raise AttributeError(f'{k} is not an attribute of ConfigHandler')
147
147
 
148
- _global_config.initialize()
148
+ _global_config._initialize()
149
149
  return _global_config
150
150
 
151
151
 
@@ -0,0 +1,32 @@
1
+ from pfeed.types.common_literals import tSUPPORTED_DATA_TOOLS, tSUPPORTED_DATA_ENGINES
2
+
3
+
4
+ SUPPORTED_ENVIRONMENTS = ['BACKTEST', 'SANDBOX', 'PAPER', 'LIVE']
5
+ SUPPORTED_DATA_FEEDS = ['YAHOO_FINANCE', 'BYBIT', 'BINANCE']
6
+ SUPPORTED_STORAGES = ['local', 'minio']
7
+ SUPPORTED_DOWNLOAD_DATA_SOURCES = ['BYBIT', 'BINANCE']
8
+ SUPPORTED_CRYPTO_EXCHANGES = ['BYBIT', 'BINANCE']
9
+ SUPPORTED_DATA_TOOLS: dict[tSUPPORTED_DATA_TOOLS, tSUPPORTED_DATA_ENGINES | bool] = {
10
+ 'pandas': ['dask'],
11
+ 'polars': ['ray'],
12
+ # True means the data tool is also an execution engine
13
+ 'dask': True,
14
+ 'spark': True,
15
+ }
16
+ SUPPORTED_DATA_ENGINES: dict[tSUPPORTED_DATA_ENGINES, list[str]] = {
17
+ # execution engine: supported cloud services
18
+ 'dask': ['coiled'],
19
+ 'spark': ['databricks'],
20
+ 'ray': ['aws'],
21
+ }
22
+ SUPPORTED_CLOUDS = ['aws']
23
+ SUPPORTED_PRODUCT_TYPES = ['SPOT', 'PERP', 'IPERP', 'FUT', 'IFUT']
24
+ SUPPORTED_DATA_TYPES = [
25
+ 'raw_tick', 'raw_second', 'raw_minute', 'raw_hour', 'raw_daily',
26
+ 'tick', 'second', 'minute', 'hour', 'daily',
27
+ ]
28
+
29
+ ALIASES = {
30
+ 'YF': 'YAHOO_FINANCE',
31
+ 'FRD': 'FIRSTRATE_DATA'
32
+ }