pfund 0.0.2.dev2__tar.gz → 0.0.4__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.2.dev2 → pfund-0.0.4}/PKG-INFO +60 -72
- {pfund-0.0.2.dev2 → pfund-0.0.4}/README.md +23 -25
- pfund-0.0.4/pyproject.toml +88 -0
- pfund-0.0.4/src/pfund/CONTRIBUTING.md +77 -0
- pfund-0.0.4/src/pfund/__init__.py +192 -0
- pfund-0.0.4/src/pfund/__main__.py +9 -0
- pfund-0.0.4/src/pfund/_backtest/backtest_mixin.py +202 -0
- pfund-0.0.4/src/pfund/_backtest/narwhals_mixin.py +200 -0
- pfund-0.0.4/src/pfund/_backtest/numba_kernel.py +581 -0
- pfund-0.0.4/src/pfund/_backtest/pandas.py +707 -0
- pfund-0.0.4/src/pfund/_backtest/polars.py +820 -0
- pfund-0.0.4/src/pfund/_backtest/portfolio.py +118 -0
- pfund-0.0.4/src/pfund/_backtest/typing.py +13 -0
- pfund-0.0.4/src/pfund/brokers/__init__.py +25 -0
- pfund-0.0.4/src/pfund/brokers/broker_base.py +185 -0
- pfund-0.0.4/src/pfund/brokers/broker_defi.py +8 -0
- pfund-0.0.4/src/pfund/brokers/broker_simulated.py +155 -0
- pfund-0.0.4/src/pfund/brokers/crypto/broker.py +411 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/__init__.py +1 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/binance/exchange.py +30 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/binance/rest_api.py +46 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/binance/rest_api_inverse.py +12 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/binance/rest_api_linear.py +12 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/binance/rest_api_option.py +13 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/binance/rest_api_spot.py +20 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/binance/ws_api.py +40 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/binance/ws_api_inverse.py +12 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/binance/ws_api_linear.py +24 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/binance/ws_api_option.py +10 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/binance/ws_api_spot.py +32 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/bybit/adapter.yml +80 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/bybit/exchange.py +438 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/bybit/rest_api.py +184 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/bybit/ws_api.py +146 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/bybit/ws_api_bybit.py +437 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/bybit/ws_api_inverse.py +28 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/bybit/ws_api_linear.py +28 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/bybit/ws_api_option.py +30 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/bybit/ws_api_spot.py +30 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/exchange_base.py +527 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/okx/exchange.py +42 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/rest_api_base.py +234 -0
- pfund-0.0.4/src/pfund/brokers/crypto/exchanges/ws_api_base.py +570 -0
- pfund-0.0.4/src/pfund/brokers/ibkr/adapter.yml +32 -0
- pfund-0.0.4/src/pfund/brokers/ibkr/api.py +261 -0
- pfund-0.0.4/src/pfund/brokers/ibkr/broker.py +277 -0
- pfund-0.0.4/src/pfund/brokers/ibkr/client.py +170 -0
- pfund-0.0.4/src/pfund/brokers/ibkr/wrapper.py +365 -0
- pfund-0.0.4/src/pfund/brokers/managers/order_manager.py +309 -0
- pfund-0.0.4/src/pfund/brokers/managers/portfolio_manager.py +128 -0
- {pfund-0.0.2.dev2 → pfund-0.0.4/src}/pfund/cli/__init__.py +1 -2
- pfund-0.0.4/src/pfund/cli/commands/settings.py +70 -0
- pfund-0.0.4/src/pfund/cli/main.py +20 -0
- pfund-0.0.4/src/pfund/components/__init__.py +11 -0
- pfund-0.0.4/src/pfund/components/actor_proxy.py +107 -0
- pfund-0.0.4/src/pfund/components/features/feature_base.py +52 -0
- pfund-0.0.4/src/pfund/components/indicators/indicator_base.py +59 -0
- {pfund-0.0.2.dev2/pfund → pfund-0.0.4/src/pfund/components}/indicators/ta_indicator.py +42 -39
- {pfund-0.0.2.dev2/pfund → pfund-0.0.4/src/pfund/components}/indicators/talib_indicator.py +37 -30
- pfund-0.0.4/src/pfund/components/mixin.py +1117 -0
- pfund-0.0.4/src/pfund/components/models/jax_model.py +84 -0
- pfund-0.0.4/src/pfund/components/models/model_backtest.py +33 -0
- pfund-0.0.4/src/pfund/components/models/model_base.py +220 -0
- pfund-0.0.4/src/pfund/components/models/model_meta.py +141 -0
- pfund-0.0.4/src/pfund/components/models/pytorch_model.py +79 -0
- pfund-0.0.4/src/pfund/components/models/sklearn_model.py +19 -0
- pfund-0.0.4/src/pfund/components/strategies/_dummy_strategy.py +21 -0
- pfund-0.0.4/src/pfund/components/strategies/allocation_strategy.py +26 -0
- pfund-0.0.4/src/pfund/components/strategies/diversification_strategy.py +36 -0
- pfund-0.0.4/src/pfund/components/strategies/execution_strategy.py +6 -0
- pfund-0.0.4/src/pfund/components/strategies/hedging_strategy.py +26 -0
- pfund-0.0.4/src/pfund/components/strategies/optimization_strategy.py +36 -0
- {pfund-0.0.2.dev2/pfund → pfund-0.0.4/src/pfund/components}/strategies/portfolio_strategy.py +40 -38
- pfund-0.0.4/src/pfund/components/strategies/rebalancing_strategy.py +26 -0
- pfund-0.0.4/src/pfund/components/strategies/strategy_backtest.py +117 -0
- pfund-0.0.4/src/pfund/components/strategies/strategy_base.py +334 -0
- pfund-0.0.4/src/pfund/components/strategies/strategy_meta.py +36 -0
- pfund-0.0.4/src/pfund/config.py +144 -0
- pfund-0.0.4/src/pfund/datas/__init__.py +5 -0
- pfund-0.0.4/src/pfund/datas/data_bar.py +332 -0
- pfund-0.0.4/src/pfund/datas/data_base.py +51 -0
- pfund-0.0.4/src/pfund/datas/data_config.py +298 -0
- pfund-0.0.4/src/pfund/datas/data_market.py +129 -0
- pfund-0.0.4/src/pfund/datas/data_quote.py +99 -0
- pfund-0.0.4/src/pfund/datas/data_tick.py +66 -0
- pfund-0.0.4/src/pfund/datas/data_time_based.py +43 -0
- pfund-0.0.4/src/pfund/datas/databoy.py +301 -0
- pfund-0.0.4/src/pfund/datas/orderbook.py +23 -0
- pfund-0.0.4/src/pfund/datas/resolution.py +258 -0
- pfund-0.0.4/src/pfund/datas/stores/base_data_store.py +127 -0
- pfund-0.0.4/src/pfund/datas/stores/market_data_store.py +404 -0
- pfund-0.0.4/src/pfund/datas/stores/trading_store.py +148 -0
- pfund-0.0.4/src/pfund/datas/timeframe.py +100 -0
- pfund-0.0.4/src/pfund/engines/backtest_engine.py +484 -0
- pfund-0.0.4/src/pfund/engines/base_engine.py +269 -0
- pfund-0.0.4/src/pfund/engines/engine_context.py +158 -0
- pfund-0.0.4/src/pfund/engines/sandbox_engine.py +30 -0
- pfund-0.0.4/src/pfund/engines/settings/backtest_engine_settings.py +45 -0
- pfund-0.0.4/src/pfund/engines/settings/base_engine_settings.py +54 -0
- pfund-0.0.4/src/pfund/engines/settings/sandbox_engine_settings.py +29 -0
- pfund-0.0.4/src/pfund/engines/settings/trade_engine_settings.py +67 -0
- pfund-0.0.4/src/pfund/engines/trade_engine.py +306 -0
- pfund-0.0.4/src/pfund/entities/accounts/account_base.py +50 -0
- pfund-0.0.4/src/pfund/entities/accounts/account_crypto.py +40 -0
- pfund-0.0.4/src/pfund/entities/accounts/account_ibkr.py +75 -0
- pfund-0.0.4/src/pfund/entities/balances/balance_base.py +37 -0
- pfund-0.0.4/src/pfund/entities/balances/balance_crypto.py +12 -0
- pfund-0.0.2.dev2/pfund/balances/balance_ib.py → pfund-0.0.4/src/pfund/entities/balances/balance_ibkr.py +7 -7
- pfund-0.0.4/src/pfund/entities/balances/balance_update.py +22 -0
- pfund-0.0.4/src/pfund/entities/orders/__init__.py +29 -0
- pfund-0.0.4/src/pfund/entities/orders/mixins/limit_order.py +2 -0
- pfund-0.0.4/src/pfund/entities/orders/mixins/market_order.py +2 -0
- pfund-0.0.4/src/pfund/entities/orders/mixins/stop_limit_order.py +6 -0
- pfund-0.0.4/src/pfund/entities/orders/mixins/stop_market_order.py +6 -0
- pfund-0.0.4/src/pfund/entities/orders/mixins/stop_order.py +2 -0
- pfund-0.0.4/src/pfund/entities/orders/order_base.py +358 -0
- pfund-0.0.4/src/pfund/entities/orders/order_bybit.py +6 -0
- pfund-0.0.4/src/pfund/entities/orders/order_crypto.py +14 -0
- pfund-0.0.4/src/pfund/entities/orders/order_ibkr.py +15 -0
- pfund-0.0.4/src/pfund/entities/portfolios/mixins/all_assets_mixin.py +32 -0
- pfund-0.0.4/src/pfund/entities/portfolios/mixins/cefi_assets_mixin.py +33 -0
- pfund-0.0.4/src/pfund/entities/portfolios/mixins/defi_assets_mixin.py +27 -0
- {pfund-0.0.2.dev2/pfund/mixins/assets → pfund-0.0.4/src/pfund/entities/portfolios/mixins}/tradfi_assets_mixin.py +16 -14
- pfund-0.0.4/src/pfund/entities/portfolios/portfolio.py +99 -0
- pfund-0.0.2.dev2/pfund/portfolios/base_portfolio.py → pfund-0.0.4/src/pfund/entities/portfolios/portfolio_base.py +52 -46
- pfund-0.0.4/src/pfund/entities/portfolios/portfolio_cefi.py +11 -0
- pfund-0.0.4/src/pfund/entities/portfolios/portfolio_defi.py +8 -0
- pfund-0.0.4/src/pfund/entities/portfolios/portfolio_tradfi.py +8 -0
- {pfund-0.0.2.dev2/pfund → pfund-0.0.4/src/pfund/entities}/positions/position_base.py +15 -12
- {pfund-0.0.2.dev2/pfund → pfund-0.0.4/src/pfund/entities}/positions/position_crypto.py +25 -13
- pfund-0.0.2.dev2/pfund/positions/position_ib.py → pfund-0.0.4/src/pfund/entities/positions/position_ibkr.py +18 -12
- pfund-0.0.4/src/pfund/entities/products/__init__.py +9 -0
- pfund-0.0.4/src/pfund/entities/products/asset_type.py +112 -0
- pfund-0.0.4/src/pfund/entities/products/mixins/crypto.py +12 -0
- pfund-0.0.4/src/pfund/entities/products/mixins/derivative.py +28 -0
- pfund-0.0.4/src/pfund/entities/products/mixins/etf.py +11 -0
- pfund-0.0.4/src/pfund/entities/products/mixins/forex.py +11 -0
- pfund-0.0.4/src/pfund/entities/products/mixins/future.py +34 -0
- pfund-0.0.4/src/pfund/entities/products/mixins/index.py +11 -0
- pfund-0.0.4/src/pfund/entities/products/mixins/inverse.py +11 -0
- pfund-0.0.4/src/pfund/entities/products/mixins/option.py +45 -0
- pfund-0.0.4/src/pfund/entities/products/mixins/perpetual.py +26 -0
- pfund-0.0.4/src/pfund/entities/products/mixins/stock.py +11 -0
- pfund-0.0.4/src/pfund/entities/products/product_base.py +197 -0
- pfund-0.0.4/src/pfund/entities/products/product_basis.py +69 -0
- pfund-0.0.4/src/pfund/entities/products/product_bybit.py +98 -0
- pfund-0.0.4/src/pfund/entities/products/product_crypto.py +60 -0
- pfund-0.0.4/src/pfund/entities/products/product_factory.py +46 -0
- pfund-0.0.4/src/pfund/entities/products/product_ibkr.py +79 -0
- pfund-0.0.4/src/pfund/entities/universes/universe.py +91 -0
- pfund-0.0.2.dev2/pfund/universes/base_universe.py → pfund-0.0.4/src/pfund/entities/universes/universe_base.py +30 -21
- pfund-0.0.4/src/pfund/entities/universes/universe_cefi.py +11 -0
- pfund-0.0.4/src/pfund/entities/universes/universe_defi.py +8 -0
- pfund-0.0.4/src/pfund/entities/universes/universe_tradfi.py +8 -0
- pfund-0.0.4/src/pfund/enums/__init__.py +69 -0
- pfund-0.0.4/src/pfund/enums/artifact_type.py +7 -0
- pfund-0.0.4/src/pfund/enums/asset_type.py +86 -0
- pfund-0.0.4/src/pfund/enums/backtest_mode.py +7 -0
- pfund-0.0.4/src/pfund/enums/broker.py +26 -0
- pfund-0.0.4/src/pfund/enums/component_type.py +20 -0
- pfund-0.0.4/src/pfund/enums/crypto_exchange.py +24 -0
- pfund-0.0.4/src/pfund/enums/data_channel.py +26 -0
- pfund-0.0.4/src/pfund/enums/database.py +7 -0
- pfund-0.0.4/src/pfund/enums/env.py +11 -0
- pfund-0.0.4/src/pfund/enums/month_code.py +25 -0
- pfund-0.0.4/src/pfund/enums/option_type.py +6 -0
- pfund-0.0.4/src/pfund/enums/order_side.py +6 -0
- pfund-0.0.4/src/pfund/enums/order_status.py +29 -0
- pfund-0.0.4/src/pfund/enums/order_type.py +12 -0
- pfund-0.0.4/src/pfund/enums/run_mode.py +7 -0
- pfund-0.0.4/src/pfund/enums/run_stage.py +7 -0
- pfund-0.0.4/src/pfund/enums/source_type.py +6 -0
- pfund-0.0.4/src/pfund/enums/time_in_force.py +8 -0
- pfund-0.0.4/src/pfund/enums/trading_venue.py +70 -0
- pfund-0.0.4/src/pfund/errors.py +8 -0
- pfund-0.0.4/src/pfund/logging.yml +65 -0
- pfund-0.0.4/src/pfund/typing.py +50 -0
- pfund-0.0.4/src/pfund/utils/adapter.py +94 -0
- pfund-0.0.4/src/pfund/utils/aliases.py +70 -0
- pfund-0.0.4/src/pfund/utils/dataset_splitter.py +145 -0
- pfund-0.0.4/src/pfund/utils/decorators.py +10 -0
- pfund-0.0.4/src/pfund/utils/parser.py +160 -0
- pfund-0.0.4/src/pfund/utils/ray_dict.py +186 -0
- pfund-0.0.4/src/pfund/utils/zmq_pub_handler.py +45 -0
- pfund-0.0.2.dev2/LICENSE +0 -201
- pfund-0.0.2.dev2/pfund/CONTRIBUTING.md +0 -22
- pfund-0.0.2.dev2/pfund/__init__.py +0 -32
- pfund-0.0.2.dev2/pfund/accounts/__init__.py +0 -3
- pfund-0.0.2.dev2/pfund/accounts/account_base.py +0 -35
- pfund-0.0.2.dev2/pfund/accounts/account_crypto.py +0 -33
- pfund-0.0.2.dev2/pfund/accounts/account_ib.py +0 -11
- pfund-0.0.2.dev2/pfund/adapter.py +0 -64
- pfund-0.0.2.dev2/pfund/analyzer.py +0 -217
- pfund-0.0.2.dev2/pfund/backtest_history.py +0 -210
- pfund-0.0.2.dev2/pfund/balances/__init__.py +0 -3
- pfund-0.0.2.dev2/pfund/balances/balance_base.py +0 -61
- pfund-0.0.2.dev2/pfund/balances/balance_crypto.py +0 -13
- pfund-0.0.2.dev2/pfund/brokers/__init__.py +0 -3
- pfund-0.0.2.dev2/pfund/brokers/broker_backtest.py +0 -86
- pfund-0.0.2.dev2/pfund/brokers/broker_base.py +0 -26
- pfund-0.0.2.dev2/pfund/brokers/broker_crypto.py +0 -297
- pfund-0.0.2.dev2/pfund/brokers/broker_defi.py +0 -8
- pfund-0.0.2.dev2/pfund/brokers/broker_live.py +0 -98
- pfund-0.0.2.dev2/pfund/brokers/ib/__init__.py +0 -1
- pfund-0.0.2.dev2/pfund/brokers/ib/broker_ib.py +0 -238
- pfund-0.0.2.dev2/pfund/brokers/ib/ib_api.py +0 -279
- pfund-0.0.2.dev2/pfund/brokers/ib/ib_client.py +0 -143
- pfund-0.0.2.dev2/pfund/brokers/ib/ib_wrapper.py +0 -210
- pfund-0.0.2.dev2/pfund/cli/commands/config.py +0 -66
- pfund-0.0.2.dev2/pfund/cli/commands/docker_compose.py +0 -27
- pfund-0.0.2.dev2/pfund/cli/main.py +0 -18
- pfund-0.0.2.dev2/pfund/config/binance/linear/config.yml +0 -7
- pfund-0.0.2.dev2/pfund/config/binance/linear/lot_sizes_linear.yml +0 -2
- pfund-0.0.2.dev2/pfund/config/binance/linear/pdt_matchings_linear.yml +0 -2
- pfund-0.0.2.dev2/pfund/config/binance/linear/tick_sizes_linear.yml +0 -2
- pfund-0.0.2.dev2/pfund/config/bybit/config.yml +0 -99
- pfund-0.0.2.dev2/pfund/config/bybit/lot_sizes_inverse.yml +0 -12
- pfund-0.0.2.dev2/pfund/config/bybit/lot_sizes_linear.yml +0 -291
- pfund-0.0.2.dev2/pfund/config/bybit/lot_sizes_option.yml +0 -500
- pfund-0.0.2.dev2/pfund/config/bybit/lot_sizes_spot.yml +0 -440
- pfund-0.0.2.dev2/pfund/config/bybit/pdt_matchings_inverse.yml +0 -8
- pfund-0.0.2.dev2/pfund/config/bybit/pdt_matchings_linear.yml +0 -277
- pfund-0.0.2.dev2/pfund/config/bybit/pdt_matchings_option.yml +0 -1
- pfund-0.0.2.dev2/pfund/config/bybit/pdt_matchings_spot.yml +0 -440
- pfund-0.0.2.dev2/pfund/config/bybit/tick_sizes_inverse.yml +0 -12
- pfund-0.0.2.dev2/pfund/config/bybit/tick_sizes_linear.yml +0 -291
- pfund-0.0.2.dev2/pfund/config/bybit/tick_sizes_option.yml +0 -500
- pfund-0.0.2.dev2/pfund/config/bybit/tick_sizes_spot.yml +0 -440
- pfund-0.0.2.dev2/pfund/config/configuration.py +0 -59
- pfund-0.0.2.dev2/pfund/config/ib/config.yml +0 -24
- pfund-0.0.2.dev2/pfund/config_handler.py +0 -184
- pfund-0.0.2.dev2/pfund/const/__init__.py +0 -2
- pfund-0.0.2.dev2/pfund/const/_zmq_routes.py +0 -90
- pfund-0.0.2.dev2/pfund/const/aliases.py +0 -103
- pfund-0.0.2.dev2/pfund/const/common.py +0 -26
- pfund-0.0.2.dev2/pfund/const/paths.py +0 -27
- pfund-0.0.2.dev2/pfund/data_tools/data_tool_base.py +0 -61
- pfund-0.0.2.dev2/pfund/data_tools/data_tool_pandas.py +0 -748
- pfund-0.0.2.dev2/pfund/data_tools/data_tool_polars.py +0 -151
- pfund-0.0.2.dev2/pfund/datas/__init__.py +0 -4
- pfund-0.0.2.dev2/pfund/datas/data_bar.py +0 -194
- pfund-0.0.2.dev2/pfund/datas/data_base.py +0 -20
- pfund-0.0.2.dev2/pfund/datas/data_quote.py +0 -46
- pfund-0.0.2.dev2/pfund/datas/data_tick.py +0 -41
- pfund-0.0.2.dev2/pfund/datas/data_time_based.py +0 -61
- pfund-0.0.2.dev2/pfund/datas/resolution.py +0 -100
- pfund-0.0.2.dev2/pfund/datas/timeframe.py +0 -76
- pfund-0.0.2.dev2/pfund/engines/__init__.py +0 -4
- pfund-0.0.2.dev2/pfund/engines/backtest_engine.py +0 -419
- pfund-0.0.2.dev2/pfund/engines/base_engine.py +0 -135
- pfund-0.0.2.dev2/pfund/engines/sandbox_engine.py +0 -53
- pfund-0.0.2.dev2/pfund/engines/trade_engine.py +0 -228
- pfund-0.0.2.dev2/pfund/engines/train_engine.py +0 -52
- pfund-0.0.2.dev2/pfund/errors.py +0 -8
- pfund-0.0.2.dev2/pfund/exchanges/binance/__init__.py +0 -3
- pfund-0.0.2.dev2/pfund/exchanges/binance/exchange.py +0 -37
- pfund-0.0.2.dev2/pfund/exchanges/binance/linear/exchange.py +0 -7
- pfund-0.0.2.dev2/pfund/exchanges/binance/rest_api.py +0 -15
- pfund-0.0.2.dev2/pfund/exchanges/binance/ws_api.py +0 -33
- pfund-0.0.2.dev2/pfund/exchanges/bybit/__init__.py +0 -3
- pfund-0.0.2.dev2/pfund/exchanges/bybit/exchange.py +0 -422
- pfund-0.0.2.dev2/pfund/exchanges/bybit/rest_api.py +0 -127
- pfund-0.0.2.dev2/pfund/exchanges/bybit/rest_api_samples/get_markets_result_inverse +0 -286
- pfund-0.0.2.dev2/pfund/exchanges/bybit/rest_api_samples/get_markets_result_linear +0 -4856
- pfund-0.0.2.dev2/pfund/exchanges/bybit/rest_api_samples/get_markets_result_option +0 -6500
- pfund-0.0.2.dev2/pfund/exchanges/bybit/rest_api_samples/get_markets_result_spot +0 -2808
- pfund-0.0.2.dev2/pfund/exchanges/bybit/rest_api_samples/get_markets_return_inverse +0 -292
- pfund-0.0.2.dev2/pfund/exchanges/bybit/rest_api_samples/get_markets_return_linear +0 -4868
- pfund-0.0.2.dev2/pfund/exchanges/bybit/rest_api_samples/get_markets_return_option +0 -7506
- pfund-0.0.2.dev2/pfund/exchanges/bybit/rest_api_samples/get_markets_return_spot +0 -2813
- pfund-0.0.2.dev2/pfund/exchanges/bybit/ws_api.py +0 -425
- pfund-0.0.2.dev2/pfund/exchanges/exchange_base.py +0 -445
- pfund-0.0.2.dev2/pfund/exchanges/rest_api_base.py +0 -100
- pfund-0.0.2.dev2/pfund/exchanges/ws_api_base.py +0 -626
- pfund-0.0.2.dev2/pfund/externals/ibapi/__init__.py +0 -18
- pfund-0.0.2.dev2/pfund/externals/ibapi/account_summary_tags.py +0 -48
- pfund-0.0.2.dev2/pfund/externals/ibapi/client.py +0 -3749
- pfund-0.0.2.dev2/pfund/externals/ibapi/comm.py +0 -85
- pfund-0.0.2.dev2/pfund/externals/ibapi/commission_report.py +0 -21
- pfund-0.0.2.dev2/pfund/externals/ibapi/common.py +0 -243
- pfund-0.0.2.dev2/pfund/externals/ibapi/connection.py +0 -127
- pfund-0.0.2.dev2/pfund/externals/ibapi/contract.py +0 -219
- pfund-0.0.2.dev2/pfund/externals/ibapi/decoder.py +0 -1481
- pfund-0.0.2.dev2/pfund/externals/ibapi/enum_implem.py +0 -20
- pfund-0.0.2.dev2/pfund/externals/ibapi/errors.py +0 -41
- pfund-0.0.2.dev2/pfund/externals/ibapi/execution.py +0 -55
- pfund-0.0.2.dev2/pfund/externals/ibapi/ibapi.pyproj +0 -51
- pfund-0.0.2.dev2/pfund/externals/ibapi/message.py +0 -184
- pfund-0.0.2.dev2/pfund/externals/ibapi/news.py +0 -10
- pfund-0.0.2.dev2/pfund/externals/ibapi/object_implem.py +0 -12
- pfund-0.0.2.dev2/pfund/externals/ibapi/order.py +0 -246
- pfund-0.0.2.dev2/pfund/externals/ibapi/order_condition.py +0 -275
- pfund-0.0.2.dev2/pfund/externals/ibapi/order_state.py +0 -29
- pfund-0.0.2.dev2/pfund/externals/ibapi/orderdecoder.py +0 -457
- pfund-0.0.2.dev2/pfund/externals/ibapi/reader.py +0 -54
- pfund-0.0.2.dev2/pfund/externals/ibapi/scanner.py +0 -56
- pfund-0.0.2.dev2/pfund/externals/ibapi/server_versions.py +0 -134
- pfund-0.0.2.dev2/pfund/externals/ibapi/softdollartier.py +0 -17
- pfund-0.0.2.dev2/pfund/externals/ibapi/tag_value.py +0 -22
- pfund-0.0.2.dev2/pfund/externals/ibapi/ticktype.py +0 -119
- pfund-0.0.2.dev2/pfund/externals/ibapi/utils.py +0 -141
- pfund-0.0.2.dev2/pfund/externals/ibapi/wrapper.py +0 -734
- pfund-0.0.2.dev2/pfund/git_controller.py +0 -60
- pfund-0.0.2.dev2/pfund/indicators/__init__.py +0 -3
- pfund-0.0.2.dev2/pfund/indicators/indicator_base.py +0 -70
- pfund-0.0.2.dev2/pfund/investment_profile.py +0 -18
- pfund-0.0.2.dev2/pfund/main.py +0 -18
- pfund-0.0.2.dev2/pfund/managers/__init__.py +0 -7
- pfund-0.0.2.dev2/pfund/managers/base_manager.py +0 -28
- pfund-0.0.2.dev2/pfund/managers/connection_manager.py +0 -182
- pfund-0.0.2.dev2/pfund/managers/data_manager.py +0 -245
- pfund-0.0.2.dev2/pfund/managers/order_manager.py +0 -261
- pfund-0.0.2.dev2/pfund/managers/portfolio_manager.py +0 -99
- pfund-0.0.2.dev2/pfund/managers/risk_manager.py +0 -8
- pfund-0.0.2.dev2/pfund/managers/strategy_manager.py +0 -205
- pfund-0.0.2.dev2/pfund/mixins/assets/__init__.py +0 -4
- pfund-0.0.2.dev2/pfund/mixins/assets/all_assets_mixin.py +0 -25
- pfund-0.0.2.dev2/pfund/mixins/assets/crypto_assets_mixin.py +0 -29
- pfund-0.0.2.dev2/pfund/mixins/assets/defi_assets_mixin.py +0 -30
- pfund-0.0.2.dev2/pfund/mixins/backtest_mixin.py +0 -335
- pfund-0.0.2.dev2/pfund/mixins/trade_mixin.py +0 -427
- pfund-0.0.2.dev2/pfund/models/__init__.py +0 -11
- pfund-0.0.2.dev2/pfund/models/model_backtest.py +0 -85
- pfund-0.0.2.dev2/pfund/models/model_base.py +0 -335
- pfund-0.0.2.dev2/pfund/models/model_meta.py +0 -57
- pfund-0.0.2.dev2/pfund/models/pytorch_model.py +0 -79
- pfund-0.0.2.dev2/pfund/models/sklearn_model.py +0 -58
- pfund-0.0.2.dev2/pfund/orders/__init__.py +0 -2
- pfund-0.0.2.dev2/pfund/orders/order_base.py +0 -263
- pfund-0.0.2.dev2/pfund/orders/order_crypto.py +0 -55
- pfund-0.0.2.dev2/pfund/orders/order_ib.py +0 -8
- pfund-0.0.2.dev2/pfund/orders/order_statuses.py +0 -42
- pfund-0.0.2.dev2/pfund/orders/order_time_in_force.py +0 -8
- pfund-0.0.2.dev2/pfund/plogging/__init__.py +0 -80
- pfund-0.0.2.dev2/pfund/plogging/config.py +0 -76
- pfund-0.0.2.dev2/pfund/plogging/filters.py +0 -12
- pfund-0.0.2.dev2/pfund/plogging/formatter.py +0 -17
- pfund-0.0.2.dev2/pfund/plogging/handlers.py +0 -49
- pfund-0.0.2.dev2/pfund/portfolios/__init__.py +0 -5
- pfund-0.0.2.dev2/pfund/portfolios/crypto_portfolio.py +0 -8
- pfund-0.0.2.dev2/pfund/portfolios/defi_portfolio.py +0 -8
- pfund-0.0.2.dev2/pfund/portfolios/portfolio.py +0 -69
- pfund-0.0.2.dev2/pfund/portfolios/tradfi_portfolio.py +0 -8
- pfund-0.0.2.dev2/pfund/positions/__init__.py +0 -3
- pfund-0.0.2.dev2/pfund/products/__init__.py +0 -3
- pfund-0.0.2.dev2/pfund/products/product_base.py +0 -52
- pfund-0.0.2.dev2/pfund/products/product_crypto.py +0 -81
- pfund-0.0.2.dev2/pfund/products/product_ib.py +0 -66
- pfund-0.0.2.dev2/pfund/strategies/__init__.py +0 -1
- pfund-0.0.2.dev2/pfund/strategies/allocation_strategy.py +0 -17
- pfund-0.0.2.dev2/pfund/strategies/diversification_strategy.py +0 -20
- pfund-0.0.2.dev2/pfund/strategies/execution_strategy.py +0 -6
- pfund-0.0.2.dev2/pfund/strategies/hedging_strategy.py +0 -17
- pfund-0.0.2.dev2/pfund/strategies/optimization_strategy.py +0 -20
- pfund-0.0.2.dev2/pfund/strategies/rebalancing_strategy.py +0 -17
- pfund-0.0.2.dev2/pfund/strategies/strategy_backtest.py +0 -65
- pfund-0.0.2.dev2/pfund/strategies/strategy_base.py +0 -428
- pfund-0.0.2.dev2/pfund/strategies/strategy_meta.py +0 -33
- pfund-0.0.2.dev2/pfund/templates/dashboards/pfund-overview.streamlit.py +0 -0
- pfund-0.0.2.dev2/pfund/templates/notebooks/pfund-analytics.ipynb +0 -49
- pfund-0.0.2.dev2/pfund/templates/notebooks/pfund-overview.ipynb +0 -55
- pfund-0.0.2.dev2/pfund/types/backtest.py +0 -10
- pfund-0.0.2.dev2/pfund/types/bybit.py +0 -4
- pfund-0.0.2.dev2/pfund/types/common_literals.py +0 -27
- pfund-0.0.2.dev2/pfund/types/core.py +0 -14
- pfund-0.0.2.dev2/pfund/types/data_tool.py +0 -57
- pfund-0.0.2.dev2/pfund/universes/__init__.py +0 -5
- pfund-0.0.2.dev2/pfund/universes/crypto_universe.py +0 -8
- pfund-0.0.2.dev2/pfund/universes/defi_universe.py +0 -8
- pfund-0.0.2.dev2/pfund/universes/tradfi_universe.py +0 -8
- pfund-0.0.2.dev2/pfund/universes/universe.py +0 -74
- pfund-0.0.2.dev2/pfund/utils/envs.py +0 -29
- pfund-0.0.2.dev2/pfund/utils/utils.py +0 -185
- pfund-0.0.2.dev2/pfund/validations/backtest.py +0 -39
- pfund-0.0.2.dev2/pfund/zeromq.py +0 -101
- pfund-0.0.2.dev2/pyproject.toml +0 -97
- /pfund-0.0.2.dev2/pfund/cli/commands/__init__.py → /pfund-0.0.4/src/pfund/py.typed +0 -0
- {pfund-0.0.2.dev2/pfund/exchanges → pfund-0.0.4/src/pfund/utils}/__init__.py +0 -0
|
@@ -1,68 +1,60 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pfund
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4
|
|
4
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
5
|
Keywords: trading,algo-trading,stocks,cryptos,cryptocurrencies,TradFi,CeFi,DeFi,portfolio management,investment,backtesting,machine learning
|
|
8
6
|
Author: Stephen Yau
|
|
9
|
-
Author-email: softwareentrepreneer+pfund@gmail.com
|
|
10
|
-
|
|
11
|
-
Classifier:
|
|
12
|
-
Classifier:
|
|
13
|
-
Classifier:
|
|
7
|
+
Author-email: Stephen Yau <softwareentrepreneer+pfund@gmail.com>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
13
|
+
Classifier: Intended Audience :: Information Technology
|
|
14
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
17
|
+
Classifier: Typing :: Typed
|
|
14
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Requires-Dist:
|
|
23
|
-
Requires-Dist:
|
|
24
|
-
Requires-Dist:
|
|
25
|
-
Requires-Dist:
|
|
26
|
-
Requires-Dist:
|
|
27
|
-
Requires-Dist:
|
|
28
|
-
Requires-Dist:
|
|
29
|
-
Requires-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
Requires-Dist: requests (>=2.31.0,<3.0.0)
|
|
40
|
-
Requires-Dist: rich (>=13.7.1,<14.0.0)
|
|
41
|
-
Requires-Dist: schedule (>=1.2.2,<2.0.0)
|
|
42
|
-
Requires-Dist: scikit-learn (>=1.5.2,<2.0.0) ; extra == "ml" or extra == "all"
|
|
43
|
-
Requires-Dist: streamlit (>=1.39.0,<2.0.0) ; extra == "train" or extra == "all"
|
|
44
|
-
Requires-Dist: ta (>=0.11.0,<0.12.0) ; extra == "fe" or extra == "all"
|
|
45
|
-
Requires-Dist: torch (>=2.4.1,<3.0.0) ; extra == "ml" or extra == "all"
|
|
46
|
-
Requires-Dist: tqdm (>=4.66.2,<5.0.0)
|
|
47
|
-
Requires-Dist: trogon (>=0.6.0,<0.7.0)
|
|
48
|
-
Requires-Dist: tsfresh (>=0.20.3,<0.21.0) ; extra == "fe" or extra == "all"
|
|
49
|
-
Requires-Dist: voila (>=0.5.7,<0.6.0) ; extra == "stats" or extra == "all"
|
|
50
|
-
Requires-Dist: websocket-client (>=1.8.0,<2.0.0)
|
|
51
|
-
Project-URL: Documentation, https://pfund-docs.pfund.ai
|
|
52
|
-
Project-URL: Repository, https://github.com/PFund-Software-Ltd/pfund
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Requires-Dist: pfund-kit>=0.1.6
|
|
22
|
+
Requires-Dist: httpx>=0.28.1
|
|
23
|
+
Requires-Dist: websockets>=16.0 ; sys_platform != 'emscripten'
|
|
24
|
+
Requires-Dist: numba>=0.65.1 ; sys_platform != 'emscripten'
|
|
25
|
+
Requires-Dist: pfund-ibapi>=10.42.1 ; sys_platform != 'emscripten' and extra == 'ibkr'
|
|
26
|
+
Requires-Dist: jax>=0.10.0 ; sys_platform != 'emscripten' and extra == 'jax'
|
|
27
|
+
Requires-Dist: orbax-checkpoint>=0.11.39 ; sys_platform != 'emscripten' and extra == 'jax'
|
|
28
|
+
Requires-Dist: joblib>=1.5.3 ; extra == 'sklean'
|
|
29
|
+
Requires-Dist: scikit-learn>=1.8.0 ; extra == 'sklean'
|
|
30
|
+
Requires-Dist: ta-lib>=0.6.4 ; sys_platform != 'emscripten' and extra == 'ta-lib'
|
|
31
|
+
Requires-Dist: torch>=2.11.0 ; sys_platform != 'emscripten' and extra == 'torch'
|
|
32
|
+
Requires-Dist: safetensors>=0.7.0 ; sys_platform != 'emscripten' and extra == 'torch'
|
|
33
|
+
Requires-Python: >=3.11
|
|
34
|
+
Project-URL: homepage, https://pfund.ai
|
|
35
|
+
Project-URL: repository, https://github.com/PFund-Software-Ltd/pfund
|
|
36
|
+
Project-URL: documentation, https://pfund-docs.pfund.ai
|
|
37
|
+
Provides-Extra: core
|
|
38
|
+
Provides-Extra: ibkr
|
|
39
|
+
Provides-Extra: jax
|
|
40
|
+
Provides-Extra: sklean
|
|
41
|
+
Provides-Extra: ta-lib
|
|
42
|
+
Provides-Extra: torch
|
|
53
43
|
Description-Content-Type: text/markdown
|
|
54
44
|
|
|
55
45
|
# PFund: A Complete Algo-Trading Framework powered by Machine Learning and Data Engineering, TradFi, CeFi and DeFi ready.
|
|
56
46
|
|
|
57
47
|
[](https://x.com/pfund_ai)
|
|
58
|
-
](https://pepy.tech/project/pfund)
|
|
49
|
+
[](https://pypi.org/project/pfund)
|
|
50
|
+

|
|
51
|
+
[](https://afterpython.org)
|
|
52
|
+
[](https://deepwiki.com/PFund-Software-Ltd/pfund)
|
|
53
|
+
[](https://codewiki.google/github.com/pfund-software-ltd/pfund?utm_source=badge&utm_medium=github&utm_campaign=github.com/pfund-software-ltd/pfund)
|
|
54
|
+
[](https://github.com/PFund-Software-Ltd/pfund/discussions)
|
|
55
|
+
<!--  -->
|
|
56
|
+
<!--  -->
|
|
57
|
+
<!-- [](https://marimo.io) -->
|
|
66
58
|
|
|
67
59
|
[TradFi]: https://www.techopedia.com/definition/traditional-finance-tradfi
|
|
68
60
|
[CeFi]: https://www.techopedia.com/definition/centralized-finance-cefi
|
|
@@ -75,9 +67,11 @@ Description-Content-Type: text/markdown
|
|
|
75
67
|
[Bybit]: https://bybit.com/
|
|
76
68
|
[PyTorch]: https://pytorch.org/
|
|
77
69
|
[Poetry]: https://python-poetry.org
|
|
70
|
+
[uv]: https://docs.astral.sh/uv/
|
|
78
71
|
[Futu]: https://www.futunn.com
|
|
79
72
|
[FirstRate Data]: https://firstratedata.com
|
|
80
|
-
|
|
73
|
+
|
|
74
|
+
> **This library is NOT ready for use, please wait for 0.1.0 release.**
|
|
81
75
|
|
|
82
76
|
## Problem
|
|
83
77
|
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.
|
|
@@ -97,8 +91,6 @@ PFund (/piː fʌnd/), which stands for "**Personal Fund**", is an **algo-trading
|
|
|
97
91
|
- [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
|
|
98
92
|
- [x] Enables parallel data processing, e.g. Interactive Brokers and Binance each have their own process for receiving data feeds
|
|
99
93
|
- [x] Switches from backtesting to live trading by just changing **ONE line of code!!**
|
|
100
|
-
- [ ] Features a modern frontend using [Mantine UI] and TradingView's Charts library
|
|
101
|
-
- [ ] Supports manual/semi-manual trading via a trading app
|
|
102
94
|
|
|
103
95
|
> As PFund is for trading only, for all the data workloads, there is a separate library to handle that:\
|
|
104
96
|
[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.
|
|
@@ -124,25 +116,21 @@ PFund (/piː fʌnd/), which stands for "**Personal Fund**", is an **algo-trading
|
|
|
124
116
|
|
|
125
117
|
## Installation
|
|
126
118
|
|
|
127
|
-
### Using [
|
|
119
|
+
### Using [uv] (Recommended)
|
|
128
120
|
```bash
|
|
129
|
-
|
|
130
|
-
poetry add "pfund[all]"
|
|
131
|
-
|
|
132
|
-
# [Trading + Backtesting + Machine Learning + Feature Engineering]:
|
|
133
|
-
poetry add "pfund[data,ml,fe]"
|
|
121
|
+
uv add pfund
|
|
134
122
|
|
|
135
|
-
#
|
|
136
|
-
|
|
123
|
+
# pick your data sources, e.g. yfinance for Yahoo Finance
|
|
124
|
+
uv add pfeed[yfinance]
|
|
137
125
|
|
|
138
|
-
# [
|
|
139
|
-
|
|
126
|
+
# [optional] install pfund-plot for plotting, pick your notebook, e.g. marimo notebook and/or jupyter notebook
|
|
127
|
+
uv add pfund-plot[marimo,jupyter]
|
|
140
128
|
|
|
141
|
-
# [
|
|
142
|
-
|
|
129
|
+
# [optional] install mtflow for handling trading ops, e.g. adding monitors, running dashboards, etc.
|
|
130
|
+
uv add mtflow
|
|
143
131
|
|
|
144
132
|
# update to the latest version:
|
|
145
|
-
|
|
133
|
+
uv update pfund
|
|
146
134
|
```
|
|
147
135
|
|
|
148
136
|
### Using Pip
|
|
@@ -264,7 +252,7 @@ Strategy and model development could be so much faster since you can build on to
|
|
|
264
252
|
|
|
265
253
|
|
|
266
254
|
## Related Projects
|
|
267
|
-
- [PFeed] — Data
|
|
255
|
+
- [PFeed] — Data engine for algo-trading, helping traders in getting real-time and historical data, and storing them in a local data lake for quantitative research.
|
|
268
256
|
- [PyTrade.org] - A curated list of Python libraries and resources for algorithmic trading.
|
|
269
257
|
|
|
270
258
|
|
|
@@ -273,4 +261,4 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
273
261
|
|
|
274
262
|
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.
|
|
275
263
|
|
|
276
|
-
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.
|
|
264
|
+
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.
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# PFund: A Complete Algo-Trading Framework powered by Machine Learning and Data Engineering, TradFi, CeFi and DeFi ready.
|
|
2
2
|
|
|
3
3
|
[](https://x.com/pfund_ai)
|
|
4
|
-
](https://pepy.tech/project/pfund)
|
|
5
|
+
[](https://pypi.org/project/pfund)
|
|
6
|
+

|
|
7
|
+
[](https://afterpython.org)
|
|
8
|
+
[](https://deepwiki.com/PFund-Software-Ltd/pfund)
|
|
9
|
+
[](https://codewiki.google/github.com/pfund-software-ltd/pfund?utm_source=badge&utm_medium=github&utm_campaign=github.com/pfund-software-ltd/pfund)
|
|
10
|
+
[](https://github.com/PFund-Software-Ltd/pfund/discussions)
|
|
11
|
+
<!--  -->
|
|
12
|
+
<!--  -->
|
|
13
|
+
<!-- [](https://marimo.io) -->
|
|
12
14
|
|
|
13
15
|
[TradFi]: https://www.techopedia.com/definition/traditional-finance-tradfi
|
|
14
16
|
[CeFi]: https://www.techopedia.com/definition/centralized-finance-cefi
|
|
@@ -21,9 +23,11 @@
|
|
|
21
23
|
[Bybit]: https://bybit.com/
|
|
22
24
|
[PyTorch]: https://pytorch.org/
|
|
23
25
|
[Poetry]: https://python-poetry.org
|
|
26
|
+
[uv]: https://docs.astral.sh/uv/
|
|
24
27
|
[Futu]: https://www.futunn.com
|
|
25
28
|
[FirstRate Data]: https://firstratedata.com
|
|
26
|
-
|
|
29
|
+
|
|
30
|
+
> **This library is NOT ready for use, please wait for 0.1.0 release.**
|
|
27
31
|
|
|
28
32
|
## Problem
|
|
29
33
|
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.
|
|
@@ -43,8 +47,6 @@ PFund (/piː fʌnd/), which stands for "**Personal Fund**", is an **algo-trading
|
|
|
43
47
|
- [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
|
|
44
48
|
- [x] Enables parallel data processing, e.g. Interactive Brokers and Binance each have their own process for receiving data feeds
|
|
45
49
|
- [x] Switches from backtesting to live trading by just changing **ONE line of code!!**
|
|
46
|
-
- [ ] Features a modern frontend using [Mantine UI] and TradingView's Charts library
|
|
47
|
-
- [ ] Supports manual/semi-manual trading via a trading app
|
|
48
50
|
|
|
49
51
|
> As PFund is for trading only, for all the data workloads, there is a separate library to handle that:\
|
|
50
52
|
[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.
|
|
@@ -70,25 +72,21 @@ PFund (/piː fʌnd/), which stands for "**Personal Fund**", is an **algo-trading
|
|
|
70
72
|
|
|
71
73
|
## Installation
|
|
72
74
|
|
|
73
|
-
### Using [
|
|
75
|
+
### Using [uv] (Recommended)
|
|
74
76
|
```bash
|
|
75
|
-
|
|
76
|
-
poetry add "pfund[all]"
|
|
77
|
-
|
|
78
|
-
# [Trading + Backtesting + Machine Learning + Feature Engineering]:
|
|
79
|
-
poetry add "pfund[data,ml,fe]"
|
|
77
|
+
uv add pfund
|
|
80
78
|
|
|
81
|
-
#
|
|
82
|
-
|
|
79
|
+
# pick your data sources, e.g. yfinance for Yahoo Finance
|
|
80
|
+
uv add pfeed[yfinance]
|
|
83
81
|
|
|
84
|
-
# [
|
|
85
|
-
|
|
82
|
+
# [optional] install pfund-plot for plotting, pick your notebook, e.g. marimo notebook and/or jupyter notebook
|
|
83
|
+
uv add pfund-plot[marimo,jupyter]
|
|
86
84
|
|
|
87
|
-
# [
|
|
88
|
-
|
|
85
|
+
# [optional] install mtflow for handling trading ops, e.g. adding monitors, running dashboards, etc.
|
|
86
|
+
uv add mtflow
|
|
89
87
|
|
|
90
88
|
# update to the latest version:
|
|
91
|
-
|
|
89
|
+
uv update pfund
|
|
92
90
|
```
|
|
93
91
|
|
|
94
92
|
### Using Pip
|
|
@@ -210,7 +208,7 @@ Strategy and model development could be so much faster since you can build on to
|
|
|
210
208
|
|
|
211
209
|
|
|
212
210
|
## Related Projects
|
|
213
|
-
- [PFeed] — Data
|
|
211
|
+
- [PFeed] — Data engine for algo-trading, helping traders in getting real-time and historical data, and storing them in a local data lake for quantitative research.
|
|
214
212
|
- [PyTrade.org] - A curated list of Python libraries and resources for algorithmic trading.
|
|
215
213
|
|
|
216
214
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pfund"
|
|
3
|
+
version = "0.0.4"
|
|
4
|
+
description = "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
|
+
license = "Apache-2.0"
|
|
6
|
+
authors = [
|
|
7
|
+
{name = "Stephen Yau", email = "softwareentrepreneer+pfund@gmail.com"}
|
|
8
|
+
]
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
keywords = ["trading", "algo-trading", "stocks", "cryptos", "cryptocurrencies", "TradFi", "CeFi", "DeFi", "portfolio management", "investment", "backtesting", "machine learning"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Operating System :: OS Independent",
|
|
13
|
+
"Intended Audience :: Developers",
|
|
14
|
+
"Intended Audience :: Science/Research",
|
|
15
|
+
"Intended Audience :: Financial and Insurance Industry",
|
|
16
|
+
"Intended Audience :: Information Technology",
|
|
17
|
+
"Topic :: Office/Business :: Financial :: Investment",
|
|
18
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
19
|
+
"Topic :: Software Development :: Libraries :: Application Frameworks",
|
|
20
|
+
"Typing :: Typed",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
]
|
|
25
|
+
requires-python = ">=3.11"
|
|
26
|
+
dependencies = [
|
|
27
|
+
"pfund-kit>=0.1.6",
|
|
28
|
+
# TODO: enable when ready
|
|
29
|
+
# 'pfeed[duckdb]>=0.0.5',
|
|
30
|
+
"httpx>=0.28.1",
|
|
31
|
+
"websockets>=16.0 ; sys_platform != 'emscripten'",
|
|
32
|
+
"numba>=0.65.1 ; sys_platform != 'emscripten'",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
core = [
|
|
37
|
+
# TODO: enable when ready
|
|
38
|
+
# 'pfolio>=0.0.3',
|
|
39
|
+
# 'pfund-plot[marimo]>=0.0.1.dev3',
|
|
40
|
+
# 'mtflow>=0.0.1.dev2 ; sys_platform != "emscripten"',
|
|
41
|
+
]
|
|
42
|
+
ibkr = ["pfund-ibapi>=10.42.1 ; sys_platform != 'emscripten'"]
|
|
43
|
+
ta-lib = ["ta-lib>=0.6.4 ; sys_platform != 'emscripten'"]
|
|
44
|
+
sklean = ["joblib>=1.5.3", "scikit-learn>=1.8.0"]
|
|
45
|
+
torch = ["torch>=2.11.0 ; sys_platform != 'emscripten'", "safetensors>=0.7.0 ; sys_platform != 'emscripten'"]
|
|
46
|
+
jax = ["jax>=0.10.0 ; sys_platform != 'emscripten'", "orbax-checkpoint>=0.11.39 ; sys_platform != 'emscripten'"]
|
|
47
|
+
|
|
48
|
+
[project.scripts]
|
|
49
|
+
pfund = "pfund.__main__:run_cli"
|
|
50
|
+
|
|
51
|
+
[project.entry-points."pfund_shell.commands"]
|
|
52
|
+
pfund = "pfund.cli:pfund_group"
|
|
53
|
+
|
|
54
|
+
[project.urls]
|
|
55
|
+
homepage = "https://pfund.ai"
|
|
56
|
+
repository = "https://github.com/PFund-Software-Ltd/pfund"
|
|
57
|
+
documentation = "https://pfund-docs.pfund.ai"
|
|
58
|
+
|
|
59
|
+
[build-system]
|
|
60
|
+
requires = ["uv_build>=0.11.14,<0.12.0"]
|
|
61
|
+
build-backend = "uv_build"
|
|
62
|
+
|
|
63
|
+
[tool.pyright]
|
|
64
|
+
# typeCheckingMode = "basic"
|
|
65
|
+
reportAny = false
|
|
66
|
+
reportExplicitAny = false
|
|
67
|
+
reportIncompatibleMethodOverride = false
|
|
68
|
+
reportUnreachable = false
|
|
69
|
+
reportRedeclaration = false
|
|
70
|
+
reportImportCycles = false
|
|
71
|
+
reportPrivateUsage = false
|
|
72
|
+
reportUnusedCallResult = false
|
|
73
|
+
reportImplicitOverride = false
|
|
74
|
+
reportMissingTypeStubs = false
|
|
75
|
+
reportUnannotatedClassAttribute = false
|
|
76
|
+
reportUnnecessaryIsInstance = false
|
|
77
|
+
|
|
78
|
+
[tool.uv.build-backend]
|
|
79
|
+
module-name = "pfund"
|
|
80
|
+
module-root = "src"
|
|
81
|
+
|
|
82
|
+
[tool.pytest.ini_options]
|
|
83
|
+
markers = [
|
|
84
|
+
"smoke: Run the most important tests",
|
|
85
|
+
]
|
|
86
|
+
addopts = [
|
|
87
|
+
"--strict-markers",
|
|
88
|
+
]
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
## Installation
|
|
2
|
+
```bash
|
|
3
|
+
git clone git@github.com:PFund-Software-Ltd/pfund.git
|
|
4
|
+
cd pfund
|
|
5
|
+
git submodule update --init --recursive
|
|
6
|
+
poetry install --with dev,test,doc --all-extras
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Pull updates
|
|
10
|
+
```bash
|
|
11
|
+
# --recurse-submodules also updates each submodule to the commit specified by the main repository,
|
|
12
|
+
git pull --recurse-submodules # = git pull + git submodule update --recursive
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Build Documentation using [jupyterbook](https://jupyterbook.org/)
|
|
16
|
+
```bash
|
|
17
|
+
# at the root directory, run:
|
|
18
|
+
jb build docs/ [--all]
|
|
19
|
+
|
|
20
|
+
# check if external links are broken:
|
|
21
|
+
jb build docs/ --builder linkcheck
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## How to define schema in crypto exchange APIs
|
|
25
|
+
A schema is a dictionary that maps the response from the exchange API to an internal response in a standard format. \
|
|
26
|
+
They are defined in rest_api.py and ws_api.py so that you don't need to parse the response to get the fields you need by writing code that is specific to the exchange API.
|
|
27
|
+
```
|
|
28
|
+
# example schema
|
|
29
|
+
schema = {
|
|
30
|
+
'result': ['result', 'list'],
|
|
31
|
+
'my_key': 'hard-coded value', # case 1
|
|
32
|
+
'product': ['symbol'],
|
|
33
|
+
'base_asset': ['baseCoin'],
|
|
34
|
+
'quote_asset': ['quoteCoin'],
|
|
35
|
+
'product_type': ['contractType'],
|
|
36
|
+
'tick_size': ['priceFilter', 'tickSize'],
|
|
37
|
+
'lot_size': ['lotSizeFilter', 'qtyStep'],
|
|
38
|
+
'expiration': (
|
|
39
|
+
'deliveryTime',
|
|
40
|
+
lambda expiration: datetime.datetime.fromtimestamp(int(expiration) / 1000, tz=datetime.timezone.utc),
|
|
41
|
+
lambda expiration: expiration.strftime('%Y-%m-%d')
|
|
42
|
+
),
|
|
43
|
+
'option_type': ('optionsType', lambda option_type: OptionType[option_type.upper()].value),
|
|
44
|
+
'strike_price': ('symbol', lambda symbol: symbol.split('-')[2], Decimal),
|
|
45
|
+
'data': {
|
|
46
|
+
'wallet': ('walletBalance', str, Decimal),
|
|
47
|
+
'available': ('availableToWithdraw', str, Decimal),
|
|
48
|
+
'margin': ('equity', str, Decimal),
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
Rules for defining schema:
|
|
54
|
+
1. 'result' is the key that contains the info that you need to parse.
|
|
55
|
+
2. The rest of the keys are the fields that will be returned in the internal response.
|
|
56
|
+
3. RHS can be a string (case 1), list/tuple (case 2), or a dictionary (case 3)
|
|
57
|
+
- Case 1: e.g. 'my_key': 'hard-coded value'\
|
|
58
|
+
It means the value is hard-coded.
|
|
59
|
+
|
|
60
|
+
- Case 2: e.g. 'product': ['symbol']\
|
|
61
|
+
It means that to get the value of 'product', you need to parse 'symbol' from the response. \
|
|
62
|
+
behind the scenes, the code will be sth like this: `product = result['symbol']` \
|
|
63
|
+
You can define a series of objects in the list/tuple, and they will be run in the order they are defined. e.g. \
|
|
64
|
+
- 'tick_size': ['priceFilter', 'tickSize']
|
|
65
|
+
- 'strike_price': ('symbol', lambda symbol: symbol.split('-')[2], Decimal) \
|
|
66
|
+
You can define functions or strings in the list/tuple. \
|
|
67
|
+
Consider it as a pipeline, the output of the previous object will be the input of the next object.
|
|
68
|
+
|
|
69
|
+
- Case 3: e.g. 'data': {
|
|
70
|
+
'wallet': ('walletBalance', str, Decimal),
|
|
71
|
+
'available': ('availableToWithdraw', str, Decimal),
|
|
72
|
+
'margin': ('equity', str, Decimal),
|
|
73
|
+
} \
|
|
74
|
+
It means that there is another schema inside the 'data' key, so consider it as a nested schema. \
|
|
75
|
+
Everything defined above will be applied as well.
|
|
76
|
+
It is useful when you need to parse a nested response.
|
|
77
|
+
4. if the key is not found in the response, it will be skipped.
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
# need these imports to support IDE hints:
|
|
7
|
+
import pfund_plot as plot
|
|
8
|
+
|
|
9
|
+
from pfund._backtest.typing import BacktestDataFrame
|
|
10
|
+
from pfund.brokers.broker_defi import DeFiBroker
|
|
11
|
+
from pfund.brokers.crypto.broker import CryptoBroker
|
|
12
|
+
from pfund.brokers.crypto.exchanges import Bybit
|
|
13
|
+
from pfund.brokers.ibkr.broker import (
|
|
14
|
+
InteractiveBrokers as IB,
|
|
15
|
+
)
|
|
16
|
+
from pfund.brokers.ibkr.broker import (
|
|
17
|
+
InteractiveBrokers as IBKR,
|
|
18
|
+
)
|
|
19
|
+
from pfund.components.features.feature_base import BaseFeature as Feature
|
|
20
|
+
from pfund.components.indicators.indicator_base import BaseIndicator as Indicator
|
|
21
|
+
from pfund.components.indicators.talib_indicator import TalibIndicator
|
|
22
|
+
from pfund.components.models.model_base import BaseModel as Model
|
|
23
|
+
from pfund.components.models.pytorch_model import PytorchModel
|
|
24
|
+
from pfund.components.models.sklearn_model import SklearnModel
|
|
25
|
+
from pfund.components.strategies.strategy_base import BaseStrategy as Strategy
|
|
26
|
+
from pfund.datas.data_config import DataConfig
|
|
27
|
+
from pfund.engines.backtest_engine import BacktestEngine
|
|
28
|
+
from pfund.engines.sandbox_engine import SandboxEngine
|
|
29
|
+
from pfund.engines.settings.backtest_engine_settings import BacktestEngineSettings
|
|
30
|
+
from pfund.engines.settings.sandbox_engine_settings import SandboxEngineSettings
|
|
31
|
+
from pfund.engines.settings.trade_engine_settings import TradeEngineSettings
|
|
32
|
+
from pfund.engines.trade_engine import TradeEngine
|
|
33
|
+
from pfund.utils.aliases import ALIASES as alias
|
|
34
|
+
|
|
35
|
+
from importlib.metadata import version
|
|
36
|
+
|
|
37
|
+
from pfund.config import configure, configure_logging, get_config
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def __getattr__(name: str):
|
|
41
|
+
if name == "alias":
|
|
42
|
+
from pfund.utils.aliases import ALIASES
|
|
43
|
+
|
|
44
|
+
return ALIASES
|
|
45
|
+
elif name == "plot":
|
|
46
|
+
import pfund_plot as plot
|
|
47
|
+
|
|
48
|
+
return plot
|
|
49
|
+
elif name == "DataConfig":
|
|
50
|
+
from pfund.datas.data_config import DataConfig
|
|
51
|
+
|
|
52
|
+
return DataConfig
|
|
53
|
+
elif name == "BacktestEngine":
|
|
54
|
+
from pfund.engines.backtest_engine import BacktestEngine
|
|
55
|
+
|
|
56
|
+
return BacktestEngine
|
|
57
|
+
elif name == "BacktestDataFrame":
|
|
58
|
+
from pfeed import get_config
|
|
59
|
+
from pfeed.enums import DataTool
|
|
60
|
+
|
|
61
|
+
pfeed_config = get_config()
|
|
62
|
+
if pfeed_config.data_tool == DataTool.polars:
|
|
63
|
+
from pfund._backtest.polars import BacktestDataFrame
|
|
64
|
+
|
|
65
|
+
return BacktestDataFrame
|
|
66
|
+
elif pfeed_config.data_tool == DataTool.pandas:
|
|
67
|
+
from pfund._backtest.pandas import BacktestDataFrame
|
|
68
|
+
|
|
69
|
+
return BacktestDataFrame
|
|
70
|
+
else:
|
|
71
|
+
raise ValueError(f"Unsupported data tool: {pfeed_config.data_tool}")
|
|
72
|
+
return BacktestDataFrame
|
|
73
|
+
elif name == "TradeEngine":
|
|
74
|
+
from pfund.engines.trade_engine import TradeEngine
|
|
75
|
+
|
|
76
|
+
return TradeEngine
|
|
77
|
+
elif name == "SandboxEngine":
|
|
78
|
+
from pfund.engines.sandbox_engine import SandboxEngine
|
|
79
|
+
|
|
80
|
+
return SandboxEngine
|
|
81
|
+
elif name == "TradeEngineSettings":
|
|
82
|
+
from pfund.engines.settings.trade_engine_settings import TradeEngineSettings
|
|
83
|
+
|
|
84
|
+
return TradeEngineSettings
|
|
85
|
+
elif name == "SandboxEngineSettings":
|
|
86
|
+
from pfund.engines.settings.sandbox_engine_settings import SandboxEngineSettings
|
|
87
|
+
|
|
88
|
+
return SandboxEngineSettings
|
|
89
|
+
elif name == "BacktestEngineSettings":
|
|
90
|
+
from pfund.engines.settings.backtest_engine_settings import (
|
|
91
|
+
BacktestEngineSettings,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
return BacktestEngineSettings
|
|
95
|
+
elif name == "Strategy":
|
|
96
|
+
from pfund.components.strategies.strategy_base import BaseStrategy as Strategy
|
|
97
|
+
|
|
98
|
+
return Strategy
|
|
99
|
+
elif name == "Model":
|
|
100
|
+
from pfund.components.models.model_base import BaseModel as Model
|
|
101
|
+
|
|
102
|
+
return Model
|
|
103
|
+
elif name == "Feature":
|
|
104
|
+
from pfund.components.features.feature_base import BaseFeature as Feature
|
|
105
|
+
|
|
106
|
+
return Feature
|
|
107
|
+
elif name == "PytorchModel":
|
|
108
|
+
from pfund.components.models.pytorch_model import PytorchModel
|
|
109
|
+
|
|
110
|
+
return PytorchModel
|
|
111
|
+
elif name == "SklearnModel":
|
|
112
|
+
from pfund.components.models.sklearn_model import SklearnModel
|
|
113
|
+
|
|
114
|
+
return SklearnModel
|
|
115
|
+
elif name == "Indicator":
|
|
116
|
+
from pfund.components.indicators.indicator_base import (
|
|
117
|
+
BaseIndicator as Indicator,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
return Indicator
|
|
121
|
+
elif name == "TalibIndicator":
|
|
122
|
+
from pfund.components.indicators.talib_indicator import TalibIndicator
|
|
123
|
+
|
|
124
|
+
return TalibIndicator
|
|
125
|
+
elif name == "CryptoBroker":
|
|
126
|
+
from pfund.brokers.crypto.broker import CryptoBroker
|
|
127
|
+
|
|
128
|
+
return CryptoBroker
|
|
129
|
+
elif name in ("InteractiveBrokers", "IBKR", "IB"):
|
|
130
|
+
from pfund.brokers.ibkr.broker import InteractiveBrokers
|
|
131
|
+
|
|
132
|
+
return InteractiveBrokers
|
|
133
|
+
elif name == "DeFiBroker":
|
|
134
|
+
from pfund.brokers.broker_defi import DeFiBroker
|
|
135
|
+
|
|
136
|
+
return DeFiBroker
|
|
137
|
+
elif name == "Bybit":
|
|
138
|
+
from pfund.brokers.crypto.exchanges import Bybit
|
|
139
|
+
|
|
140
|
+
return Bybit
|
|
141
|
+
elif name == "Binance":
|
|
142
|
+
from pfund.brokers.crypto.exchanges import Binance
|
|
143
|
+
|
|
144
|
+
return Binance
|
|
145
|
+
elif name.upper() == "OKX":
|
|
146
|
+
from pfund.brokers.crypto.exchanges import OKX
|
|
147
|
+
|
|
148
|
+
return OKX
|
|
149
|
+
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
__version__ = version("pfund")
|
|
153
|
+
__all__ = (
|
|
154
|
+
"__version__",
|
|
155
|
+
"alias",
|
|
156
|
+
"plot",
|
|
157
|
+
# configs
|
|
158
|
+
"configure",
|
|
159
|
+
"get_config",
|
|
160
|
+
"configure_logging",
|
|
161
|
+
"DataConfig",
|
|
162
|
+
# engines
|
|
163
|
+
"BacktestEngine",
|
|
164
|
+
"TradeEngine",
|
|
165
|
+
"SandboxEngine",
|
|
166
|
+
"TradeEngineSettings",
|
|
167
|
+
"SandboxEngineSettings",
|
|
168
|
+
"BacktestEngineSettings",
|
|
169
|
+
# backtest
|
|
170
|
+
"BacktestDataFrame",
|
|
171
|
+
# components
|
|
172
|
+
"Strategy",
|
|
173
|
+
"Model",
|
|
174
|
+
"Feature",
|
|
175
|
+
"PytorchModel",
|
|
176
|
+
"SklearnModel",
|
|
177
|
+
"Indicator",
|
|
178
|
+
"TalibIndicator",
|
|
179
|
+
# brokers
|
|
180
|
+
"IBKR",
|
|
181
|
+
"IB",
|
|
182
|
+
"CryptoBroker",
|
|
183
|
+
"DeFiBroker",
|
|
184
|
+
# exchanges
|
|
185
|
+
"Bybit",
|
|
186
|
+
"Binance",
|
|
187
|
+
"OKX",
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def __dir__():
|
|
192
|
+
return sorted(__all__)
|