public MatchService() { preHandler = new OrderPreHandler(); postHandler = new OrderPostHandler(); Model = new OptionModel(); Model.Init(); esi = new EntitySvcImp(Model); market = new Market(Model); Matcher = new OrderMatcher(market); Matcher.OnAfterMatch += RaiseAfterMatch; foreach (var v in Model.LegacyOrders) { market.Handle(v); } preHandler.Market = market; Monitor = new OrderMonitor(Matcher, market, Model); monitorHandler = new OrderMonitorHandler(Monitor, (a, b) => { if (OnUserMsge != null) { OnUserMsge(a, b); } }); sysShare = new SysShare(Model.Traders); ks = new KlineSvc(this.Model); Matcher.OnFinish += matcher_OnFinish; Matcher.OnPositionChanged += matcher_OnPositionChanged; Matcher.OnPartialFinish += matcher_OnPartialFinish; Matcher.OnDeal += Matcher_OnDeal; foreach (var v in Model.Traders) { v.ReraiseBailEvent(); v.InitBailEvent(); } Model.Traders.First().SetMarket(market); DeepPool = new DeepDataPool2(Model, Matcher.Container); //恢复最近的成交 foreach (var v in Model.LatestDeals) { market.Deals.Handle(v); } Model.LatestDeals.Clear(); processor = new OrderSvcImp(this.Model, this.preHandler, this.postHandler, this.Matcher, log, IsAcceptByFuse); ks.Init(); PosSvc = new PositionSvcImp(this.market); }
public OrderMonitorHandler(OrderMonitor o, Action <string, string> sendToUserAct) { tms = new TraderMsgSaver(); this.sendToUserAct = sendToUserAct; this.om = o; om.OnBailWarning += om_OnBailWarning; om.prepare.OnBailAutoCollected += preBlaster_OnBailAutoCollected; om.prepare.OnRedoed += preBlaster_OnRedoed; om.prepare.OnRedoing += preBlaster_OnRedoing; }
public void Dispose() { if (om != null) { om.OnBailWarning -= om_OnBailWarning; om.prepare.OnBailAutoCollected -= preBlaster_OnBailAutoCollected; om.prepare.OnRedoed -= preBlaster_OnRedoed; om.prepare.OnRedoing -= preBlaster_OnRedoing; om.Dispose(); om = null; } if (tms != null) { tms.Dispose(); tms = null; } if (sendToUserAct != null) { sendToUserAct = null; } }