Adding call to save theos

This commit is contained in:
Taha Afzal committed 2022-03-03 16:25:04 -05:00
1 parent 70def3ce72
commit a17fcb50c4
2 files changed
+25

No files matched your search

@@ -97,6 +97,9 @@ namespace mbts.spark {
Log.Gen.info(String.Format(
"SingleVolSurfaceGateway._on_bb_data Time to commit volsurface {0} {1} msecs",
_volsurface_id, _timer.lastIntervalTime));
var archived_theos = _get_theos();
if (archived_theos != null)
_analytics_service.archive_theos(archived_theos);
} catch (Exception ex) {
Log.Gen.warn(ex.ToString());
_bb.post(SparkTags.MessageDisplayTag,
@@ -122,6 +125,27 @@ namespace mbts.spark {
vssr.connected_symbols = distinct_syms;
}
private bts.api.analytics.ArchivedTheoList _get_theos() {
ArchivedTheoList rv = new ArchivedTheoList();
IReadOnlyDictionary<uint, GreeksTuple> theo_map = _bb.read_state(SparkTags.Greeks);
SystemContractData sc_data = _bb.read_state(SparkTags.SystemContractsTag);
if (theo_map == null || sc_data == null)
return null;
foreach (var kv in theo_map) {
var sec = sc_data.get_sec_md(kv.Key);
GreeksTuple gtup = kv.Value;
if (sec != null) {
var asec_theo = new ArchivedSecurityTheo();
asec_theo.Driver = gtup.driver;
asec_theo.Theo = gtup.theo;
asec_theo.Vol = gtup.vol;
asec_theo.Delta = gtup.delta;
rv.SecTheo.Add(asec_theo);
}
}
return rv;
}
#region Disposable
public void Dispose() {
_bb.data_callback -= _on_bb_data;
@@ -5,6 +5,7 @@ using bts.api;
using mbts.ui;
namespace mbts.spark {
// Publishes theos for all options (on the side, also publishes the theos for TC2)
public class LiveTheoPublisher : IDisposable {
private ThreadedBlackboard _bb;
private readonly ITag<IReadOnlyDictionary<string, OptionTheoInterpolationData>>