MathWorks - Mobile View
  • Accedere al proprio MathWorks AccountAccedere al proprio MathWorks Account
  • Access your MathWorks Account
    • Il Mio Account
    • Il mio Profilo utente
    • Associa Licenza
    • Disconnettiti
  • Prodotti
  • Soluzioni
  • Università
  • Assistenza
  • Community
  • Eventi
  • Acquista MATLAB
MathWorks
  • Prodotti
  • Soluzioni
  • Università
  • Assistenza
  • Community
  • Eventi
  • Acquista MATLAB
  • Accedere al proprio MathWorks AccountAccedere al proprio MathWorks Account
  • Access your MathWorks Account
    • Il Mio Account
    • Il mio Profilo utente
    • Associa Licenza
    • Disconnettiti

Video e Webinar

  • MathWorks
  • Video
  • Home Video
  • Cerca
  • Home Video
  • Cerca
  • Contattaci
  • Software di prova
  Register to watch video
  • Description
  • Full Transcript
  • Related Resources

Reinforcement Learning in Finance

Alex Roumi, MathWorks

This video shows an automated trader who is able to decide when to hedge a European call option contract to have a trade-off between transaction costs and hedging risk using reinforcement learning.

In this video I will be talking about building an automated trader that is able to decide when to hedge a European call option contract in the presence of transaction costs using reinforcement learning.

Think of hedging as home insurance, but in finance we use hedging to reduce risk from stock price movement.

The amount of stocks traded at each time step is calculated using delta from the Black-Scholes formula. Therefore, if the call option is for 100 shares of MLB stock, and delta is 0.1, the trader needs to short 10 shares of MLB.

In a real-world scenario, where transaction costs exist, it becomes critical, while observing the market, to know when to hedge during the life of the option to have this tradeoff between trading costs and hedging risk.

Let’s see how we apply reinforcement learning in hedging.

The agent is observing the financial market inputs like the stock price, time to maturity, the option price, and the stock holdings and takes an action of whether to hedge or not. If the agent hedges, the new stock holdings are -51 calculated using delta. Therefore, the agent has sold 6 stocks resulting in $3 in transaction costs. If the agent doesn’t hedge, the holdings remain the same.

After one period, the stock price moves to $99.40. The agent observes a total profit and loss resulting from the change of the stock price, the change of the option price, transaction costs paid, and a reward related to the total profit and loss.

In reinforcement learning, the agent will learn by trial and error to maximize the cumulative reward by choosing when to hedge during the life of the option.

The RL setup is composed of an agent and an environment. The environment sends a state to the agent, which takes an action in response. The agent will evaluate its last action based on the reward it returned. The loop keeps going until the environment sends a terminal state, say the maturity of the option, which ends the episode. After each episode the agent will learn to take actions that maximize the cumulative reward.

MATLAB made it easier to set up the environment and design the reinforcement learning components.

The reset function returns the initial state of the environment. It is called at the beginning of each training episode.

The step function specifies how the environment advances to the next state based on which action the agent takes.

The observations include the stock price, time to maturity, and the agent’s stock holdings.

The action is whether to hedge or not.

The observations, actions, and reset and step functions form the environment.

The agent consists of a policy and a reinforcement learning algorithm. The policy is a mapping function between observations and action. It can be a neural network designed by specifying the layers, activation functions, and neurons.

The reinforcement learning algorithm continuously updates the policy parameters and will find an optimal policy that maximizes the cumulative reward.

We train the agent for an hour and we can see that the agent has learned to maximize the cumulative reward over time.

As a result, a trained agent outperformed a trader who used delta hedging and another who decided not to hedge at all.

We simulate a random stock path, and when all periods are hedged, the loss is $120. The agent hedged 38 periods and didn’t trade for 12 times and the loss is $55.

Thank you for watching.

Related Products

  • Reinforcement Learning Toolbox
  • Deep Learning Toolbox
  • Financial Toolbox
  • Risk Management Toolbox

Feedback

Featured Product

Reinforcement Learning Toolbox

  • Request Trial
  • Get Pricing

Up Next:

55:12
MATLAB for R Users in Computational Finance

Related Videos:

43:59
Introduction to Computational Finance with MATLAB: A Risk...
51:53
Parallel Computing with MATLAB in Computational Finance
34:46
Using MATLAB for Real-Measure Calibration of Stochastic...
35:00
Hands-on Learning with MATLAB and Analog Discovery

View more related videos

MathWorks - Domain Selector

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web site

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文Chinese
    • English
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

  • Contattaci
  • Software di prova

Scopri i nostri prodotti

  • MATLAB
  • Simulink
  • Software per studenti​
  • Supporto hardware
  • File Exchange

Prova o Acquista

  • Download
  • Software di prova
  • Contattaci
  • Prezzi e licenze
  • Come acquistare

Impara ad utilizzare i nostri prodotti

  • Documentazione
  • Tutorial
  • Esempi
  • Video e Webinar
  • Formazione

Ricevi supporto tecnico

  • Aiuto all'installazione
  • Risposte​
  • Consulenza
  • License Center
  • Contatta l'assistenza

Informazioni su MathWorks

  • Lavora con noi
  • Sala stampa
  • Missione sociale​
  • Contattaci
  • Informazioni su MathWorks

MathWorks

Accelerating the pace of engineering and science

MathWorks è leader nello sviluppo di software per il calcolo matematico per ingegneri e ricercatori

Scopri…

  • Select a Web Site United States
  • Brevetti
  • Marchi
  • Informativa sulla privacy
  • Antipirateria
  • Stato dell'applicazione

© 1994-2021 The MathWorks, Inc.

  • Facebook
  • Twitter
  • Instagram
  • YouTube
  • LinkedIn
  • RSS

Unisciti alla discussione

This website uses cookies to improve your user experience, personalize content and ads, and analyze website traffic.  By continuing to use this website, you consent to our use of cookies.  Please see our Privacy Policy to learn more about cookies and how to change your settings.