Skip to content

Commit

Permalink
Adds underlying meta to FxVega cubes
Browse files Browse the repository at this point in the history
  • Loading branch information
gavbrennan committed Nov 29, 2022
1 parent deed698 commit 6fdd7de
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
39 changes: 39 additions & 0 deletions clients/Qwack.Excel/Options/VolSurfaceFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
using Qwack.Excel.Curves;
using Qwack.Core.Cubes;
using Qwack.Transport.BasicTypes;
using Qwack.Transport.TransportObjects.MarketData.VolSurfaces;
using Newtonsoft.Json;

namespace Qwack.Excel.Options
{
Expand Down Expand Up @@ -526,5 +528,42 @@ public static object SurfaceToQuotes(
return rrbf.DisplayQuotes();
});
}

[ExcelFunction(Description = "Extracts TO from surface object", Category = CategoryNames.Volatility,
Name = CategoryNames.Volatility + "_" + nameof(SurfaceToTransportObject), IsThreadSafe = Parallel)]
public static object SurfaceToTransportObject(
[ExcelArgument(Description = "Surface name")] string SurfaceName,
[ExcelArgument(Description = "Transport Object filename")] string TOFileName)
{
return ExcelHelper.Execute(_logger, () =>
{
var surface = ContainerStores.GetObjectCache<IVolSurface>().GetObjectOrThrow(SurfaceName, $"Vol surface {SurfaceName} not found");
var jsonString = string.Empty;
if(surface.Value is RiskyFlySurface rrbf)
{
var to = rrbf.GetTransportObject();
jsonString = JsonConvert.SerializeObject(to);
}
else if (surface.Value is GridVolSurface gr)
{
var to = gr.GetTransportObject();
jsonString = JsonConvert.SerializeObject(to);
}
else if (surface.Value is ConstantVolSurface cv)
{
var to = cv.GetTransportObject();
jsonString = JsonConvert.SerializeObject(to);
}
if(jsonString != string.Empty)
{
System.IO.File.WriteAllText(TOFileName, jsonString);
return $"Wrote {jsonString.Length} chars to {TOFileName}";
}
return "Unable to convert surface object";
});
}
}
}
2 changes: 2 additions & 0 deletions src/Qwack.Models/Risk/BasicMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ public static ICube FxVega(this IPvModel pvModel, Currency reportingCcy)
{ TradeId, typeof(string) },
{ TradeType, typeof(string) },
{ AssetId, typeof(string) },
{ "Underlying", typeof(string) },
{ "PointDate", typeof(DateTime) },
{ PointLabel, typeof(string) },
{ Metric, typeof(string) }
Expand Down Expand Up @@ -326,6 +327,7 @@ public static ICube FxVega(this IPvModel pvModel, Currency reportingCcy)
{ TradeId, bumpedRows[i].MetaData[tidIx] },
{ TradeType, bumpedRows[i].MetaData[tTypeIx] },
{ AssetId, surface.Key },
{ "Underlying", surface.Key },
{ "PointDate", bCurve.Value.PillarDatesForLabel(bCurve.Key) },
{ PointLabel, bCurve.Key },
{ Metric, "Vega" }
Expand Down
2 changes: 1 addition & 1 deletion version.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<VersionPrefix>0.7.10</VersionPrefix>
<VersionPrefix>0.7.11</VersionPrefix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.10
0.7.11

0 comments on commit 6fdd7de

Please sign in to comment.