diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 1484e76be..ad0466afe 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -28,6 +28,7 @@ "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/shared", "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/winrt", "${workspaceRoot}/src", + "${workspaceRoot}/build/src", "${workspaceRoot}/externals/windows/include", "${workspaceRoot}/externals/linux/include", "${localappdata}/lxss/rootfs/usr/include/c++/5", diff --git a/src/client/spark/core/GlobalExtensions/ContractExtensions.cs b/src/client/spark/core/GlobalExtensions/ContractExtensions.cs deleted file mode 100644 index a833bd7e0..000000000 --- a/src/client/spark/core/GlobalExtensions/ContractExtensions.cs +++ /dev/null @@ -1,11 +0,0 @@ -using bts.security_model; -using System; - -namespace mbts -{ - static class ContractExtensions - { - public static DateTime expiration(this OptionContract option) { return new DateTime((int)option.expiration_year, (int)option.expiration_month, (int)option.expiration_day); } - public static DateTime expiration(this FutureContract future) { return new DateTime((int)future.expiration_year, (int)future.expiration_month, (int)future.expiration_day); } - } -} \ No newline at end of file diff --git a/src/client/spark/core/data/SecurityTuple.cs b/src/client/spark/core/data/SecurityTuple.cs index ee0c9d2cc..d88dbcb6d 100644 --- a/src/client/spark/core/data/SecurityTuple.cs +++ b/src/client/spark/core/data/SecurityTuple.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using bts.security_model; using ProtoBuf; +using bts.api; namespace mbts { @@ -14,17 +14,17 @@ namespace mbts class SecurityTuple : IComparable, IEquatable { [ProtoMember(1)] - public readonly SecurityType.type security_type; + public readonly SecurityType security_type; [ProtoMember(2)] public readonly string security_name; [ProtoMember(3)] - public readonly Exchange.type security_exchange; - public readonly static SecurityTuple empty = new SecurityTuple(SecurityType.type.UNSET, String.Empty, Exchange.type.UNSET); + public readonly Venue security_exchange; + public readonly static SecurityTuple empty = new SecurityTuple(SecurityType.Unset, String.Empty, Venue.Unset); public SecurityTuple() { } - public SecurityTuple(SecurityType.type the_security_type, + public SecurityTuple(SecurityType the_security_type, string the_security_name, - Exchange.type the_security_exchange) + Venue the_security_exchange) { security_type = the_security_type; security_name = the_security_name; @@ -33,7 +33,7 @@ namespace mbts public bool is_empty() { return Equals(empty); } - public SecurityTuple unset_exchange() { return new SecurityTuple(security_type, security_name, Exchange.type.UNSET); } + public SecurityTuple unset_exchange() { return new SecurityTuple(security_type, security_name, Venue.Unset); } #region Object overrides public override int GetHashCode() { return security_type.GetHashCode() ^ security_name.GetHashCode() ^ security_exchange.GetHashCode(); } diff --git a/src/client/spark/core/user/settings/ISecurityBasedSettings.cs b/src/client/spark/core/user/settings/ISecurityBasedSettings.cs index 039255243..bdc1bde6d 100644 --- a/src/client/spark/core/user/settings/ISecurityBasedSettings.cs +++ b/src/client/spark/core/user/settings/ISecurityBasedSettings.cs @@ -1,4 +1,4 @@ -using bts.security_model; +using bts.api; using System.ComponentModel.Composition; namespace mbts.user.settings @@ -6,7 +6,7 @@ namespace mbts.user.settings [InheritedExport] internal interface ISecurityBasedSettingsFactory { - SecurityBasedSettings get(Exchange.type exchange, SecurityType.type type, string symbol); + SecurityBasedSettings get(Venue exchange, SecurityType type, string symbol); } internal interface ISecurityBasedSettingsFactory : ISecurityBasedSettingsFactory where T : class diff --git a/src/client/spark/mspark/Algo/ClientAPI/AlgoClient.cs b/src/client/spark/mspark/Algo/ClientAPI/AlgoClient.cs index d34117e7d..49a3b4d7a 100644 --- a/src/client/spark/mspark/Algo/ClientAPI/AlgoClient.cs +++ b/src/client/spark/mspark/Algo/ClientAPI/AlgoClient.cs @@ -62,9 +62,9 @@ namespace mbts.spark var tocancel = _orders.Values.Where(x => security_ids.Contains(x.security.Id)); List> result = new List>(); if(buys) - result.AddRange(tocancel.Where(x => x.side == BuySell.Buy).Select(x => x.cancel())); + result.AddRange(tocancel.Where(x => x.side == Side.Buy).Select(x => x.cancel())); if(sells) - result.AddRange(tocancel.Where(x => x.side == BuySell.Sell).Select(x => x.cancel())); + result.AddRange(tocancel.Where(x => x.side == Side.Sell).Select(x => x.cancel())); if(result.Any()) return Task.Factory.ContinueWhenAll(result.ToArray(), x => new ActionResult { result = true }); diff --git a/src/client/spark/mspark/Algo/Interfaces/IOrderHandle.cs b/src/client/spark/mspark/Algo/Interfaces/IOrderHandle.cs index 13f48fb9f..4ca09e6de 100644 --- a/src/client/spark/mspark/Algo/Interfaces/IOrderHandle.cs +++ b/src/client/spark/mspark/Algo/Interfaces/IOrderHandle.cs @@ -19,7 +19,7 @@ namespace mbts.spark //I don't think services will expose these..... OrderID order_id { get; } Security security { get; } - bts.api.BuySell side { get; } + bts.api.Side side { get; } } //This interface is a standin for the I that Pedro will generate diff --git a/src/client/spark/mspark/Algo/OrderFacade.cs b/src/client/spark/mspark/Algo/OrderFacade.cs index bd26bcd89..d2bd5bf00 100644 --- a/src/client/spark/mspark/Algo/OrderFacade.cs +++ b/src/client/spark/mspark/Algo/OrderFacade.cs @@ -43,7 +43,7 @@ namespace mbts.spark.orders } } - public BuySell side + public Side side { get { diff --git a/src/client/spark/mspark/Algo/Orders/ComplexSpreader/CrossingHedgeOrderActor.cs b/src/client/spark/mspark/Algo/Orders/ComplexSpreader/CrossingHedgeOrderActor.cs index 8ccae4f74..835dde63e 100644 --- a/src/client/spark/mspark/Algo/Orders/ComplexSpreader/CrossingHedgeOrderActor.cs +++ b/src/client/spark/mspark/Algo/Orders/ComplexSpreader/CrossingHedgeOrderActor.cs @@ -54,7 +54,7 @@ namespace mbts.spark.orders if(_status != null) { PriceSize bid_or_ask; - if(_status.Order.Side == BuySell.Buy) + if(_status.Order.Side == Side.Buy) bid_or_ask = bbo.Item2; else bid_or_ask = bbo.Item1; diff --git a/src/client/spark/mspark/Algo/Orders/ComplexSpreader/SyntheticLimitOrder.cs b/src/client/spark/mspark/Algo/Orders/ComplexSpreader/SyntheticLimitOrder.cs index 485715a0b..4e337f399 100644 --- a/src/client/spark/mspark/Algo/Orders/ComplexSpreader/SyntheticLimitOrder.cs +++ b/src/client/spark/mspark/Algo/Orders/ComplexSpreader/SyntheticLimitOrder.cs @@ -40,7 +40,7 @@ namespace mbts.spark.orders { IOrderHandle current_order = _children.Values .Where(x => x.security.Equals(sec) && !_hedges.Contains(x.order_id)).FirstOrDefault(); - double price; uint size; BuySell side; IReadOnlyList this_leg_book; + double price; uint size; Side side; IReadOnlyList this_leg_book; if(compute_quote_price_size(sec, out price, out size, out side, out this_leg_book)) { if(size == 0) @@ -65,7 +65,7 @@ namespace mbts.spark.orders } } - void update_existing_order(IOrderHandle current_order, double new_price, uint new_size, BuySell side, + void update_existing_order(IOrderHandle current_order, double new_price, uint new_size, Side side, IReadOnlyList this_leg_book, SyntheticLegExecutionParams param, bool bypass_quote_rules) { OrderStatus status; @@ -99,17 +99,17 @@ namespace mbts.spark.orders double filled_size(Security sec) { double sum = _child_fills.Where(x => sec.Equals(x.Order.Security)) - .Sum(x => x.Size * (x.Side == BuySell.Buy ? 1.0 : -1.0)); + .Sum(x => x.Size * (x.Side == Side.Buy ? 1.0 : -1.0)); return sum; } bool compute_quote_price_size(Security leg, out double final_price, out uint final_size, - out BuySell final_side, out IReadOnlyList this_leg_book) + out Side final_side, out IReadOnlyList this_leg_book) { //this is the price we want the spread, this algorithm works backwards from this price to get the price of the quote leg final_price = _order_price * -1.0; //-X means credit final_size = 0; - final_side = BuySell.Buy; + final_side = Side.Buy; this_leg_book = null; bool hit_myself = false; foreach(Security sec in _leg_ratios.Keys) @@ -128,12 +128,12 @@ namespace mbts.spark.orders final_size = Convert.ToUInt32(Math.Abs(needed_quote_size)); if(quote_size > 0.0) { - final_side = BuySell.Buy; + final_side = Side.Buy; this_leg_book = _books[sec].Item1; } else if(quote_size < 0.0) { - final_side = BuySell.Sell; + final_side = Side.Sell; this_leg_book = _books[sec].Item2; } hit_myself = quote_size != 0.0; @@ -175,7 +175,7 @@ namespace mbts.spark.orders } if(!ok) return false; - final_price = (quote_size < 0.0 ? -1 : 1) * (_order.Side == BuySell.Sell ? -1 : 1) * leg_price + final_price = (quote_size < 0.0 ? -1 : 1) * (_order.Side == Side.Sell ? -1 : 1) * leg_price + final_price; _hedge_info[sec] = new HedgeInfo { leg = sec, price = leg_price, size = quote_size, leg_params = param }; } diff --git a/src/client/spark/mspark/Algo/Orders/ComplexSpreader/SyntheticMarketOrder.cs b/src/client/spark/mspark/Algo/Orders/ComplexSpreader/SyntheticMarketOrder.cs index f241b885d..44f8bd50a 100644 --- a/src/client/spark/mspark/Algo/Orders/ComplexSpreader/SyntheticMarketOrder.cs +++ b/src/client/spark/mspark/Algo/Orders/ComplexSpreader/SyntheticMarketOrder.cs @@ -27,7 +27,7 @@ namespace mbts.spark.orders { if(param.QuoteParams.IsWorking) { - BuySell side = kv.Value > 0.0 ? BuySell.Buy : BuySell.Sell; + Side side = kv.Value > 0.0 ? Side.Buy : Side.Sell; uint size = Convert.ToUInt32(Math.Abs(kv.Value * _order.Size)); spawn_market_order(kv.Key, size, side, _order.TimeInForce); //break; //only send market for one working leg, the rest should come out in the hedge diff --git a/src/client/spark/mspark/Algo/Orders/ComplexSpreader/SyntheticOrderBase.cs b/src/client/spark/mspark/Algo/Orders/ComplexSpreader/SyntheticOrderBase.cs index 08cb2ac97..850a2f07b 100644 --- a/src/client/spark/mspark/Algo/Orders/ComplexSpreader/SyntheticOrderBase.cs +++ b/src/client/spark/mspark/Algo/Orders/ComplexSpreader/SyntheticOrderBase.cs @@ -72,7 +72,7 @@ namespace mbts.spark.orders reduce_and_hedge(fill).ContinueWith( _ => { }); } - protected void clear_working(Security sec, BuySell side) + protected void clear_working(Security sec, Side side) { reduce_working(sec, 0, side, null, true).ContinueWith(_ => { }); } @@ -88,12 +88,12 @@ namespace mbts.spark.orders } } - protected async Task reduce_working(Security sec, uint size, BuySell side, OrderID oid = null, bool all = false) + protected async Task reduce_working(Security sec, uint size, Side side, OrderID oid = null, bool all = false) { bool gotone = false; - var existing = _child_status.Where(x => x.Value.Order.Security.Equals(sec) && + var existing = _child_status.Where((Func, bool>)((KeyValuePair x) => (bool)(x.Value.Order.Security.Equals(sec) && x.Value.Order.Side == side && - !_hedges.Contains(x.Key) ); + !_hedges.Contains(x.Key))) ); foreach(var x in existing) { if(!x.Key.Equals(oid ?? new OrderID())) @@ -125,7 +125,7 @@ namespace mbts.spark.orders if(fill.Order.Security.Equals(kv.Key)) continue; //don't hedge yourself - var hedge_side = (kv.Value.size > 0.0) ? BuySell.Buy : BuySell.Sell; + var hedge_side = (kv.Value.size > 0.0) ? Side.Buy : Side.Sell; double ratio = _leg_ratios[kv.Key]; uint hedge_size = Convert.ToUInt32(Math.Abs(ratio) * fill.Size); double hedge_price = kv.Value.price; @@ -168,12 +168,12 @@ namespace mbts.spark.orders } } - double compute_hedge_price(Security security, BuySell side, uint size, SyntheticLegExecutionParams param, double base_price) + double compute_hedge_price(Security security, Side side, uint size, SyntheticLegExecutionParams param, double base_price) { if(param.HedgeParams.PaylessHedgeRules.EnablePayless || param.HedgeParams.PayupHedgeRules.EnablePayup) { PriceSize bbo; - if(side == BuySell.Buy) + if(side == Side.Buy) bbo = _books[security].Item2.Where(x => Math.Abs(x.price - base_price) < 1e-5).DefaultIfEmpty(PriceSize.no_market).First(); else bbo = _books[security].Item1.Where(x => Math.Abs(x.price - base_price) < 1e-5).DefaultIfEmpty(PriceSize.no_market).First(); @@ -184,14 +184,14 @@ namespace mbts.spark.orders return base_price; } - void check_payup(PriceSize bbo, Security security, BuySell side, uint size, SyntheticLegExecutionParams param, ref double price) + void check_payup(PriceSize bbo, Security security, Side side, uint size, SyntheticLegExecutionParams param, ref double price) { var rules = param.HedgeParams.PayupHedgeRules; if(rules.EnablePayup) { double tick = compute_tick(security); double ratio = rules.RatioThreshold <= 0.0 ? 1.0 : rules.RatioThreshold; - if(side == BuySell.Buy) + if(side == Side.Buy) { if(bbo.size <= rules.SizeThreshold || bbo.size <= ratio * size) price += tick * rules.PayupTicks; @@ -204,14 +204,14 @@ namespace mbts.spark.orders } } - void check_payless(PriceSize bbo, Security security, BuySell side, uint size, SyntheticLegExecutionParams param, ref double price) + void check_payless(PriceSize bbo, Security security, Side side, uint size, SyntheticLegExecutionParams param, ref double price) { var rules = param.HedgeParams.PaylessHedgeRules; if(rules.EnablePayless) { double tick = compute_tick(security); double ratio = rules.RatioThreshold <= 0.0 ? 1.0 : rules.RatioThreshold; - if(side == BuySell.Buy) + if(side == Side.Buy) { if(bbo.size >= rules.SizeThreshold || bbo.size >= ratio * size) price -= tick * rules.PaylessTicks; diff --git a/src/client/spark/mspark/Algo/Orders/OrderActorBase.cs b/src/client/spark/mspark/Algo/Orders/OrderActorBase.cs index c5da96b53..7e2402abf 100644 --- a/src/client/spark/mspark/Algo/Orders/OrderActorBase.cs +++ b/src/client/spark/mspark/Algo/Orders/OrderActorBase.cs @@ -26,7 +26,7 @@ namespace mbts.spark.orders order.ExecutionStrategy.SecurityIdToParams.ForEach(x => _execution_strategy.TryAdd(x.Key, x.Value)); } - protected IOrderHandle spawn_limit_order(Security sec, uint size, double price, BuySell side, + protected IOrderHandle spawn_limit_order(Security sec, uint size, double price, Side side, Order.Types.TimeInForce tif = Order.Types.TimeInForce.Day) { Order ord = new Order(); @@ -43,7 +43,7 @@ namespace mbts.spark.orders return algoorder; } - protected IOrderHandle spawn_market_order(Security sec, uint size, BuySell side, + protected IOrderHandle spawn_market_order(Security sec, uint size, Side side, Order.Types.TimeInForce tif = Order.Types.TimeInForce.Day) { Order ord = new Order(); @@ -59,7 +59,7 @@ namespace mbts.spark.orders return algoorder; } - protected IOrderHandle spawn_stop_limit_order(Security sec, uint size, double price, BuySell side, double stop_price, + protected IOrderHandle spawn_stop_limit_order(Security sec, uint size, double price, Side side, double stop_price, Order.Types.TimeInForce tif = Order.Types.TimeInForce.Day) { Order ord = new Order(); @@ -77,7 +77,7 @@ namespace mbts.spark.orders } - protected IOrderHandle spawn_stop_market_order(Security sec, uint size, BuySell side, double stop_price, + protected IOrderHandle spawn_stop_market_order(Security sec, uint size, Side side, double stop_price, Order.Types.TimeInForce tif = Order.Types.TimeInForce.Day) { Order ord = new Order(); diff --git a/src/client/spark/mspark/Algo/Orders/SimpleSpreader/SimpleHedgeOrderActor.cs b/src/client/spark/mspark/Algo/Orders/SimpleSpreader/SimpleHedgeOrderActor.cs index 05179f548..5d7252ccb 100644 --- a/src/client/spark/mspark/Algo/Orders/SimpleSpreader/SimpleHedgeOrderActor.cs +++ b/src/client/spark/mspark/Algo/Orders/SimpleSpreader/SimpleHedgeOrderActor.cs @@ -68,7 +68,7 @@ namespace mbts.spark.orders if(_status != null) { PriceSize inside_market; - if(_status.Order.Side == BuySell.Buy) + if(_status.Order.Side == Side.Buy) inside_market = bbo.Item2; else inside_market = bbo.Item1; @@ -83,7 +83,7 @@ namespace mbts.spark.orders if(post == null || _status == null || post.TicksThreshold == 0 || post.MarketCrossTicks == 0) return; - if(_status.Order.Side == BuySell.Buy) + if(_status.Order.Side == Side.Buy) { uint diff = Convert.ToUInt32((inside_market.price - _status.Order.Price) / _tick); if(diff >= post.TicksThreshold) diff --git a/src/client/spark/mspark/Algo/Orders/SimpleSpreader/SimpleOrderBase.cs b/src/client/spark/mspark/Algo/Orders/SimpleSpreader/SimpleOrderBase.cs index b6a56a54c..bdfadb195 100644 --- a/src/client/spark/mspark/Algo/Orders/SimpleSpreader/SimpleOrderBase.cs +++ b/src/client/spark/mspark/Algo/Orders/SimpleSpreader/SimpleOrderBase.cs @@ -38,7 +38,7 @@ namespace mbts.spark.orders //break the synthetic into a dictionary of listed sub-securities and the proper signed quantity per leg static void crack_synthetic(Security security, IDictionary listed_vs_signed_ratio, IDictionary listed_vs_price_mult, - BuySell side = BuySell.Buy, uint quantity = 1) + Side side = Side.Buy, uint quantity = 1) { if(security.ContractCase == Security.ContractOneofCase.Synthetic) { @@ -48,15 +48,15 @@ namespace mbts.spark.orders crack_synthetic(leg.Security, listed_vs_signed_ratio, listed_vs_price_mult, side, quantity); else { - listed_vs_signed_ratio.Add(leg.Security, leg.Quantity * (leg.Side == BuySell.Sell ? -1 : 1) * - quantity * (side == BuySell.Sell ? -1 : 1)); + listed_vs_signed_ratio.Add(leg.Security, leg.Quantity * (leg.Side == Side.Sell ? -1 : 1) * + quantity * (side == Side.Sell ? -1 : 1)); listed_vs_price_mult.Add(leg.Security, leg.PriceMultiplier == 0.0 ? 1.0 : leg.PriceMultiplier); } } } else { - listed_vs_signed_ratio.Add(security, quantity * (side == BuySell.Sell ? -1 : 1)); + listed_vs_signed_ratio.Add(security, quantity * (side == Side.Sell ? -1 : 1)); listed_vs_price_mult.Add(security, 1.0); } } @@ -80,7 +80,7 @@ namespace mbts.spark.orders return id; } - protected IOrderHandle create_order(Security sec, uint size, double price, BuySell side, + protected IOrderHandle create_order(Security sec, uint size, double price, Side side, Order.Types.TimeInForce tif = Order.Types.TimeInForce.Day, T algo_order_params = default(T)) where T : new() { diff --git a/src/client/spark/mspark/Algo/Orders/SimpleSpreader/SimpleSyntheticLimitOrder.cs b/src/client/spark/mspark/Algo/Orders/SimpleSpreader/SimpleSyntheticLimitOrder.cs index 1f2107d14..4fbca8a06 100644 --- a/src/client/spark/mspark/Algo/Orders/SimpleSpreader/SimpleSyntheticLimitOrder.cs +++ b/src/client/spark/mspark/Algo/Orders/SimpleSpreader/SimpleSyntheticLimitOrder.cs @@ -182,7 +182,7 @@ namespace mbts.spark.orders return ok; } - void new_quote_order(Security security, uint quote_size, double quote_price, BuySell quote_side, double hedge_price, + void new_quote_order(Security security, uint quote_size, double quote_price, Side quote_side, double hedge_price, SpreaderLegOrderInfo order_info) { order_info.handle = create_order(security, quote_size, quote_price, quote_side, _order.TimeInForce, new LimitOrder()); @@ -231,13 +231,13 @@ namespace mbts.spark.orders else walk_book(hedge_leg.book.Item2, hedge_size, out hedge_price_at_size); - quote_price += hedge_side * hedge_price_at_size * (_order.Side == BuySell.Sell ? -1 : 1); + quote_price += hedge_side * hedge_price_at_size * (_order.Side == Side.Sell ? -1 : 1); quote_price = Math.Round(Math.Abs(quote_price) / quote_leg.tick, MidpointRounding.AwayFromZero) * quote_leg.tick; if(quote_leg.order_info.handle == null && !double.IsNaN(quote_price)) //new order { int quote_size_signed = Convert.ToInt32(_order.Size * quote_leg.ratio); - BuySell quote_side = (quote_size_signed < 0 ? BuySell.Sell : BuySell.Buy); + Side quote_side = (quote_size_signed < 0 ? Side.Sell : Side.Buy); uint quote_size = Convert.ToUInt32(Math.Abs(quote_size_signed)); new_quote_order(quote_leg.security, quote_size, quote_price, quote_side, hedge_price_at_size, quote_leg.order_info); } @@ -257,7 +257,7 @@ namespace mbts.spark.orders int diff = Convert.ToInt32((quote_price - orig_price) / quote_leg.tick); if(diff != 0) { - if(quote_leg.status.Order.Side == BuySell.Buy) + if(quote_leg.status.Order.Side == Side.Buy) { if(diff >= param.Slop.InsideTicks || diff <= -param.Slop.OutsideTicks) return true; @@ -311,8 +311,8 @@ namespace mbts.spark.orders if(!hedge_leg.param.IsHedging) return; - double hedge_size_signed = hedge_leg.ratio * fill.Size * (fill.Side == BuySell.Buy ? 1.0 : -1.0); - var hedge_side = (hedge_size_signed > 0.0) ? BuySell.Buy : BuySell.Sell; + double hedge_size_signed = hedge_leg.ratio * fill.Size * (fill.Side == Side.Buy ? 1.0 : -1.0); + var hedge_side = (hedge_size_signed > 0.0) ? Side.Buy : Side.Sell; uint hedge_size = Convert.ToUInt32(Math.Abs(hedge_size_signed)); reduce_working_order(hedge_leg.status, hedge_leg.order_info, hedge_size); double hedge_price = quote_leg.order_info.last_hedge_price + hedge_leg.param.PreHedgePayupTicks * hedge_leg.tick; diff --git a/src/client/spark/mspark/Algo/Scratch/ScratchPad.cs b/src/client/spark/mspark/Algo/Scratch/ScratchPad.cs index 401d66841..19c3033fa 100644 --- a/src/client/spark/mspark/Algo/Scratch/ScratchPad.cs +++ b/src/client/spark/mspark/Algo/Scratch/ScratchPad.cs @@ -21,7 +21,7 @@ namespace mbts.spark internal interface IOrderStateWatcher { void on_order_status(bts.spark.OrderID order_id, bts.spark.OrderStatus.Types.Status status); - void on_fills(bts.spark.OrderID order_id, bts.api.BuySell side, uint qty, double price); + void on_fills(bts.spark.OrderID order_id, bts.api.Side side, uint qty, double price); } internal interface IOrderManager : IOrderStateWatcher @@ -48,7 +48,7 @@ namespace mbts.spark //OrderResult pause(OrderID order_id); /// send status void send_status(bts.spark.OrderID order_id, bts.spark.OrderStatus.Types.Status status); - void send_fill_status(bts.spark.OrderID order_id, bts.api.BuySell side, uint qty, double price); + void send_fill_status(bts.spark.OrderID order_id, bts.api.Side side, uint qty, double price); mbts.co2.IMDHandle get_md_handle(); } diff --git a/src/client/spark/mspark/Algo/Scratch/SingleLegQuoter.cs b/src/client/spark/mspark/Algo/Scratch/SingleLegQuoter.cs index 388c81e56..fa4727b3a 100644 --- a/src/client/spark/mspark/Algo/Scratch/SingleLegQuoter.cs +++ b/src/client/spark/mspark/Algo/Scratch/SingleLegQuoter.cs @@ -176,7 +176,7 @@ namespace mbts.spark _handler_map[_state](e); } - private void _on_fill(double price, BuySell side, uint qty) + private void _on_fill(double price, Side side, uint qty) { _price_qty_state.update_fills(qty); _handler_map[_state](ExternalEvents.OrderFills); @@ -330,7 +330,7 @@ namespace mbts.spark #region External Calls - public void set_other_leg_fill(uint sec_key, bts.api.BuySell side, uint fill_qty) + public void set_other_leg_fill(uint sec_key, bts.api.Side side, uint fill_qty) { /// reduce the leg qty and send out a hedge request uint equivelant_qty = _get_equivelant_qty(sec_key, fill_qty); diff --git a/src/client/spark/mspark/Core/OrderUtils.cs b/src/client/spark/mspark/Core/OrderUtils.cs index b9ccbb82e..7d8e0433b 100644 --- a/src/client/spark/mspark/Core/OrderUtils.cs +++ b/src/client/spark/mspark/Core/OrderUtils.cs @@ -73,7 +73,7 @@ namespace mbts.spark { public static class Compare { public static readonly IComparer DepthComparer = CompareUtils.NullCheckComparer(depth_compare_never_null); public static int depth_compare(Order x, Order y) { return CompareUtils.NullCheckCompare(x, y, depth_compare_never_null); } - private static int depth_compare_never_null(Order x, Order y) { return x.Side == y.Side ? x.Side == BuySell.Buy ? y.Price.CompareTo(x.Price) : x.Price.CompareTo(y.Price) : x.Side == BuySell.Buy ? 1 : -1; } + private static int depth_compare_never_null(Order x, Order y) { return x.Side == y.Side ? x.Side == Side.Buy ? y.Price.CompareTo(x.Price) : x.Price.CompareTo(y.Price) : x.Side == Side.Buy ? 1 : -1; } } } } \ No newline at end of file diff --git a/src/client/spark/mspark/Core/PositionSource.cs b/src/client/spark/mspark/Core/PositionSource.cs index 6c11a2880..fde9c4891 100644 --- a/src/client/spark/mspark/Core/PositionSource.cs +++ b/src/client/spark/mspark/Core/PositionSource.cs @@ -25,7 +25,7 @@ namespace mbts.spark public void initialize() { _orders_model.on_orderbook().Subscribe(ob => _bus.post(SparkTags.PositionsTag, new SparkBusData.PositionsMessage( new ReadOnlyDictionary(ob.get_fill_sec_map().MapAggregate(kv => kv.Key, - kv => kv.Value.Select(f => f.Side == BuySell.Buy ? (int)f.Size : -(int)f.Size).Sum(), 0, (x, y) => x + y))))); + kv => kv.Value.Select(f => f.Side == Side.Buy ? (int)f.Size : -(int)f.Size).Sum(), 0, (x, y) => x + y))))); } } } \ No newline at end of file diff --git a/src/client/spark/mspark/Core/SyntheticSecurityMDHandle.cs b/src/client/spark/mspark/Core/SyntheticSecurityMDHandle.cs index 074419b1a..02258abd6 100644 --- a/src/client/spark/mspark/Core/SyntheticSecurityMDHandle.cs +++ b/src/client/spark/mspark/Core/SyntheticSecurityMDHandle.cs @@ -33,10 +33,10 @@ namespace mbts.spark public class DepthTraversal { public List levels; - public readonly BuySell side; + public readonly Side side; public readonly double mult; - public DepthTraversal(BuySell side, double mult, NativePriceSize[] depth) + public DepthTraversal(Side side, double mult, NativePriceSize[] depth) { this.side = side; this.mult = Math.Abs(mult); @@ -72,7 +72,7 @@ namespace mbts.spark } private readonly Security _security; - private IEnumerable> _legs; + private IEnumerable> _legs; private const uint _default_book_size = 10; public SyntheticSecurityMDHandle(Security security, IDictionary md_handles) { @@ -202,26 +202,26 @@ namespace mbts.spark private NativePriceSize[] _leg_bids, _leg_asks; - private static BuySell _opp_side(BuySell side) { return side == BuySell.Buy ? BuySell.Sell : BuySell.Buy; } + private static Side _opp_side(Side side) { return side == Side.Buy ? Side.Sell : Side.Buy; } public bool get_depth(ref ulong time, ref NativePriceSize[] bids, ref NativePriceSize[] asks) { - IEnumerable> t_asks = _get_depth(BuySell.Sell), t_bids = _get_depth(BuySell.Buy); + IEnumerable> t_asks = _get_depth(Side.Sell), t_bids = _get_depth(Side.Buy); time = 0; bids = t_bids.Select(t => _from_price_size(t)).ToArray(); asks = t_asks.Select(t => _from_price_size(t)).ToArray(); return true; } - private IEnumerable> _get_depth(BuySell side) + private IEnumerable> _get_depth(Side side) { List leg_travs = new List(); foreach (var t in _legs) { - SecurityMD md = t.Item1; BuySell leg_side = t.Item2; double leg_qty = t.Item3; + SecurityMD md = t.Item1; Side leg_side = t.Item2; double leg_qty = t.Item3; md.md.get_depth(ref _leg_bids, ref _leg_asks); - BuySell eff_side = side == BuySell.Buy ? leg_side : _opp_side(leg_side); - DepthTraversal leg_traversal = new DepthTraversal(leg_side, leg_qty, eff_side == BuySell.Buy ? _leg_bids : _leg_asks); + Side eff_side = side == Side.Buy ? leg_side : _opp_side(leg_side); + DepthTraversal leg_traversal = new DepthTraversal(leg_side, leg_qty, eff_side == Side.Buy ? _leg_bids : _leg_asks); leg_travs.Add(leg_traversal); } List> rv = new List>(); @@ -239,7 +239,7 @@ namespace mbts.spark foreach (DepthTraversal t in leg_travs) { double leg_price = t.down(min_head); - price_at_this_level += leg_price * t.mult * (t.side == BuySell.Buy ? 1.0 : -1.0); + price_at_this_level += leg_price * t.mult * (t.side == Side.Buy ? 1.0 : -1.0); } rv.Add(Tuple.Create(price_at_this_level, min_head)); } diff --git a/src/client/spark/mspark/Ladder/LadderGridHost.cs b/src/client/spark/mspark/Ladder/LadderGridHost.cs index 1fb613ca0..a168f6fee 100644 --- a/src/client/spark/mspark/Ladder/LadderGridHost.cs +++ b/src/client/spark/mspark/Ladder/LadderGridHost.cs @@ -53,7 +53,7 @@ namespace mbts.spark { DataContextChanged += (s, e) => _connect_vm(); } - public event Action click; + public event Action click; public Security security => _vm.security; @@ -88,9 +88,9 @@ namespace mbts.spark { x_off -= col.width; } - BuySell? bs = null; - if (column == _settings.bid_column) bs = BuySell.Buy; - if (column == _settings.ask_column) bs = BuySell.Sell; + Side? bs = null; + if (column == _settings.bid_column) bs = Side.Buy; + if (column == _settings.ask_column) bs = Side.Sell; click?.Invoke(price,bs); var pbs = (price, bs); if (Command != null && Command.CanExecute(pbs)) { diff --git a/src/client/spark/mspark/Ladder/LadderVM.cs b/src/client/spark/mspark/Ladder/LadderVM.cs index ac21179b1..fb2c02963 100644 --- a/src/client/spark/mspark/Ladder/LadderVM.cs +++ b/src/client/spark/mspark/Ladder/LadderVM.cs @@ -46,7 +46,7 @@ namespace mbts.spark { // cancel cancel_command = new DelegateCommand(_model.cancel_orders); - send_order_command = new DelegateCommand<(double, BuySell?)>(send_order); + send_order_command = new DelegateCommand<(double, Side?)>(send_order); // Order _selected_order_type = backing(nameof(selected_order_type), Order.Types.TimeInForce.Day); @@ -145,7 +145,7 @@ namespace mbts.spark { public ICommand show_ticket_command => new DelegateCommand(show_ticket); - public void send_order((double price,BuySell? side) args) { + public void send_order((double price,Side? side) args) { if (args.side.HasValue) { Order order = _order_template.Clone(); order.Size = (uint)Math.Abs(calculator.value); diff --git a/src/client/spark/mspark/Ladder/OrderVM.cs b/src/client/spark/mspark/Ladder/OrderVM.cs index 21312937b..8512c094a 100644 --- a/src/client/spark/mspark/Ladder/OrderVM.cs +++ b/src/client/spark/mspark/Ladder/OrderVM.cs @@ -90,7 +90,7 @@ namespace mbts.spark { public Brush foreground => Brushes.Black; public Brush background { get; private set; } public Brush hoverbackground { get; private set; } - public Brush header_brush => _order.order().Side == bts.api.BuySell.Buy ? BTSColors.MarketData.bid : BTSColors.MarketData.ask; + public Brush header_brush => _order.order().Side == bts.api.Side.Buy ? BTSColors.MarketData.bid : BTSColors.MarketData.ask; public Brush border { get; } diff --git a/src/client/spark/mspark/MarketView/MarketViewRow.cs b/src/client/spark/mspark/MarketView/MarketViewRow.cs index 8deb07d3b..d1c6bac9b 100644 --- a/src/client/spark/mspark/MarketView/MarketViewRow.cs +++ b/src/client/spark/mspark/MarketView/MarketViewRow.cs @@ -39,8 +39,8 @@ namespace mbts.spark volume = AddCell(Columns.Volume, md_pump.volume, (ulong)0); // _working_orders = new ObservableFilterCollection(_orders, o => o.is_active()); - _working_bids = new ObservableFilterCollection(_working_orders, o => o.order().Side == BuySell.Buy); - _working_asks = new ObservableFilterCollection(_working_orders, o => o.order().Side == BuySell.Sell); + _working_bids = new ObservableFilterCollection(_working_orders, o => o.order().Side == Side.Buy); + _working_asks = new ObservableFilterCollection(_working_orders, o => o.order().Side == Side.Sell); _working_bids_sorted = new ObservableSortedCollection(_working_bids, CompareUtils.NullCheckComparer((x, y) => y.order().Price.CompareTo(x.order().Price))); _working_asks_sorted = new ObservableSortedCollection(_working_asks, CompareUtils.NullCheckComparer((x, y) => x.order().Price.CompareTo(y.order().Price))); _inside_bids = new ObservableFilterCollection(_working_bids_sorted, o => o.order().Price >= bid_price.output); diff --git a/src/client/spark/mspark/Orders/OrderIconFactory.cs b/src/client/spark/mspark/Orders/OrderIconFactory.cs index 46ee1465d..409511156 100644 --- a/src/client/spark/mspark/Orders/OrderIconFactory.cs +++ b/src/client/spark/mspark/Orders/OrderIconFactory.cs @@ -21,14 +21,14 @@ namespace mbts.ui.spark private static readonly Pen _bid_pen = new Pen(BTSColors.MarketData.bid_brush, 4), _ask_pen = new Pen(BTSColors.MarketData.ask_brush, 4); private static readonly ConcurrentDictionary _algo_pallete = new ConcurrentDictionary(); - public static ImageSource Create(OrderMetadata metadata, BuySell side) { + public static ImageSource Create(OrderMetadata metadata, Side side) { Brush brush = _algo_pallete.GetOrAdd(metadata.Color, c => { Brush b = new SolidColorBrush(c.rgb_color()); b.Freeze(); return b; }); var group = new DrawingGroup(); - group.Children.Add(new GeometryDrawing(brush, side == BuySell.Buy ? _bid_pen : _ask_pen, new RectangleGeometry(new Rect(0, 0, 40, 28), 3, 3))); + group.Children.Add(new GeometryDrawing(brush, side == Side.Buy ? _bid_pen : _ask_pen, new RectangleGeometry(new Rect(0, 0, 40, 28), 3, 3))); return new DrawingImage { Drawing = group }; } } diff --git a/src/client/spark/mspark/Orders/OrderTicketVM.cs b/src/client/spark/mspark/Orders/OrderTicketVM.cs index f91cb0294..2f5ad58b2 100644 --- a/src/client/spark/mspark/Orders/OrderTicketVM.cs +++ b/src/client/spark/mspark/Orders/OrderTicketVM.cs @@ -22,7 +22,7 @@ namespace mbts.spark bbo = new BBOVM(order.Select(o => o.Security)); size_calculator = new CalculatorLogic(0, settings.Select(s => s.calculator_buttons)); set_price_command = new DelegateCommand(p => { price = p; RaisePropertyChanged(nameof(price)); }); - send_order = new DelegateCommand(side => { _prepare_order(side); model.send_order(_order); }); + send_order = new DelegateCommand(side => { _prepare_order(side); model.send_order(_order); }); modify_order = new DelegateCommand(() => { _prepare_order(); model.modify_order(_order); }); cancel_order = new DelegateCommand(() => model.cancel_order(new[] { _order.Id })); _dispose = Disposable.Create(order_pub.Connect(), order_params, bbo); @@ -30,7 +30,7 @@ namespace mbts.spark private Order _order = new Order { Security = Security.Empty, LimitOrder = new LimitOrder() }; - private void _prepare_order(BuySell? side = null) { + private void _prepare_order(Side? side = null) { _order.Size = size_calculator.value; if (side != null) _order.Side = side.Value; } diff --git a/src/client/spark/mspark/Orders/Sim/OrderActivitySimulator.cs b/src/client/spark/mspark/Orders/Sim/OrderActivitySimulator.cs index 0c0e74896..a2611d8df 100644 --- a/src/client/spark/mspark/Orders/Sim/OrderActivitySimulator.cs +++ b/src/client/spark/mspark/Orders/Sim/OrderActivitySimulator.cs @@ -27,7 +27,7 @@ namespace mbts.spark _bus.subscribe(SparkTags.ClockTag).ObserveOnDispatcher().Subscribe(t => _clock()); } - private static BuySell _invert (BuySell side) {return side == BuySell.Buy ? BuySell.Sell : BuySell.Buy;} + private static Side _invert (Side side) {return side == Side.Buy ? Side.Sell : Side.Buy;} private readonly TimeSpan _fill_activity_period = TimeSpan.FromSeconds(10); private DateTime _last_fill_activity = DateTime.Now; @@ -63,7 +63,7 @@ namespace mbts.spark /// make a child for each working order leg and submit it foreach (ContractLeg leg in order.Security.Synthetic.Legs) { - BuySell leg_side = leg.Side == BuySell.Buy ? order.Side : _invert(order.Side); + Side leg_side = leg.Side == Side.Buy ? order.Side : _invert(order.Side); OrderStatus leg_ord_status = new OrderStatus() { Order = new Order() @@ -99,14 +99,14 @@ namespace mbts.spark return new OrderID() { Id = Guid.NewGuid().ToString() }; } - private double _get_random_price(uint sec_id, BuySell side) + private double _get_random_price(uint sec_id, Side side) { SecurityMD rv; if (_md_map.TryGetValue(sec_id, out rv)) { co2.NativePriceSize[] bids = null, asks = null, eff_side; rv.md.get_depth(ref bids, ref asks); - eff_side = side == BuySell.Buy ? bids : asks; + eff_side = side == Side.Buy ? bids : asks; int index = Math.Min(eff_side.Length, 3) - 1; return index <= 0 ? Double.NaN : eff_side[index].price; } @@ -128,9 +128,9 @@ namespace mbts.spark rv.AddRange(e.ChildOrders); } if (cancel_orders.all_buys) - cxled.AddRange(rv.Where(o => o.order().Side == BuySell.Buy)); + cxled.AddRange(rv.Where(o => o.order().Side == Side.Buy)); if (cancel_orders.all_sells) - cxled.AddRange(rv.Where(o => o.order().Side == BuySell.Sell)); + cxled.AddRange(rv.Where(o => o.order().Side == Side.Sell)); foreach (OrderBookEntry o in cxled) o.OrderStatus.Status = OrderStatus.Types.Status.Canceled; foreach (var o in cxled) diff --git a/src/client/spark/mspark/Orders/Sim/SimSingleSecurityOrderExchangeGateway.cs b/src/client/spark/mspark/Orders/Sim/SimSingleSecurityOrderExchangeGateway.cs index dab657db1..3cad84e51 100644 --- a/src/client/spark/mspark/Orders/Sim/SimSingleSecurityOrderExchangeGateway.cs +++ b/src/client/spark/mspark/Orders/Sim/SimSingleSecurityOrderExchangeGateway.cs @@ -86,7 +86,7 @@ namespace mbts.spark } else { co2.NativePriceSize[] bids = null, asks = null; if (_md.md.get_depth(ref _depth_ref, ref bids, ref asks)) { - if (_order.Order.Side == bts.api.BuySell.Buy) _process_fills(asks, acceptable_buy_price); + if (_order.Order.Side == bts.api.Side.Buy) _process_fills(asks, acceptable_buy_price); else _process_fills(bids, acceptable_sell_price); if (_fills.Count == 0) { /// cross hasnt happened diff --git a/src/client/spark/mspark/Shell/Fills/FillsVM.cs b/src/client/spark/mspark/Shell/Fills/FillsVM.cs index 6e79cc482..368b5c219 100644 --- a/src/client/spark/mspark/Shell/Fills/FillsVM.cs +++ b/src/client/spark/mspark/Shell/Fills/FillsVM.cs @@ -109,7 +109,7 @@ namespace mbts.spark public string user => _fill.Order.User; public Venue exchange => _fill.Order.Security.Exchange; public Security security => _fill.Order.Security; - public BuySell side => _fill.Order.Side; + public Side side => _fill.Order.Side; public double price => _fill.Price; public uint size => _fill.Size; public string size_text => _fill.Size < _fill.Order.Size ? "{0} ({1})".fmt(_fill.Size, _fill.Order.Size) : _fill.Size.ToString(); diff --git a/src/client/spark/mspark/Shell/MenuItems/CancelOrdersMenuItem.cs b/src/client/spark/mspark/Shell/MenuItems/CancelOrdersMenuItem.cs index ad1d9911c..3feab29ab 100644 --- a/src/client/spark/mspark/Shell/MenuItems/CancelOrdersMenuItem.cs +++ b/src/client/spark/mspark/Shell/MenuItems/CancelOrdersMenuItem.cs @@ -38,12 +38,12 @@ namespace mbts.spark.menu_items internal class CancelBuyOrdersMenuItem : CancelOrdersMenuItem { public CancelBuyOrdersMenuItem(OrdersModel model) : base(model) { } public override string display_name => "Cancel Buy Orders"; - protected override bool filter(Order order) { return order.Side == BuySell.Buy; } + protected override bool filter(Order order) { return order.Side == Side.Buy; } } internal class CancelSellOrdersMenuItem : CancelOrdersMenuItem { public CancelSellOrdersMenuItem(OrdersModel model) : base(model) { } - protected override bool filter(Order order) { return order.Side == BuySell.Sell; } + protected override bool filter(Order order) { return order.Side == Side.Sell; } public override string display_name => "Cancel Sell Orders"; } } \ No newline at end of file diff --git a/src/client/spark/mspark/Shell/OrderBook/OrderBookRowVM.cs b/src/client/spark/mspark/Shell/OrderBook/OrderBookRowVM.cs index 6fdb85d54..86a0946d5 100644 --- a/src/client/spark/mspark/Shell/OrderBook/OrderBookRowVM.cs +++ b/src/client/spark/mspark/Shell/OrderBook/OrderBookRowVM.cs @@ -86,7 +86,7 @@ namespace mbts.spark get_metadata(_order.order().AlgoOrderTypeCase).Color); set => ignore(); } - public BuySell side { + public Side side { get => _order.order().Side; set => ignore(); } diff --git a/src/client/spark/mspark/Shell/Securities/Synthetic/SyntheticEditorVM.cs b/src/client/spark/mspark/Shell/Securities/Synthetic/SyntheticEditorVM.cs index adf00a560..92015d9ce 100644 --- a/src/client/spark/mspark/Shell/Securities/Synthetic/SyntheticEditorVM.cs +++ b/src/client/spark/mspark/Shell/Securities/Synthetic/SyntheticEditorVM.cs @@ -89,7 +89,7 @@ namespace mbts.spark #endregion public Security security { get; } - public BuySell side { get; set; } + public Side side { get; set; } public uint quantity { get; set; } = 1u; public double multiplier { get; set; } = 1.0; public bool is_working { get => _is_working.Value; set => _is_working.Value = value; } diff --git a/src/client/spark/mspark/Shell/Securities/Synthetic2/ParameterRow.cs b/src/client/spark/mspark/Shell/Securities/Synthetic2/ParameterRow.cs index d5e8cde89..07e732792 100644 --- a/src/client/spark/mspark/Shell/Securities/Synthetic2/ParameterRow.cs +++ b/src/client/spark/mspark/Shell/Securities/Synthetic2/ParameterRow.cs @@ -40,9 +40,9 @@ namespace mbts.spark } internal class SizeRowModel : ParameterBase { - public override int get_value(LegSpreaderParamsTuple leg_tup) { return leg_tup.leg.Side == BuySell.Buy ? (int)leg_tup.leg.Quantity : -(int)leg_tup.leg.Quantity; } + public override int get_value(LegSpreaderParamsTuple leg_tup) { return leg_tup.leg.Side == Side.Buy ? (int)leg_tup.leg.Quantity : -(int)leg_tup.leg.Quantity; } public override void set_value(LegSpreaderParamsTuple leg_tup, int value) { - leg_tup.leg.Side = value > 0 ? BuySell.Buy : BuySell.Sell; + leg_tup.leg.Side = value > 0 ? Side.Buy : Side.Sell; leg_tup.leg.Quantity = (uint)Math.Abs(value); } public override string display_name { get; } = "Size"; diff --git a/src/client/spark/mspark/Shell/TimeAndSales/TimeAndSalesModel.cs b/src/client/spark/mspark/Shell/TimeAndSales/TimeAndSalesModel.cs index e87527822..ae54703aa 100644 --- a/src/client/spark/mspark/Shell/TimeAndSales/TimeAndSalesModel.cs +++ b/src/client/spark/mspark/Shell/TimeAndSales/TimeAndSalesModel.cs @@ -35,7 +35,8 @@ namespace mbts.spark public void set_securities(IEnumerable securities) { foreach (var r in _channels.Keys.Except(securities).ToList()) _channels.Remove(r); - foreach (var a in securities.Except(_channels.Keys).ToList()) _channels.Add(a, Co2RelayControl.instance.consumer.get_channel(a.Symbol, get_type(a.ContractCase), get_exchange(a.Exchange))); + foreach (var a in securities.Except(_channels.Keys).ToList()) + _channels.Add(a, Co2RelayControl.instance.consumer.get_channel(a.Symbol, a.security_type(), a.Exchange)); } public void Dispose() { _work_loop.Dispose(); } diff --git a/src/client/spark/mspark/Shell/TimeAndSales/TimeAndSalesVM.cs b/src/client/spark/mspark/Shell/TimeAndSales/TimeAndSalesVM.cs index 2c89cac96..21db18d72 100644 --- a/src/client/spark/mspark/Shell/TimeAndSales/TimeAndSalesVM.cs +++ b/src/client/spark/mspark/Shell/TimeAndSales/TimeAndSalesVM.cs @@ -93,9 +93,9 @@ namespace mbts.spark private class Row : GridRowViewModelBase { public Row(Security security, TradeMessage trade) { this.security = AddCell(Columns.Security, security); - quantity = AddCell(Columns.Size, trade.size); - price = AddCell(Columns.Price, trade.mantissa * Math.Pow(10, trade.exponent)); - trade_time = AddCell(Columns.TradeTime, trade.time.lldatetime()); + quantity = AddCell(Columns.Size, trade.Size); + price = AddCell(Columns.Price, trade.Mantissa * Math.Pow(10, trade.Exponent)); + trade_time = AddCell(Columns.TradeTime, trade.Time.lldatetime()); order_type = AddCell(Columns.OrderType, Order.AlgoOrderTypeOneofCase.None); } diff --git a/src/client/spark/mspark/Utilities/SyntheticDataHelper.cs b/src/client/spark/mspark/Utilities/SyntheticDataHelper.cs index 7a0c90b9b..8c4a7505b 100644 --- a/src/client/spark/mspark/Utilities/SyntheticDataHelper.cs +++ b/src/client/spark/mspark/Utilities/SyntheticDataHelper.cs @@ -179,7 +179,7 @@ namespace mbts.spark.utilities return rv; } public static ContractLeg ContractLeg(Security security) { - return new ContractLeg { Security = security, PriceMultiplier = 1, Quantity = 1, Side = BuySell.Buy }; + return new ContractLeg { Security = security, PriceMultiplier = 1, Quantity = 1, Side = Side.Buy }; } public static ExecutionStrategy ExecutionStrategy(Security security) { diff --git a/src/client/spark/sys/api/SecurityConverter.cs b/src/client/spark/sys/api/SecurityConverter.cs index 73ee8ace4..861a913e5 100644 --- a/src/client/spark/sys/api/SecurityConverter.cs +++ b/src/client/spark/sys/api/SecurityConverter.cs @@ -4,22 +4,11 @@ namespace bts.api { static class SecurityConverter { - public static security_model.Exchange.type get_exchange(Venue exchange) { - switch(exchange) { - case Venue.Cboe: return security_model.Exchange.type.CBOE; - case Venue.Cboecfe: return security_model.Exchange.type.CBOECFE; - case Venue.Glbx: return security_model.Exchange.type.GLBX; - case Venue.Ice: return security_model.Exchange.type.ICE; - case Venue.Bts: return security_model.Exchange.type.TESTEXCHANGE; - default: return security_model.Exchange.type.UNSET; - } - } - - public static security_model.SecurityType.type get_type(ContractOneofCase type) { - switch(type) { - case ContractOneofCase.Future: return security_model.SecurityType.type.FUTURE; - case ContractOneofCase.Spread: return security_model.SecurityType.type.SPREAD; - default: return security_model.SecurityType.type.UNSET; + public static SecurityType security_type(this Security security) { + switch (security.ContractCase) { + case ContractOneofCase.Future: return SecurityType.Future; + case ContractOneofCase.Spread: return SecurityType.Spread; + default: return SecurityType.Unset; } } } diff --git a/src/client/spark/uicore/Shell/Login/LoginModel.cs b/src/client/spark/uicore/Shell/Login/LoginModel.cs index c40c192b8..638b6cc5c 100644 --- a/src/client/spark/uicore/Shell/Login/LoginModel.cs +++ b/src/client/spark/uicore/Shell/Login/LoginModel.cs @@ -117,7 +117,7 @@ namespace mbts.ui.shell } public Task preload_securities() { - return mbts.co2.Co2RelayControl.instance.preload_securities((MDRequest.Flags)0xFF); + return mbts.co2.Co2RelayControl.instance.preload_securities((MDRequest.Types.Flags)0xFF); } #endregion diff --git a/src/client/spark/uicore/Utility/ExpirationFormatter.cs b/src/client/spark/uicore/Utility/ExpirationFormatter.cs index 6be49312b..50b2c5d47 100644 --- a/src/client/spark/uicore/Utility/ExpirationFormatter.cs +++ b/src/client/spark/uicore/Utility/ExpirationFormatter.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using bts.security_model; +using bts.api; namespace mbts.ui.utility { @@ -60,24 +60,24 @@ namespace mbts.ui.utility } } - private static IDictionary> _offset_map; + private static IDictionary> _offset_map; static ExpirationFormatter() { try { - _offset_map = new Dictionary>(); - _offset_map[SecurityType.type.OPTION] = new Dictionary(); - _offset_map[SecurityType.type.FUTURE] = new Dictionary(); + _offset_map = new Dictionary>(); + _offset_map[SecurityType.Option] = new Dictionary(); + _offset_map[SecurityType.Future] = new Dictionary(); bts.config.ExpirationDisplayOffset offset_list = mbts.config.Configuration.get(); foreach (bts.config.ExpirationDisplayOffsetEntry e in offset_list.entries) { string security_name = e.security_name; string security_type_text = e.security_type; - bts.security_model.SecurityType.type security_type = bts.security_model.SecurityType.type.UNSET; - Enum.TryParse(security_type_text, true, out security_type); - if (security_type == bts.security_model.SecurityType.type.OPTION || security_type == bts.security_model.SecurityType.type.FUTURE) + SecurityType security_type = SecurityType.Unset; + Enum.TryParse(security_type_text, true, out security_type); + if (security_type == SecurityType.Option || security_type == SecurityType.Future) _offset_map[security_type][security_name] = e; } } @@ -87,7 +87,7 @@ namespace mbts.ui.utility } } - private static bts.config.ExpirationDisplayOffsetEntry _get_offset_entry(bts.security_model.SecurityType.type security_type, string security_name) + private static bts.config.ExpirationDisplayOffsetEntry _get_offset_entry(SecurityType security_type, string security_name) { bts.config.ExpirationDisplayOffsetEntry rv = null; IDictionary this_security_type_map = null; @@ -97,7 +97,7 @@ namespace mbts.ui.utility return rv; } - public static DateTime convert_real_to_mapped(SecurityType.type security_type, string security_name, DateTime security_expiration) + public static DateTime convert_real_to_mapped(SecurityType security_type, string security_name, DateTime security_expiration) { bts.config.ExpirationDisplayOffsetEntry offset_entry = _get_offset_entry(security_type, security_name); DateTime rv = security_expiration; @@ -114,42 +114,42 @@ namespace mbts.ui.utility return rv; } - public static string format_expiration_standard(SecurityType.type security_type, string security_name, DateTime security_expiration, bool map_expiration) { + public static string format_expiration_standard(SecurityType security_type, string security_name, DateTime security_expiration, bool map_expiration) { return format_expiration_standard(security_type, security_name, security_expiration, map_expiration, false); } - public static string format_expiration_standard(SecurityType.type security_type, string security_name, DateTime security_expiration, bool map_expiration, bool use_month_code) { + public static string format_expiration_standard(SecurityType security_type, string security_name, DateTime security_expiration, bool map_expiration, bool use_month_code) { return format_expiration_standard(security_type, security_name, security_expiration, map_expiration, use_month_code, true); } - public static string format_expiration_standard(SecurityType.type security_type, string security_name, DateTime security_expiration, bool map_expiration, bool use_month_code, bool show_day) { + public static string format_expiration_standard(SecurityType security_type, string security_name, DateTime security_expiration, bool map_expiration, bool use_month_code, bool show_day) { DateTime mapped_expiration = map_expiration ? convert_real_to_mapped(security_type, security_name, security_expiration) : security_expiration; return DateFormatter.format(mapped_expiration, use_month_code, show_day); } - public static string format_symbol_expiration_standard (SecurityType.type security_type, string security_name, DateTime security_expiration, bool map_expiration) { + public static string format_symbol_expiration_standard (SecurityType security_type, string security_name, DateTime security_expiration, bool map_expiration) { return format_symbol_expiration_standard(security_type, security_name, security_expiration, map_expiration, false, false, true); } - public static string format_symbol_expiration_standard (SecurityType.type security_type, string security_name, DateTime security_expiration, bool map_expiration, bool show_security_type) { + public static string format_symbol_expiration_standard (SecurityType security_type, string security_name, DateTime security_expiration, bool map_expiration, bool show_security_type) { return format_symbol_expiration_standard(security_type, security_name, security_expiration, map_expiration, show_security_type, false, true); } - public static string format_symbol_expiration_standard(SecurityType.type security_type, string security_name, DateTime security_expiration, bool map_expiration, bool show_security_type, bool use_month_code) { + public static string format_symbol_expiration_standard(SecurityType security_type, string security_name, DateTime security_expiration, bool map_expiration, bool show_security_type, bool use_month_code) { return format_symbol_expiration_standard(security_type, security_name, security_expiration, map_expiration, show_security_type, use_month_code, true); } - public static string format_symbol_expiration_standard (SecurityType.type security_type, string security_name, DateTime security_expiration, bool map_expiration, bool show_security_type, bool use_month_code, bool show_day) { + public static string format_symbol_expiration_standard (SecurityType security_type, string security_name, DateTime security_expiration, bool map_expiration, bool show_security_type, bool use_month_code, bool show_day) { string exp_text = format_expiration_standard(security_type, security_name, security_expiration, map_expiration, use_month_code, show_day); return !show_security_type ? String.Format("{0} {1}", security_name, exp_text) : String.Format("{0} {1} {2}", security_type.ToString().ToUpper(), security_name, exp_text); } public static string format_option_expiration_condensed(string option_name, DateTime option_expiration, bool map_expiration, bool show_symbol_name, bool show_year) { - DateTime mapped_expiration = map_expiration ? convert_real_to_mapped(SecurityType.type.OPTION, option_name, option_expiration) : option_expiration; + DateTime mapped_expiration = map_expiration ? convert_real_to_mapped(SecurityType.Option, option_name, option_expiration) : option_expiration; return String.Format("{0}{1}", show_symbol_name ? option_name : String.Empty, DateFormatter.format_condensed(mapped_expiration, true, show_year)); } - public static DateTime parse_standard_formatted_expiration(SecurityType.type security_type, string security_name, string security_expiration) { return DateFormatter.parse_standard(security_expiration); } + public static DateTime parse_standard_formatted_expiration(SecurityType security_type, string security_name, string security_expiration) { return DateFormatter.parse_standard(security_expiration); } } } diff --git a/src/client/spark/uitests/mcore/SecurityTests.cs b/src/client/spark/uitests/mcore/SecurityTests.cs index 3c27923f9..c9a8e1ec8 100644 --- a/src/client/spark/uitests/mcore/SecurityTests.cs +++ b/src/client/spark/uitests/mcore/SecurityTests.cs @@ -1,10 +1,10 @@ -using bts.security_model; -using NUnit.Framework; +using NUnit.Framework; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using bts.api; namespace bts.mcore { @@ -12,14 +12,14 @@ namespace bts.mcore class SecurityTests { [Test] public void test_security_equal() { - OldSecurity a = new OldSecurity() { security_key = 42 }; - OldSecurity b = new OldSecurity() { security_key = 42 }; - OldSecurity c = new OldSecurity() { security_key = 4 }; + Security a = new Security() { Id = 42 }; + Security b = new Security() { Id = 42 }; + Security c = new Security() { Id = 4 }; Assert.True(a == b); Assert.False(a == c); - Dictionary dict = new Dictionary(); + Dictionary dict = new Dictionary(); dict[a] = 1; dict[c] = 2; Assert.That(dict[b] == 1); diff --git a/src/client/spark/view/Controls/ControlPointEditor.xaml b/src/client/spark/view/Controls/ControlPointEditor.xaml deleted file mode 100644 index 6cbf239ba..000000000 --- a/src/client/spark/view/Controls/ControlPointEditor.xaml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - -