Setup market, PV and Greeks calculation example
This file demonstrates how
- to create market environment from csv files (
*.csv
)
- load instrument script
- calculate PV and Greeks.
All script are written in F# for quick references to F# language
see Learn F# in Y minutes.
Another extremely useful library which we use for working for time series and data tables is Deedle see Deedle in 10 minutes using F#.
AutocallScript.fsx
AutocallScript.fsx loads main Dlls and Autocall definition from script AutocallScript.fsx
#I @"..\src\"
#load "AutocallScript.fsx"
open AutocallScript
Setup market data
Setup path to market data and conventions
let root = IO.Path.GetDirectoryName(__SOURCE_DIRECTORY__)
let marketDataPath = IO.Path.Combine(root , @"Tests\Data\FXHybrid - Smile\")
let conventionsPath = IO.Path.Combine(root , @"Tests\Data\Conventions\")
let spotConvention =
Json.readFile< Map<string,SpotConventions> > (conventionsPath + "spotConventions.json")
let fxVolConventions =
Json.readFile< Map<string,VolatilityFrame.Settings> > (conventionsPath + "fxVolConventions.json")
Load
- spots
- dividends and rate curves.
- correlation matrix
let today = DateTime(2019,3,29)
let currencyNames = [USD;EUR]
let fxNames = [|"EURUSD"|]
let equityNames = [|"DAIGR"; "AAPLUS"; "GOOGLUS"|]
let spots, assetCurrency = CSV.readSpotData (marketDataPath + "spots.csv")
let ratesData = CSV.rates marketDataPath currencyNames
let dividendsData = CSV.discreteDividends marketDataPath equityNames
let dividendYieldData = CSV.dividendYields marketDataPath equityNames
let fxVolatilityData = CSV.fxVolatility marketDataPath fxNames
let eqVolatilityData = CSV.eqVolatility marketDataPath equityNames
let corr = CSV.correlation marketDataPath
EURUSD DAIGR AAPLUS GOOGLUS
EURUSD -> 1.00 -0.14 0.01 0.29
DAIGR -> -0.14 1.00 0.37 0.81
AAPLUS -> 0.01 0.37 1.00 0.18
GOOGLUS -> 0.29 0.81 0.18 1.00
|
Parameter fxSmileSmoothing - defines some weights setting for smooth interpolation of volatility smiles.
- Accuracy - high values gives better fit to volatility data
- Smoothness - high values smoother interpolation
- Flatness and Linearity - regulate shape of smile wings.
let fxSmileSmoothing:SmoothSpline.Parameters =
{Accuracy = 10000.0;Flatness = 1.; Linearity = 0.01; Smoothness = 0.000001}
Build fx assets
let fxAssets =
fxNames
|>Array.map(fun name ->
let ccyPair = CcyPair.FromString name
let data:Asset.FX.Data =
{
Name=name
Spot=spots.[name]
Currency = ccyPair.Domestic
ForeignCurrency = ccyPair.Foreign
VolatilityFrame = fxVolatilityData.[name]
VolatilitySettings = Some fxVolConventions.[name]
SpotConventions = Some spotConvention.[name]
}
data
)
and FX local volatility models
let fxLVModels =
fxAssets
|>Array.map(fun asset ->
Model.FX.lv(asset,today, Yield.Rates ratesData.[asset.Currency], Yield.Rates ratesData.[asset.ForeignCurrency], fxSmileSmoothing)
)
let rateCurve = ratesData.[USD]
Build equity assets
// vol smile parameters
let eqSmileSmoothing:SmoothSpline.Parameters =
{Accuracy = 10000.0;Flatness = 0.100; Linearity = 0.10; Smoothness = 0.0001}
let eqAssets =
equityNames
|>Array.map(fun name ->
let data:Asset.EQ.Data =
{
Name = name
Spot = spots.[name]
DividendYield = Yield.Rates dividendYieldData.[name]
DividendDiscrete = dividendsData.[name]
VolatilityFrame = eqVolatilityData.[name]
Currency = assetCurrency.[name]
SpotConventions = Some spotConvention.[name]
}
data
)
and equity local volatility models
let eqLVModels =
eqAssets
|>Array.map(fun asset ->
Model.EQ.lv(asset,today, Yield.Rates ratesData.[assetCurrency.[asset.Name]], eqSmileSmoothing)
)
Charts for volatility surface
We can view resulting volatility smiles and surfaces. In case if script is running in Notebook VS Code "Chart.Show" can be dropped and chart will be plotted directly in notebook.
If script is running in Visual Studio then "Chart.Show" should be used to show chart in browser.
let eqAssetVol = eqLVModels.[2].ImpliedVol
AssetVol.Report.chart eqAssetVol |>Chart.show
AssetVol.Report.chartImplied3D (eqAssetVol.Spot/2.,eqAssetVol.Spot*2.) (0.1,2.1) eqAssetVol
View local volatility surface
VolatilitySurface.Report.chartLV3D (eqAssetVol.Spot/2.,eqAssetVol.Spot*2.) (0.1,2.1) eqAssetVol.Spot 0. 0. eqAssetVol.ImpVol
|>Chart.show
View interpolation fit quality
let calibrationErrors = AssetVol.Report.error eqAssetVol
0 1 2 3 4 5 6 7 8
28/04/2019 12:00:00 am error -> 0.16% -0.36% -0.08% 0.17% 0.20% 0.16% -0.05% -0.35% 0.13%
strike -> 941.51 1059.20 1118.05 1147.47 1176.89 1206.31 1235.73 1294.58 1412.27
28/05/2019 12:00:00 am error -> 0.15% -0.35% -0.03% 0.08% 0.21% 0.14% 0.01% -0.30% 0.09%
strike -> 941.51 1059.20 1118.05 1147.47 1176.89 1206.31 1235.73 1294.58 1412.27
29/06/2019 12:00:00 am error -> 0.10% -0.21% -0.04% 0.02% 0.14% 0.10% 0.02% -0.18% 0.05%
strike -> 941.51 1059.20 1118.05 1147.47 1176.89 1206.31 1235.73 1294.58 1412.27
29/09/2019 12:00:00 am error -> 0.04% -0.08% -0.01% 0.03% 0.03% -0.01% 0.02% -0.04% 0.01%
strike -> 941.51 1059.20 1118.05 1147.47 1176.89 1206.31 1235.73 1294.58 1412.27
29/03/2020 12:00:00 am error -> 0.03% -0.04% -0.02% -0.01% 0.01% 0.03% 0.03% -0.02% 0.00%
strike -> 941.51 1059.20 1118.05 1147.47 1176.89 1206.31 1235.73 1294.58 1412.27
29/09/2020 12:00:00 am error -> 0.02% -0.04% 0.00% 0.00% -0.00% 0.00% 0.02% -0.00% -0.00%
strike -> 941.51 1059.20 1118.05 1147.47 1176.89 1206.31 1235.73 1294.58 1412.27
29/03/2021 12:00:00 am error -> 0.02% -0.05% 0.02% 0.02% -0.01% -0.02% 0.01% 0.00% -0.00%
strike -> 941.51 1059.20 1118.05 1147.47 1176.89 1206.31 1235.73 1294.58 1412.27
|
Setup instrument parameters
Read coupon and funding dates from csv files and set values for autocall parameters
let couponDates = Frame.ReadCsv(marketDataPath + "CouponDates.csv")
let fundingDatesDates = Frame.ReadCsv(marketDataPath + "FundingDates.csv")
let autocallData:Autocall.Data =
{
CouponDates = couponDates.GetColumn<DateTime>("Fix Date").Values|>Seq.toArray
CouponPayDates = couponDates.GetColumn<DateTime>("Pay Date").Values |>Seq.toArray
FundingDates = fundingDatesDates.GetColumn<DateTime>("Fix Date").Values|>Seq.toArray
FundingPayDates = fundingDatesDates.GetColumn<DateTime>("Pay Date").Values |>Seq.toArray
InitialLevels = eqAssets|>Array.map(fun eq -> eq.Spot)
CouponTriggerLevel = 0.8
Coupon = 0.1
FundingRate = 0.0
Notional = 1000000.
Currency = USD
PutGearing = 1./0.8
Strike = 0.8
AutocallTriggerLevel = 1.0
AssetNames = equityNames
}
let autocall = Autocall.Instrument autocallData
Build Monte Carlo model
instrumentDates - includes all dates for which paths should be generated.
open QFL.MonteCarlo
open QFL.MonteCarlo.Instrument
let instrumentDates = getDates [ autocall ]
We also can define more refined time grid using nTimes parameter for additional number of time steps for Monte-Carlo modeling.
nPaths - number of paths generated by model
let mcSettings:Model.MCSettings =
{
RandomGenerator=RandomGenerator.Sobol;
Seed = 0;
NPaths = 10000;
NTimes = 200
}
let mcModel = MonteCarlo.Model.buildHY mcSettings instrumentDates USD today (Yield.Rates rateCurve) fxLVModels eqLVModels corr
PV and Greeks calculation
With given model and instrument we can calculate PV of instrument by function Instrument.pv
let pv = Instrument.pv mcModel autocall
or get cash flow values
let cf = Instrument.pvCashFlow mcModel autocall |>Frame.ofRecords
Date Amount Currency
0 -> 29/03/2024 12:00:00 am 0 USD
1 -> 29/03/2024 12:00:00 am -120748.33051136325 USD
2 -> 29/03/2024 12:00:00 am 1376.1533041237788 USD
3 -> 29/12/2023 12:00:00 am 0 USD
4 -> 29/12/2023 12:00:00 am 1761.9708944204333 USD
5 -> 29/09/2023 12:00:00 am 0 USD
6 -> 29/09/2023 12:00:00 am 2117.3390299751995 USD
7 -> 29/06/2023 12:00:00 am 0 USD
8 -> 29/06/2023 12:00:00 am 1879.452127846058 USD
9 -> 29/03/2023 12:00:00 am 0 USD
10 -> 29/03/2023 12:00:00 am 1936.0330028631367 USD
11 -> 29/12/2022 12:00:00 am 0 USD
12 -> 29/12/2022 12:00:00 am 2223.1852755694554 USD
13 -> 29/09/2022 12:00:00 am 0 USD
14 -> 29/09/2022 12:00:00 am 2444.0814154662285 USD
: ... ... ...
26 -> 29/03/2021 12:00:00 am 3940.0271888252305 USD
27 -> 29/12/2020 12:00:00 am 0 USD
28 -> 29/12/2020 12:00:00 am 4451.451482042615 USD
29 -> 29/09/2020 12:00:00 am 0 USD
30 -> 29/09/2020 12:00:00 am 4706.686038299015 USD
31 -> 29/06/2020 12:00:00 am 0 USD
32 -> 29/06/2020 12:00:00 am 5658.607025459361 USD
33 -> 29/03/2020 12:00:00 am 0 USD
34 -> 29/03/2020 12:00:00 am 7152.265442745875 USD
35 -> 29/12/2019 12:00:00 am 0 USD
36 -> 29/12/2019 12:00:00 am 9175.263573538594 USD
37 -> 29/09/2019 12:00:00 am 0 USD
38 -> 29/09/2019 12:00:00 am 12644.732784503458 USD
39 -> 29/06/2019 12:00:00 am 0 USD
40 -> 29/06/2019 12:00:00 am 21734.354292553042 USD
|
So we can easily make list of instruments with different parameters
let autocals =
[0.1 .. 0.1 .. 0.9]
|>List.map(fun level ->
"Instr " + string (int (10.*level)),
Autocall.Instrument{autocallData with CouponTriggerLevel = level}
)
|>series
And a plot for dependency of PV on instrument parameter
let prices = autocals|>Series.mapValues (Instrument.pv mcModel)
prices|>Series.observations
|>Chart.Line
Risk calculation
Change market data and recalculate price
Shift spot for first asset and rebuild asset
let eqIndex = 0
let eqName = equityNames.[eqIndex]
let assetBump =
Model.EQ.lv(
{eqAssets.[eqIndex] with Spot = spots.[eqName] + 1.},
today, Yield.Rates ratesData.[assetCurrency.[eqName]], eqSmileSmoothing)
Replace asset by bumped version
eqLVModels.[eqIndex] <- assetBump
let mcModelBump =
Model.buildHY mcSettings instrumentDates USD today (Yield.Rates rateCurve) fxLVModels eqLVModels corr
let bumpPV = Instrument.pv mcModelBump autocall
bumpPV - pv
VEGA
let assetVegaBump =
Model.EQ.lv(
{eqAssets.[eqIndex] with VolatilityFrame = eqVolatilityData.[eqName] + 0.01},
today, Yield.Rates ratesData.[assetCurrency.[eqName]], eqSmileSmoothing)
eqLVModels.[eqIndex] <- assetVegaBump
let mcModelVegaBump =
Model.buildHY mcSettings instrumentDates USD today (Yield.Rates rateCurve) fxLVModels eqLVModels corr
let bumpVegaPV = Instrument.pv mcModelVegaBump autocall
bumpVegaPV - pv
PHI
let assetPhiBump =
Model.EQ.lv(
{eqAssets.[eqIndex] with DividendYield = Yield.Rates (dividendYieldData.[eqName] + 0.01) },
today, Yield.Rates ratesData.[assetCurrency.[eqName]], eqSmileSmoothing)
eqLVModels.[eqIndex] <- assetPhiBump
let mcModelPhiBump =
Model.buildHY mcSettings instrumentDates USD today (Yield.Rates rateCurve) fxLVModels eqLVModels corr
let bumpPhiPV = Instrument.pv mcModelPhiBump autocall
bumpPhiPV - pv
It is easy to apply to series of instruments
let delta =
Series.mapValues (Instrument.pv mcModelBump) autocals - prices
let vega =
Series.mapValues (Instrument.pv mcModelVegaBump) autocals - prices
let phi =
Series.mapValues (Instrument.pv mcModelPhiBump) autocals - prices
let greeks =
Deedle.Frame(
["PV"; "Delta " + eqName; "Vega " + eqName; "Phi " + eqName],
[prices; delta; vega; phi ]
)
PV Delta DAIGR Vega DAIGR Phi DAIGR
Instr 1 -> 91765.22366477487 -1281.9267755415349 -2835.83352556506 -4127.851237129056
Instr 2 -> 90565.99145732954 -1084.7506598171167 -3153.2826174721413 -4402.842697065193
Instr 3 -> 85205.05653548674 -669.9336808366497 -3782.6215624736215 -5168.157100965298
Instr 4 -> 72081.5558068442 -98.44754308067786 -4041.2759315720323 -5845.660143719506
Instr 5 -> 52237.63129482791 802.665279483379 -4700.616260606796 -7229.130389850572
Instr 6 -> 28100.342903592 1615.830733845145 -4557.085393409248 -8288.001785898621
Instr 7 -> 1824.425613776264 2455.7729504056806 -4300.154130106133 -8453.06765412404
Instr 8 -> -23254.90474913566 3663.053979570541 -3685.9804690502606 -8856.037743405082
Instr 9 -> -47134.78604315325 4713.152253999768 -3407.36621165806 -9190.266878518232
|
module AutocallScript
namespace Plotly
namespace Plotly.NET
module Chart2D
from Plotly.NET
namespace QFL
namespace System
namespace QFL.Volatility
namespace Deedle
module CSV
val rates: dataPath: string -> currencyNames: 'a list -> Map<'a,Series<DateTime,float>> (requires comparison)
val dataPath: string
val currencyNames: 'a list (requires comparison)
Multiple items
module List
from QFL.Misc
--------------------
module List
from Microsoft.FSharp.Collections
<summary>Contains operations for working with values of type <see cref="T:Microsoft.FSharp.Collections.list`1" />.</summary>
<namespacedoc><summary>Operations for collections such as lists, arrays, sets, maps and sequences. See also
<a href="https://docs.microsoft.com/dotnet/fsharp/language-reference/fsharp-collection-types">F# Collection Types</a> in the F# Language Guide.
</summary></namespacedoc>
--------------------
type List<'T> =
| op_Nil
| op_ColonColon of Head: 'T * Tail: 'T list
interface IReadOnlyList<'T>
interface IReadOnlyCollection<'T>
interface IEnumerable
interface IEnumerable<'T>
member GetReverseIndex: rank: int * offset: int -> int
member GetSlice: startIndex: int option * endIndex: int option -> 'T list
static member Cons: head: 'T * tail: 'T list -> 'T list
member Head: 'T
member IsEmpty: bool
member Item: index: int -> 'T with get
...
<summary>The type of immutable singly-linked lists.</summary>
<remarks>Use the constructors <c>[]</c> and <c>::</c> (infix) to create values of this type, or
the notation <c>[1;2;3]</c>. Use the values in the <c>List</c> module to manipulate
values of this type, or pattern match against the values directly.
</remarks>
<exclude />
val map: mapping: ('T -> 'U) -> list: 'T list -> 'U list
<summary>Builds a new collection whose elements are the results of applying the given function
to each of the elements of the collection.</summary>
<param name="mapping">The function to transform elements from the input list.</param>
<param name="list">The input list.</param>
<returns>The list of transformed elements.</returns>
val ccy: 'a (requires comparison)
val readYieldData: path: string -> Series<DateTime,float>
Object.ToString() : string
Multiple items
module Map
from Microsoft.FSharp.Collections
<summary>Contains operations for working with values of type <see cref="T:Microsoft.FSharp.Collections.Map`2" />.</summary>
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: seq<'Key * 'Value> -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
member Change: key: 'Key * f: ('Value option -> 'Value option) -> Map<'Key,'Value>
...
<summary>Immutable maps based on binary trees, where keys are ordered by F# generic comparison. By default
comparison is the F# structural comparison function or uses implementations of the IComparable interface on key values.</summary>
<remarks>See the <see cref="T:Microsoft.FSharp.Collections.MapModule" /> module for further operations on maps.
All members of this class are thread-safe and may be used concurrently from multiple threads.</remarks>
--------------------
new: elements: seq<'Key * 'Value> -> Map<'Key,'Value>
val discreteDividends: dataPath: string -> equityNames: string[] -> Map<string,DividendDiscrete.Data>
val equityNames: string[]
type Array =
interface ICollection
interface IEnumerable
interface IList
interface IStructuralComparable
interface IStructuralEquatable
interface ICloneable
member Clone: unit -> obj
member CopyTo: array: Array * index: int -> unit + 1 overload
member GetEnumerator: unit -> IEnumerator
member GetLength: dimension: int -> int
...
<summary>Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the base class for all arrays in the common language runtime.</summary>
val map: mapping: ('T -> 'U) -> array: 'T[] -> 'U[]
<summary>Builds a new array whose elements are the results of applying the given function
to each of the elements of the array.</summary>
<param name="mapping">The function to transform elements of the array.</param>
<param name="array">The input array.</param>
<returns>The array of transformed elements.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input array is null.</exception>
val name: string
Multiple items
module Frame
from Deedle
--------------------
type Frame =
static member ReadCsv: location: string * hasHeaders: Nullable<bool> * inferTypes: Nullable<bool> * inferRows: Nullable<int> * schema: string * separators: string * culture: string * maxRows: Nullable<int> * missingValues: string[] * preferOptions: bool -> Frame<int,string> + 1 overload
static member ReadReader: reader: IDataReader -> Frame<int,string>
static member CustomExpanders: Dictionary<Type,Func<obj,seq<string * Type * obj>>>
static member NonExpandableInterfaces: ResizeArray<Type>
static member NonExpandableTypes: HashSet<Type>
--------------------
type Frame<'TRowKey,'TColumnKey (requires equality and equality)> =
interface IDynamicMetaObjectProvider
interface INotifyCollectionChanged
interface IFsiFormattable
interface IFrame
new: rowIndex: IIndex<'TRowKey> * columnIndex: IIndex<'TColumnKey> * data: IVector<IVector> * indexBuilder: IIndexBuilder * vectorBuilder: IVectorBuilder -> Frame<'TRowKey,'TColumnKey> + 1 overload
member AddColumn: column: 'TColumnKey * series: seq<'V> -> unit + 3 overloads
member AggregateRowsBy: groupBy: seq<'TColumnKey> * aggBy: seq<'TColumnKey> * aggFunc: Func<Series<'TRowKey,'a>,'b> -> Frame<int,'TColumnKey>
member Clone: unit -> Frame<'TRowKey,'TColumnKey>
member ColumnApply: f: Func<Series<'TRowKey,'T>,ISeries<'TRowKey>> -> Frame<'TRowKey,'TColumnKey> + 1 overload
member DropColumn: column: 'TColumnKey -> unit
...
--------------------
new: names: seq<'TColumnKey> * columns: seq<ISeries<'TRowKey>> -> Frame<'TRowKey,'TColumnKey>
new: rowIndex: Indices.IIndex<'TRowKey> * columnIndex: Indices.IIndex<'TColumnKey> * data: IVector<IVector> * indexBuilder: Indices.IIndexBuilder * vectorBuilder: Vectors.IVectorBuilder -> Frame<'TRowKey,'TColumnKey>
static member Frame.ReadCsv: path: string * ?hasHeaders: bool * ?inferTypes: bool * ?inferRows: int * ?schema: string * ?separators: string * ?culture: string * ?maxRows: int * ?missingValues: string[] * ?preferOptions: bool -> Frame<int,string>
static member Frame.ReadCsv: stream: IO.Stream * ?hasHeaders: bool * ?inferTypes: bool * ?inferRows: int * ?schema: string * ?separators: string * ?culture: string * ?maxRows: int * ?missingValues: string[] * ?preferOptions: bool -> Frame<int,string>
static member Frame.ReadCsv: reader: IO.TextReader * ?hasHeaders: bool * ?inferTypes: bool * ?inferRows: int * ?schema: string * ?separators: string * ?culture: string * ?maxRows: int * ?missingValues: string[] * ?preferOptions: bool -> Frame<int,string>
static member Frame.ReadCsv: stream: IO.Stream * hasHeaders: Nullable<bool> * inferTypes: Nullable<bool> * inferRows: Nullable<int> * schema: string * separators: string * culture: string * maxRows: Nullable<int> * missingValues: string[] * preferOptions: Nullable<bool> -> Frame<int,string>
static member Frame.ReadCsv: location: string * hasHeaders: Nullable<bool> * inferTypes: Nullable<bool> * inferRows: Nullable<int> * schema: string * separators: string * culture: string * maxRows: Nullable<int> * missingValues: string[] * preferOptions: bool -> Frame<int,string>
static member Frame.ReadCsv: path: string * indexCol: string * ?hasHeaders: bool * ?inferTypes: bool * ?inferRows: int * ?schema: string * ?separators: string * ?culture: string * ?maxRows: int * ?missingValues: string[] * ?preferOptions: bool -> Frame<'R,string> (requires equality)
Multiple items
[<Struct>]
type DateTime =
new: year: int * month: int * day: int -> unit + 10 overloads
member Add: value: TimeSpan -> DateTime
member AddDays: value: float -> DateTime
member AddHours: value: float -> DateTime
member AddMilliseconds: value: float -> DateTime
member AddMinutes: value: float -> DateTime
member AddMonths: months: int -> DateTime
member AddSeconds: value: float -> DateTime
member AddTicks: value: int64 -> DateTime
member AddYears: value: int -> DateTime
...
<summary>Represents an instant in time, typically expressed as a date and time of day.</summary>
--------------------
DateTime ()
(+0 other overloads)
DateTime(ticks: int64) : DateTime
(+0 other overloads)
DateTime(ticks: int64, kind: DateTimeKind) : DateTime
(+0 other overloads)
DateTime(year: int, month: int, day: int) : DateTime
(+0 other overloads)
DateTime(year: int, month: int, day: int, calendar: Globalization.Calendar) : DateTime
(+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int) : DateTime
(+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, kind: DateTimeKind) : DateTime
(+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, calendar: Globalization.Calendar) : DateTime
(+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, millisecond: int) : DateTime
(+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, millisecond: int, kind: DateTimeKind) : DateTime
(+0 other overloads)
module DividendDiscrete
from QFL
val fromFrame: dividendsFrame: Frame<DateTime,string> -> DividendDiscrete.Data
val dividendYields: dataPath: string -> equityNames: string[] -> Map<string,Series<DateTime,float>>
val fxVolatility: dataPath: string -> fxNames: string[] -> Map<string,Frame<string,string>>
val fxNames: string[]
val ccyPair: string
Multiple items
val string: value: 'T -> string
<summary>Converts the argument to a string using <c>ToString</c>.</summary>
<remarks>For standard integer and floating point values the and any type that implements <c>IFormattable</c><c>ToString</c> conversion uses <c>CultureInfo.InvariantCulture</c>. </remarks>
<param name="value">The input value.</param>
<returns>The converted string.</returns>
--------------------
type string = String
<summary>An abbreviation for the CLI type <see cref="T:System.String" />.</summary>
<category>Basic Types</category>
val eqVolatility: dataPath: string -> equityNames: string[] -> Map<string,Frame<DateTime,float>>
val readVolatilityAsFrameWithWings: path: string -> Frame<DateTime,float>
val correlation: dataPath: string -> Frame<string,string>
Multiple items
union case Html.Html: string -> Html
--------------------
type Html = | Html of string
val chartToHTML: chart: GenericChart.GenericChart -> Html
val chart: GenericChart.GenericChart
module GenericChart
from Plotly.NET
val toChartHTML: gChart: GenericChart.GenericChart -> string
val root: string
namespace System.IO
type Path =
static member ChangeExtension: path: string * extension: string -> string
static member Combine: path1: string * path2: string -> string + 3 overloads
static member EndsInDirectorySeparator: path: ReadOnlySpan<char> -> bool + 1 overload
static member GetDirectoryName: path: ReadOnlySpan<char> -> ReadOnlySpan<char> + 1 overload
static member GetExtension: path: ReadOnlySpan<char> -> ReadOnlySpan<char> + 1 overload
static member GetFileName: path: ReadOnlySpan<char> -> ReadOnlySpan<char> + 1 overload
static member GetFileNameWithoutExtension: path: ReadOnlySpan<char> -> ReadOnlySpan<char> + 1 overload
static member GetFullPath: path: string -> string + 1 overload
static member GetInvalidFileNameChars: unit -> char[]
static member GetInvalidPathChars: unit -> char[]
...
<summary>Performs operations on <see cref="T:System.String" /> instances that contain file or directory path information. These operations are performed in a cross-platform manner.</summary>
IO.Path.GetDirectoryName(path: string) : string
IO.Path.GetDirectoryName(path: ReadOnlySpan<char>) : ReadOnlySpan<char>
val marketDataPath: string
IO.Path.Combine([<ParamArray>] paths: string[]) : string
IO.Path.Combine(path1: string, path2: string) : string
IO.Path.Combine(path1: string, path2: string, path3: string) : string
IO.Path.Combine(path1: string, path2: string, path3: string, path4: string) : string
val conventionsPath: string
val spotConvention: Map<string,SpotConventions>
module Json
from QFL
val readFile: filePath: string -> 'T
val fxVolConventions: Map<string,VolatilityFrame.Settings>
module VolatilityFrame
from QFL.Volatility
val today: DateTime
val currencyNames: Currency list
union case Currency.USD: Currency
union case Currency.EUR: Currency
val spots: Series<string,float>
val assetCurrency: Series<string,Currency>
Multiple items
module CSV
from Overview
--------------------
module CSV
val readSpotData: path: string -> Series<string,float> * Series<string,Currency>
val ratesData: Map<Currency,Series<DateTime,float>>
val dividendsData: Map<string,DividendDiscrete.Data>
val dividendYieldData: Map<string,Series<DateTime,float>>
val fxVolatilityData: Map<string,Frame<string,string>>
val eqVolatilityData: Map<string,Frame<DateTime,float>>
val corr: Frame<string,string>
val fxSmileSmoothing: SmoothSpline.Parameters
module SmoothSpline
from QFL
type Parameters =
{
Accuracy: float
Flatness: float
Linearity: float
Smoothness: float
}
val fxAssets: Asset.FX.Data[]
val ccyPair: CcyPair
type CcyPair =
{
Foreign: Currency
Domestic: Currency
}
member Inverse: unit -> CcyPair
override ToString: unit -> string
static member FromString: s: string -> CcyPair
static member Make: und: Currency * acc: Currency -> CcyPair
static member tryFromString: s: string -> CcyPair option
static member CcyPair.FromString: s: string -> CcyPair
val data: Asset.FX.Data
module Asset
from QFL
module FX
from QFL.Asset
type Data =
{
Name: string
Spot: float
VolatilityFrame: Frame<string,string>
Currency: Currency
ForeignCurrency: Currency
SpotConventions: Option<SpotConventions>
VolatilitySettings: Option<Settings>
}
type Currency =
| RUB
| USD
| EUR
| GBP
| CHF
| XAU
| JPY
| CNH
| TRY
| RON
...
override ToString: unit -> string
static member FromString: s: string -> Currency option
CcyPair.Domestic: Currency
CcyPair.Foreign: Currency
union case Option.Some: Value: 'T -> Option<'T>
<summary>The representation of "Value of type 'T"</summary>
<param name="Value">The input value.</param>
<returns>An option representing the value.</returns>
val fxLVModels: Model.FX[]
val asset: Asset.FX.Data
module Model
from QFL
type FX =
| Model of Data<Data>
static member data: FX -> Data<Data>
static member lv: asset: Data * today: DateTime * domRateCurve: Data * foreignRateCurve: Data * ?smoothingParam: Parameters -> FX
static member slv: asset: Data * today: DateTime * rateCurve: Data * foreignRateCurve: Data * cir: Data * rhoSLV: float * fdSettings: FinDiffSettings * ?maxTime: float * ?smoothingParam: Parameters -> FX
static member Model.FX.lv: asset: Asset.FX.Data * today: DateTime * domRateCurve: Yield.Data * foreignRateCurve: Yield.Data * ?smoothingParam: SmoothSpline.Parameters -> Model.FX
module Yield
from QFL
union case Yield.Data.Rates: Series<DateTime,float> -> Yield.Data
Asset.FX.Data.Currency: Currency
Asset.FX.Data.ForeignCurrency: Currency
val rateCurve: Series<DateTime,float>
val eqSmileSmoothing: SmoothSpline.Parameters
val eqAssets: Asset.EQ.Data[]
val data: Asset.EQ.Data
module EQ
from QFL.Asset
type Data =
{
Name: string
Spot: float
DividendYield: Data
DividendDiscrete: Data
VolatilityFrame: Frame<DateTime,float>
Currency: Currency
SpotConventions: Option<SpotConventions>
}
val eqLVModels: Model.EQ[]
val asset: Asset.EQ.Data
type EQ =
| Model of Data<Data>
static member data: EQ -> Data<Data>
static member impliedVol: EQ -> Data
static member lv: asset: Data * today: DateTime * rateCurve: Data * ?smoothingParam: Parameters -> EQ
static member slv: asset: Data * today: DateTime * rateCurve: Data * cir: Data * rhoSLV: float * fdSettings: FinDiffSettings * ?maxTime: float * ?smoothingParam: Parameters -> EQ
member ImpliedVol: Data
static member Model.EQ.lv: asset: Asset.EQ.Data * today: DateTime * rateCurve: Yield.Data * ?smoothingParam: SmoothSpline.Parameters -> Model.EQ
Asset.EQ.Data.Name: string
val eqAssetVol: AssetVol.EQ.Data
module AssetVol
from QFL
module Report
from QFL.AssetVol
val chart: asset: AssetVol.IImpliedVolatility -> GenericChart.GenericChart
type Chart =
static member Area: x: seq<#IConvertible> * y: seq<#IConvertible> * ?Name: string * ?ShowMarkers: bool * ?ShowLegend: bool * ?MarkerSymbol: MarkerSymbol * ?Color: Color * ?Opacity: float * ?Labels: seq<#IConvertible> * ?TextPosition: TextPosition * ?TextFont: Font * ?Dash: DrawingStyle * ?Width: float -> GenericChart + 1 overload
static member Bar: values: seq<#IConvertible> * ?Keys: seq<#IConvertible> * ?Name: string * ?ShowLegend: bool * ?Color: Color * ?PatternShape: PatternShape * ?MultiPatternShape: seq<PatternShape> * ?Pattern: Pattern * ?Base: #IConvertible * ?Width: 'a3 * ?MultiWidth: seq<'a3> * ?Opacity: float * ?MultiOpacity: seq<float> * ?Text: 'a4 * ?MultiText: seq<'a4> * ?TextPosition: TextPosition * ?MultiTextPosition: seq<TextPosition> * ?TextFont: Font * ?Marker: Marker -> GenericChart (requires 'a3 :> IConvertible and 'a4 :> IConvertible) + 1 overload
static member BoxPlot: ?x: 'a0 * ?y: 'a1 * ?Name: string * ?ShowLegend: bool * ?Color: Color * ?Fillcolor: Color * ?Opacity: float * ?Whiskerwidth: 'a2 * ?Boxpoints: Boxpoints * ?Boxmean: BoxMean * ?Jitter: 'a3 * ?Pointpos: 'a4 * ?Orientation: Orientation * ?Marker: Marker * ?Line: Line * ?Alignmentgroup: 'a5 * ?Offsetgroup: 'a6 * ?Notched: bool * ?NotchWidth: float * ?QuartileMethod: QuartileMethod -> GenericChart + 1 overload
static member Bubble: x: seq<#IConvertible> * y: seq<#IConvertible> * sizes: seq<int> * ?Name: string * ?ShowLegend: bool * ?MarkerSymbol: MarkerSymbol * ?Color: Color * ?Opacity: float * ?Labels: seq<#IConvertible> * ?TextPosition: TextPosition * ?TextFont: Font * ?StackGroup: string * ?Orientation: Orientation * ?GroupNorm: GroupNorm * ?UseWebGL: bool -> GenericChart + 1 overload
static member Candlestick: ``open`` : seq<#IConvertible> * high: seq<#IConvertible> * low: seq<#IConvertible> * close: seq<#IConvertible> * x: seq<#IConvertible> * ?Increasing: Line * ?Decreasing: Line * ?WhiskerWidth: float * ?Line: Line * ?XCalendar: Calendar -> GenericChart + 1 overload
static member Column: values: seq<#IConvertible> * ?Keys: seq<#IConvertible> * ?Name: string * ?ShowLegend: bool * ?Color: Color * ?Pattern: Pattern * ?PatternShape: PatternShape * ?MultiPatternShape: seq<PatternShape> * ?Base: #IConvertible * ?Width: 'a3 * ?MultiWidth: seq<'a3> * ?Opacity: float * ?MultiOpacity: seq<float> * ?Text: 'a4 * ?MultiText: seq<'a4> * ?TextPosition: TextPosition * ?MultiTextPosition: seq<TextPosition> * ?TextFont: Font * ?Marker: Marker -> GenericChart (requires 'a3 :> IConvertible and 'a4 :> IConvertible) + 1 overload
static member Contour: data: seq<#seq<'a1>> * ?X: seq<#IConvertible> * ?Y: seq<#IConvertible> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?Colorscale: Colorscale * ?Showscale: 'a4 * ?zSmooth: SmoothAlg * ?ColorBar: 'a5 -> GenericChart (requires 'a1 :> IConvertible)
static member Funnel: x: seq<#IConvertible> * y: seq<#IConvertible> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?Labels: seq<#IConvertible> * ?TextPosition: TextPosition * ?TextFont: Font * ?Color: Color * ?Line: Line * ?x0: 'a3 * ?dX: float * ?y0: 'a4 * ?dY: float * ?Width: float * ?Offset: float * ?Orientation: Orientation * ?Alignmentgroup: string * ?Offsetgroup: string * ?Cliponaxis: bool * ?Connector: FunnelConnector * ?Insidetextfont: Font * ?Outsidetextfont: Font -> GenericChart
static member Heatmap: data: seq<#seq<'a1>> * ?ColNames: seq<#IConvertible> * ?RowNames: seq<#IConvertible> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?Colorscale: Colorscale * ?Showscale: 'a4 * ?Xgap: 'a5 * ?Ygap: 'a6 * ?zSmooth: SmoothAlg * ?ColorBar: 'a7 * ?UseWebGL: bool -> GenericChart (requires 'a1 :> IConvertible)
static member Histogram: data: seq<#IConvertible> * ?Orientation: Orientation * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?Color: Color * ?HistNorm: HistNorm * ?HistFunc: HistFunc * ?nBinsx: int * ?nBinsy: int * ?Xbins: Bins * ?Ybins: Bins * ?xError: 'a1 * ?yError: 'a2 -> GenericChart
...
static member Chart.show: ch: GenericChart.GenericChart -> unit
val chartImplied3D: xMin: float * xMax: float -> tMin: float * tMax: float -> asset: AssetVol.IImpliedVolatility -> GenericChart.GenericChart
AssetVol.EQ.Data.Spot: float
module VolatilitySurface
from QFL
module Report
from QFL.VolatilitySurface
val chartLV3D: xMin: float * xMax: float -> tMin: float * tMax: float -> spot: float -> r: float -> q: float -> vol: VolatilitySurface.Data -> GenericChart.GenericChart
AssetVol.EQ.Data.ImpVol: VolatilitySurface.Data
val calibrationErrors: Frame<(DateTime * string),int>
val error: asset: AssetVol.IImpliedVolatility -> Frame<(DateTime * string),int>
val couponDates: Frame<int,string>
val fundingDatesDates: Frame<int,string>
val autocallData: Autocall.Data
module Autocall
from AutocallScript
type Data =
{
AssetNames: string[]
CouponDates: DateTime[]
CouponPayDates: DateTime[]
FundingDates: DateTime[]
FundingPayDates: DateTime[]
InitialLevels: float[]
CouponTriggerLevel: float
Coupon: float
FundingRate: float
Notional: float
...
}
member Frame.GetColumn: column: 'TColumnKey -> Series<'TRowKey,'R>
member Frame.GetColumn: column: 'TColumnKey * lookup: Lookup -> Series<'TRowKey,'R>
Multiple items
module Seq
from Plotly.NET
--------------------
module Seq
from Microsoft.FSharp.Collections
<summary>Contains operations for working with values of type <see cref="T:Microsoft.FSharp.Collections.seq`1" />.</summary>
val toArray: source: seq<'T> -> 'T[]
<summary>Builds an array from the given collection.</summary>
<param name="source">The input sequence.</param>
<returns>The result array.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input sequence is null.</exception>
val eq: Asset.EQ.Data
Asset.EQ.Data.Spot: float
val autocall: Autocall.Instrument
Multiple items
type Instrument =
interface IPayoffInstrument<State,float[]>
new: x: Data -> Instrument
--------------------
new: x: Autocall.Data -> Autocall.Instrument
namespace QFL.MonteCarlo
module Instrument
from QFL.MonteCarlo
val instrumentDates: DateTime[]
val getDates: instruments: seq<IPayoffInstrument<'a,'b>> -> DateTime[]
val mcSettings: Model.MCSettings
Multiple items
module Model
from QFL.MonteCarlo
--------------------
module Model
from QFL
type MCSettings =
{
RandomGenerator: RandomGenerator
Seed: int
NPaths: int
NTimes: int
}
type RandomGenerator =
| Sobol
| Halton
| MersenneTwister
| System
union case RandomGenerator.Sobol: RandomGenerator
val mcModel: Model.MultiFactor<float[]>
module Model
from QFL.MonteCarlo
val buildHY: mcSettings: Model.MCSettings -> allInstrumentDates: DateTime[] -> baseCurrency: Currency -> today: DateTime -> rateCurve: Yield.Data -> fxModels: Model.FX[] -> eqModels: Model.EQ[] -> correlation: Frame<string,string> -> Model.MultiFactor<float[]>
val pv: float
val pv: mcData: Model.MultiFactor<float[]> -> instrument: IPayoffInstrument<'a,float[]> -> float (requires member get_CashFlow and member get_Clone)
val cf: Frame<int,string>
val pvCashFlow: mcData: Model.MultiFactor<float[]> -> instrument: IPayoffInstrument<'a,float[]> -> Cash list (requires member get_CashFlow and member get_Clone)
static member Frame.ofRecords: series: Series<'K,'R> -> Frame<'K,string> (requires equality)
static member Frame.ofRecords: values: seq<'T> -> Frame<int,string>
static member Frame.ofRecords: values: Collections.IEnumerable * indexCol: string -> Frame<'R,string> (requires equality)
val autocals: Series<string,Autocall.Instrument>
val level: float
Multiple items
val int: value: 'T -> int (requires member op_Explicit)
<summary>Converts the argument to signed 32-bit integer. This is a direct conversion for all
primitive numeric types. For strings, the input is converted using <c>Int32.Parse()</c>
with InvariantCulture settings. Otherwise the operation requires an appropriate
static conversion method on the input type.</summary>
<param name="value">The input value.</param>
<returns>The converted int</returns>
--------------------
[<Struct>]
type int = int32
<summary>An abbreviation for the CLI type <see cref="T:System.Int32" />.</summary>
<category>Basic Types</category>
--------------------
type int<'Measure> =
int
<summary>The type of 32-bit signed integer numbers, annotated with a unit of measure. The unit
of measure is erased in compiled code and when values of this type
are analyzed using reflection. The type is representationally equivalent to
<see cref="T:System.Int32" />.</summary>
<category>Basic Types with Units of Measure</category>
val series: observations: seq<'a * 'b> -> Series<'a,'b> (requires equality)
val prices: Series<string,float>
Multiple items
module Series
from Deedle
--------------------
type Series =
static member ofNullables: values: seq<Nullable<'a0>> -> Series<int,'a0> (requires default constructor and value type and 'a0 :> ValueType)
static member ofObservations: observations: seq<'c * 'd> -> Series<'c,'d> (requires equality)
static member ofOptionalObservations: observations: seq<'K * 'a1 option> -> Series<'K,'a1> (requires equality)
static member ofValues: values: seq<'a> -> Series<int,'a>
--------------------
type Series<'K,'V (requires equality)> =
interface IFsiFormattable
interface ISeries<'K>
new: index: IIndex<'K> * vector: IVector<'V> * vectorBuilder: IVectorBuilder * indexBuilder: IIndexBuilder -> Series<'K,'V> + 3 overloads
member After: lowerExclusive: 'K -> Series<'K,'V>
member Aggregate: aggregation: Aggregation<'K> * keySelector: Func<DataSegment<Series<'K,'V>>,'TNewKey> * valueSelector: Func<DataSegment<Series<'K,'V>>,OptionalValue<'R>> -> Series<'TNewKey,'R> (requires equality) + 1 overload
member AsyncMaterialize: unit -> Async<Series<'K,'V>>
member Before: upperExclusive: 'K -> Series<'K,'V>
member Between: lowerInclusive: 'K * upperInclusive: 'K -> Series<'K,'V>
member Compare: another: Series<'K,'V> -> Series<'K,Diff<'V>>
member Convert: forward: Func<'V,'R> * backward: Func<'R,'V> -> Series<'K,'R>
...
--------------------
new: pairs: seq<Collections.Generic.KeyValuePair<'K,'V>> -> Series<'K,'V>
new: keys: seq<'K> * values: seq<'V> -> Series<'K,'V>
new: keys: 'K[] * values: 'V[] -> Series<'K,'V>
new: index: Indices.IIndex<'K> * vector: IVector<'V> * vectorBuilder: Vectors.IVectorBuilder * indexBuilder: Indices.IIndexBuilder -> Series<'K,'V>
val mapValues: f: ('T -> 'R) -> series: Series<'K,'T> -> Series<'K,'R> (requires equality)
val observations: series: Series<'K,'T> -> seq<'K * 'T> (requires equality)
static member Chart.Line: xy: seq<#IConvertible * #IConvertible> * ?Name: string * ?ShowMarkers: bool * ?ShowLegend: bool * ?MarkerSymbol: StyleParam.MarkerSymbol * ?Color: Color * ?Opacity: float * ?Labels: seq<#IConvertible> * ?TextPosition: StyleParam.TextPosition * ?TextFont: Font * ?Dash: StyleParam.DrawingStyle * ?Width: float * ?StackGroup: string * ?Orientation: StyleParam.Orientation * ?GroupNorm: StyleParam.GroupNorm * ?UseWebGL: bool -> GenericChart.GenericChart
static member Chart.Line: x: seq<#IConvertible> * y: seq<#IConvertible> * ?Name: string * ?ShowMarkers: bool * ?ShowLegend: bool * ?MarkerSymbol: StyleParam.MarkerSymbol * ?Color: Color * ?Opacity: float * ?Labels: seq<#IConvertible> * ?TextPosition: StyleParam.TextPosition * ?TextFont: Font * ?Dash: StyleParam.DrawingStyle * ?Width: float * ?StackGroup: string * ?Orientation: StyleParam.Orientation * ?GroupNorm: StyleParam.GroupNorm * ?UseWebGL: bool -> GenericChart.GenericChart
val eqIndex: int
val eqName: string
val assetBump: Model.EQ
val mcModelBump: Model.MultiFactor<float[]>
val bumpPV: float
val assetVegaBump: Model.EQ
val mcModelVegaBump: Model.MultiFactor<float[]>
val bumpVegaPV: float
val assetPhiBump: Model.EQ
val mcModelPhiBump: Model.MultiFactor<float[]>
val bumpPhiPV: float
val delta: Series<string,float>
val vega: Series<string,float>
val phi: Series<string,float>
val greeks: Frame<string,string>