Adding combo report classes (1)
This commit is contained in:
1 parent
41a072d4d2
commit
cb8a23c73f
7 files changed
+443
-119
No files matched your search
@@ -0,0 +1,26 @@
|
||||
using bts.api;
|
||||
|
||||
using mbts;
|
||||
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
using mbts.spark;
|
||||
|
||||
namespace BCG {
|
||||
internal class ComboDataModel : IDisposable {
|
||||
public ComboDataModel(string name, IBus bus) {
|
||||
bus.post(SparkTags.ReportBlackboardTags.Combo.Activate, name);
|
||||
data_stream = bus.subscribe<ComboFullData>(SparkTags.ReportBlackboardTags.Combo.DataOutput(name)).AsObservable();
|
||||
// TODO
|
||||
//_dispose = new DisposableSingle(GetType().FullName, () => bus.post(new ReportBlackboardTags.Combo.Deactivate(), name));
|
||||
}
|
||||
|
||||
//private readonly DisposableSingle _dispose;
|
||||
public readonly IObservable<ComboFullData> data_stream;
|
||||
|
||||
public void Dispose() {
|
||||
//_dispose.check_not_disposed();
|
||||
//_dispose.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using mbts;
|
||||
using mbts.analytics;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace BCG {
|
||||
internal class ComboOptionExpDateData {
|
||||
public ComboOptionExpDateData(IDictionary<string, ComboStrikeData> symbol_data) {
|
||||
this.symbol_data = new ReadOnlyDictionary<string, ComboStrikeData>(symbol_data);
|
||||
double call_pos =
|
||||
symbol_data.Values.Select(csd => csd.call_pos).Where(cp => !double.IsNaN(cp)).Sum();
|
||||
double put_pos =
|
||||
symbol_data.Values.Select(csd => csd.put_pos).Where(pp => !double.IsNaN(pp)).Sum();
|
||||
if (call_pos == 0.0 && put_pos == 0.0 &&
|
||||
!symbol_data.Values.Any(csd => (csd.call_raw_pos != 0.0 && !double.IsNaN(csd.call_raw_pos)) ||
|
||||
(csd.call_raw_pos != 0.0 && !double.IsNaN(csd.call_raw_pos))))
|
||||
aggregate = ComboStrikeData.Empty;
|
||||
else aggregate = new ComboStrikeData(call_pos, put_pos, double.NaN, double.NaN);
|
||||
}
|
||||
|
||||
public readonly IReadOnlyDictionary<string, ComboStrikeData> symbol_data;
|
||||
public readonly ComboStrikeData aggregate;
|
||||
}
|
||||
|
||||
internal class ComboFutureExpDateData {
|
||||
public ComboFutureExpDateData(IDictionary<string, ComboFutureData> symbol_data) {
|
||||
this.symbol_data = new ReadOnlyDictionary<string, ComboFutureData>(symbol_data);
|
||||
double pos =
|
||||
symbol_data.Values.Select(cfd => cfd.pos).Where(p => !double.IsNaN(p)).Sum();
|
||||
aggregate = new ComboFutureData(pos, double.NaN);
|
||||
}
|
||||
|
||||
public readonly ReadOnlyDictionary<string, ComboFutureData> symbol_data;
|
||||
public readonly ComboFutureData aggregate;
|
||||
}
|
||||
|
||||
internal class ComboFullData {
|
||||
public static readonly ComboFullData Empty =
|
||||
new ComboFullData(new ReportParameters(ReportType.Combo, string.Empty), null,
|
||||
new Dictionary<VolSurfaceExpiration, IDictionary<double, ComboStrikeData>>(),
|
||||
new Dictionary<VolSurfaceExpiration, Tuple<double, double>>());
|
||||
|
||||
public readonly TradeLogRow last_trade;
|
||||
public readonly ReportParameters report_parameters;
|
||||
private readonly IDictionary<VolSurfaceExpiration,
|
||||
ReadOnlyDictionary<double, ComboStrikeData>> _option_pos_map;
|
||||
private readonly IReadOnlyDictionary<VolSurfaceExpiration, Tuple<double, double>> _future_pos_map;
|
||||
|
||||
public ComboFullData(ReportParameters report_parameters,
|
||||
TradeLogRow latest_trade,
|
||||
IDictionary<VolSurfaceExpiration,
|
||||
IDictionary<double, ComboStrikeData>> option_pos_map,
|
||||
IDictionary<VolSurfaceExpiration, Tuple<double, double>> future_pos_map) {
|
||||
this.report_parameters = report_parameters;
|
||||
this.last_trade = latest_trade;
|
||||
_option_pos_map = option_pos_map.ToDictionary(
|
||||
kv => kv.Key,
|
||||
kv => new ReadOnlyDictionary<double, ComboStrikeData>(kv.Value));
|
||||
_future_pos_map = new ReadOnlyDictionary<VolSurfaceExpiration, Tuple<double, double>>(future_pos_map);
|
||||
}
|
||||
|
||||
public IEnumerable<VolSurfaceExpiration> option_expirations {
|
||||
get {
|
||||
return _option_pos_map.Keys;
|
||||
}
|
||||
}
|
||||
public IEnumerable<VolSurfaceExpiration> future_expirations {
|
||||
get {
|
||||
return _future_pos_map.Keys;
|
||||
}
|
||||
}
|
||||
public IEnumerable<double> strikes {
|
||||
get {
|
||||
return _option_pos_map.Values.SelectMany(kvp => kvp.Keys).Distinct();
|
||||
}
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<DateTime, ComboOptionExpDateData> get_option_exp_date_map(double strike) {
|
||||
return option_expirations.Select(vse => vse.expiration).Distinct().ToDictionary(
|
||||
exp_date => exp_date,
|
||||
exp_date => new ComboOptionExpDateData(
|
||||
_option_pos_map.Where(kv => kv.Key.expiration == exp_date).ToDictionary(
|
||||
kv => kv.Key.symbol, kv => kv.Value.GetValueOrDefault(strike) ?? ComboStrikeData.Empty)));
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<DateTime, ComboFutureExpDateData> get_future_exp_date_map() {
|
||||
return future_expirations.Select(vse => vse.expiration).Distinct().ToDictionary(
|
||||
exp_date => exp_date,
|
||||
exp_date => new ComboFutureExpDateData(
|
||||
_future_pos_map.Where(kv => kv.Key.expiration == exp_date).ToDictionary(
|
||||
kv => kv.Key.symbol, kv => new ComboFutureData(kv.Value.Item1, kv.Value.Item2))));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using mbts;
|
||||
using mbts.analytics;
|
||||
using mbts.spark;
|
||||
using bts.api;
|
||||
using System.Reactive.Linq;
|
||||
|
||||
namespace BCG {
|
||||
class SingleComboReportCalculator : IDisposable {
|
||||
private readonly bts.api.IBus _bus;
|
||||
private readonly ReportParameters _report_params;
|
||||
private readonly IList<IDisposable> _subscriptions = new List<IDisposable>();
|
||||
private bool _compute_dirty = false;
|
||||
private HighPerformanceTimer _timer = new HighPerformanceTimer();
|
||||
/// Data
|
||||
private IEnumerable<TradeLogRow> _trades;
|
||||
private IDictionary<mbts.SecurityTuple, double> _cpp_map;
|
||||
|
||||
public SingleComboReportCalculator(bts.api.IBus bus, ReportParameters report_params) {
|
||||
_bus = bus;
|
||||
_report_params = report_params;
|
||||
_subscriptions.Add(_bus.subscribe(
|
||||
SparkTags.VolSurfaceNonVolInputTag).OnDispatcher().Subscribe(_on_nonvol_input));
|
||||
_subscriptions.Add(_bus.subscribe(
|
||||
SparkTags.TradeLogTag).OnDispatcher().Subscribe(_on_trades));
|
||||
}
|
||||
|
||||
private void _on_nonvol_input(mbts.analytics.VolSurfaceNonVolInput nonvol_input) {
|
||||
_cpp_map = nonvol_input.get_cpp_map();
|
||||
_compute_dirty = true;
|
||||
}
|
||||
|
||||
private void _on_trades(IEnumerable<TradeLogRow> trades) {
|
||||
_trades = trades;
|
||||
_compute_dirty = true;
|
||||
}
|
||||
|
||||
private bool _compute_and_fire() {
|
||||
if (_cpp_map != null && _trades != null) {
|
||||
_timer.start();
|
||||
TradeLogRow latest_trade;
|
||||
IDictionary<VolSurfaceExpiration, IDictionary<double, ComboStrikeData>> option_data;
|
||||
IDictionary<VolSurfaceExpiration, Tuple<double, double>> future_data;
|
||||
IEnumerable<TradeLogRow> account_trades = _trades.Where(
|
||||
t => String.Compare(t.account, _report_params.internal_account, true) == 0);
|
||||
VolSurfaceRiskCalculator.compute_combo(
|
||||
account_trades, _cpp_map,
|
||||
new mbts.SecurityTuple(_report_params.risk_terms_type,
|
||||
_report_params.risk_terms_name,
|
||||
Venue.Unset),
|
||||
out latest_trade, out option_data, out future_data);
|
||||
/// Converting to mapped expirations. For Combo this could have been done
|
||||
/// in the UI layer, because the aggregation is different from Slide
|
||||
option_data = option_data.ToDictionary(kv => new VolSurfaceExpiration() {
|
||||
symbol = kv.Key.symbol,
|
||||
expiration = mbts.ui.utility.ExpirationFormatter.convert_real_to_mapped(
|
||||
SecurityType.Option, kv.Key.symbol, kv.Key.expiration)
|
||||
},
|
||||
kv => kv.Value);
|
||||
future_data = future_data.ToDictionary(kv => new VolSurfaceExpiration() {
|
||||
symbol = kv.Key.symbol,
|
||||
expiration = mbts.ui.utility.ExpirationFormatter.convert_real_to_mapped(
|
||||
SecurityType.Future, kv.Key.symbol, kv.Key.expiration)
|
||||
},
|
||||
kv => kv.Value);
|
||||
ComboFullData out_data =
|
||||
new ComboFullData(_report_params, latest_trade, option_data, future_data);
|
||||
_timer.stop();
|
||||
bts.Log.Gen.info(String.Format("Combo Report {0} trades time {1}",
|
||||
account_trades.Count(), _timer.lastIntervalTime));
|
||||
_bus.post(SparkTags.ReportBlackboardTags.Combo.DataOutput(_report_params.name),
|
||||
out_data);
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
private DateTime _last_fire_time = DateTime.MinValue;
|
||||
private readonly TimeSpan _period = TimeSpan.FromMilliseconds(1000.0);
|
||||
|
||||
#region IWorker
|
||||
// TODO
|
||||
public void doWork() {
|
||||
if (_compute_dirty && DateTime.Now - _last_fire_time > _period) {
|
||||
if (_compute_and_fire()) {
|
||||
_compute_dirty = false;
|
||||
_last_fire_time = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
public void Dispose() {
|
||||
Disposable.dispose(_subscriptions);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,33 @@
|
||||
// using bts.api;
|
||||
// using mbts;
|
||||
// using System;
|
||||
// using System.Reactive.Linq;
|
||||
|
||||
// namespace BCG
|
||||
// {
|
||||
// internal class SlideDataModel : IDisposable
|
||||
// {
|
||||
// public SlideDataModel(string name, IBus bus) {
|
||||
// _name = name;
|
||||
// _bus = bus;
|
||||
// data_stream = _bus.subscribe<SlideFullData>(new ReportBlackboardTags.Slide.SyncCalculationResponse(_name)).AsObservable();
|
||||
// _dispose = new DisposableSingle(GetType().FullName, () => _bus.post(new ReportBlackboardTags.Slide.Deactivate(), _name));
|
||||
// _bus.post(new ReportBlackboardTags.Slide.Activate(), _name);
|
||||
// }
|
||||
|
||||
// private readonly string _name;
|
||||
// private readonly IBus _bus;
|
||||
// private readonly DisposableSingle _dispose;
|
||||
|
||||
// public readonly IObservable<SlideFullData> data_stream;
|
||||
|
||||
// public void calculate() { _bus.post(new ReportBlackboardTags.Slide.SyncCalculationRequest(_name), true); }
|
||||
// public void set_ui_overrides(SlideModelUIOverrides ui_overrides) { _bus.post(new ReportBlackboardTags.Slide.UIOverrides(_name), ui_overrides); }
|
||||
// public void save_report_parameters(ReportParameters report_params) { _bus.post(new ReportBlackboardTags.SaveTag(), ReportPersistence.get_save_req(report_params)); }
|
||||
|
||||
// public void Dispose() {
|
||||
// _dispose.check_not_disposed();
|
||||
// _dispose.Dispose();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -1,138 +1,122 @@
|
||||
// using bts.o2.msgs;
|
||||
// using mbts;
|
||||
// using System;
|
||||
// using System.Collections.Generic;
|
||||
// using System.Linq;
|
||||
// using mbts.analytics;
|
||||
using mbts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using mbts.analytics;
|
||||
|
||||
// namespace BCG
|
||||
// {
|
||||
// class SlideGreekUnitKey : IEquatable<SlideGreekUnitKey>
|
||||
// {
|
||||
// public enum GroupType { SumAll, SumPostWeekly, SumPostMonthly, SumPostQuarterly, Exp, SymExp }
|
||||
namespace BCG {
|
||||
class SlideGreekUnitKey : IEquatable<SlideGreekUnitKey> {
|
||||
public enum GroupType { SumAll, SumPostWeekly, SumPostMonthly, SumPostQuarterly, Exp, SymExp }
|
||||
|
||||
// public static SlideGreekUnitKey get_sum_all_key() { return new SlideGreekUnitKey(GroupType.SumAll, "All"); }
|
||||
public static SlideGreekUnitKey get_sum_all_key() { return new SlideGreekUnitKey(GroupType.SumAll, "All"); }
|
||||
|
||||
// public static SlideGreekUnitKey get_sum_post_weekly_key() { return new SlideGreekUnitKey(GroupType.SumPostWeekly, "Post Weekly"); }
|
||||
public static SlideGreekUnitKey get_sum_post_weekly_key() { return new SlideGreekUnitKey(GroupType.SumPostWeekly, "Post Weekly"); }
|
||||
|
||||
// public static SlideGreekUnitKey get_sum_post_monthly_key() { return new SlideGreekUnitKey(GroupType.SumPostMonthly, "Post Monthly"); }
|
||||
public static SlideGreekUnitKey get_sum_post_monthly_key() { return new SlideGreekUnitKey(GroupType.SumPostMonthly, "Post Monthly"); }
|
||||
|
||||
// public static SlideGreekUnitKey get_sum_post_quarterly_key() { return new SlideGreekUnitKey(GroupType.SumPostQuarterly, "Post Quarterly"); }
|
||||
public static SlideGreekUnitKey get_sum_post_quarterly_key() { return new SlideGreekUnitKey(GroupType.SumPostQuarterly, "Post Quarterly"); }
|
||||
|
||||
// public static SlideGreekUnitKey get_exp_date_key(DateTime exp_date) { return new SlideGreekUnitKey(exp_date); }
|
||||
public static SlideGreekUnitKey get_exp_date_key(DateTime exp_date) { return new SlideGreekUnitKey(exp_date); }
|
||||
|
||||
// public static SlideGreekUnitKey get_symbol_exp_date_key(DateTime exp_date, string symbol) { return new SlideGreekUnitKey(exp_date, symbol); }
|
||||
public static SlideGreekUnitKey get_symbol_exp_date_key(DateTime exp_date, string symbol) { return new SlideGreekUnitKey(exp_date, symbol); }
|
||||
|
||||
// private SlideGreekUnitKey(GroupType type, string name)
|
||||
// {
|
||||
// _unique_name = display_name = name;
|
||||
// this.type = type;
|
||||
// }
|
||||
private SlideGreekUnitKey(GroupType type, string name) {
|
||||
_unique_name = display_name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
// private SlideGreekUnitKey(DateTime exp_date)
|
||||
// {
|
||||
// _exp = exp_date;
|
||||
// _unique_name = exp_date.ToShortDateString();
|
||||
// display_name = ContractUtilities.get_expiration_text_no_symbol(exp_date);
|
||||
// type = GroupType.Exp;
|
||||
// }
|
||||
private SlideGreekUnitKey(DateTime exp_date) {
|
||||
_exp = exp_date;
|
||||
_unique_name = exp_date.ToShortDateString();
|
||||
display_name = _unique_name; // TODO; ContractUtilities.get_expiration_text_no_symbol(exp_date);
|
||||
type = GroupType.Exp;
|
||||
}
|
||||
|
||||
// private SlideGreekUnitKey(DateTime exp_date, string symbol)
|
||||
// {
|
||||
// _exp = exp_date;
|
||||
// _symbol = symbol;
|
||||
// display_name = symbol;
|
||||
// _unique_name = "{0}:{1}".fmt(exp_date.ToShortDateString(), symbol);
|
||||
// type = GroupType.SymExp;
|
||||
// }
|
||||
private SlideGreekUnitKey(DateTime exp_date, string symbol) {
|
||||
_exp = exp_date;
|
||||
_symbol = symbol;
|
||||
display_name = symbol;
|
||||
_unique_name = "{0}:{1}".fmt(exp_date.ToShortDateString(), symbol);
|
||||
type = GroupType.SymExp;
|
||||
}
|
||||
|
||||
// private readonly DateTime _exp;
|
||||
// private readonly string _symbol;
|
||||
// private readonly string _unique_name;
|
||||
// public readonly string display_name;
|
||||
// public readonly GroupType type;
|
||||
private readonly DateTime _exp;
|
||||
private readonly string _symbol;
|
||||
private readonly string _unique_name;
|
||||
public readonly string display_name;
|
||||
public readonly GroupType type;
|
||||
|
||||
// public bool Equals(SlideGreekUnitKey other) { return other != null && other._unique_name == _unique_name; }
|
||||
public bool Equals(SlideGreekUnitKey other) { return other != null && other._unique_name == _unique_name; }
|
||||
|
||||
// public override bool Equals(object obj) { return Equals(obj as SlideGreekUnitKey); }
|
||||
public override bool Equals(object obj) { return Equals(obj as SlideGreekUnitKey); }
|
||||
|
||||
// public override int GetHashCode() { return _unique_name.GetHashCode(); }
|
||||
public override int GetHashCode() { return _unique_name.GetHashCode(); }
|
||||
|
||||
// public static int comp(SlideGreekUnitKey k1, SlideGreekUnitKey k2)
|
||||
// {
|
||||
// int rv = 0;
|
||||
// if (k1.type == GroupType.SumAll)
|
||||
// rv = -1;
|
||||
// else if (k1.type == GroupType.Exp)
|
||||
// {
|
||||
// if (k2.type == GroupType.SumAll)
|
||||
// rv = 1;
|
||||
// else
|
||||
// {
|
||||
// int exp_comp = k1._exp.CompareTo(k2._exp);
|
||||
// rv = exp_comp != 0 ? exp_comp : (k2.type == GroupType.SymExp ? -1 : exp_comp);
|
||||
// }
|
||||
// }
|
||||
// else if (k1.type == GroupType.SymExp)
|
||||
// {
|
||||
// if (k2.type == GroupType.SumAll)
|
||||
// rv = 1;
|
||||
// else
|
||||
// {
|
||||
// int exp_comp = k1._exp.CompareTo(k2._exp);
|
||||
// rv = exp_comp != 0 ? exp_comp : (k2.type == GroupType.Exp ? 1 : k1._symbol.CompareTo (k2._symbol));
|
||||
// }
|
||||
// }
|
||||
// return rv;
|
||||
// }
|
||||
// }
|
||||
public static int comp(SlideGreekUnitKey k1, SlideGreekUnitKey k2) {
|
||||
int rv = 0;
|
||||
if (k1.type == GroupType.SumAll)
|
||||
rv = -1;
|
||||
else if (k1.type == GroupType.Exp) {
|
||||
if (k2.type == GroupType.SumAll)
|
||||
rv = 1;
|
||||
else {
|
||||
int exp_comp = k1._exp.CompareTo(k2._exp);
|
||||
rv = exp_comp != 0 ? exp_comp : (k2.type == GroupType.SymExp ? -1 : exp_comp);
|
||||
}
|
||||
} else if (k1.type == GroupType.SymExp) {
|
||||
if (k2.type == GroupType.SumAll)
|
||||
rv = 1;
|
||||
else {
|
||||
int exp_comp = k1._exp.CompareTo(k2._exp);
|
||||
rv = exp_comp != 0 ? exp_comp : (k2.type == GroupType.Exp ? 1 : k1._symbol.CompareTo(k2._symbol));
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// class SlideFullData
|
||||
// {
|
||||
// public static SlideFullData empty(string report_name = "")
|
||||
// {
|
||||
// return new SlideFullData(new ReportParameters(ReportType.Slide, report_name),
|
||||
// Enumerable.Empty<SlideGreekUnitKey>(),
|
||||
// new Dictionary<SlideGreekUnitKey, IDictionary<double, SlideGreekUnit>>(),
|
||||
// null,
|
||||
// Enumerable.Empty<mbts.SecurityExpiration>(),
|
||||
// DateTime.MinValue,
|
||||
// null);
|
||||
// }
|
||||
class SlideFullData {
|
||||
public static SlideFullData empty(string report_name = "") {
|
||||
return new SlideFullData(new ReportParameters(ReportType.Slide, report_name),
|
||||
Enumerable.Empty<SlideGreekUnitKey>(),
|
||||
new Dictionary<SlideGreekUnitKey, IDictionary<double, SlideGreekUnit>>(),
|
||||
null,
|
||||
Enumerable.Empty<mbts.SecurityExpiration>(),
|
||||
DateTime.MinValue,
|
||||
null);
|
||||
}
|
||||
|
||||
// public readonly ReportParameters report_parameters;
|
||||
// public readonly IEnumerable<SlideGreekUnitKey> ordered_headers;
|
||||
// public readonly mbts.TradeLogRow last_trade;
|
||||
// public readonly DateTime last_volsave_time;
|
||||
// public readonly IEnumerable<mbts.SecurityExpiration> all_expirations;
|
||||
// public readonly SlideModelUIOverrides ui_override;
|
||||
// public readonly IDictionary<SlideGreekUnitKey, IDictionary<double, SlideGreekUnit>> _map;
|
||||
public readonly ReportParameters report_parameters;
|
||||
public readonly IEnumerable<SlideGreekUnitKey> ordered_headers;
|
||||
public readonly mbts.TradeLogRow last_trade;
|
||||
public readonly DateTime last_volsave_time;
|
||||
public readonly IEnumerable<mbts.SecurityExpiration> all_expirations;
|
||||
public readonly SlideModelUIOverrides ui_override;
|
||||
public readonly IDictionary<SlideGreekUnitKey, IDictionary<double, SlideGreekUnit>> _map;
|
||||
|
||||
// public SlideFullData(ReportParameters report_parameters,
|
||||
// IEnumerable<SlideGreekUnitKey> this_ordered_headers,
|
||||
// IDictionary<SlideGreekUnitKey, IDictionary<double, SlideGreekUnit>> map,
|
||||
// mbts.TradeLogRow this_last_trade,
|
||||
// IEnumerable<mbts.SecurityExpiration> all_expirations,
|
||||
// DateTime this_last_volsave_time,
|
||||
// SlideModelUIOverrides ui_override)
|
||||
// {
|
||||
// this.report_parameters = report_parameters;
|
||||
// ordered_headers = this_ordered_headers;
|
||||
// _map = map;
|
||||
// last_trade = this_last_trade;
|
||||
// this.all_expirations = all_expirations;
|
||||
// last_volsave_time = this_last_volsave_time;
|
||||
// this.ui_override = ui_override;
|
||||
// }
|
||||
public SlideFullData(ReportParameters report_parameters,
|
||||
IEnumerable<SlideGreekUnitKey> this_ordered_headers,
|
||||
IDictionary<SlideGreekUnitKey, IDictionary<double, SlideGreekUnit>> map,
|
||||
mbts.TradeLogRow this_last_trade,
|
||||
IEnumerable<mbts.SecurityExpiration> all_expirations,
|
||||
DateTime this_last_volsave_time,
|
||||
SlideModelUIOverrides ui_override) {
|
||||
this.report_parameters = report_parameters;
|
||||
ordered_headers = this_ordered_headers;
|
||||
_map = map;
|
||||
last_trade = this_last_trade;
|
||||
this.all_expirations = all_expirations;
|
||||
last_volsave_time = this_last_volsave_time;
|
||||
this.ui_override = ui_override;
|
||||
}
|
||||
|
||||
// public SlideGreekUnit get_data(SlideGreekUnitKey header, double slide_handle)
|
||||
// {
|
||||
// IDictionary<double, SlideGreekUnit> row = null;
|
||||
// SlideGreekUnit rv = null;
|
||||
// if (_map.TryGetValue(header, out row))
|
||||
// if (row.TryGetValue(slide_handle, out rv) && rv != null)
|
||||
// return rv;
|
||||
// return new SlideGreekUnit(Double.NaN, Enumerable.Repeat<double>(Double.NaN, report_parameters.ordered_greeks.Length).ToList());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
public SlideGreekUnit get_data(SlideGreekUnitKey header, double slide_handle) {
|
||||
IDictionary<double, SlideGreekUnit> row = null;
|
||||
SlideGreekUnit rv = null;
|
||||
if (_map.TryGetValue(header, out row))
|
||||
if (row.TryGetValue(slide_handle, out rv) && rv != null)
|
||||
return rv;
|
||||
return new SlideGreekUnit(Double.NaN, Enumerable.Repeat<double>(Double.NaN, report_parameters.ordered_greeks.Length).ToList());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,10 @@ namespace mbts.spark {
|
||||
|
||||
public static ITag<IReadOnlyDictionary<uint, ExecutionStrategyImmutable>> SyntheticstrategiesTag { get; } =
|
||||
_mk_tag<IReadOnlyDictionary<uint, ExecutionStrategyImmutable>>();
|
||||
|
||||
public static ITag<IEnumerable<TradeLogRow>> TradeLogTag { get; } =
|
||||
_mk_tag<IEnumerable<TradeLogRow>>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Order
|
||||
@@ -366,6 +370,84 @@ namespace mbts.spark {
|
||||
public static ITag<Nothing> VoidTag { get; } = _mk_tag<Nothing>();
|
||||
}
|
||||
|
||||
internal static class ReportBlackboardTags {
|
||||
// Publisher: ReportDataProvider
|
||||
public static ITag<IEnumerable<ReportParameters>> ListTag { get; } =
|
||||
_mk_tag<IEnumerable<ReportParameters>>();
|
||||
|
||||
public static class Slide {
|
||||
// Publisher: SlideDataModel
|
||||
public static ITag<string> Activate { get; } =
|
||||
_mk_tag<string>();
|
||||
|
||||
// Publisher: SlideDataModel
|
||||
public static ITag<string> Deactivate { get; } =
|
||||
_mk_tag<string>();
|
||||
|
||||
// Publisher: SlideDataModel
|
||||
public static ITag<bool> SyncCalculationRequest(string id) =>
|
||||
_mk_tag<bool, string>(id);
|
||||
|
||||
// Publisher: SingleSlideReportCalculator
|
||||
public static ITag<SlideFullData> SyncCalculationResponse(string id) =>
|
||||
_mk_tag<SlideFullData, string>(id);
|
||||
|
||||
// Publisher: SlideDataModel
|
||||
public static ITag<SlideModelUIOverrides> UIOverrides(string id) =>
|
||||
_mk_tag<SlideModelUIOverrides, string>(id);
|
||||
}
|
||||
|
||||
public static class Combo {
|
||||
// Publisher: SingleComboReportCalculator
|
||||
public static ITag<ComboFullData> DataOutput(string id) =>
|
||||
_mk_tag<ComboFullData, string>(id);
|
||||
|
||||
// Publisher: ComboDataModel
|
||||
public static ITag<string> Activate { get; } =
|
||||
_mk_tag<string>();
|
||||
|
||||
// Publisher: ComboDataModel
|
||||
public static ITag<string> Deactivate { get; } =
|
||||
_mk_tag<string>();
|
||||
}
|
||||
|
||||
// public static class PNL {
|
||||
// /// Publisher: PNLDataModel
|
||||
// /// Data: string (report_name)
|
||||
// public class Activate : EqualsHelper, IBlackboardTag { }
|
||||
|
||||
// /// Publisher: PNLDataModel
|
||||
// /// Data: string (report_name)
|
||||
// public class Deactivate : EqualsHelper, IBlackboardTag { }
|
||||
|
||||
// /// Publisher: PnLDataModel
|
||||
// /// Data: [bool] (just a placeholder type)
|
||||
// public class SyncCalculationRequest : KeyedTag<string>, IBlackboardTag {
|
||||
// public SyncCalculationRequest(string report_name) : base(report_name) { }
|
||||
// }
|
||||
|
||||
// /// Publisher: SinglePnLReportCalculator
|
||||
// /// Data: PnLFullData
|
||||
// public class SyncCalculationResponse : KeyedTag<string>, IBlackboardTag {
|
||||
// public SyncCalculationResponse(string report_name) : base(report_name) { }
|
||||
// }
|
||||
|
||||
// /// Publisher: PnLDataModel
|
||||
// /// Data: PnLModelUIOverrides
|
||||
// public class UIOverrides : KeyedTag<string>, IBlackboardTag {
|
||||
// public UIOverrides(string report_name) : base(report_name) { }
|
||||
// }
|
||||
// }
|
||||
|
||||
// /// Publisher: ReportConfigurationEditorVM
|
||||
// /// Data: ReportPersistence.SaveReportRequest
|
||||
// public class SaveTag : BusySpinnerRequestTag, IBlackboardTag { }
|
||||
|
||||
// /// Publisher: ReportShellModule
|
||||
// /// Data: ReportParameters
|
||||
// public class DeleteTag : BusySpinnerRequestTag, IBlackboardTag { }
|
||||
}
|
||||
|
||||
internal class SparkTag<T> : ITag<T> {
|
||||
readonly string _name;
|
||||
|
||||
|
||||
Reference in new issue
Block a user