# Backtrade
<p align="center">
<a href="https://github.com/34j/backtrade/actions?query=workflow%3ACI">
<img src="https://img.shields.io/github/workflow/status/34j/backtrade/CI/main?label=CI&logo=github&style=flat-square" alt="CI Status" >
</a>
<a href="https://backtrade.readthedocs.io">
<img src="https://img.shields.io/readthedocs/backtrade.svg?logo=read-the-docs&logoColor=fff&style=flat-square" alt="Documentation Status">
</a>
<a href="https://codecov.io/gh/34j/backtrade">
<img src="https://img.shields.io/codecov/c/github/34j/backtrade.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">
</a>
</p>
<p align="center">
<a href="https://python-poetry.org/">
<img src="https://img.shields.io/badge/packaging-poetry-299bd7?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAASCAYAAABrXO8xAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJJSURBVHgBfZLPa1NBEMe/s7tNXoxW1KJQKaUHkXhQvHgW6UHQQ09CBS/6V3hKc/AP8CqCrUcpmop3Cx48eDB4yEECjVQrlZb80CRN8t6OM/teagVxYZi38+Yz853dJbzoMV3MM8cJUcLMSUKIE8AzQ2PieZzFxEJOHMOgMQQ+dUgSAckNXhapU/NMhDSWLs1B24A8sO1xrN4NECkcAC9ASkiIJc6k5TRiUDPhnyMMdhKc+Zx19l6SgyeW76BEONY9exVQMzKExGKwwPsCzza7KGSSWRWEQhyEaDXp6ZHEr416ygbiKYOd7TEWvvcQIeusHYMJGhTwF9y7sGnSwaWyFAiyoxzqW0PM/RjghPxF2pWReAowTEXnDh0xgcLs8l2YQmOrj3N7ByiqEoH0cARs4u78WgAVkoEDIDoOi3AkcLOHU60RIg5wC4ZuTC7FaHKQm8Hq1fQuSOBvX/sodmNJSB5geaF5CPIkUeecdMxieoRO5jz9bheL6/tXjrwCyX/UYBUcjCaWHljx1xiX6z9xEjkYAzbGVnB8pvLmyXm9ep+W8CmsSHQQY77Zx1zboxAV0w7ybMhQmfqdmmw3nEp1I0Z+FGO6M8LZdoyZnuzzBdjISicKRnpxzI9fPb+0oYXsNdyi+d3h9bm9MWYHFtPeIZfLwzmFDKy1ai3p+PDls1Llz4yyFpferxjnyjJDSEy9CaCx5m2cJPerq6Xm34eTrZt3PqxYO1XOwDYZrFlH1fWnpU38Y9HRze3lj0vOujZcXKuuXm3jP+s3KbZVra7y2EAAAAAASUVORK5CYII=" alt="Poetry">
</a>
<a href="https://github.com/ambv/black">
<img src="https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square" alt="black">
</a>
<a href="https://github.com/pre-commit/pre-commit">
<img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=flat-square" alt="pre-commit">
</a>
</p>
<p align="center">
<a href="https://pypi.org/project/backtrade/">
<img src="https://img.shields.io/pypi/v/backtrade.svg?logo=python&logoColor=fff&style=flat-square" alt="PyPI Version">
</a>
<img src="https://img.shields.io/pypi/pyversions/backtrade.svg?style=flat-square&logo=python&logoColor=fff" alt="Supported Python versions">
<img src="https://img.shields.io/pypi/l/backtrade.svg?style=flat-square" alt="License">
</p>
A small Python package for backtesting.
## Installation
Install this via pip (or your favourite package manager):
`pip install backtrade`
## Usage
```python
from backtrade import Backtester, CloseData, LimitOrder, MarketOrder, _IndexType
# Define my strategy
class MyBacktest(Backtester):
def init(self):
pass
def next(
self, close_data: "CloseData[_IndexType]", row: "Series[Any]"
) -> "Iterable[Union[MarketOrder, LimitOrder]]":
yield MarketOrder(size=1 / close_data.close)
yield MarketOrder(size=-1 / close_data.close)
# Run backtest and plot results
bt = MyBacktest()
bt(df, maker_fee=-0.025 * 0.01, taker_fee=0.001).plot()
```
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
<!-- prettier-ignore-start -->
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center"><a href="https://github.com/34j"><img src="https://avatars.githubusercontent.com/u/55338215?v=4?s=80" width="80px;" alt="34j"/><br /><sub><b>34j</b></sub></a><br /><a href="https://github.com/34j/backtrade/commits?author=34j" title="Code">💻</a></td>
</tr>
</tbody>
</table>
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
<!-- prettier-ignore-end -->
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
## Credits
This package was created with
[Copier](https://copier.readthedocs.io/) and the
[browniebroke/pypackage-template](https://github.com/browniebroke/pypackage-template)
project template.
Raw data
{
"_id": null,
"home_page": "https://github.com/34j/backtrade",
"name": "backtrade",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "34j",
"author_email": "55338215+34j@users.noreply.github.com",
"download_url": "https://files.pythonhosted.org/packages/60/6a/40c3076b29eee278736c7e0541affd40ab39bce7b44c6bf17b2f687b358d/backtrade-0.7.2.tar.gz",
"platform": null,
"description": "# Backtrade\n\n<p align=\"center\">\n <a href=\"https://github.com/34j/backtrade/actions?query=workflow%3ACI\">\n <img src=\"https://img.shields.io/github/workflow/status/34j/backtrade/CI/main?label=CI&logo=github&style=flat-square\" alt=\"CI Status\" >\n </a>\n <a href=\"https://backtrade.readthedocs.io\">\n <img src=\"https://img.shields.io/readthedocs/backtrade.svg?logo=read-the-docs&logoColor=fff&style=flat-square\" alt=\"Documentation Status\">\n </a>\n <a href=\"https://codecov.io/gh/34j/backtrade\">\n <img src=\"https://img.shields.io/codecov/c/github/34j/backtrade.svg?logo=codecov&logoColor=fff&style=flat-square\" alt=\"Test coverage percentage\">\n </a>\n</p>\n<p align=\"center\">\n <a href=\"https://python-poetry.org/\">\n <img src=\"https://img.shields.io/badge/packaging-poetry-299bd7?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAASCAYAAABrXO8xAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJJSURBVHgBfZLPa1NBEMe/s7tNXoxW1KJQKaUHkXhQvHgW6UHQQ09CBS/6V3hKc/AP8CqCrUcpmop3Cx48eDB4yEECjVQrlZb80CRN8t6OM/teagVxYZi38+Yz853dJbzoMV3MM8cJUcLMSUKIE8AzQ2PieZzFxEJOHMOgMQQ+dUgSAckNXhapU/NMhDSWLs1B24A8sO1xrN4NECkcAC9ASkiIJc6k5TRiUDPhnyMMdhKc+Zx19l6SgyeW76BEONY9exVQMzKExGKwwPsCzza7KGSSWRWEQhyEaDXp6ZHEr416ygbiKYOd7TEWvvcQIeusHYMJGhTwF9y7sGnSwaWyFAiyoxzqW0PM/RjghPxF2pWReAowTEXnDh0xgcLs8l2YQmOrj3N7ByiqEoH0cARs4u78WgAVkoEDIDoOi3AkcLOHU60RIg5wC4ZuTC7FaHKQm8Hq1fQuSOBvX/sodmNJSB5geaF5CPIkUeecdMxieoRO5jz9bheL6/tXjrwCyX/UYBUcjCaWHljx1xiX6z9xEjkYAzbGVnB8pvLmyXm9ep+W8CmsSHQQY77Zx1zboxAV0w7ybMhQmfqdmmw3nEp1I0Z+FGO6M8LZdoyZnuzzBdjISicKRnpxzI9fPb+0oYXsNdyi+d3h9bm9MWYHFtPeIZfLwzmFDKy1ai3p+PDls1Llz4yyFpferxjnyjJDSEy9CaCx5m2cJPerq6Xm34eTrZt3PqxYO1XOwDYZrFlH1fWnpU38Y9HRze3lj0vOujZcXKuuXm3jP+s3KbZVra7y2EAAAAAASUVORK5CYII=\" alt=\"Poetry\">\n </a>\n <a href=\"https://github.com/ambv/black\">\n <img src=\"https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square\" alt=\"black\">\n </a>\n <a href=\"https://github.com/pre-commit/pre-commit\">\n <img src=\"https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=flat-square\" alt=\"pre-commit\">\n </a>\n</p>\n<p align=\"center\">\n <a href=\"https://pypi.org/project/backtrade/\">\n <img src=\"https://img.shields.io/pypi/v/backtrade.svg?logo=python&logoColor=fff&style=flat-square\" alt=\"PyPI Version\">\n </a>\n <img src=\"https://img.shields.io/pypi/pyversions/backtrade.svg?style=flat-square&logo=python&logoColor=fff\" alt=\"Supported Python versions\">\n <img src=\"https://img.shields.io/pypi/l/backtrade.svg?style=flat-square\" alt=\"License\">\n</p>\n\nA small Python package for backtesting.\n\n## Installation\n\nInstall this via pip (or your favourite package manager):\n\n`pip install backtrade`\n\n## Usage\n\n```python\nfrom backtrade import Backtester, CloseData, LimitOrder, MarketOrder, _IndexType\n\n# Define my strategy\nclass MyBacktest(Backtester):\n def init(self):\n pass\n\n def next(\n self, close_data: \"CloseData[_IndexType]\", row: \"Series[Any]\"\n ) -> \"Iterable[Union[MarketOrder, LimitOrder]]\":\n yield MarketOrder(size=1 / close_data.close)\n yield MarketOrder(size=-1 / close_data.close)\n\n# Run backtest and plot results\nbt = MyBacktest()\nbt(df, maker_fee=-0.025 * 0.01, taker_fee=0.001).plot()\n```\n\n## Contributors \u2728\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- prettier-ignore-start -->\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n <tbody>\n <tr>\n <td align=\"center\"><a href=\"https://github.com/34j\"><img src=\"https://avatars.githubusercontent.com/u/55338215?v=4?s=80\" width=\"80px;\" alt=\"34j\"/><br /><sub><b>34j</b></sub></a><br /><a href=\"https://github.com/34j/backtrade/commits?author=34j\" title=\"Code\">\ud83d\udcbb</a></td>\n </tr>\n </tbody>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n<!-- prettier-ignore-end -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n## Credits\n\nThis package was created with\n[Copier](https://copier.readthedocs.io/) and the\n[browniebroke/pypackage-template](https://github.com/browniebroke/pypackage-template)\nproject template.\n\n",
"bugtrack_url": null,
"license": "GNU General Public License v3",
"summary": "A small Python package for backtesting.",
"version": "0.7.2",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "623fb4b2ed57abba0a9324339da0212e",
"sha256": "8e634387da6df152e72409722c3e8786dada478c51fca6fd7bb44416d6fc4629"
},
"downloads": -1,
"filename": "backtrade-0.7.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "623fb4b2ed57abba0a9324339da0212e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 26337,
"upload_time": "2022-12-02T14:24:22",
"upload_time_iso_8601": "2022-12-02T14:24:22.415102Z",
"url": "https://files.pythonhosted.org/packages/3a/cd/26b6f536f9dd636dcb6ca3c9b42ef2d63064b51f99cdcf2a1bc4477294b4/backtrade-0.7.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "b99c29b4c165adab16769790d1564055",
"sha256": "55dcbb93b362c3c2ef69f017e87e068feb3b65d2cc95acc484e66ba7108fbf4f"
},
"downloads": -1,
"filename": "backtrade-0.7.2.tar.gz",
"has_sig": false,
"md5_digest": "b99c29b4c165adab16769790d1564055",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 26974,
"upload_time": "2022-12-02T14:24:24",
"upload_time_iso_8601": "2022-12-02T14:24:24.603031Z",
"url": "https://files.pythonhosted.org/packages/60/6a/40c3076b29eee278736c7e0541affd40ab39bce7b44c6bf17b2f687b358d/backtrade-0.7.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-02 14:24:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "34j",
"github_project": "backtrade",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "backtrade"
}