Added ability to view md/theo in USD, in the sheets
This commit is contained in:
1 parent
e159e0e77b
commit
c1951ac49a
4 files changed
+89
-2
No files matched your search
@@ -165,5 +165,28 @@ namespace BCG
|
||||
return rv;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region accessors
|
||||
public BBOPacket get_bbo(uint sec_key) {
|
||||
foreach (var kv in _bbo_map) {
|
||||
var map = kv.Value;
|
||||
BBOPacket rv;
|
||||
if (map.TryGetValue(sec_key, out rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public mbts.spark.TheoPoint get_theo(bts.api.Venue exchange, string symbol,
|
||||
DateTime exp, double strike) {
|
||||
var sym = new NMSheetSymbol(exchange, symbol);
|
||||
NMSheetSingleOptionData sym_data;
|
||||
if (_sym_data_map.TryGetValue(sym, out sym_data)) {
|
||||
return sym_data.get_theo(exp, strike);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -279,5 +279,14 @@ namespace BCG {
|
||||
else
|
||||
return mbts.analytics.VolSurfaceCoreFunctions.compute_theo_at_nearbydriver(tp.driver, tp.put, tp.pdelta, tp.pgamma, effective_driver);
|
||||
}
|
||||
|
||||
#region accessors
|
||||
public TheoPoint get_theo(DateTime exp, double strike) {
|
||||
var rv = _theo_data_map.get_data(exp, strike);
|
||||
if (rv == null)
|
||||
return null;
|
||||
return rv.first;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+15
-1
@@ -100,6 +100,7 @@
|
||||
this._toolstripmenuitem_sheet_settings_window = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this._statusbar_toolstripstatus_security = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this._statusbar_vs_dropdown = new System.Windows.Forms.ToolStripComboBox();
|
||||
this._statusbar_toolstripstatus_md_theo = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this._statusbar_toolstripstatus_column = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this._statustrip_main = new System.Windows.Forms.StatusStrip();
|
||||
this._statusbar_toolstripstatus_task = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
@@ -726,6 +727,17 @@
|
||||
this._statusbar_vs_dropdown.Enabled = false;
|
||||
this._statusbar_vs_dropdown.Text = "Vol Time";
|
||||
this._statusbar_vs_dropdown.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// _statusbar_toolstripstatus_md_theo
|
||||
//
|
||||
this._statusbar_toolstripstatus_md_theo.Font = new System.Drawing.Font("Tahoma", 9F);
|
||||
this._statusbar_toolstripstatus_md_theo.Name = "_statusbar_toolstripstatus_md_theo";
|
||||
this._statusbar_toolstripstatus_md_theo.Size = new System.Drawing.Size(49, 17);
|
||||
this._statusbar_toolstripstatus_md_theo.Enabled = true;
|
||||
this._statusbar_toolstripstatus_md_theo.Text = "Test";
|
||||
this._statusbar_toolstripstatus_md_theo.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
this._statusbar_toolstripstatus_md_theo.BackColor = System.Drawing.Color.FromArgb(64, 64, 64);
|
||||
this._statusbar_toolstripstatus_md_theo.ForeColor = System.Drawing.Color.Yellow;
|
||||
//
|
||||
// _statusbar_toolstripstatus_column
|
||||
//
|
||||
@@ -741,7 +753,8 @@
|
||||
this._statustrip_main.GripMargin = new System.Windows.Forms.Padding(0);
|
||||
this._statustrip_main.GripStyle = System.Windows.Forms.ToolStripGripStyle.Visible;
|
||||
this._statustrip_main.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this._statusbar_vs_dropdown,
|
||||
this._statusbar_toolstripstatus_md_theo,
|
||||
// this._statusbar_vs_dropdown,
|
||||
this._statusbar_toolstripstatus_security,
|
||||
this._statusbar_toolstripstatus_task,
|
||||
this._statusbar_toolstripstatus_quoterdata,
|
||||
@@ -843,6 +856,7 @@
|
||||
private System.Windows.Forms.ToolStripStatusLabel _statusbar_toolstripstatus_security;
|
||||
|
||||
private System.Windows.Forms.ToolStripComboBox _statusbar_vs_dropdown;
|
||||
private System.Windows.Forms.ToolStripStatusLabel _statusbar_toolstripstatus_md_theo;
|
||||
|
||||
private System.Windows.Forms.ToolStripStatusLabel _statusbar_toolstripstatus_column;
|
||||
private System.Windows.Forms.StatusStrip _statustrip_main;
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
using bts.api;
|
||||
|
||||
using mbts.spark;
|
||||
using mbts.ui.converters;
|
||||
|
||||
namespace BCG {
|
||||
partial class NMSheetControl {
|
||||
private NMSheetTheoGrid.GridCell _last_mousemove_cell = null;
|
||||
@@ -19,6 +22,7 @@ namespace BCG {
|
||||
if (force_update || (_statusbar_dirty && DateTime.Now - _last_statusbar_update_time >= _statusbar_refresh_period)) {
|
||||
uint sec_key = _refresh_status_security_data();
|
||||
_refresh_status_column_data();
|
||||
_refresh_md_theo_data(sec_key);
|
||||
if (!_api_tasking_enabled) {
|
||||
_refresh_task_data(sec_key);
|
||||
}
|
||||
@@ -28,11 +32,48 @@ namespace BCG {
|
||||
}
|
||||
}
|
||||
|
||||
private void _refresh_md_theo_data(uint sec_key) {
|
||||
string null_txt = "---";
|
||||
Func<BBOPacket, TheoPoint, bool, String> md_txt = (md, tp, is_bid) => {
|
||||
if (md == null) {
|
||||
return null_txt;
|
||||
}
|
||||
var fwd = tp == null ? Double.NaN : tp.fwd;
|
||||
double pr = is_bid ? md.md.bid_price : md.md.ask_price;
|
||||
double qty = is_bid ? md.md.bid_size : md.md.ask_size;
|
||||
double adjusted_pr = pr * fwd;
|
||||
if (Double.IsNaN(adjusted_pr)) {
|
||||
return null_txt;
|
||||
}
|
||||
string price_txt = Math.Round(adjusted_pr, 2).ToString();
|
||||
return $"{price_txt} / {qty}";
|
||||
};
|
||||
Func<TheoPoint, bool, string> theo_txt = (tp, is_call) => {
|
||||
if (tp == null)
|
||||
return null_txt;
|
||||
double theo = is_call ? tp.call : tp.put;
|
||||
return Math.Round(theo, 2).ToString();
|
||||
};
|
||||
BBOPacket md = _sheet_data.get_bbo(sec_key);
|
||||
TheoPoint tp = _sheet_data.get_theo(
|
||||
_last_mousemove_cell.expiration.nmsheet_symbol.option_exchange,
|
||||
_last_mousemove_cell.expiration.nmsheet_symbol.option_name,
|
||||
_last_mousemove_cell.expiration.option_expiration,
|
||||
_last_mousemove_cell.strike);
|
||||
_statusbar_toolstripstatus_md_theo.Text =
|
||||
$"{md_txt(md, tp, true)} | " +
|
||||
$"{theo_txt(tp, _last_mousemove_cell.call_selected)} | " +
|
||||
$"{md_txt(md, tp, false)}";
|
||||
}
|
||||
|
||||
private uint _refresh_status_security_data() {
|
||||
uint seckey = _get_seckey();
|
||||
string key_text = seckey == 0 ? "(Unlisted)" : String.Format("(Key:{0})", seckey);
|
||||
_set_text_visibility(_statusbar_toolstripstatus_security, true,
|
||||
String.Format("{0} {1} {2} {3}", _formatter.format_expiration(_last_mousemove_cell.expiration), _last_mousemove_cell.strike, _last_mousemove_cell.call_selected ? "C" : "P", key_text));
|
||||
String.Format("{0} {1} {2} {3}",
|
||||
_formatter.format_expiration(_last_mousemove_cell.expiration),
|
||||
Math.Round(_last_mousemove_cell.strike, 2),
|
||||
_last_mousemove_cell.call_selected ? "C" : "P", key_text));
|
||||
return seckey;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user