Quantitative Finance

Investment Management, Risk Management, Algorithmic Trading, Econometric Modeling, Pricing and Insurance

MATLAB Portfolio Backtesting – A new app now on GitHub!

The following blog was written by Sara Galante, Senior Finance Application Engineer at Mathworks. 

MathWorks has a new application to implement backtesting strategies available on GitHub. This custom application provides an intuitive GUI to import portfolio data, create backtesting strategies, and test and compare them against each other. The backtesting application can also automatically generate the code to run said strategies with the click of a button, making integration into the portfolio optimization workflow simpler.

The GitHub documentation and MATLAB files are available here.

To help you get started watch this video on how to use the BackTesting App in MATLAB:

Workflow and Features

 

  1. Import Data Module:
    1.1. Import prices data directly from Excel sheet, .mat file or choose existing timetable from MATLAB workspace.
    1.2. Optionally, import signal data directly from Excel sheet, .mat file or choose existing timetable from MATLAB workspace.
    1-ImportData
  2. Create Backtest Strategies:
    2.1. In the main window, there is a tab showing the list of created backtest strategies
    2.1.1.Text box shows list of backtest strategies created using application.
    2.1.2. Add button: Add a brand new strategy.
    2.1.3. Edit button: Edit existing strategy.
    2.1.4. Duplicate button: Create a copy of existing strategy and simply modify their fields to create a new one.
    2.1.5. Delete button: Delete an existing strategy.
    2a-BacktestStrategyList
    2.2. Window 2B is launched in a different pane.
    2.2.1. Default values from BacktestStrategy objects are pre populated.
    2.2.2. If you choose to edit/duplicate a value, all fields will be populated from the selected strategy.
    2.2.3. The Pre-exec text box on top executes MATLAB code before creating the BacktestStrategy object. This allows the user to compute any values/variables/function-handles before using them in the other fields.
    2b-CreateStrategy
  3. Create Backtest Engine:
    3.1. With the imported data, create a backtest engine by selecting the strategies to consider and parameter values chosen.
    3.2. The Prices and Signal data fields are un-editable and are only to inform of the data being worked on. 3-CreateEngine
  4. Run Backtest:
    4.1. Choose the start and end dates for backtest to run in.
    4.2. Optionally add an array of strings with the names of the cash assets and the names of the debt assets.
    4.3. Upon running, find Equity Curve, Summary Table and Asset Area Curves plotted in different tabs.
    4-RunBacktest
  5. Use Export to Workspace button to export BacktestStrategy and BacktestEngine objects to ‘base’ workspace. This creates a new structure named backtestingStruct that has the backtest strategies and engine as its fields.
  6. Use Export Session and Import Session buttons to export application state as a appSession variable. Save this variable as mat file to import session later.
  7. Click Generate Code button to generate code for importing data, creating backtest strategies, backtest engine and then running the backtest.
|
  • print

コメント

コメントを残すには、ここ をクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。