示例#1
0
        public override void OnQuote(Quote quote)
        {
            server.SetData(TOPIC_QUOTE_BID,
                Instrument.ToString(),
                1,
                quote.Bid
                );

            server.SetData(TOPIC_QUOTE_BID_SIZE,
                Instrument.ToString(),
                1,
                quote.BidSize
                );

            server.SetData(TOPIC_QUOTE_ASK,
                Instrument.ToString(),
                1,
                quote.Ask
                );

            server.SetData(TOPIC_QUOTE_ASK_SIZE,
                Instrument.ToString(),
                1,
                quote.AskSize
                );
        }
示例#2
0
 public override void OnQuote(Quote quote)
 {
     // 插件3.8.2.1 中开始可用,是将Quote数据中的深度数据取出
     if (DataConvert.TryConvert(quote, ref DepthMarketData))
     {
         Console.WriteLine("OnQuote " + DepthMarketData.LastPrice);
         Console.WriteLine("OnQuote " + DepthMarketData.UpperLimitPrice);
     }
 }
示例#3
0
        public static bool TryConvert(Quote quote, ref DFITCDepthMarketDataField DepthMarketData)
        {
            if (quoteField == null)
            {
                quoteField = typeof(Quote).GetField("quote", BindingFlags.NonPublic | BindingFlags.Instance);
            }

            XSpeedQuote q = quoteField.GetValue(quote) as XSpeedQuote;
            if (null != q)
            {
                DepthMarketData = q.DepthMarketData;
                return true;
            }
            return false;
        }
示例#4
0
 public override void OnQuote(Quote quote)
 {
     // 只要有报价就会生成,数量约为两个合约Quote之和
     //if(Instrument == Instrument2)
     {
         if (Instrument1.Quote != null
                 && Instrument2.Quote != null)
         {
             double Ask = Instrument1.Quote.Ask - Instrument2.Quote.Bid;
             int AskSize = Math.Min(Instrument1.Quote.AskSize, Instrument2.Quote.BidSize);
             double Bid = Instrument1.Quote.Bid - Instrument2.Quote.Ask;
             int BidSize = Math.Min(Instrument1.Quote.BidSize, Instrument2.Quote.AskSize);
             Quote q = new Quote(Clock.Now, Bid, BidSize, Ask, AskSize);
             DataManager.Add(Instrument3, q);
         }
     }
 }
示例#5
0
        public static bool TryConvert(Quote quote, ref CThostFtdcDepthMarketDataField DepthMarketData)
        {
#if OQ
            if (quoteField == null)
            {
                quoteField = typeof(Quote).GetField("quote", BindingFlags.NonPublic | BindingFlags.Instance);
            }

            CTPQuote q = quoteField.GetValue(quote) as CTPQuote;
#elif QD
            CTPQuote q = quote as CTPQuote;
#endif
            if (null != q)
            {
                DepthMarketData = q.DepthMarketData;
                return true;
            }
            return false;
        }
示例#6
0
        public override void OnQuote(Quote quote)
        {
            if (!quote.DateTime.IsWithinRegularTradingHours(Instrument.Type))
            {
                return;
            }

            CurrentAskPrice = quote.Ask;
            CurrentBidPrice = quote.Bid;

            //LoggingUtility.WriteInfoFormat(this, "Current Bid={0:c}, Ask={1:c}", CurrentBidPrice, CurrentAskPrice);
        }
        protected void SaveData(Instrument instrument, Quote quote)
        {
            DataManager.Add(instrument, quote);

            DataManager.Flush();
        }
示例#8
0
		public static void Add(Instrument instrument, Quote quote)
		{
			SmartQuant.Instruments.Instrument instrument2 = Map.OQ_SQ_Instrument[instrument] as SmartQuant.Instruments.Instrument;
			SmartQuant.Instruments.DataManager.Add(instrument2, quote.quote);
		}
        public override void OnQuote(Quote quote)
        {
            //lock(this)
            {
                Process();
            }

            // 如果只有Quote数据,如何更新?
            // 那就会不用这个目标仓位助手了
            //if(!DataRequests.HasTradeRequest)
            //{ 
            //}
        }
示例#10
0
		public void Add(Quote quote)
		{
			this.series.Add(quote.quote);
		}
示例#11
0
 public override Quote FilterQuote(OpenQuant.API.Quote quote, string symbol)
 {
     // 接收所有报价
     return(quote);
 }
示例#12
0
文件: Strategy.cs 项目: heber/FreeOQ
 public void EmitQuote(Quote quote)
 {
   this.EmitQuote(this.Instrument, quote);
 }
示例#13
0
 public override void OnQuote(Quote quote)
 {
     if (StrategyMode.Simulation != Mode)
         DataManager.Add(Instrument, quote);
 }
        public void ProcessQuote(Quote quote)
        {
            try
            {

                if (!IsItOkToHandleQuote(quote))
                {
                    return;
                }

                if (GetCurrentDateTime() >= CurrentValidityDateTime && !AreAllLegsCompleted)
                {
                    LoggingUtility.WriteTraceFormat(this, "Processing quote: {0}", quote);
                }

                CurrentQuoteRef = quote;

                SaveData(Instrument, quote);

                CurrentAskPrice = quote.Ask;
                CurrentBidPrice = quote.Bid;

                AttempOrder();
            }
            catch (Exception ex)
            {
                LoggingUtility.WriteError(this, ex, "Error in ProcessQuote");
            }
            finally
            {
                CurrentQuoteRef = null;
            }
        }
		public virtual Quote FilterQuote(Quote quote, string symbol)
		{
			return quote;
		}
示例#16
0
        public override void OnQuote(Quote quote)
        {
            PublishQuote(quote);

            base.OnQuote(quote);
        }
示例#17
0
        private void PublishQuote(Quote quote)
        {
            string topic = Instrument.Symbol.ToUpperInvariant();
            OnQuoteMessage message = new OnQuoteMessage {Quote = ConvertQuote(quote), Instrument = ConvertInstrument()};

            Bus.Publish(message, topic);
        }
示例#18
0
文件: Strategy.cs 项目: heber/FreeOQ
 public virtual void OnQuote(Quote quote)
 {
 }
        public override void OnQuote(Quote quote)
        {
            try
            {

                if (!quote.IsWithinRegularTradingHours(Instrument.Type))
                {
                    LoggingUtility.WriteTraceFormat(this,
                                "Discarding quote outside of trading hours. {0}", quote);
                    return;
                }

                if (!QuoteClientEnabled)
                {
                    LoggingUtility.WriteTraceFormat(this,
                                "Processing native quote. {0}", quote);

                    ProcessQuote(quote);
                }
                else
                {
                    LoggingUtility.WriteTraceFormat(this,
                                "Discarding native quote. {0}", quote);
                }

                base.OnQuote(quote);
            }
            catch (Exception ex)
            {
                LoggingUtility.WriteError(this, ex, "Error in OnQuote");
            }
        }
示例#20
0
 public override void OnQuote(Quote quote)
 {
     Process();
 }
示例#21
0
文件: Strategy.cs 项目: heber/FreeOQ
 public void EmitQuote(Instrument instrument, Quote quote)
 {
   if (!(this.MarketDataProvider.provider is ISimulationMarketDataProvider))
     return;
   (this.MarketDataProvider.provider as ISimulationMarketDataProvider).EmitQuote((IFIXInstrument) instrument.instrument, quote.quote);
 }
        protected bool IsItOkToHandleQuote(Quote quote)
        {
            if (!quote.IsWithinRegularTradingHours(Instrument.Type))
            {
                LoggingUtility.WriteTraceFormat(this, "Quote is not within regular trading hours: {0}", quote);
                return false;
            }

            return true;
        }
示例#23
0
        private SpiderQuote ConvertQuote(Quote originalQuote)
        {
            SpiderQuote spiderQuote = new SpiderQuote()
            {
                DateTime = originalQuote.DateTime,
                Ask = originalQuote.Ask,
                Bid = originalQuote.Bid,
                AskSize = originalQuote.AskSize,
                BidSize = originalQuote.BidSize
            };

            return spiderQuote;
        }