pfund 0.0.1__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.
- pfund-0.0.1/LICENSE +201 -0
- pfund-0.0.1/PKG-INFO +271 -0
- pfund-0.0.1/README.md +221 -0
- pfund-0.0.1/pfund/CONTRIBUTING.md +22 -0
- pfund-0.0.1/pfund/__init__.py +32 -0
- pfund-0.0.1/pfund/accounts/__init__.py +3 -0
- pfund-0.0.1/pfund/accounts/account_base.py +35 -0
- pfund-0.0.1/pfund/accounts/account_crypto.py +33 -0
- pfund-0.0.1/pfund/accounts/account_ib.py +11 -0
- pfund-0.0.1/pfund/adapter.py +64 -0
- pfund-0.0.1/pfund/analyzer.py +217 -0
- pfund-0.0.1/pfund/backtest_history.py +210 -0
- pfund-0.0.1/pfund/balances/__init__.py +3 -0
- pfund-0.0.1/pfund/balances/balance_base.py +61 -0
- pfund-0.0.1/pfund/balances/balance_crypto.py +13 -0
- pfund-0.0.1/pfund/balances/balance_ib.py +26 -0
- pfund-0.0.1/pfund/brokers/__init__.py +3 -0
- pfund-0.0.1/pfund/brokers/broker_backtest.py +86 -0
- pfund-0.0.1/pfund/brokers/broker_base.py +26 -0
- pfund-0.0.1/pfund/brokers/broker_crypto.py +297 -0
- pfund-0.0.1/pfund/brokers/broker_defi.py +8 -0
- pfund-0.0.1/pfund/brokers/broker_live.py +98 -0
- pfund-0.0.1/pfund/brokers/ib/__init__.py +1 -0
- pfund-0.0.1/pfund/brokers/ib/broker_ib.py +238 -0
- pfund-0.0.1/pfund/brokers/ib/ib_api.py +279 -0
- pfund-0.0.1/pfund/brokers/ib/ib_client.py +143 -0
- pfund-0.0.1/pfund/brokers/ib/ib_wrapper.py +210 -0
- pfund-0.0.1/pfund/cli/__init__.py +4 -0
- pfund-0.0.1/pfund/cli/commands/__init__.py +0 -0
- pfund-0.0.1/pfund/cli/commands/config.py +66 -0
- pfund-0.0.1/pfund/cli/commands/docker_compose.py +27 -0
- pfund-0.0.1/pfund/cli/main.py +18 -0
- pfund-0.0.1/pfund/config/binance/linear/config.yml +7 -0
- pfund-0.0.1/pfund/config/binance/linear/lot_sizes_linear.yml +2 -0
- pfund-0.0.1/pfund/config/binance/linear/pdt_matchings_linear.yml +2 -0
- pfund-0.0.1/pfund/config/binance/linear/tick_sizes_linear.yml +2 -0
- pfund-0.0.1/pfund/config/bybit/config.yml +99 -0
- pfund-0.0.1/pfund/config/bybit/lot_sizes_inverse.yml +12 -0
- pfund-0.0.1/pfund/config/bybit/lot_sizes_linear.yml +291 -0
- pfund-0.0.1/pfund/config/bybit/lot_sizes_option.yml +500 -0
- pfund-0.0.1/pfund/config/bybit/lot_sizes_spot.yml +440 -0
- pfund-0.0.1/pfund/config/bybit/pdt_matchings_inverse.yml +8 -0
- pfund-0.0.1/pfund/config/bybit/pdt_matchings_linear.yml +277 -0
- pfund-0.0.1/pfund/config/bybit/pdt_matchings_option.yml +1 -0
- pfund-0.0.1/pfund/config/bybit/pdt_matchings_spot.yml +440 -0
- pfund-0.0.1/pfund/config/bybit/tick_sizes_inverse.yml +12 -0
- pfund-0.0.1/pfund/config/bybit/tick_sizes_linear.yml +291 -0
- pfund-0.0.1/pfund/config/bybit/tick_sizes_option.yml +500 -0
- pfund-0.0.1/pfund/config/bybit/tick_sizes_spot.yml +440 -0
- pfund-0.0.1/pfund/config/configuration.py +59 -0
- pfund-0.0.1/pfund/config/ib/config.yml +24 -0
- pfund-0.0.1/pfund/config_handler.py +184 -0
- pfund-0.0.1/pfund/const/__init__.py +2 -0
- pfund-0.0.1/pfund/const/_zmq_routes.py +90 -0
- pfund-0.0.1/pfund/const/aliases.py +103 -0
- pfund-0.0.1/pfund/const/common.py +26 -0
- pfund-0.0.1/pfund/const/paths.py +27 -0
- pfund-0.0.1/pfund/data_tools/data_tool_base.py +61 -0
- pfund-0.0.1/pfund/data_tools/data_tool_pandas.py +748 -0
- pfund-0.0.1/pfund/data_tools/data_tool_polars.py +151 -0
- pfund-0.0.1/pfund/datas/__init__.py +4 -0
- pfund-0.0.1/pfund/datas/data_bar.py +194 -0
- pfund-0.0.1/pfund/datas/data_base.py +20 -0
- pfund-0.0.1/pfund/datas/data_quote.py +46 -0
- pfund-0.0.1/pfund/datas/data_tick.py +41 -0
- pfund-0.0.1/pfund/datas/data_time_based.py +61 -0
- pfund-0.0.1/pfund/datas/resolution.py +100 -0
- pfund-0.0.1/pfund/datas/timeframe.py +76 -0
- pfund-0.0.1/pfund/engines/__init__.py +4 -0
- pfund-0.0.1/pfund/engines/backtest_engine.py +419 -0
- pfund-0.0.1/pfund/engines/base_engine.py +135 -0
- pfund-0.0.1/pfund/engines/sandbox_engine.py +53 -0
- pfund-0.0.1/pfund/engines/trade_engine.py +228 -0
- pfund-0.0.1/pfund/engines/train_engine.py +52 -0
- pfund-0.0.1/pfund/errors.py +8 -0
- pfund-0.0.1/pfund/exchanges/__init__.py +0 -0
- pfund-0.0.1/pfund/exchanges/binance/__init__.py +3 -0
- pfund-0.0.1/pfund/exchanges/binance/exchange.py +37 -0
- pfund-0.0.1/pfund/exchanges/binance/linear/exchange.py +7 -0
- pfund-0.0.1/pfund/exchanges/binance/rest_api.py +15 -0
- pfund-0.0.1/pfund/exchanges/binance/ws_api.py +33 -0
- pfund-0.0.1/pfund/exchanges/bybit/__init__.py +3 -0
- pfund-0.0.1/pfund/exchanges/bybit/exchange.py +422 -0
- pfund-0.0.1/pfund/exchanges/bybit/rest_api.py +127 -0
- pfund-0.0.1/pfund/exchanges/bybit/rest_api_samples/get_markets_result_inverse +286 -0
- pfund-0.0.1/pfund/exchanges/bybit/rest_api_samples/get_markets_result_linear +4856 -0
- pfund-0.0.1/pfund/exchanges/bybit/rest_api_samples/get_markets_result_option +6500 -0
- pfund-0.0.1/pfund/exchanges/bybit/rest_api_samples/get_markets_result_spot +2808 -0
- pfund-0.0.1/pfund/exchanges/bybit/rest_api_samples/get_markets_return_inverse +292 -0
- pfund-0.0.1/pfund/exchanges/bybit/rest_api_samples/get_markets_return_linear +4868 -0
- pfund-0.0.1/pfund/exchanges/bybit/rest_api_samples/get_markets_return_option +7506 -0
- pfund-0.0.1/pfund/exchanges/bybit/rest_api_samples/get_markets_return_spot +2813 -0
- pfund-0.0.1/pfund/exchanges/bybit/ws_api.py +425 -0
- pfund-0.0.1/pfund/exchanges/exchange_base.py +445 -0
- pfund-0.0.1/pfund/exchanges/rest_api_base.py +100 -0
- pfund-0.0.1/pfund/exchanges/ws_api_base.py +626 -0
- pfund-0.0.1/pfund/externals/ibapi/__init__.py +18 -0
- pfund-0.0.1/pfund/externals/ibapi/account_summary_tags.py +48 -0
- pfund-0.0.1/pfund/externals/ibapi/client.py +3749 -0
- pfund-0.0.1/pfund/externals/ibapi/comm.py +85 -0
- pfund-0.0.1/pfund/externals/ibapi/commission_report.py +21 -0
- pfund-0.0.1/pfund/externals/ibapi/common.py +243 -0
- pfund-0.0.1/pfund/externals/ibapi/connection.py +127 -0
- pfund-0.0.1/pfund/externals/ibapi/contract.py +219 -0
- pfund-0.0.1/pfund/externals/ibapi/decoder.py +1481 -0
- pfund-0.0.1/pfund/externals/ibapi/enum_implem.py +20 -0
- pfund-0.0.1/pfund/externals/ibapi/errors.py +41 -0
- pfund-0.0.1/pfund/externals/ibapi/execution.py +55 -0
- pfund-0.0.1/pfund/externals/ibapi/ibapi.pyproj +51 -0
- pfund-0.0.1/pfund/externals/ibapi/message.py +184 -0
- pfund-0.0.1/pfund/externals/ibapi/news.py +10 -0
- pfund-0.0.1/pfund/externals/ibapi/object_implem.py +12 -0
- pfund-0.0.1/pfund/externals/ibapi/order.py +246 -0
- pfund-0.0.1/pfund/externals/ibapi/order_condition.py +275 -0
- pfund-0.0.1/pfund/externals/ibapi/order_state.py +29 -0
- pfund-0.0.1/pfund/externals/ibapi/orderdecoder.py +457 -0
- pfund-0.0.1/pfund/externals/ibapi/reader.py +54 -0
- pfund-0.0.1/pfund/externals/ibapi/scanner.py +56 -0
- pfund-0.0.1/pfund/externals/ibapi/server_versions.py +134 -0
- pfund-0.0.1/pfund/externals/ibapi/softdollartier.py +17 -0
- pfund-0.0.1/pfund/externals/ibapi/tag_value.py +22 -0
- pfund-0.0.1/pfund/externals/ibapi/ticktype.py +119 -0
- pfund-0.0.1/pfund/externals/ibapi/utils.py +141 -0
- pfund-0.0.1/pfund/externals/ibapi/wrapper.py +734 -0
- pfund-0.0.1/pfund/git_controller.py +60 -0
- pfund-0.0.1/pfund/indicators/__init__.py +3 -0
- pfund-0.0.1/pfund/indicators/indicator_base.py +70 -0
- pfund-0.0.1/pfund/indicators/ta_indicator.py +118 -0
- pfund-0.0.1/pfund/indicators/talib_indicator.py +77 -0
- pfund-0.0.1/pfund/investment_profile.py +18 -0
- pfund-0.0.1/pfund/main.py +18 -0
- pfund-0.0.1/pfund/managers/__init__.py +7 -0
- pfund-0.0.1/pfund/managers/base_manager.py +28 -0
- pfund-0.0.1/pfund/managers/connection_manager.py +182 -0
- pfund-0.0.1/pfund/managers/data_manager.py +245 -0
- pfund-0.0.1/pfund/managers/order_manager.py +261 -0
- pfund-0.0.1/pfund/managers/portfolio_manager.py +99 -0
- pfund-0.0.1/pfund/managers/risk_manager.py +8 -0
- pfund-0.0.1/pfund/managers/strategy_manager.py +205 -0
- pfund-0.0.1/pfund/mixins/assets/__init__.py +4 -0
- pfund-0.0.1/pfund/mixins/assets/all_assets_mixin.py +25 -0
- pfund-0.0.1/pfund/mixins/assets/crypto_assets_mixin.py +29 -0
- pfund-0.0.1/pfund/mixins/assets/defi_assets_mixin.py +30 -0
- pfund-0.0.1/pfund/mixins/assets/tradfi_assets_mixin.py +33 -0
- pfund-0.0.1/pfund/mixins/backtest_mixin.py +335 -0
- pfund-0.0.1/pfund/mixins/trade_mixin.py +427 -0
- pfund-0.0.1/pfund/models/__init__.py +11 -0
- pfund-0.0.1/pfund/models/model_backtest.py +85 -0
- pfund-0.0.1/pfund/models/model_base.py +335 -0
- pfund-0.0.1/pfund/models/model_meta.py +57 -0
- pfund-0.0.1/pfund/models/pytorch_model.py +79 -0
- pfund-0.0.1/pfund/models/sklearn_model.py +58 -0
- pfund-0.0.1/pfund/orders/__init__.py +2 -0
- pfund-0.0.1/pfund/orders/order_base.py +263 -0
- pfund-0.0.1/pfund/orders/order_crypto.py +55 -0
- pfund-0.0.1/pfund/orders/order_ib.py +8 -0
- pfund-0.0.1/pfund/orders/order_statuses.py +42 -0
- pfund-0.0.1/pfund/orders/order_time_in_force.py +8 -0
- pfund-0.0.1/pfund/plogging/__init__.py +80 -0
- pfund-0.0.1/pfund/plogging/config.py +76 -0
- pfund-0.0.1/pfund/plogging/filters.py +12 -0
- pfund-0.0.1/pfund/plogging/formatter.py +17 -0
- pfund-0.0.1/pfund/plogging/handlers.py +49 -0
- pfund-0.0.1/pfund/portfolios/__init__.py +5 -0
- pfund-0.0.1/pfund/portfolios/base_portfolio.py +110 -0
- pfund-0.0.1/pfund/portfolios/crypto_portfolio.py +8 -0
- pfund-0.0.1/pfund/portfolios/defi_portfolio.py +8 -0
- pfund-0.0.1/pfund/portfolios/portfolio.py +69 -0
- pfund-0.0.1/pfund/portfolios/tradfi_portfolio.py +8 -0
- pfund-0.0.1/pfund/positions/__init__.py +3 -0
- pfund-0.0.1/pfund/positions/position_base.py +56 -0
- pfund-0.0.1/pfund/positions/position_crypto.py +108 -0
- pfund-0.0.1/pfund/positions/position_ib.py +67 -0
- pfund-0.0.1/pfund/products/__init__.py +3 -0
- pfund-0.0.1/pfund/products/product_base.py +52 -0
- pfund-0.0.1/pfund/products/product_crypto.py +81 -0
- pfund-0.0.1/pfund/products/product_ib.py +66 -0
- pfund-0.0.1/pfund/strategies/__init__.py +1 -0
- pfund-0.0.1/pfund/strategies/allocation_strategy.py +17 -0
- pfund-0.0.1/pfund/strategies/diversification_strategy.py +20 -0
- pfund-0.0.1/pfund/strategies/execution_strategy.py +6 -0
- pfund-0.0.1/pfund/strategies/hedging_strategy.py +17 -0
- pfund-0.0.1/pfund/strategies/optimization_strategy.py +20 -0
- pfund-0.0.1/pfund/strategies/portfolio_strategy.py +104 -0
- pfund-0.0.1/pfund/strategies/rebalancing_strategy.py +17 -0
- pfund-0.0.1/pfund/strategies/strategy_backtest.py +65 -0
- pfund-0.0.1/pfund/strategies/strategy_base.py +428 -0
- pfund-0.0.1/pfund/strategies/strategy_meta.py +33 -0
- pfund-0.0.1/pfund/templates/dashboards/pfund-overview.streamlit.py +0 -0
- pfund-0.0.1/pfund/templates/notebooks/pfund-analytics.ipynb +49 -0
- pfund-0.0.1/pfund/templates/notebooks/pfund-overview.ipynb +55 -0
- pfund-0.0.1/pfund/types/backtest.py +10 -0
- pfund-0.0.1/pfund/types/bybit.py +4 -0
- pfund-0.0.1/pfund/types/common_literals.py +27 -0
- pfund-0.0.1/pfund/types/core.py +14 -0
- pfund-0.0.1/pfund/types/data_tool.py +57 -0
- pfund-0.0.1/pfund/universes/__init__.py +5 -0
- pfund-0.0.1/pfund/universes/base_universe.py +59 -0
- pfund-0.0.1/pfund/universes/crypto_universe.py +8 -0
- pfund-0.0.1/pfund/universes/defi_universe.py +8 -0
- pfund-0.0.1/pfund/universes/tradfi_universe.py +8 -0
- pfund-0.0.1/pfund/universes/universe.py +74 -0
- pfund-0.0.1/pfund/utils/envs.py +29 -0
- pfund-0.0.1/pfund/utils/utils.py +185 -0
- pfund-0.0.1/pfund/validations/backtest.py +39 -0
- pfund-0.0.1/pfund/zeromq.py +101 -0
- pfund-0.0.1/pyproject.toml +88 -0
pfund-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [2024] [Stephen Yau, PFund.ai]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
pfund-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pfund
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A Complete Algo-Trading Framework for Machine Learning, enabling trading across TradFi, CeFi and DeFi. Supports Vectorized and Event-Driven Backtesting, Paper and Live Trading
|
|
5
|
+
Home-page: https://pfund.ai
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Keywords: trading,algo-trading,stocks,cryptos,cryptocurrencies,TradFi,CeFi,DeFi,portfolio management,investment,backtesting,machine learning
|
|
8
|
+
Author: Stephen Yau
|
|
9
|
+
Author-email: softwareentrepreneer+pfund@gmail.com
|
|
10
|
+
Requires-Python: >=3.10,<3.13
|
|
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: analytics
|
|
18
|
+
Provides-Extra: boost
|
|
19
|
+
Provides-Extra: data
|
|
20
|
+
Provides-Extra: fe
|
|
21
|
+
Provides-Extra: ml
|
|
22
|
+
Requires-Dist: click (>=8.1.7,<9.0.0)
|
|
23
|
+
Requires-Dist: feast (>=0.40.1,<0.41.0) ; extra == "fe" or extra == "all"
|
|
24
|
+
Requires-Dist: gitpython (>=3.1.43,<4.0.0)
|
|
25
|
+
Requires-Dist: ipython (>=8.27.0,<9.0.0)
|
|
26
|
+
Requires-Dist: mlflow (>=2.16.1,<3.0.0) ; extra == "ml" or extra == "all"
|
|
27
|
+
Requires-Dist: numba (>=0.60.0,<0.61.0) ; extra == "boost" or extra == "all"
|
|
28
|
+
Requires-Dist: orjson (>=3.10.7,<4.0.0) ; extra == "data" or extra == "all"
|
|
29
|
+
Requires-Dist: papermill (>=2.6.0,<3.0.0) ; extra == "analytics" or extra == "all"
|
|
30
|
+
Requires-Dist: pfeed[all] (>=0.0.2.dev1,<0.0.3) ; extra == "data" or extra == "all"
|
|
31
|
+
Requires-Dist: pfolio (>=0.0.1.dev4,<0.0.2) ; extra == "analytics" or extra == "all"
|
|
32
|
+
Requires-Dist: platformdirs (>=4.3.3,<5.0.0)
|
|
33
|
+
Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
|
|
34
|
+
Requires-Dist: python-telegram-bot (>=21.5,<22.0)
|
|
35
|
+
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
|
36
|
+
Requires-Dist: pyzmq (>=26.2.0,<27.0.0) ; extra == "data" or extra == "all"
|
|
37
|
+
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
38
|
+
Requires-Dist: rich (>=13.8.1,<14.0.0)
|
|
39
|
+
Requires-Dist: schedule (>=1.2.2,<2.0.0)
|
|
40
|
+
Requires-Dist: scikit-learn (>=1.5.2,<2.0.0) ; extra == "ml" or extra == "all"
|
|
41
|
+
Requires-Dist: ta (>=0.11.0,<0.12.0) ; extra == "fe" or extra == "all"
|
|
42
|
+
Requires-Dist: torch (>=2.4.1,<3.0.0) ; extra == "ml" or extra == "all"
|
|
43
|
+
Requires-Dist: tqdm (>=4.66.5,<5.0.0)
|
|
44
|
+
Requires-Dist: tsfresh (>=0.20.3,<0.21.0) ; extra == "fe" or extra == "all"
|
|
45
|
+
Requires-Dist: voila (>=0.5.7,<0.6.0) ; extra == "analytics" or extra == "all"
|
|
46
|
+
Requires-Dist: websocket-client (>=1.8.0,<2.0.0)
|
|
47
|
+
Project-URL: Documentation, https://pfund-docs.pfund.ai
|
|
48
|
+
Project-URL: Repository, https://github.com/PFund-Software-Ltd/pfund
|
|
49
|
+
Description-Content-Type: text/markdown
|
|
50
|
+
|
|
51
|
+
# PFund: A Complete Algo-Trading Framework powered by Machine Learning and Data Engineering, TradFi, CeFi and DeFi ready.
|
|
52
|
+
|
|
53
|
+

|
|
54
|
+

|
|
55
|
+
[](https://pypi.org/project/pfund)
|
|
56
|
+

|
|
57
|
+
[](https://jupyterbook.org)
|
|
59
|
+
[](https://marimo.io)
|
|
60
|
+
[](https://python-poetry.org/)
|
|
61
|
+
|
|
62
|
+
[TradFi]: https://www.techopedia.com/definition/traditional-finance-tradfi
|
|
63
|
+
[CeFi]: https://www.techopedia.com/definition/centralized-finance-cefi
|
|
64
|
+
[DeFi]: https://www.coinbase.com/learn/crypto-basics/what-is-defi
|
|
65
|
+
[pytrade.org]: https://pytrade.org
|
|
66
|
+
[dYdX]: https://dydx.exchange
|
|
67
|
+
[polars]: https://pola.rs/
|
|
68
|
+
[PFund.ai]: https://pfund.ai
|
|
69
|
+
[PFeed]: https://github.com/PFund-Software-Ltd/pfeed
|
|
70
|
+
[Bybit]: https://bybit.com/
|
|
71
|
+
[PyTorch]: https://pytorch.org/
|
|
72
|
+
[Poetry]: https://python-poetry.org
|
|
73
|
+
[Futu]: https://www.futunn.com
|
|
74
|
+
[FirstRate Data]: https://firstratedata.com
|
|
75
|
+
[Mantine UI]: https://ui.mantine.dev/
|
|
76
|
+
|
|
77
|
+
## Problem
|
|
78
|
+
Machine learning (**AI**) and data engineering (**Big Data**) fields are advancing every year, but everyday traders are **not able to enjoy the benefits** of these improvements, leading to a **widening gap** between retail traders and professional traders.
|
|
79
|
+
|
|
80
|
+
## Solution
|
|
81
|
+
A modern algo-trading framework is needed to **bridge the gap** between algo-trading, machine learning and data engineering, empowering retail traders with state-of-the-art machine learning models and data engineering tools so that traders only need to focus on strategy research and the framework takes care of the rest.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
PFund (/piː fʌnd/), which stands for "**Personal Fund**", is an **algo-trading framework** designed for using **machine learning** models natively to trade across [TradFi] (Traditional Finance, e.g. **Interactive Brokers**), [CeFi] (Centralized Finance, e.g. Binance) and [DeFi] (Decentralized Finance, e.g. [dYdX]), or in simple terms, **Stocks** and **Cryptos**.
|
|
85
|
+
|
|
86
|
+
## Core Features
|
|
87
|
+
- [x] Supports vectorized and event-driven backtesting with different resolutions of data, e.g. tick data, second data and minute data etc.
|
|
88
|
+
- [x] Allows choosing your preferred data tool, e.g. pandas, polars, pyspark etc.
|
|
89
|
+
- [x] Supports machine learning models, features, technical analysis indicators
|
|
90
|
+
- [x] Trains machine learning models using your favorite frameworks, i.e. PFund is **ML-framework agnostic**
|
|
91
|
+
- [x] Offers **LEGO-style** strategy and model building, allowing strategies to add other strategies, models to add other models
|
|
92
|
+
- [x] Streamlines the algo-trading flow, from vectorized backtesting for strategy prototyping and event-driven backtesting for strategy development, to live trading for strategy deployment
|
|
93
|
+
- [x] Enables parallel data processing, e.g. Interactive Brokers and Binance each have their own process for receiving data feeds
|
|
94
|
+
- [x] Switches from backtesting to live trading by just changing **ONE line of code!!**
|
|
95
|
+
- [ ] Features a modern frontend using [Mantine UI] and TradingView's Charts library
|
|
96
|
+
- [ ] Supports manual/semi-manual trading via a trading app
|
|
97
|
+
|
|
98
|
+
> As PFund is for trading only, for all the data workloads, there is a separate library to handle that:\
|
|
99
|
+
[PFeed] - Data pipeline for algo-trading, helping traders in getting real-time and historical data, and storing them in a local data lake for quantitative research.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
<details>
|
|
104
|
+
<summary>Table of Contents</summary>
|
|
105
|
+
|
|
106
|
+
- [Installation](#installation)
|
|
107
|
+
- [Quick Start](#quick-start)
|
|
108
|
+
- [Backtesting](#backtesting)
|
|
109
|
+
- [Live Trading](#live-trading)
|
|
110
|
+
- [Parameter Training / Hyperparameter Tuning](#parameter-training--hyperparameter-tuning)
|
|
111
|
+
- [Building LEGO-Style Strategy and Model](#building-lego-style-strategy-and-model)
|
|
112
|
+
- [PFund Hub](#pfund-hub)
|
|
113
|
+
- [Supported Trading Venues](#supported-trading-venues)
|
|
114
|
+
- [Related Projects](#related-projects)
|
|
115
|
+
- [Disclaimer](#disclaimer)
|
|
116
|
+
|
|
117
|
+
</details>
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
## Installation
|
|
121
|
+
|
|
122
|
+
### Using [Poetry] (Recommended)
|
|
123
|
+
```bash
|
|
124
|
+
# [RECOMMENDED]: Trading + Backtesting + Machine Learning + Feature Engineering (e.g. feast, tsfresh, ta) + Analytics
|
|
125
|
+
poetry add "pfund[all]"
|
|
126
|
+
|
|
127
|
+
# [Trading + Backtesting + Machine Learning + Feature Engineering]:
|
|
128
|
+
poetry add "pfund[data,ml,fe]"
|
|
129
|
+
|
|
130
|
+
# [Trading + Backtesting + Machine Learning]:
|
|
131
|
+
poetry add "pfund[data,ml]"
|
|
132
|
+
|
|
133
|
+
# [Trading + Backtesting]:
|
|
134
|
+
poetry add "pfund[data]"
|
|
135
|
+
|
|
136
|
+
# [Trading only]:
|
|
137
|
+
poetry add pfund
|
|
138
|
+
|
|
139
|
+
# update to the latest version:
|
|
140
|
+
poetry update pfund
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Using Pip
|
|
144
|
+
```bash
|
|
145
|
+
# same as above, you can choose to install "pfund[all]", "pfund[data,ml,fe]", "pfund[data,ml]", "pfund[data]" or "pfund"
|
|
146
|
+
pip install "pfund[all]"
|
|
147
|
+
|
|
148
|
+
# install the latest version:
|
|
149
|
+
pip install -U pfund
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Checking your installation
|
|
153
|
+
```bash
|
|
154
|
+
$ pfund --version
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
## Quick Start
|
|
159
|
+
### Backtesting
|
|
160
|
+
```python
|
|
161
|
+
import pfund as pf
|
|
162
|
+
|
|
163
|
+
# NOTE: for more exciting strategies, please visit pfund.ai
|
|
164
|
+
class YourStrategy(pf.Strategy):
|
|
165
|
+
# triggered by bar/kline data (e.g. 1-minute data)
|
|
166
|
+
def on_bar(self):
|
|
167
|
+
# write your trading logic here
|
|
168
|
+
pass
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
engine = pf.BacktestEngine(mode='vectorized')
|
|
172
|
+
strategy = engine.add_strategy(YourStrategy(), name='your_strategy')
|
|
173
|
+
strategy.add_data(
|
|
174
|
+
'IB', 'AAPL', 'USD', 'STK', resolutions=['1d'],
|
|
175
|
+
backtest={
|
|
176
|
+
# NOTE: since IB does not provide any historical data for backtesting purpose, use data from 'YAHOO_FINANCE'
|
|
177
|
+
'data_source': 'YAHOO_FINANCE',
|
|
178
|
+
'start_date': '2024-01-01',
|
|
179
|
+
'end_date': '2024-02-01',
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
engine.run()
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
### Live Trading
|
|
187
|
+
> Just change one line of code, from '**BacktestEngine**' to '**TradeEngine**'. BOOM! you can now start live trading.
|
|
188
|
+
```python
|
|
189
|
+
import pfund as pf
|
|
190
|
+
|
|
191
|
+
engine = pf.TradeEngine(env='LIVE')
|
|
192
|
+
strategy = engine.add_strategy(YourStrategy(), name='your_strategy')
|
|
193
|
+
strategy.add_data(
|
|
194
|
+
'IB', 'AAPL', 'USD', 'STK', resolutions=['1d'],
|
|
195
|
+
# for convenience, you can keep the kwarg `backtest`, `TradeEngine` will ignore it
|
|
196
|
+
backtest={
|
|
197
|
+
# NOTE: since IB does not provide any historical data for backtesting purpose, use data from 'YAHOO_FINANCE'
|
|
198
|
+
'data_source': 'YAHOO_FINANCE',
|
|
199
|
+
'start_date': '2024-01-01',
|
|
200
|
+
'end_date': '2024-02-01',
|
|
201
|
+
}
|
|
202
|
+
)
|
|
203
|
+
engine.run()
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Parameter Training / Hyperparameter Tuning
|
|
207
|
+
> The correct term should be "Hyperparameter Tuning", but since not all traders are familiar with machine learning, the framework uses a more well-known term "training".
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
import pfund as pf
|
|
211
|
+
|
|
212
|
+
engine = pf.TrainEngine()
|
|
213
|
+
strategy = engine.add_strategy(...)
|
|
214
|
+
strategy.add_data(...)
|
|
215
|
+
strategy.add_indicator(...)
|
|
216
|
+
engine.run()
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Building LEGO-Style Strategy and Model
|
|
220
|
+
```python
|
|
221
|
+
import pfund as pf
|
|
222
|
+
|
|
223
|
+
engine = pf.TradeEngine(env='LIVE')
|
|
224
|
+
strategy = engine.add_strategy(...)
|
|
225
|
+
strategy.add_data(...)
|
|
226
|
+
model = strategy.add_model(...)
|
|
227
|
+
|
|
228
|
+
model.add_data(...) # using different data than strategy's
|
|
229
|
+
sub_model = model.add_model(...) # YES, model can add another model to its use
|
|
230
|
+
# You can keep going:
|
|
231
|
+
# sub_sub_model = sub_model.add_model(...)
|
|
232
|
+
|
|
233
|
+
engine.run()
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
## PFund Hub
|
|
238
|
+
Imagine a space where algo-traders can share their trading strategies and machine learning models with one another.
|
|
239
|
+
Strategy and model development could be so much faster since you can build on top of an existing working model.
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Supported Trading Venues
|
|
245
|
+
| Trading Venue | Vectorized Backtesting | Event-Driven Backtesting | Paper Trading | Live Trading |
|
|
246
|
+
| ------------------------- | ---------------------- | ------------------------ | ------------- | ------------ |
|
|
247
|
+
| Bybit | 🟢 | 🟡 | 🟡 | 🟡 |
|
|
248
|
+
| *Interactive Brokers (IB) | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
249
|
+
| Binance | 🔴 | 🔴 | 🔴 | 🔴 |
|
|
250
|
+
| OKX | 🔴 | 🔴 | 🔴 | 🔴 |
|
|
251
|
+
| *Alpaca | 🔴 | 🔴 | 🔴 | 🔴 |
|
|
252
|
+
| *[Futu] | 🔴 | 🔴 | 🔴 | 🔴 |
|
|
253
|
+
| dYdX | 🔴 | 🔴 | 🔴 | 🔴 |
|
|
254
|
+
|
|
255
|
+
🟢 = finished \
|
|
256
|
+
🟡 = in progress \
|
|
257
|
+
🔴 = todo \
|
|
258
|
+
\* = use a **_separate data source_** (e.g. [FirstRate Data]) for backtesting
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
## Related Projects
|
|
262
|
+
- [PFeed] — Data pipeline for algo-trading, helping traders in getting real-time and historical data, and storing them in a local data lake for quantitative research.
|
|
263
|
+
- [PyTrade.org] - A curated list of Python libraries and resources for algorithmic trading.
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
## Disclaimer
|
|
267
|
+
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.
|
|
268
|
+
|
|
269
|
+
This algo-trading 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.
|
|
270
|
+
|
|
271
|
+
The developers of this framework are not responsible for any financial losses incurred from using this software. Users should conduct their due diligence and consult with a professional financial advisor before engaging in real trading activities.
|