# ICARUS-BT
![ICARUS-BT](./preview.jpg?raw=true)
# Riley: Backtesting Engine for Trading Strategies
[![Python](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org/downloads/release/python-310/)
[![PyPI](https://img.shields.io/pypi/v/icarus-bt?color=blue)](https://pypi.org/project/icarus-bt/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/icarus-bt?color=blue)](https://img.shields.io/github/downloads/devthakker/icarus-bt/total.svg)
![GitHub](https://img.shields.io/pypi/l/icarus-bt?color=blue)
## Overview
Icarus is a Python package designed to facilitate the backtesting of trading strategies. It provides a framework to simulate and evaluate trading decisions based on historical data, calculate various performance metrics, and generate graphical representations of the results. Riley is equipped with features to compute metrics like Sharpe ratio and Sortino ratio, allowing traders and quantitative analysts to assess the risk-adjusted returns of their strategies.
## Features
1. Backtesting: Riley enables users to simulate the execution of trading strategies on historical data. It supports various order types, including market orders, limit orders, and stop orders, allowing for flexible trade execution scenarios.
2. Performance Metrics: The package includes functions to calculate essential performance metrics commonly used in financial analysis. These metrics include but are not limited to the following:
- [Sharpe Ratio: Measures the risk-adjusted return of a strategy.](https://www.investopedia.com/terms/s/sharperatio.asp)
- [Sortino Ratio: Similar to Sharpe Ratio, but focuses on downside risk.](https://www.investopedia.com/terms/s/sortinoratio.asp)
- [Maximum Drawdown: Determines the largest peak-to-trough decline in strategy value.](https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp)
- [Calmar Ratio: Measures the risk-adjusted return of a strategy relative to its maximum drawdown.](https://www.investopedia.com/terms/c/calmarratio.asp)
- [Annualized Returns: Calculates the compounded annual growth rate of the strategy.](https://www.investopedia.com/terms/a/annualized-total-return.asp)
- [Total Return: Computes the overall return of the strategy.](https://www.investopedia.com/terms/t/totalreturn.asp)
3. Data Sources: Icarus provides support for multiple data sources, including Yahoo Finance (via `yfinance`) and CSV files. This allows users to easily fetch historical price data or load data from their own sources.
4. Graphical Representation: Riley provides capabilities to generate graphical representations of backtesting results. This includes visualizations of strategy performance, equity curves, trade signals, and other relevant data.
5. Candlestick Charts: Icarus provides capabilities to generate candlestick charts for the backtested ticker. This allows users to visualize the price action of the ticker over the backtesting period.
6. Customization: Riley is designed to be flexible and customizable. It allows users to specify the stake amount, stake percentage, or stake dollars for each trade. Additionally, users can specify the commission amount for each trade, as well as the slippage percentage. This allows for a wide range of backtesting scenarios.
7. Optimization capabilities: Not yet implemented.
## Installation
To install Icarus, follow these steps:
1. Ensure that you have Python 3.7 or above installed on your system.
2. Open a terminal or command prompt.
3. Run the following command to install Riley using pip:
```python
pip install ICARUS-BT
```
## Getting Started
To begin using Icarus for backtesting trading strategies, follow the example below:
```python
import Icarus as ic
import strategy as st
# Create an instance of the BacktestEngine
riley = ic.Riley()
# Set Cash Amount
riley.set_cash(10000)
# Fetch data chosen source
data = ic.source.csv('HistoricalData/F.csv')
# Alternatively, pull data from Yahoo Finance
# Also, you can specify the start and end dates
# data = ic.source.PandasDF(data.data)
# data = ic.source.yFinance('F', '2020-01-01', '2020-12-31')
# Add data to the backtest engine
riley.add_data(data)
# Set the ticker for the backtest
riley.set_ticker('F')
#Add the strategy class
riley.set_strategy(st.BollingerBands())
# Set the stake amount
riley.set_stake_quantity(50)
# Alternatively, you can set the stake percentage or the stake dollars
# riley.set_stake_percentage(100)
# riley.set_stake_dollars(1000)
# Add metrics to the backtest engine
riley.add_metric(ic.metrics.SharpeRatio, 'sharpe')
riley.add_metric(ic.metrics.SortinoRatio, 'sortino')
# Run the backtest
riley.run()
# Generate graphical representation of the backtest results
riley.plot()
# riley.plot_bar()
```
## Graphical Representation
Icarus provides capabilities to generate graphical representations of backtesting results. This includes visualizations of strategy performance, equity curves, trade signals, and other relevant data.
![ICARUS-BT](./Backtest.png?raw=true)
## Candlestick Charts
Icarus provides capabilities to generate candlestick charts for the backtested ticker. This allows users to visualize the price action of the ticker over the backtesting period.
![ICARUS-BT](./Candlestick.png?raw=true)
## Documentation
For more information on how to use Riley, please refer to the [documentation](https://icarus-bt.readthedocs.io/en/latest/).
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## Contributing
Icarus is an open-source project, and contributions are welcome. If you find any issues, have suggestions for improvements, or would like to add new features, please submit a pull request on the GitHub repository, as well as detailed information on what is changed, added, or improved.
## Contact
If you have any questions, suggestions, or feedback, feel free to reach out to the development team at devin.thakker@outlook.com
We hope Icarus proves to be a valuable tool for backtesting and evaluating your trading strategies. Happy trading!
## Credits
- Devin Thakker \<<devin.thakker@outlook.com>>
Raw data
{
"_id": null,
"home_page": "https://github.com/devthaakker/icarus-bt",
"name": "icarus-bt",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "backtesting,trading,algorithmic trading,finance,stock market,stock,market,backtest,backtesting framework,backtesting library,backtesting tool,backtesting software,backtesting python,backtesting python library,backtesting python framework,backtesting python tool,backtesting python software,backtesting python library finance,backtesting python framework finance,backtesting python tool finance,backtesting python software finance,backtesting python library stock market,backtesting python framework stock market,backtesting python tool stock market,backtesting python software stock market",
"author": "Devin Thakker",
"author_email": "devin.thakker@outlook.com",
"download_url": "https://files.pythonhosted.org/packages/0b/2f/478284071f868c0cb947585e9d7a24c1c9988d11ea628ea37c4b38c566b0/icarus-bt-0.2.1.tar.gz",
"platform": null,
"description": "\n# ICARUS-BT\n\n![ICARUS-BT](./preview.jpg?raw=true)\n\n# Riley: Backtesting Engine for Trading Strategies\n\n[![Python](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org/downloads/release/python-310/)\n[![PyPI](https://img.shields.io/pypi/v/icarus-bt?color=blue)](https://pypi.org/project/icarus-bt/)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/icarus-bt?color=blue)](https://img.shields.io/github/downloads/devthakker/icarus-bt/total.svg)\n![GitHub](https://img.shields.io/pypi/l/icarus-bt?color=blue)\n\n## Overview\nIcarus is a Python package designed to facilitate the backtesting of trading strategies. It provides a framework to simulate and evaluate trading decisions based on historical data, calculate various performance metrics, and generate graphical representations of the results. Riley is equipped with features to compute metrics like Sharpe ratio and Sortino ratio, allowing traders and quantitative analysts to assess the risk-adjusted returns of their strategies.\n\n## Features\n1. Backtesting: Riley enables users to simulate the execution of trading strategies on historical data. It supports various order types, including market orders, limit orders, and stop orders, allowing for flexible trade execution scenarios.\n\n2. Performance Metrics: The package includes functions to calculate essential performance metrics commonly used in financial analysis. These metrics include but are not limited to the following:\n - [Sharpe Ratio: Measures the risk-adjusted return of a strategy.](https://www.investopedia.com/terms/s/sharperatio.asp)\n - [Sortino Ratio: Similar to Sharpe Ratio, but focuses on downside risk.](https://www.investopedia.com/terms/s/sortinoratio.asp)\n - [Maximum Drawdown: Determines the largest peak-to-trough decline in strategy value.](https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp)\n - [Calmar Ratio: Measures the risk-adjusted return of a strategy relative to its maximum drawdown.](https://www.investopedia.com/terms/c/calmarratio.asp)\n - [Annualized Returns: Calculates the compounded annual growth rate of the strategy.](https://www.investopedia.com/terms/a/annualized-total-return.asp)\n - [Total Return: Computes the overall return of the strategy.](https://www.investopedia.com/terms/t/totalreturn.asp)\n\n3. Data Sources: Icarus provides support for multiple data sources, including Yahoo Finance (via `yfinance`) and CSV files. This allows users to easily fetch historical price data or load data from their own sources.\n\n4. Graphical Representation: Riley provides capabilities to generate graphical representations of backtesting results. This includes visualizations of strategy performance, equity curves, trade signals, and other relevant data.\n\n5. Candlestick Charts: Icarus provides capabilities to generate candlestick charts for the backtested ticker. This allows users to visualize the price action of the ticker over the backtesting period.\n\n6. Customization: Riley is designed to be flexible and customizable. It allows users to specify the stake amount, stake percentage, or stake dollars for each trade. Additionally, users can specify the commission amount for each trade, as well as the slippage percentage. This allows for a wide range of backtesting scenarios.\n\n7. Optimization capabilities: Not yet implemented.\n\n## Installation\nTo install Icarus, follow these steps:\n\n1. Ensure that you have Python 3.7 or above installed on your system.\n2. Open a terminal or command prompt.\n3. Run the following command to install Riley using pip:\n\n```python\npip install ICARUS-BT\n```\n\n## Getting Started\nTo begin using Icarus for backtesting trading strategies, follow the example below:\n\n```python\nimport Icarus as ic\nimport strategy as st\n\n\n# Create an instance of the BacktestEngine\nriley = ic.Riley()\n\n# Set Cash Amount\nriley.set_cash(10000)\n\n# Fetch data chosen source\ndata = ic.source.csv('HistoricalData/F.csv')\n\n# Alternatively, pull data from Yahoo Finance\n# Also, you can specify the start and end dates\n\n# data = ic.source.PandasDF(data.data)\n# data = ic.source.yFinance('F', '2020-01-01', '2020-12-31')\n\n# Add data to the backtest engine\nriley.add_data(data)\n\n# Set the ticker for the backtest\nriley.set_ticker('F')\n\n#Add the strategy class\nriley.set_strategy(st.BollingerBands())\n\n# Set the stake amount\nriley.set_stake_quantity(50)\n\n# Alternatively, you can set the stake percentage or the stake dollars\n# riley.set_stake_percentage(100)\n# riley.set_stake_dollars(1000)\n\n# Add metrics to the backtest engine\nriley.add_metric(ic.metrics.SharpeRatio, 'sharpe')\nriley.add_metric(ic.metrics.SortinoRatio, 'sortino')\n\n# Run the backtest\nriley.run()\n\n# Generate graphical representation of the backtest results\nriley.plot()\n# riley.plot_bar()\n```\n\n## Graphical Representation\nIcarus provides capabilities to generate graphical representations of backtesting results. This includes visualizations of strategy performance, equity curves, trade signals, and other relevant data.\n\n![ICARUS-BT](./Backtest.png?raw=true)\n\n## Candlestick Charts\nIcarus provides capabilities to generate candlestick charts for the backtested ticker. This allows users to visualize the price action of the ticker over the backtesting period.\n\n![ICARUS-BT](./Candlestick.png?raw=true)\n\n\n## Documentation\nFor more information on how to use Riley, please refer to the [documentation](https://icarus-bt.readthedocs.io/en/latest/).\n\n## License\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Contributing\nIcarus is an open-source project, and contributions are welcome. If you find any issues, have suggestions for improvements, or would like to add new features, please submit a pull request on the GitHub repository, as well as detailed information on what is changed, added, or improved.\n\n## Contact\nIf you have any questions, suggestions, or feedback, feel free to reach out to the development team at devin.thakker@outlook.com\n\nWe hope Icarus proves to be a valuable tool for backtesting and evaluating your trading strategies. Happy trading!\n\n## Credits\n\n- Devin Thakker \\<<devin.thakker@outlook.com>>\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A backtesting framework for algorithmic trading",
"version": "0.2.1",
"project_urls": {
"Download": "https://github.com/devthakker/Icarus-bt/archive/refs/tags/v0.2.1.tar.gz",
"Homepage": "https://github.com/devthaakker/icarus-bt"
},
"split_keywords": [
"backtesting",
"trading",
"algorithmic trading",
"finance",
"stock market",
"stock",
"market",
"backtest",
"backtesting framework",
"backtesting library",
"backtesting tool",
"backtesting software",
"backtesting python",
"backtesting python library",
"backtesting python framework",
"backtesting python tool",
"backtesting python software",
"backtesting python library finance",
"backtesting python framework finance",
"backtesting python tool finance",
"backtesting python software finance",
"backtesting python library stock market",
"backtesting python framework stock market",
"backtesting python tool stock market",
"backtesting python software stock market"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0b2f478284071f868c0cb947585e9d7a24c1c9988d11ea628ea37c4b38c566b0",
"md5": "fc409762a319c13ce48f4ec65a285a82",
"sha256": "675e4530b18aa03b1b5b61ceaa0bf0ec0aaf194d0a3d51ce0de9d729991b54d9"
},
"downloads": -1,
"filename": "icarus-bt-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "fc409762a319c13ce48f4ec65a285a82",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 19251,
"upload_time": "2023-06-22T19:39:41",
"upload_time_iso_8601": "2023-06-22T19:39:41.520112Z",
"url": "https://files.pythonhosted.org/packages/0b/2f/478284071f868c0cb947585e9d7a24c1c9988d11ea628ea37c4b38c566b0/icarus-bt-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-22 19:39:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "devthaakker",
"github_project": "icarus-bt",
"github_not_found": true,
"lcname": "icarus-bt"
}