主要内容

AssetReinforcementLearning

Create AssetReinforcementLearning pricer object for an equity instrument using a BlackScholes or Heston model

Since R2026a

Description

Create and price a Vanilla instrument object with a BlackScholes or Heston model and a AssetReinforcementLearning pricing method using this workflow:

  1. Use fininstrument to create a Vanilla instrument object with an ExerciseStyle of "American" or "Bermudan" .

  2. Use finmodel to specify a BlackScholes or Heston model for the Vanilla instrument object.

  3. When using a BlackScholes or Heston model, use finpricer to specify an AssetReinforcementLearning pricer object for the Vanilla instrument object.

    Note

    The AssetReinforcementLearning pricer and the associated price function require the installation of Reinforcement Learning Toolbox™.

For more information on this workflow, see Get Started with Workflows Using Object-Based Framework for Pricing Financial Instruments.

For more information on the available instruments, models, and pricing methods for a Vanilla instruments, see Choose Instruments, Models, and Pricers.

Creation

Description

AssetReinforcementLearningPricerObj = finpricer(PricerType,Model=model,DiscountCurve=ratecurve_obj,SpotPrice=spotprice_value,SimulationDates=simulation_dates) creates an AssetReinforcementLearning pricer object by specifying PricerType and sets the properties using the required name-value arguments Model, DiscountCurve, SpotPrice, and SimulationDates.

example

IRMonteCarloPricerObj = finpricer(___,Name=Value) sets optional properties using additional name-value arguments in addition to the required arguments in the previous syntax. For example, AssetReinforcementLearningPricerObj = finpricer("AssetReinforcementLearning",Model=HestonModel,DiscountCurve=ratecurve_obj,SpotPrice=500,SimulationDates=[datetime(2018,1,30); datetime(2019,1,30)],NumTrials=500) creates an AssetReinforcementLearning pricer object using a Heston model. You can specify multiple name-value arguments.

example

Input Arguments

expand all

Pricer type, specified as a string with the value "AssetReinforcementLearning" or a character vector with the value 'AssetReinforcementLearning'.

Data Types: char | string

Name-Value Arguments

expand all

Specify required and optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: AssetReinforcementLearningPricerObj = finpricer("AssetReinforcementLearning",Model=HestonModel,DiscountCurve=ratecurve_obj,SpotPrice=500,SimulationDates=[datetime(2018,1,30); datetime(2019,1,30)],NumTrials=500)

Required AssetReinforcementLearning Name-Value Arguments

expand all

Model object, specified as Model and the name of a previously created BlackScholes or Heston model object. Create the model object using finmodel.

Data Types: object

ratecurve object for discounting cash flows, specified as DiscountCurve and the name of a previously created ratecurve object.

Data Types: object

Spot price for underlying asset, specified using a scalar positive, real numeric value.

Data Types: double

Simulation dates, specified as SimulationDates and a scalar or a vector using a datetime array, string array, or date character vectors.

Optional AssetReinforcementLearning Name-Value Arguments

expand all

Dividend type in Model, specified as a scalar string or character vector. The DividendType must be either "cash" for actual dollar dividends or "continuous" for continuous dividend yield.

Data Types: string | char | cell

Dividend yield, or dividend schedule for the underlying equity asset, specified as a scalar numeric or a timetable for a dividend schedule.

Data Types: double | timetable

Simulation trials, specified as a scalar positive integer for the number of independent sample paths.

Data Types: double

Output Arguments

expand all

AssetReinforcementLearning pricer, returned as a AssetReinforcementLearning object.

Properties

expand all

This property is read-only.

Model object, returned as an object.

Data Types: object

ratecurve object for discounting cash flows, returned as a ratecurve object.

Data Types: object

Spot price for underlying asset, returned as a scalar positive, real numeric value.

Data Types: double

Simulation dates, returned as a datetime array.

Data Types: datetime

Dividend type in Model, returned as a scalar string.

Data Types: string

Dividend yield,or dividend schedule for the underlying equity asset, returned as a scalar numeric for dividend yield or a timetable for a dividend schedule.

Data Types: double | timetable

Simulation trials, returned as a scalar number of independent sample paths.

Data Types: double

Object Functions

priceCompute price for equity instrument with AssetReinforcementLearning pricer

Examples

collapse all

This example shows the workflow to price a Vanilla instrument with an "American" ExerciseStyle when using a BlackScholes model and an AssetReinforcementLearning pricing method. Note, to use this functionality, you must have Reinforcement Learning Toolbox™ installed.

Create Vanilla Instrument Object

Use fininstrument to create a Vanilla instrument object.

VanillaOpt = fininstrument("Vanilla",ExerciseDate=datetime(2021,8,15),Strike=110,OptionType="put",ExerciseStyle="american",Name="vanilla_option")
VanillaOpt = 
  Vanilla with properties:

       OptionType: "put"
    ExerciseStyle: "american"
     ExerciseDate: 15-Aug-2021
           Strike: 110
             Name: "vanilla_option"

Create BlackScholes Model Object

Use finmodel to create a BlackScholes model object.

BSModel = finmodel("BlackScholes",Volatility=0.2)
BSModel = 
  BlackScholes with properties:

     Volatility: 0.2000
    Correlation: 1

Create ratecurve Object

Create a ratecurve object using ratecurve.

Settle = datetime(2019,1,1);
Type = 'zero';
ZeroTimes = [calmonths(6) calyears([1 2 3 4 5 7 10 20 30])]';
ZeroRates = [0.0052 0.0055 0.0061 0.0073 0.0094 0.0119 0.0168 0.0222 0.0293 0.0307]';
ZeroDates = Settle + ZeroTimes;

myRC = ratecurve('zero',Settle,ZeroDates,ZeroRates)
myRC = 
  ratecurve with properties:

                 Type: "zero"
          Compounding: -1
                Basis: 0
                Dates: [10×1 datetime]
                Rates: [10×1 double]
               Settle: 01-Jan-2019
         InterpMethod: "linear"
    ShortExtrapMethod: "next"
     LongExtrapMethod: "previous"

Create AssetReinforcementLearning Pricer Object

Use finpricer to create an AssetReinforcementLearning pricer object and use the ratecurve object for the 'DiscountCurve' name-value pair argument.

SpotPrice = 100;
SimDates = [Settle+days(1):days(2):Settle+years(2)];

outPricer = finpricer("AssetReinforcementLearning",DiscountCurve=myRC,Model=BSModel,SpotPrice=SpotPrice,SimulationDates=SimDates)
outPricer = 
  AssetReinforcementLearning with properties:

      DiscountCurve: [1×1 ratecurve]
          SpotPrice: 100
    SimulationDates: [02-Jan-2019    04-Jan-2019    06-Jan-2019    08-Jan-2019    10-Jan-2019    12-Jan-2019    14-Jan-2019    16-Jan-2019    18-Jan-2019    20-Jan-2019    22-Jan-2019    24-Jan-2019    26-Jan-2019    28-Jan-2019    …    ] (1×365 datetime)
          NumTrials: 1000
              Model: [1×1 finmodel.BlackScholes]
       DividendType: "continuous"
      DividendValue: 0

Price Vanilla Instrument

Use price to compute the price for the Vanilla instrument.

[Price,priceResultData] = price(outPricer,VanillaOpt)
Price = 
16.4847
priceResultData = 
  priceresult with properties:

       Results: [1×1 table]
    PricerData: [1×1 struct]

priceResultData.PricerData
ans = struct with fields:
    SimulationTimes: [366×1 timetable]
              Paths: [366×1×1000 double]
      TrainingStats: [1×1 rl.train.result.rlTrainingResult]
              Agent: [1×1 rl.agent.rlLSPIAmericanOptionAgent]

This example shows the workflow to price a Vanilla instrument with an "Bermudan" ExerciseStyle when using a BlackScholes model and an AssetReinforcementLearning pricing method. Note, to use this functionality, you must have Reinforcement Learning Toolbox™ installed.

Create Vanilla Instrument Object

Use fininstrument to create a Vanilla instrument object.

VanillaOpt = fininstrument("Vanilla",ExerciseDate=[datetime(2019,1,16),datetime(2019,1,26)],Strike=110,OptionType="put",ExerciseStyle="bermudan",Name="vanilla_option")
VanillaOpt = 
  Vanilla with properties:

       OptionType: "put"
    ExerciseStyle: "bermudan"
     ExerciseDate: [16-Jan-2019    26-Jan-2019]
           Strike: [110 110]
             Name: "vanilla_option"

Create BlackScholes Model Object

Use finmodel to create a BlackScholes model object.

BSModel = finmodel("BlackScholes",Volatility=0.2)
BSModel = 
  BlackScholes with properties:

     Volatility: 0.2000
    Correlation: 1

Create ratecurve Object

Create a ratecurve object using ratecurve.

Settle = datetime(2019,1,1);
Type = 'zero';
ZeroTimes = [calmonths(6) calyears([1 2 3 4 5 7 10 20 30])]';
ZeroRates = [0.0052 0.0055 0.0061 0.0073 0.0094 0.0119 0.0168 0.0222 0.0293 0.0307]';
ZeroDates = Settle + ZeroTimes;

myRC = ratecurve('zero',Settle,ZeroDates,ZeroRates)
myRC = 
  ratecurve with properties:

                 Type: "zero"
          Compounding: -1
                Basis: 0
                Dates: [10×1 datetime]
                Rates: [10×1 double]
               Settle: 01-Jan-2019
         InterpMethod: "linear"
    ShortExtrapMethod: "next"
     LongExtrapMethod: "previous"

Create AssetReinforcementLearning Pricer Object

Use finpricer to create an AssetReinforcementLearning pricer object and use the ratecurve object for the 'DiscountCurve' name-value pair argument.

SpotPrice = 100;
SimDates = [Settle+days(1):days(2):Settle+calmonths(1)];

outPricer = finpricer("AssetReinforcementLearning",DiscountCurve=myRC,Model=BSModel,SpotPrice=SpotPrice,SimulationDates=SimDates)
outPricer = 
  AssetReinforcementLearning with properties:

      DiscountCurve: [1×1 ratecurve]
          SpotPrice: 100
    SimulationDates: [02-Jan-2019    04-Jan-2019    06-Jan-2019    08-Jan-2019    10-Jan-2019    12-Jan-2019    14-Jan-2019    16-Jan-2019    18-Jan-2019    20-Jan-2019    22-Jan-2019    24-Jan-2019    26-Jan-2019    28-Jan-2019    …    ] (1×16 datetime)
          NumTrials: 1000
              Model: [1×1 finmodel.BlackScholes]
       DividendType: "continuous"
      DividendValue: 0

Price Vanilla Instrument

Use price to compute the price for the Vanilla instrument.

[Price,priceResultData] = price(outPricer,VanillaOpt)
Price = 
9.9905
priceResultData = 
  priceresult with properties:

       Results: [1×1 table]
    PricerData: [1×1 struct]

priceResultData.PricerData
ans = struct with fields:
    SimulationTimes: [17×1 timetable]
              Paths: [17×1×1000 double]
      TrainingStats: [1×1 rl.train.result.rlTrainingResult]
              Agent: [1×1 rl.agent.rlLSPIAmericanOptionAgent]

This example shows the workflow to price a Vanilla instrument with an "American" ExerciseStyle when using a Heston model and an AssetReinforcementLearning pricing method. Note, to use this functionality, you must have Reinforcement Learning Toolbox™ installed.

Create Vanilla Instrument Object

Use fininstrument to create a Vanilla instrument object.

VanillaOpt = fininstrument("Vanilla",ExerciseDate=datetime(2021,8,15),Strike=110,OptionType="put",ExerciseStyle="american",Name="vanilla_option")
VanillaOpt = 
  Vanilla with properties:

       OptionType: "put"
    ExerciseStyle: "american"
     ExerciseDate: 15-Aug-2021
           Strike: 110
             Name: "vanilla_option"

Create Heston Model Object

Use finmodel to create a Heston model object.

HestonModel = finmodel("Heston",V0=0.032,ThetaV=0.1,Kappa=0.003,SigmaV=0.08,RhoSV=0.9)
HestonModel = 
  Heston with properties:

        V0: 0.0320
    ThetaV: 0.1000
     Kappa: 0.0030
    SigmaV: 0.0800
     RhoSV: 0.9000

Create ratecurve Object

Create a ratecurve object using ratecurve.

Settle = datetime(2019,1,1);
Type = 'zero';
ZeroTimes = [calmonths(6) calyears([1 2 3 4 5 7 10 20 30])]';
ZeroRates = [0.0052 0.0055 0.0061 0.0073 0.0094 0.0119 0.0168 0.0222 0.0293 0.0307]';
ZeroDates = Settle + ZeroTimes;

myRC = ratecurve('zero',Settle,ZeroDates,ZeroRates)
myRC = 
  ratecurve with properties:

                 Type: "zero"
          Compounding: -1
                Basis: 0
                Dates: [10×1 datetime]
                Rates: [10×1 double]
               Settle: 01-Jan-2019
         InterpMethod: "linear"
    ShortExtrapMethod: "next"
     LongExtrapMethod: "previous"

Create AssetReinforcementLearning Pricer Object

Use finpricer to create an AssetReinforcementLearning pricer object and use the ratecurve object for the 'DiscountCurve' name-value pair argument.

SpotPrice = 100;
SimDates = [Settle+days(1):days(2):Settle+years(2)];

outPricer = finpricer("AssetReinforcementLearning",DiscountCurve=myRC,Model=HestonModel,SpotPrice=SpotPrice,SimulationDates=SimDates)
outPricer = 
  AssetReinforcementLearning with properties:

      DiscountCurve: [1×1 ratecurve]
          SpotPrice: 100
    SimulationDates: [02-Jan-2019    04-Jan-2019    06-Jan-2019    08-Jan-2019    10-Jan-2019    12-Jan-2019    14-Jan-2019    16-Jan-2019    18-Jan-2019    20-Jan-2019    22-Jan-2019    24-Jan-2019    26-Jan-2019    28-Jan-2019    …    ] (1×365 datetime)
          NumTrials: 1000
              Model: [1×1 finmodel.Heston]
       DividendType: "continuous"
      DividendValue: 0

Price Vanilla Instrument

Use price to compute the price for the Vanilla instrument.

[Price,priceResultData] = price(outPricer,VanillaOpt)
Price = 
15.5194
priceResultData = 
  priceresult with properties:

       Results: [1×1 table]
    PricerData: [1×1 struct]

priceResultData.PricerData
ans = struct with fields:
    SimulationTimes: [366×1 timetable]
              Paths: [366×2×1000 double]
      TrainingStats: [1×1 rl.train.result.rlTrainingResult]
              Agent: [1×1 rl.agent.rlLSPIAmericanOptionAgent]

This example shows the workflow to price a Vanilla instrument with a "Bermudan" ExerciseStyle when using a Heston model and an AssetReinforcementLearning pricing method. Note, to use this functionality, you must have Reinforcement Learning Toolbox™ installed.

Create Vanilla Instrument Object

Use fininstrument to create a Vanilla instrument object.

VanillaOpt = fininstrument("Vanilla",ExerciseDate=[datetime(2019,1,16),datetime(2019,1,26)],Strike=110,OptionType="put",ExerciseStyle="bermudan",Name="vanilla_option")
VanillaOpt = 
  Vanilla with properties:

       OptionType: "put"
    ExerciseStyle: "bermudan"
     ExerciseDate: [16-Jan-2019    26-Jan-2019]
           Strike: [110 110]
             Name: "vanilla_option"

Create Heston Model Object

Use finmodel to create a Heston model object.

HestonModel = finmodel("Heston",V0=0.032,ThetaV=0.1,Kappa=0.003,SigmaV=0.08,RhoSV=0.9)
HestonModel = 
  Heston with properties:

        V0: 0.0320
    ThetaV: 0.1000
     Kappa: 0.0030
    SigmaV: 0.0800
     RhoSV: 0.9000

Create ratecurve Object

Create a ratecurve object using ratecurve.

Settle = datetime(2019,1,1);
Type = 'zero';
ZeroTimes = [calmonths(6) calyears([1 2 3 4 5 7 10 20 30])]';
ZeroRates = [0.0052 0.0055 0.0061 0.0073 0.0094 0.0119 0.0168 0.0222 0.0293 0.0307]';
ZeroDates = Settle + ZeroTimes;

myRC = ratecurve('zero',Settle,ZeroDates,ZeroRates)
myRC = 
  ratecurve with properties:

                 Type: "zero"
          Compounding: -1
                Basis: 0
                Dates: [10×1 datetime]
                Rates: [10×1 double]
               Settle: 01-Jan-2019
         InterpMethod: "linear"
    ShortExtrapMethod: "next"
     LongExtrapMethod: "previous"

Create AssetReinforcementLearning Pricer Object

Use finpricer to create an AssetReinforcementLearning pricer object and use the ratecurve object for the 'DiscountCurve' name-value pair argument.

SpotPrice = 100;
SimDates = [Settle+days(1):days(2):Settle+calmonths(1)];

outPricer = finpricer("AssetReinforcementLearning",DiscountCurve=myRC,Model=HestonModel,SpotPrice=SpotPrice,SimulationDates=SimDates)
outPricer = 
  AssetReinforcementLearning with properties:

      DiscountCurve: [1×1 ratecurve]
          SpotPrice: 100
    SimulationDates: [02-Jan-2019    04-Jan-2019    06-Jan-2019    08-Jan-2019    10-Jan-2019    12-Jan-2019    14-Jan-2019    16-Jan-2019    18-Jan-2019    20-Jan-2019    22-Jan-2019    24-Jan-2019    26-Jan-2019    28-Jan-2019    …    ] (1×16 datetime)
          NumTrials: 1000
              Model: [1×1 finmodel.Heston]
       DividendType: "continuous"
      DividendValue: 0

Price Vanilla Instrument

Use price to compute the price for the Vanilla instrument.

[Price,priceResultData] = price(outPricer,VanillaOpt)
Price = 
10.1096
priceResultData = 
  priceresult with properties:

       Results: [1×1 table]
    PricerData: [1×1 struct]

priceResultData.PricerData
ans = struct with fields:
    SimulationTimes: [17×1 timetable]
              Paths: [17×2×1000 double]
      TrainingStats: [1×1 rl.train.result.rlTrainingResult]
              Agent: [1×1 rl.agent.rlLSPIAmericanOptionAgent]

Use a trained agent (rl.agent.rlLSPIAmericanOptionAgent) from priceResultData.PricerData that you previously obtained from using the AssetReinforcementLearning pricer.

This example uses the agent (rl.agent.rlLSPIAmericanOptionAgent) that is created in the example Use AssetReinforcementLearning Pricer and BlackScholes Model to Price Vanilla Instrument with American ExerciseStyle.

Load the .mat file containing the priceResultData.PricerData.Agent.

load pricerdata.mat

Compute the price of the Vanilla option using the price function.

agent = priceResultData.PricerData.Agent;
pr = price(outPricer,VanillaOpt, Agent=agent, Training=false)
pr = 
16.4297

More About

expand all

Version History

Introduced in R2026a