static void testMarket4() { AMarket market = AMarket.GetInstance(MarketVendor.Exchange); ETF etf = new ETF("510050", Exchange.SHE); Stock s = new Stock("601318", Exchange.SHE); market.SubscribeBidAskBook(etf, 2); market.SubscribeBidAskBook(s, 2); market.Dispose(); }
static void testMarket2() { AMarket market = AMarket.GetInstance(MarketVendor.Exchange); Option o1 = new Option("90000528", Exchange.SHE); Option o2 = new Option("90000526", Exchange.SHE); Option o3 = new Option("90000543", Exchange.SHE); market.SubscribeBidAskBook(o1, 5); market.SubscribeBidAskBook(o2, 5); market.SubscribeBidAskBook(o3, 5); while (true) { o1.bidaskbook.DebugPrint(); o2.bidaskbook.DebugPrint(); o3.bidaskbook.DebugPrint(); } }
static void testMarket3() { AMarket market = AMarket.GetInstance(MarketVendor.Exchange); Option o = new Option("90000528", Exchange.SHE); market.SubscribeBidAskBook(o, 1); while (true) { o.bidaskbook.DebugPrint(); } }
public virtual void Run() { //筛选期权合约 if (_options4mm == null || _options4mm.Count == 0) { MessageManager.GetInstance().Add(MessageType.Information, string.Format("没有设置需要做市的期权合约")); return; } //做市开始 MessageManager.GetInstance().Add(MessageType.Information, string.Format("进程{2}-{0}:标的{1}", this.name, _options4mm[0].underlying.name, instanceid)); //订阅行情 foreach (Option o in _options4mm) { _optionengine.SubscribeBidAskBook(o, 5); } MessageManager.GetInstance().Add(MessageType.Information, string.Format("已订阅{0}个期权合约", _options4mm.Count)); //暂停1s Thread.Sleep(1000); MessageManager.GetInstance().Add(MessageType.Information, string.Format("开始做市")); //开市做市 while (!IsStop) { //常发射心跳,避免丢失连接 _entrustengine.SendHeartbeat(); #region 做市 foreach (Option o in _options4mm) { switch (o.bidaskbook.phase) { case TradingPhase.CALL: //开盘集合竞价 case TradingPhase.UCALL: //收盘集合竞价 case TradingPhase.VOLBREAK: //熔断集合竞价 //集合竞价策略 this.makemarket4call(o); break; case TradingPhase.TRADE: //连续竞价 //连续竞价策略 this.makemarket4trade(o); break; case TradingPhase.END: //闭市 //退出前做一次委托 this.makemarket4trade(o); IsStop = true; MessageManager.GetInstance().Add(MessageType.Information, "已闭市"); break; case TradingPhase.PAUSE: //临时停牌 //忽略该合约 continue; case TradingPhase.START: //开市前 this.makemarket4trade(o); MessageManager.GetInstance().Add(MessageType.Information, "开市前准备"); Thread.Sleep(5000); break; case TradingPhase.BREAK: //午休 //休息5秒 MessageManager.GetInstance().Add(MessageType.Information, "午休"); Thread.Sleep(5000); break; default: break; } if (IsPause || IsStop) { break; } } #endregion #region 暂停 if (IsPause && !IsStop) { MessageManager.GetInstance().Add(MessageType.Information, string.Format("暂停")); int cnt = 0; while (IsPause && !IsStop) { Thread.Sleep(500); //每30秒发射一次心跳,避免丢失连接 cnt++; if (cnt >= 30) { cnt = 0; _entrustengine.SendHeartbeat(); } } } #endregion } MessageManager.GetInstance().Add(MessageType.Information, string.Format("做市已停止")); }