Package: icarus-bt
ICARUS-BTRiley: Backtesting Engine for Trading StrategiesOverviewIcarus 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.FeaturesBacktesting: 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 (viayfinance) 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.InstallationTo 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:pipinstallICARUS-BTGetting StartedTo begin using Icarus for backtesting trading strategies, follow the example below:importIcarusasicimportstrategyasst# Create an instance of the BacktestEngineriley=ic.Riley()# Set Cash Amountriley.set_cash(10000)# Fetch data chosen sourcedata=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 engineriley.add_data(data)# Set the ticker for the backtestriley.set_ticker('F')#Add the strategy classriley.set_strategy(st.BollingerBands())# Set the stake amountriley.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 engineriley.add_metric(ic.metrics.SharpeRatio,'sharpe')riley.add_metric(ic.metrics.SortinoRatio,'sortino')# Run the backtestriley.run()# Generate graphical representation of the backtest resultsriley.plot()# riley.plot_bar()Graphical RepresentationIcarus provides capabilities to generate graphical representations of backtesting results. This includes visualizations of strategy performance, equity curves, trade signals, and other relevant data.Candlestick ChartsIcarus 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.DocumentationFor more information on how to use Riley, please refer to thedocumentation.LicenseThis project is licensed under the MIT License. See theLICENSEfile for details.ContributingIcarus 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.ContactIf you have any questions, suggestions, or feedback, feel free to reach out to the development team atdevin.thakker@outlook.comWe hope Icarus proves to be a valuable tool for backtesting and evaluating your trading strategies. Happy trading!CreditsDevin Thakker <devin.thakker@outlook.com>