{"id":21969361,"url":"https://github.com/pawelkn/btester","last_synced_at":"2025-04-27T07:18:09.899Z","repository":{"id":216847225,"uuid":"742440212","full_name":"pawelkn/btester","owner":"pawelkn","description":"Python framework optimized for running backtests on multiple asset portfolios","archived":false,"fork":false,"pushed_at":"2024-02-03T11:19:00.000Z","size":4726,"stargazers_count":16,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-27T07:18:04.752Z","etag":null,"topics":["algorithmics","analysis","backtesting","multi-asset","multi-assets","parallel","portfolio","python","python3","quantitative","trading"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pawelkn.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-12T13:37:33.000Z","updated_at":"2025-04-09T10:28:37.000Z","dependencies_parsed_at":"2024-02-01T18:28:21.691Z","dependency_job_id":"c208b05a-5dc2-4ebb-990c-0df85f0eac99","html_url":"https://github.com/pawelkn/btester","commit_stats":{"total_commits":24,"total_committers":1,"mean_commits":24.0,"dds":0.0,"last_synced_commit":"d4ba48eaedd6560ac6f7907cfe67bfc549abcd16"},"previous_names":["pawelkn/btlib","pawelkn/btester"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pawelkn%2Fbtester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pawelkn%2Fbtester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pawelkn%2Fbtester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pawelkn%2Fbtester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pawelkn","download_url":"https://codeload.github.com/pawelkn/btester/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251099763,"owners_count":21536159,"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":["algorithmics","analysis","backtesting","multi-asset","multi-assets","parallel","portfolio","python","python3","quantitative","trading"],"created_at":"2024-11-29T14:19:10.691Z","updated_at":"2025-04-27T07:18:09.879Z","avatar_url":"https://github.com/pawelkn.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# btester -   Multi-Assets Backtesting Framework\n\n[![Test btester](https://github.com/pawelkn/btester/actions/workflows/test-btester.yml/badge.svg)](https://github.com/pawelkn/btester/actions/workflows/test-btester.yml) [![PyPi](https://img.shields.io/pypi/v/btester.svg)](https://pypi.python.org/pypi/btester/) [![Downloads](https://img.shields.io/pypi/dm/btester)](https://pypi.python.org/pypi/btester/) [![Codecov](https://codecov.io/gh/pawelkn/btester/branch/master/graph/badge.svg)](https://codecov.io/gh/pawelkn/btester/)\n\n`btester` is a Python framework optimized for running backtests on multiple asset portfolios.\n\nIt provides tools for backtesting trading strategies based on historical market data. The framework includes classes for managing financial positions, completed trades, and a flexible abstract base class for implementing custom trading strategies.\n\n## Installation\n\nYou can install `btester` using pip. Simply run the following command:\n\n```bash\npip install btester\n```\n\n## Usage\n\n1. Define your custom trading strategy by creating a class that inherits from the `Strategy` abstract class.\n\n2. Implement the required methods in your custom strategy: `init` for initialization and `next` for the core strategy logic.\n\n3. Instantiate the `Backtest` class with your custom strategy, historical market data, and other parameters.\n\n4. Run the backtest using the `run` method, which returns a `Result` object containing backtest results.\n\n## Example Usage\n\n```python\n# Example usage of the btester\nfrom btester import Strategy, Backtest\nimport pandas as pd\n\n# Define a custom strategy by inheriting from the abstract Strategy class\nclass MyStrategy(Strategy):\n    def init(self):\n        # Custom initialization logic for the strategy\n        pass\n\n    def next(self, i: int, record: Dict[Hashable, Any]):\n        # Custom strategy logic for each time step\n        pass\n\n# Load historical market data\ndata = pd.read_csv('historical_data.csv', parse_dates=['Date'])\ndata.set_index('Date', inplace=True)\n\n# Initialize and run the backtest\nbacktest = Backtest(strategy=MyStrategy, data=data, cash=10000, commission=0.01)\nresult = backtest.run()\n\n# Access backtest results\nreturns_series = result.returns\ncompleted_trades = result.trades\nremaining_positions = result.open_positions\n```\n\n## Examples\n\nCheck out the examples in the `examples` directory for additional use cases and demonstrations. The examples cover various scenarios and strategies to help you understand the versatility of the `btester`.\n\n- [Example 1: Multi-Assets Moving Average Crossover Strategy](https://colab.research.google.com/github/pawelkn/btester/blob/master/examples/multi-assets-ma-crossover.ipynb)\n- [Example 2: Multi-Assets Breakout Strategy](https://colab.research.google.com/github/pawelkn/btester/blob/master/examples/multi-assets-brakeout.ipynb)\n- [Example 3: Single Asset Moving Average Crossover Strategy](https://colab.research.google.com/github/pawelkn/btester/blob/master/examples/single-asset-ma-crossover.ipynb)\n- [Example 4: Single Asset Breakout Strategy](https://colab.research.google.com/github/pawelkn/btester/blob/master/examples/single-asset-brakeout.ipynb)\n\nFeel free to explore and adapt these examples to suit your specific needs and trading strategies.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpawelkn%2Fbtester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpawelkn%2Fbtester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpawelkn%2Fbtester/lists"}