A backtesting framework for algorithmic trading
Project description
ICARUS-BT
Riley: Backtesting Engine for Trading Strategies
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
-
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.
-
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.
- Sortino Ratio: Similar to Sharpe Ratio, but focuses on downside risk.
- Maximum Drawdown: Determines the largest peak-to-trough decline in strategy value.
- Calmar Ratio: Measures the risk-adjusted return of a strategy relative to its maximum drawdown.
- Annualized Returns: Calculates the compounded annual growth rate of the strategy.
- Total Return: Computes the overall return of the strategy.
-
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. -
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.
-
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.
-
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.
-
Optimization capabilities: Not yet implemented.
Installation
To install Icarus, follow these steps:
- Ensure that you have Python 3.7 or above installed on your system.
- Open a terminal or command prompt.
- Run the following command to install Riley using pip:
pip install ICARUS-BT
Getting Started
To begin using Icarus for backtesting trading strategies, follow the example below:
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.
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.
Documentation
For more information on how to use Riley, please refer to the documentation.
License
This project is licensed under the MIT License. See the 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>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file icarus-bt-0.2.1.tar.gz
.
File metadata
- Download URL: icarus-bt-0.2.1.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 675e4530b18aa03b1b5b61ceaa0bf0ec0aaf194d0a3d51ce0de9d729991b54d9 |
|
MD5 | fc409762a319c13ce48f4ec65a285a82 |
|
BLAKE2b-256 | 0b2f478284071f868c0cb947585e9d7a24c1c9988d11ea628ea37c4b38c566b0 |