SpreadBoxes can be brought up from MV

This commit is contained in:
Taha Afzal committed 2022-10-04 22:17:46 -04:00
1 parent 5c5e5c23ef
commit cc03f47d70
3 files changed
+25 -15

No files matched your search

@@ -57,7 +57,7 @@ namespace BCG {
private readonly TimeSpan _md_period = TimeSpan.FromMilliseconds(500);
private DateTime _last_md_time = DateTime.MinValue;
private SpreadDisplayForm(ThreadedBlackboard bb, string spreadId, Control originForm, SpreadInititialState initial_state, string user) {
private SpreadDisplayForm(ThreadedBlackboard bb, string spreadId, SpreadInititialState initial_state, string user) {
_user = user;
_bb = bb;
SharedState.init();
@@ -69,11 +69,11 @@ namespace BCG {
mySpreadControl.onLocked += new GUIChange(myOnLockStateChange);
mySpreadControl.onSizeChange += new GUIChange(myOnSpreadUIResize);
mySpreadControl.onTrade += new EventHandler(myHandleTrade);
myInit(spreadId, originForm, initial_state);
myInit(spreadId, initial_state);
VisibleChanged += (o, e) => myRefresh();
}
private void myInit(string spreadId, Control originForm, SpreadInititialState initial_state) {
private void myInit(string spreadId, SpreadInititialState initial_state) {
mySpreadControl.spread_id = spreadId;
myLockedForSpreads = false;
myWasClosed = false;
@@ -109,7 +109,7 @@ namespace BCG {
}
}
if (!location_set)
mySetLocationToDefaultLocation(originForm);
mySetLocationToDefaultLocation();
_adjust_for_phantom_location();
mySpreadControl.Focus();
_timer.Interval = 1;
@@ -150,7 +150,7 @@ namespace BCG {
Show();
}
private void mySetLocationToDefaultLocation(Control originForm) {
private void mySetLocationToDefaultLocation() {
Top = SharedState.location.Y + SharedState.new_window_delta.Item1;
Left = SharedState.location.X + SharedState.new_window_delta.Item2;
SharedState.location = Location;
@@ -349,8 +349,8 @@ namespace BCG {
#endregion
public static SpreadDisplayForm make(ThreadedBlackboard bb, string spreadId,
Control originForm, SpreadInititialState initial_state, string user) {
var f = new SpreadDisplayForm(bb, spreadId, originForm, initial_state, user);
SpreadInititialState initial_state, string user) {
var f = new SpreadDisplayForm(bb, spreadId, initial_state, user);
return f;
}
@@ -59,7 +59,7 @@ namespace BCG {
var driver_map = _bb.read_state(SparkTags.AllOptionDriverBBOTag);
var sspec = SpreadUtilities.create_option_spread_spec(sec_id, sc_data, driver_map);
if (sspec != null) {
bts.Log.Gen.info(sspec.ToString());
_create_brand_new_spread(sspec);
}
}
}
@@ -128,14 +128,14 @@ namespace BCG {
} else {
// new spread
curr_spread_id = _create_brand_new_spread(new_leg_contract, new_leg_price_spec,
new_leg_size, origin_widget, originated_externally, initial_state, user);
new_leg_size, originated_externally, initial_state, user);
}
return curr_spread_id;
}
private string _create_brand_new_spread(OptionContract new_leg_contract,
PriceSpec new_leg_price_spec, int new_leg_size, Control origin_widget,
bool originated_externally, SpreadInititialState initial_state, string user) {
PriceSpec new_leg_price_spec, int new_leg_size,
bool originated_externally, SpreadInititialState initial_state, string user) {
string spread_id = _get_new_spread_id();
_bb.post(SparkTags.SpreadBoxTags.SpreadLockedTag(spread_id),
new SpreadBoxLockedState(false));
@@ -143,17 +143,27 @@ namespace BCG {
new OptionContractPosition(new_leg_contract, new_leg_size, new_leg_price_spec) });
_bb.post(SparkTags.SpreadBoxTags.SpreadSpecTag(spread_id), new_spread_spec);
_bb.post(SparkTags.SpreadBoxTags.CurrentSpreadTag, spread_id);
_create_spread_specific_agents(_bb, new_spread_spec, spread_id, initial_state, user);
return spread_id;
}
private string _create_brand_new_spread(SpreadSpec new_spread_spec) {
string spread_id = _get_new_spread_id();
_bb.post(SparkTags.SpreadBoxTags.SpreadLockedTag(spread_id),
new SpreadBoxLockedState(true));
_bb.post(SparkTags.SpreadBoxTags.SpreadSpecTag(spread_id), new_spread_spec);
_bb.post(SparkTags.SpreadBoxTags.CurrentSpreadTag, spread_id);
_create_spread_specific_agents(_bb, new_spread_spec, spread_id,
origin_widget, initial_state, user);
new SpreadInititialState(), String.Empty);
return spread_id;
}
private void _create_spread_specific_agents(ThreadedBlackboard bb, SpreadSpec new_spec,
string new_id, Control origin_widget, SpreadInititialState initial_state, string user) {
string new_id, SpreadInititialState initial_state, string user) {
bts.Log.Gen.info($"SpreadManager._create_spread_specific_agents initialized creating " +
"$new spread id: {new_id}");
_bb.post(SparkTags.SpreadBoxTags.AllSpreadBoxIDsTag, _id_map.ToList());
SpreadDisplayForm.make(bb, new_id, origin_widget, initial_state, user);
SpreadDisplayForm.make(bb, new_id, initial_state, user);
}
private OptionContractPosition _create_leg(SpreadSpec exising_spec, OptionContract new_leg,
@@ -587,7 +587,7 @@ namespace BCG {
return null;
}
return new PriceSpec(sec.Symbol, dsec.Value.Symbol,
dsec_exp.Value, 0, Double.NaN, -1);
dsec_exp.Value, 0, -1, -1);
};
SecurityMD sec_md;
if (!sc_data.sec_md_map.TryGetValue(spread_id, out sec_md)) {