• Have any questions?
  • info.zbook.org@gmail.com

Algorithmic Trading With MATLAB - Humusoft

8d ago
2 Views
0 Downloads
1.14 MB
25 Pages
Last View : 8d ago
Last Download : n/a
Upload by : Carlos Cepeda
Share:
Transcription

Algorithmic Trading with MATLAB Martin Demel, Application Engineer 2011 The MathWorks, Inc.1

Agenda Introducing MathWorks Introducting MATLAB (Portfolio Optimization Example) Introducting Algorithmic Trading with MATLABBreak Credit Risk Modeling with MATLAB Risk Management using various VaRcomputation methods Overview of derivatives pricing capabilities and furtherfinancial computing products Q&A2

RWE Develops and Deploys an AutomatedSystem for Natural Gas and Power Tradingand Risk ManagementChallengeAutomate business processes for quoting gascontracts and hedging against price fluctuationsSolutionEngage MathWorks Consulting to develop anddeploy to a production environment an automatedpricing and risk management system that fits withinthe company’s existing IT infrastructureResults Models created in minutes, not weeks 100% accurate results delivered Technical expertise applied to core businessgoalsRWE headquarters in Essen.“MathWorks consultants were wellqualified, professional, and fast. Theyunderstood not only the technicalissues but also the business goals,which is essential when working on acore business system. We got morethan we expected from MathWorksConsulting.”Dr. Norbert TönderRWELink to user story3

Challenges when building trading strategies Increasing complexity– More data– More complicated models Increasing computational speed– Push to higher frequency Long deployment cycle– (Re)coding is costly and error-prone4

Agenda Introduction: Algorithmic tradingDeveloping an automated trading decision engine– Identify a successful trading rule– Extend trading rule set– Automate trading rule selection Implementing MATLAB into your production tradingenvironmentWrap up and Q&A5

The problem at hand: Identifying profitabletrading strategies Commodities analystDeveloping a trading strategy– Multiple trading rules– High frequency Management requirements:– Tested on historical data– Uses sophisticated analytics toidentify optimal trading rulecombination– Integrates with existing data andexecution APIs6

Trading decision engineDevelopment and testingHistorical DataStrategy ModelingBack TestingEnd of Day / IntradayResearch / AlgorithmsProfit / LossFilesModel DevelopmentDatabasesCalibrationRisk ExposureLive DataDecision EngineExecutionReal-Time FeedsModelsBroker APIEvent-BasedTrading RulesOrder RoutingImplementation7

Requirements for the trading engine Sophisticated analytics– Custom rules & indicators– Non-traditional techniques Scalable speed– Higher frequency data– More trading rules Quick to develop and deploy– Try different strategies– Embed in trading engine8

Trading decision engineGoal:Task 1: Build a back testing environment around historical data and apreliminary trading ruleTask 2: Move to a higher frequency (minute-by-minute) and re-calibratethe modelTask 3: Develop a rule selection system for instruments usingevolutionary learningDevelopment and testingHistoricalDataEnd of Day/ IntradayStrategyModelingResearch/ AlgorithmsBack TestingFilesDatabasesModel DevelopmentCalibrationRisk ExposureLive DataDecision EngineExecutionReal-Time FeedsEvent-BasedModelsTrading RulesBroker APIOrder RoutingProfit / LossImplementation9

Task 1: Develop a back testing environmentGoal: Build a back testing environment around historicaldata and a preliminary trading ruleDevelopment and testingHistorical DataStrategy ModelingBack TestingEnd of Day / IntradayResearch / AlgorithmsProfit / LossFilesModel DevelopmentDatabasesCalibrationRisk ExposureLive DataDecision EngineExecutionReal-Time FeedsModelsBroker APIEvent-BasedTrading RulesOrder RoutingImplementation10

Task 1: Develop a back testing environmentKey tasks Import data from files Create a preliminary rule Test the rule’s performanceMax Sharpe Ratio 0.758 for Lead 17 and Lag 1200.80.60.60.40.20.40-0.20.2-0.4-0.6Solutions MATLAB data tools High-level programming andpre-built functions Powerful 406080100120-0.611

Task 2: Expand the scale of the engineGoal: Move to a higher frequency (minute-by-minute) andre-calibrate the modelDevelopment and testingHistorical DataStrategy ModelingBack TestingEnd of Day / IntradayResearch / AlgorithmsProfit / LossFilesModel DevelopmentDatabasesCalibrationRisk ExposureLive DataDecision EngineExecutionReal-Time FeedsModelsBroker APIEvent-BasedTrading RulesOrder RoutingImplementation12

Task 2: Expand the scale of the engineKey tasks Importing data fromdatabases Increase computational speedSolutions MATLAB data tools: DatabaseToolbox High-performance computing:Parallel Computing Toolbox,MATLAB DistributedComputing Server13

Task 3: Rule selection engineGoal: Develop a rule selection system for instrumentsusing evolutionary learningDevelopment and testingHistorical DataStrategy ModelingBack TestingEnd of Day / IntradayResearch / AlgorithmsProfit / LossFilesModel DevelopmentDatabasesCalibrationRisk ExposureLive DataDecision EngineExecutionReal-Time FeedsModelsBroker APIEvent-BasedTrading RulesOrder RoutingImplementation14

Task 3: Rule selection engineKey tasks Increase number of rules Incorporate advancedanalytics to select bestcombination15

Working with multiple strategiesShould I trade?Signal 1YesANDORSignal 2YesANDORSignal 3NoDempster et. al., Computational learning techniques for intraday fx trading using popular technical indicators,IEEE Transactions on Neural Networks (2001).16

Working with multiple strategiesRepresent different combinations as bit strings00AND1Signal 21Signal 2AND01ORSignal 3OR1Signal 3Signal 1Signal 1 111SignalsActive?17

Building Custom Evolution Algorithms Selection– Retain the best performing bit strings from one generation tothe next. Favor these for reproduction Crossover– parent1 [ 1 0 1 0 0 1 1 0 0 0 ]– parent2 [ 1 0 0 1 0 0 1 0 1 0 ]– child [1 0 0 0 0 1 1 0 1 0] Mutation– parent– child [1 0 1 0 0 1 1 0 0 0] [0 1 0 1 0 1 0 0 0 1]18

Task 3: Rule selection engineKey tasks Increase number of rules Incorporate advancedanalytics to select bestcombinationEvolutionary Learning Results, Sharpe Ratio 2.381005001000 2000 3000 4000 5000 6000 7000 8000 9000 10000Final Return 239 (249%)200Price (USD)Solutions High-level programming MATLAB Toolboxes: GlobalOptimization, Price (USD)150150100PositionCumulative Return5001000 2000 3000 4000 5000 6000 7000 8000 9000 10000Serial time number19

Agenda Introduction: Algorithmic tradingDeveloping an automated trading decision engine– Identify a successful trading rule– Extend trading rule set– Automate trading rule selection Implementing MATLAB into your production tradingenvironmentWrap up and Q&A20

Implementing the Decision EngineGoal: Evaluate and test the decision engine with real-timefeeds and execution through a messaging busDevelopment and testingHistorical DataStrategy ModelingBack TestingEnd of Day / IntradayResearch / AlgorithmsProfit / LossFilesModel DevelopmentDatabasesCalibrationRisk ExposureLive DataDecision EngineExecutionReal-Time FeedsModelsBroker APIEvent-BasedTrading RulesOrder RoutingImplementation21

Key TasksKey tasks Read live market data from data feed Connect to trading “engine”Solutions Datafeed Toolbox Many external APIs– .NET, Java, C/C , etc.– 3rd party APIs22

Deploying Applications with MATLAB Give MATLAB codeto other usersMATLAB Compiler Share applicationswith end users whodo not need MATLABMATLABBuilder EXMATLABBuilder JAMATLABBuilder NE– Stand-aloneexecutables– Shared libraries– Software components.exe.dllExcelJavaWebCOM.NET23

Review: Requirements for the trading engine Sophisticated analytics– Custom rules & indicators– Non-traditional techniques Scalable speed– Higher frequency data– More trading rules Quick to develop and deploy– Try different strategies– Embed in trading engine24

MATLAB’s solutions Sophisticated analytics– Advanced graphics environment– Toolboxes give access to hundredsof new techniques– Flexible and customizable Scalable speed– Parallel computing solution Quick to develop and deploy– High-level programming– Automated deployment25

Introduction: Algorithmic trading Developing an automated trading decision engine – Identify a successful trading rule – Extend trading rule set – Automate trading rule selection Implementing MATLAB int