[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-9849":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":23,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":44,"readmeContent":45,"aiSummary":46,"trendingCount":16,"starSnapshotCount":16,"syncStatus":47,"lastSyncTime":48,"discoverSource":49},9849,"pybroker","edtechre\u002Fpybroker","edtechre","Algorithmic Trading in Python with Machine Learning","https:\u002F\u002Fwww.pybroker.com",null,"Python",3417,439,44,8,0,3,23,107,10,87.43,"Other",false,"master",true,[27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43],"ai","algorithmic-trading","algotrading","artificial-intelligence","backtesting","crypto","cryptocurrency","data-science","finance","framework","investment","machine-learning","python","quantitative-finance","stocks","trading","trading-strategies","2026-06-12 04:00:47","\u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Fedtechre\u002Fpybroker\u002Fblob\u002Fmaster\u002Fdocs\u002F_static\u002Fpybroker-logo.png?raw=true\" alt=\"PyBroker\">\n\n[![python](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fpython-v3-brightgreen.svg)](https:\u002F\u002Fwww.python.org\u002F)\n[![Apache 2.0 with Commons Clause](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-Apache%202.0%20Clause-green)](https:\u002F\u002Fwww.pybroker.com\u002Fen\u002Flatest\u002Flicense.html)\n[![Documentation Status](https:\u002F\u002Freadthedocs.org\u002Fprojects\u002Fpybroker\u002Fbadge\u002F?version=latest)](https:\u002F\u002Fwww.pybroker.com\u002Fen\u002Flatest\u002F?badge=latest)\n[![Package status](https:\u002F\u002Fgithub.com\u002Fedtechre\u002Fpybroker\u002Factions\u002Fworkflows\u002Fmain.yml\u002Fbadge.svg?event=push)](https:\u002F\u002Fgithub.com\u002Fedtechre\u002Fpybroker\u002Factions)\n[![Downloads](https:\u002F\u002Fstatic.pepy.tech\u002Fbadge\u002Flib-pybroker)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Flib-pybroker)\n[![Github stars](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002Fedtechre\u002Fpybroker?style=social)](https:\u002F\u002Fgithub.com\u002Fedtechre\u002Fpybroker\u002F)\n[![Twitter](https:\u002F\u002Fimg.shields.io\u002Ftwitter\u002Ffollow\u002Flibpybroker?style=social)](https:\u002F\u002Ftwitter.com\u002Fintent\u002Ffollow?screen_name=libpybroker)\n\n## Algorithmic Trading in Python with Machine Learning\n\nAre you looking to enhance your trading strategies with the power of Python and\nmachine learning? Then you need to check out **PyBroker**! This Python framework\nis designed for developing algorithmic trading strategies, with a focus on\nstrategies that use machine learning. With PyBroker, you can easily create and\nfine-tune trading rules, build powerful models, and gain valuable insights into\nyour strategy’s performance.\n\n## Key Features\n\n- A super-fast backtesting engine built in [NumPy](https:\u002F\u002Fnumpy.org\u002F) and accelerated with [Numba](https:\u002F\u002Fnumba.pydata.org\u002F).\n- The ability to create and execute trading rules and models across multiple instruments with ease.\n- Access to historical data from [Alpaca](https:\u002F\u002Falpaca.markets\u002F), [Yahoo Finance](https:\u002F\u002Ffinance.yahoo.com\u002F), [AKShare](https:\u002F\u002Fgithub.com\u002Fakfamily\u002Fakshare), or from [your own data provider](https:\u002F\u002Fwww.pybroker.com\u002Fen\u002Flatest\u002Fnotebooks\u002F7.%20Creating%20a%20Custom%20Data%20Source.html).\n- The option to train and backtest models using [Walkforward Analysis](https:\u002F\u002Fwww.pybroker.com\u002Fen\u002Flatest\u002Fnotebooks\u002F6.%20Training%20a%20Model.html#Walkforward-Analysis), which simulates how the strategy would perform during actual trading.\n- More reliable trading metrics that use randomized [bootstrapping](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FBootstrapping_(statistics)) to provide more accurate results.\n- Caching of downloaded data, indicators, and models to speed up your development process.\n- Parallelized computations that enable faster performance.\n\nWith PyBroker, you'll have all the tools you need to create winning trading\nstrategies backed by data and machine learning. Start using PyBroker today and\ntake your trading to the next level!\n\n## Installation\n\nPyBroker supports Python 3.9+ on Windows, Mac, and Linux. You can install\nPyBroker using ``pip``:\n\n```bash\n   pip install -U lib-pybroker\n```\n\nOr you can clone the Git repository with:\n\n```bash\n   git clone https:\u002F\u002Fgithub.com\u002Fedtechre\u002Fpybroker\n```\n\n## A Quick Example\n\nGet a glimpse of what backtesting with PyBroker looks like with these code\nsnippets:\n\n**Rule-based Strategy**:\n\n```python\n   from pybroker import Strategy, YFinance, highest\n\n   def exec_fn(ctx):\n      # Get the rolling 10 day high.\n      high_10d = ctx.indicator('high_10d')\n      # Buy on a new 10 day high.\n      if not ctx.long_pos() and high_10d[-1] > high_10d[-2]:\n         ctx.buy_shares = 100\n         # Hold the position for 5 days.\n         ctx.hold_bars = 5\n         # Set a stop loss of 2%.\n         ctx.stop_loss_pct = 2\n\n   strategy = Strategy(YFinance(), start_date='1\u002F1\u002F2022', end_date='7\u002F1\u002F2022')\n   strategy.add_execution(\n      exec_fn, ['AAPL', 'MSFT'], indicators=highest('high_10d', 'close', period=10))\n   # Run the backtest after 20 days have passed.\n   result = strategy.backtest(warmup=20)\n```\n\n**Model-based Strategy**:\n\n```python\n   import pybroker\n   from pybroker import Alpaca, Strategy\n\n   def train_fn(train_data, test_data, ticker):\n      # Train the model using indicators stored in train_data.\n      ...\n      return trained_model\n\n   # Register the model and its training function with PyBroker.\n   my_model = pybroker.model('my_model', train_fn, indicators=[...])\n\n   def exec_fn(ctx):\n      preds = ctx.preds('my_model')\n      # Open a long position given my_model's latest prediction.\n      if not ctx.long_pos() and preds[-1] > buy_threshold:\n         ctx.buy_shares = 100\n      # Close the long position given my_model's latest prediction.\n      elif ctx.long_pos() and preds[-1] \u003C sell_threshold:\n         ctx.sell_all_shares()\n\n   alpaca = Alpaca(api_key=..., api_secret=...)\n   strategy = Strategy(alpaca, start_date='1\u002F1\u002F2022', end_date='7\u002F1\u002F2022')\n   strategy.add_execution(exec_fn, ['AAPL', 'MSFT'], models=my_model)\n   # Run Walkforward Analysis on 1 minute data using 5 windows with 50\u002F50 train\u002Ftest data.\n   result = strategy.walkforward(timeframe='1m', windows=5, train_size=0.5)\n```\n\n## User Guide\n\n- [Getting Started with Data Sources](https:\u002F\u002Fwww.pybroker.com\u002Fen\u002Flatest\u002Fnotebooks\u002F1.%20Getting%20Started%20with%20Data%20Sources.html)\n- [Backtesting a Strategy](https:\u002F\u002Fwww.pybroker.com\u002Fen\u002Flatest\u002Fnotebooks\u002F2.%20Backtesting%20a%20Strategy.html)\n- [Evaluating with Bootstrap Metrics](https:\u002F\u002Fwww.pybroker.com\u002Fen\u002Flatest\u002Fnotebooks\u002F3.%20Evaluating%20with%20Bootstrap%20Metrics.html)\n- [Ranking and Position Sizing](https:\u002F\u002Fwww.pybroker.com\u002Fen\u002Flatest\u002Fnotebooks\u002F4.%20Ranking%20and%20Position%20Sizing.html)\n- [Writing Indicators](https:\u002F\u002Fwww.pybroker.com\u002Fen\u002Flatest\u002Fnotebooks\u002F5.%20Writing%20Indicators.html)\n- [Training a Model](https:\u002F\u002Fwww.pybroker.com\u002Fen\u002Flatest\u002Fnotebooks\u002F6.%20Training%20a%20Model.html)\n- [Creating a Custom Data Source](https:\u002F\u002Fwww.pybroker.com\u002Fen\u002Flatest\u002Fnotebooks\u002F7.%20Creating%20a%20Custom%20Data%20Source.html)\n- [Applying Stops](https:\u002F\u002Fwww.pybroker.com\u002Fen\u002Flatest\u002Fnotebooks\u002F8.%20Applying%20Stops.html)\n- [Rebalancing Positions](https:\u002F\u002Fwww.pybroker.com\u002Fen\u002Flatest\u002Fnotebooks\u002F9.%20Rebalancing%20Positions.html)\n- [Rotational Trading](https:\u002F\u002Fwww.pybroker.com\u002Fen\u002Flatest\u002Fnotebooks\u002F10.%20Rotational%20Trading.html)\n- [FAQs](https:\u002F\u002Fwww.pybroker.com\u002Fen\u002Flatest\u002Fnotebooks\u002FFAQs.html)\n\n## Online Documentation\n\n[The full reference documentation is hosted at **www.pybroker.com**.](https:\u002F\u002Fwww.pybroker.com)\n\n(For Chinese users: [中文文档](https:\u002F\u002Fwww.pybroker.com\u002Fzh_CN\u002Flatest\u002F), courtesy of [Albert King](https:\u002F\u002Fgithub.com\u002Falbertandking).)\n\n## Contact\n\n\u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Fedtechre\u002Fpybroker\u002Fblob\u002Fmaster\u002Fdocs\u002F_static\u002Femail-image.png?raw=true\">\n\n## Market-Moving Stock News & Alerts\n\n**AI-driven market analysis for the stocks you follow.** Receive real-time AI alerts and sentiment analysis for 10,000+ tickers at [www.movealerts.ai](https:\u002F\u002Fwww.movealerts.ai).\n","PyBroker 是一个用于开发基于机器学习的算法交易策略的Python框架。其核心功能包括使用NumPy和Numba加速的高效回测引擎，支持跨多种金融工具轻松创建和执行交易规则与模型，并能够从Alpaca、Yahoo Finance等数据源获取历史数据。此外，它还提供了通过Walkforward Analysis训练和回测模型的能力，以及采用随机化bootstrapping方法来提高交易指标的可靠性。PyBroker适用于希望利用Python和机器学习技术优化投资策略的个人投资者或机构，在量化金融领域特别有用。",2,"2026-06-11 03:25:02","top_topic"]