price
Compute price for equity instrument with
AssetReinforcementLearning pricer
Since R2026a
Syntax
Description
[
computes the equity option instrument price and related pricing information based on the
pricing object Price,priceResultData] = price(inpPricer,inpInstrument)inpPricer and the instrument object
inpInstrument.
In addition, after having obtained a trained agent through the pricing procedure, you can price an option by reusing the trained agent. For an example of this workflow, see Use Trained Agent to Directly Price Option.
Note
The price function for the
AssetReinforcementLearning pricer requires the installation of
Reinforcement Learning Toolbox™.
[
adds name-value arguments in addition to the required arguments in the previous syntax.
For example, Price,priceResultData] = price(___,Name=Value)[Price,priceResultData] =
price(AssetReinforcementLearningPricer,Vanilla,Agent="LSPI",Training=true)
computes the equity option instrument price and related pricing information based on the
pricing object inpPricer and the instrument object
inpInstrument using the name-value arguments for
Agent and Training.
Examples
This example uses:
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 uses:
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 uses:
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.matCompute 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
Input Arguments
Pricer object, specified as a previously created AssetReinforcementLearning pricer object. Create the pricer object using
finpricer.
Data Types: object
Instrument object, specified as a scalar, previously created instrument object.
Create the Vanilla instrument object
with an ExerciseStyle of "American" or
"Bermudan" using fininstrument.
Data Types: object
Name-Value Arguments
Specify 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: [Price,priceResultData] =
price(AssetReinforcementLearningPricer,Vanilla,Agent="LSPI",Training=true)
Reinforcement learning agent, specified as scalar string with a value of
"LSPI" or the trained agent object
(rl.agent.rlLSPIAmericanOptionAgent) returned by
price.
Data Types: string | object
Flag to indicate if training process is needed before pricing, specified as a scalar logical.
Note
Training is always true when the Agent
value is "LSPI".
Data Types: logical
Output Arguments
Instrument price, returned as a numeric.
Price result, returned as a PriceResultData object. The object
has the following fields:
PriceResultData.Results— Option pricePriceResultData.PricerData— Contains the following:Trained agent —Trained built-in agent of
rlLSPIAmericanOptionAgentNote
Training must be conducted through the
finpricer.priceinterface. Directly using theagent.trainmethod is not supported.After having trained an agent using the workflow described in Price Vanilla Instrument with American ExerciseStyle Using BlackScholes Model and AssetReinforcementLearning Pricer, you can price an option by reusing the trained agent directly:
agent = priceResultData.PricerData.Agent; pr = price(Pricer_2, financialInstrument_2, Agent=agent, Training=false)
For an example of pricing an option by reusing the trained agent, see Use Trained Agent to Directly Price Option.
Also, you can retrain the agent from the last trained status. For example:
pr = price(Pricer_2, financialInstrument_2, Agent=agent, Training=true)
Training stats — Returned as
"rlTrainingResult"when training has been doneSimulation times
Paths
More About
Least-Squares Policy Iteration (LSPI) is a reinforcement learning algorithm designed to solve the policy optimization problem in Markov Decision Processes (MDPs).
LSPI combines concepts from both value iteration and policy iteration and is particularly useful for problems with large or continuous state spaces.
Version History
Introduced in R2026a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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
- United Kingdom (English)