{"id":14222481,"url":"https://github.com/PFund-Software-Ltd/pfund","last_synced_at":"2025-08-09T16:32:20.257Z","repository":{"id":219962892,"uuid":"750391365","full_name":"PFund-Software-Ltd/pfund","owner":"PFund-Software-Ltd","description":"A Complete Algo-Trading Framework for Machine Learning, TradFi+CeFi+DeFi ready. Supports Vectorized and Event-Driven Backtesting, Paper and Live Trading","archived":false,"fork":false,"pushed_at":"2024-04-12T10:28:18.000Z","size":1084,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-12T12:09:37.859Z","etag":null,"topics":["algo-trading","backtesting","crypto-trading","investing","machine-learning","python","trading"],"latest_commit_sha":null,"homepage":"https://pfund.ai","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PFund-Software-Ltd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-01-30T15:00:51.000Z","updated_at":"2024-04-15T06:16:38.937Z","dependencies_parsed_at":"2024-03-07T14:44:03.009Z","dependency_job_id":"9a590f79-bb21-4898-b990-254bbbde48a3","html_url":"https://github.com/PFund-Software-Ltd/pfund","commit_stats":null,"previous_names":["pfund-software-ltd/pfund"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PFund-Software-Ltd%2Fpfund","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PFund-Software-Ltd%2Fpfund/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PFund-Software-Ltd%2Fpfund/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PFund-Software-Ltd%2Fpfund/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PFund-Software-Ltd","download_url":"https://codeload.github.com/PFund-Software-Ltd/pfund/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229308921,"owners_count":18053032,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algo-trading","backtesting","crypto-trading","investing","machine-learning","python","trading"],"created_at":"2024-08-19T19:01:41.583Z","updated_at":"2025-08-09T16:32:20.159Z","avatar_url":"https://github.com/PFund-Software-Ltd.png","language":"Python","readme":"# PFund: A Complete Algo-Trading Framework powered by Machine Learning and Data Engineering, TradFi, CeFi and DeFi ready.\n\n[![Twitter Follow](https://img.shields.io/twitter/follow/pfund_ai?style=social)](https://x.com/pfund_ai)\n![GitHub stars](https://img.shields.io/github/stars/PFund-Software-Ltd/pfund?style=social)\n![PyPI downloads](https://img.shields.io/pypi/dm/pfund)\n[![PyPI](https://img.shields.io/pypi/v/pfund.svg)](https://pypi.org/project/pfund)\n![PyPI - Support Python Versions](https://img.shields.io/pypi/pyversions/pfund)\n![Discussions](https://img.shields.io/badge/Discussions-Let's%20Chat-green)\n[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/PFund-Software-Ltd/pfund)\n\u003c!-- [![marimo](https://marimo.io/shield.svg)](https://marimo.io) --\u003e\n\u003c!-- [![Jupyter Book Badge](https://raw.githubusercontent.com/PFund-Software-Ltd/pfund/main/docs/images/jupyterbook.svg\n)](https://jupyterbook.org) --\u003e\n\u003c!-- [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/) --\u003e\n\n[TradFi]: https://www.techopedia.com/definition/traditional-finance-tradfi\n[CeFi]: https://www.techopedia.com/definition/centralized-finance-cefi\n[DeFi]: https://www.coinbase.com/learn/crypto-basics/what-is-defi\n[pytrade.org]: https://pytrade.org\n[dYdX]: https://dydx.exchange\n[polars]: https://pola.rs/\n[PFund.ai]: https://pfund.ai\n[PFeed]: https://github.com/PFund-Software-Ltd/pfeed\n[Bybit]: https://bybit.com/\n[PyTorch]: https://pytorch.org/\n[Poetry]: https://python-poetry.org\n[Futu]: https://www.futunn.com\n[FirstRate Data]: https://firstratedata.com\n\n\u003e **This library is NOT ready for use, please wait for 0.1.0 release.**\n\n## Problem\nMachine 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.\n\n## Solution\nA 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.\n\n---\nPFund (/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**.\n\n## Core Features\n- [x] Supports vectorized and event-driven backtesting with different resolutions of data, e.g. tick data, second data and minute data etc.\n- [x] Allows choosing your preferred data tool, e.g. pandas, polars, pyspark etc.\n- [x] Supports machine learning models, features, technical analysis indicators\n- [x] Trains machine learning models using your favorite frameworks, i.e. PFund is **ML-framework agnostic**\n- [x] Offers **LEGO-style** strategy and model building, allowing strategies to add other strategies, models to add other models\n- [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\n- [x] Enables parallel data processing, e.g. Interactive Brokers and Binance each have their own process for receiving data feeds\n- [x] Switches from backtesting to live trading by just changing **ONE line of code!!**\n\n\u003e As PFund is for trading only, for all the data workloads, there is a separate library to handle that:\\\n[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.\n\n---\n\n\u003cdetails\u003e\n\u003csummary\u003eTable of Contents\u003c/summary\u003e\n\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n  - [Backtesting](#backtesting)\n  - [Live Trading](#live-trading)\n  - [Parameter Training / Hyperparameter Tuning](#parameter-training--hyperparameter-tuning)\n  - [Building LEGO-Style Strategy and Model](#building-lego-style-strategy-and-model)\n- [PFund Hub](#pfund-hub)\n- [Supported Trading Venues](#supported-trading-venues)\n- [Related Projects](#related-projects)\n- [Disclaimer](#disclaimer)\n\n\u003c/details\u003e\n\n\n## Installation\n\n### Using [Poetry] (Recommended)\n```bash\n# [RECOMMENDED]: Trading + Backtesting + Machine Learning + Feature Engineering (e.g. feast, tsfresh, ta) + Analytics\npoetry add \"pfund[all]\"\n\n# [Trading + Backtesting + Machine Learning + Feature Engineering]:\npoetry add \"pfund[data,ml,fe]\"\n\n# [Trading + Backtesting + Machine Learning]:\npoetry add \"pfund[data,ml]\"\n\n# [Trading + Backtesting]:\npoetry add \"pfund[data]\"\n\n# [Trading only]:\npoetry add pfund\n\n# update to the latest version:\npoetry update pfund\n```\n\n### Using Pip\n```bash\n# same as above, you can choose to install \"pfund[all]\", \"pfund[data,ml,fe]\", \"pfund[data,ml]\", \"pfund[data]\" or \"pfund\"\npip install \"pfund[all]\"\n\n# install the latest version:\npip install -U pfund\n```\n\n### Checking your installation\n```bash\n$ pfund --version\n```\n\n\n## Quick Start\n### Backtesting\n```python\nimport pfund as pf\n\n# NOTE: for more exciting strategies, please visit pfund.ai\nclass YourStrategy(pf.Strategy):\n    # triggered by bar/kline data (e.g. 1-minute data)\n    def on_bar(self):\n        # write your trading logic here\n        pass\n\n\nengine = pf.BacktestEngine(mode='vectorized')\nstrategy = engine.add_strategy(YourStrategy(), name='your_strategy')\nstrategy.add_data(\n  'IB', 'AAPL', 'USD', 'STK', resolutions=['1d'],\n  backtest={\n    # NOTE: since IB does not provide any historical data for backtesting purpose, use data from 'YAHOO_FINANCE'\n    'data_source': 'YAHOO_FINANCE',\n    'start_date': '2024-01-01',\n    'end_date': '2024-02-01',\n  }\n)\nengine.run()\n```\n\n\n### Live Trading\n\u003e Just change one line of code, from '**BacktestEngine**' to '**TradeEngine**'. BOOM! you can now start live trading.\n```python\nimport pfund as pf\n\nengine = pf.TradeEngine(env='LIVE')\nstrategy = engine.add_strategy(YourStrategy(), name='your_strategy')\nstrategy.add_data(\n  'IB', 'AAPL', 'USD', 'STK', resolutions=['1d'],\n  # for convenience, you can keep the kwarg `backtest`, `TradeEngine` will ignore it\n  backtest={\n    # NOTE: since IB does not provide any historical data for backtesting purpose, use data from 'YAHOO_FINANCE'\n    'data_source': 'YAHOO_FINANCE',\n    'start_date': '2024-01-01',\n    'end_date': '2024-02-01',\n  }\n)\nengine.run()\n```\n\n### Parameter Training / Hyperparameter Tuning\n\u003e 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\".\n\n```python\nimport pfund as pf\n\nengine = pf.TrainEngine()\nstrategy = engine.add_strategy(...)\nstrategy.add_data(...)\nstrategy.add_indicator(...)\nengine.run()\n```\n\n### Building LEGO-Style Strategy and Model\n```python\nimport pfund as pf\n\nengine = pf.TradeEngine(env='LIVE')\nstrategy = engine.add_strategy(...)\nstrategy.add_data(...)\nmodel = strategy.add_model(...)\n\nmodel.add_data(...)  # using different data than strategy's\nsub_model = model.add_model(...)  # YES, model can add another model to its use\n# You can keep going: \n# sub_sub_model = sub_model.add_model(...)\n\nengine.run()\n```\n\n\n## PFund Hub\nImagine a space where algo-traders can share their trading strategies and machine learning models with one another.\nStrategy and model development could be so much faster since you can build on top of an existing working model.\n\n\n---\n\n## Supported Trading Venues\n| Trading Venue             | Vectorized Backtesting | Event-Driven Backtesting | Paper Trading | Live Trading |\n| ------------------------- | ---------------------- | ------------------------ | ------------- | ------------ |\n| Bybit                     | 🟢                     | 🟡                       | 🟡            | 🟡           |\n| *Interactive Brokers (IB) | 🟡                     | 🟡                       | 🟡            | 🟡           |\n| Binance                   | 🔴                     | 🔴                       | 🔴            | 🔴           |\n| OKX                       | 🔴                     | 🔴                       | 🔴            | 🔴           |\n| *Alpaca                   | 🔴                     | 🔴                       | 🔴            | 🔴           |\n| *[Futu]                   | 🔴                     | 🔴                       | 🔴            | 🔴           |\n| dYdX                      | 🔴                     | 🔴                       | 🔴            | 🔴           |\n\n🟢 = finished \\\n🟡 = in progress \\\n🔴 = todo \\\n\\* = use a **_separate data source_** (e.g. [FirstRate Data]) for backtesting\n\n\n## Related Projects\n- [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.\n- [PyTrade.org] - A curated list of Python libraries and resources for algorithmic trading.\n\n\n## Disclaimer\nTHE 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.\n\nThis 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.\n\nThe 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.","funding_links":[],"categories":["Python","Curated List"],"sub_categories":["Trading Frameworks (support backtesting and live trading)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPFund-Software-Ltd%2Fpfund","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPFund-Software-Ltd%2Fpfund","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPFund-Software-Ltd%2Fpfund/lists"}