Example #1
0
        public void Invoke_OnQuoteTick(Quote qt)
        {
            QuoteEventArgs args = new QuoteEventArgs();

            args.quote = qt;
            OnQuoteTick?.Invoke(this, args);
        }
Example #2
0
        protected virtual void OnNewQuote(object sender, QuoteEventArgs args)
        {
            if (((IntradayEventArgs)args).Provider != this.marketDataProvider)
            {
                return;
            }
            QuoteViewRow quoteViewRow;
            bool         flag;

            lock (this.lockObject)
                flag = this.quoteRows.TryGetValue(((IntradayEventArgs)args).Instrument, out quoteViewRow);
            if (!flag)
            {
                return;
            }
            if (this.eventQueue.Enabled)
            {
                this.eventQueue.Enqueue(new MarketDataUpdateItem((MarketDataViewRow)quoteViewRow, args.Quote, (Trade)null, (Bar)null));
            }
            else
            {
                quoteViewRow.Update(args.Quote, (Trade)null, (Bar)null);
            }
            this.instrumentPad.OnNewQuote(sender, args);
        }
Example #3
0
 private void OnNewQuote(object sender, QuoteEventArgs args)
 {
     if (this.HandleMarketData(args.Provider, args.Instrument))
     {
         this.metaStrategyBase.SetNewQuote(args);
     }
 }
Example #4
0
 internal void EmitNewQuote(QuoteEventArgs e)
 {
     this.Quote = e.Quote;
     if (this.NewQuote != null)
     {
         this.NewQuote(this, e);
     }
 }
Example #5
0
 private void ProviderManager_NewQuote(object sender, QuoteEventArgs args)
 {
     lock (this)
     {
         ++this.countQuote;
         ++this.countMarketDataTotal;
     }
 }
Example #6
0
 public void Add(QuoteEventArgs args)
 {
     lock (this.lockObject)
     {
         this.GetProviderCounter((IProvider)((IntradayEventArgs)args).Provider).AddQuote(((IntradayEventArgs)args).Instrument);
         this.Quotes.Increment();
     }
 }
Example #7
0
 public void Publish(int count)
 {
     for (int i = 1; i <= count; ++i)
     {
         double value = Fetch(i);
         var    e     = new QuoteEventArgs(value);
         Available?.Invoke(this, e);
     }
 }
Example #8
0
        internal void EmitQuoteTrade(object sender, UpdateMessageEventArgs args)
        {
            IQFeedDataRequestRecord rr = htL1WatchedSymbols[args.Message.Symbol] as IQFeedDataRequestRecord;

            /*
             * if (SmartQuant.TraceLevel.Verbose == trace) {
             * string s;
             * s = string.Format("  sym='{0}',lst='{1}',vol='{2}',bid='{3}',ask='{4}',bsz='{5}',asz='{6}',typ='{7}'",
             *  args.Message.Symbol, args.Message.Last, args.Message.LastSize,
             *  args.Message.Bid, args.Message.Ask, args.Message.BidSize, args.Message.Type );
             * Console.WriteLine(s);
             * }
             */

            switch (args.Message.Type)
            {
            case "a":
            case "b":
                if (null != NewQuote)
                {
                    QuoteEventArgs q = new QuoteEventArgs(
                        new Quote(
                            rr.GetUniqueTimeStamp(),
                            args.Message.Bid,
                            args.Message.BidSize,
                            args.Message.Ask,
                            args.Message.AskSize),
                        rr.instrument, this);
                    NewQuote(this, q);
                }
                break;

            case "t":
            case "T":
                Trade trade = new Trade(
                    rr.GetUniqueTimeStamp(),
                    args.Message.Last,
                    args.Message.LastSize);
                if (null != NewTrade)
                {
                    TradeEventArgs t = new TradeEventArgs(trade, rr.instrument, this);
                    NewTrade(this, t);
                }
                if (null != factory)
                {
                    factory.OnNewTrade(rr.instrument, trade);
                }
                break;

            case "o":
                break;

            default:
                break;
            }
        }
    public void Publish(int count)
    {
        for (int i = 1; i <= count; ++i)
        {
            double value = Generate(i);
            var    e     = new QuoteEventArgs(value);

            Available?.Invoke(this, e);             //if(Available != null) Available.Invoke(this, e)
        }
    }
Example #10
0
 void m_messageUtilities_OnQuote(object sender, QuoteEventArgs e)
 {
     try
     {
         DataSet1.StockQuotesRow row = e.ClientObject as DataSet1.StockQuotesRow;
         OnQuote(e.Quote, row);
     }
     catch (Exception ex)
     {
         OnError("Error reading QuoteEventArgs", ex);
     }
 }
Example #11
0
        private void marketDataProvider_NewQuote(object sender, QuoteEventArgs args)
        {
            FreeQuant.Instruments.Instrument instrument = args.Instrument as FreeQuant.Instruments.Instrument;
            List <StrategyRunner>            list       = (List <StrategyRunner>)null;

            if (!this.instrumentTable.TryGetValue(instrument, out list))
            {
                return;
            }
            foreach (StrategyRunner strategyRunner in list)
            {
                if (strategyRunner.Enabled)
                {
                    strategyRunner.SetNewQuote(instrument, args.Quote);
                }
            }
        }
Example #12
0
 private void OnNewQuote(object sender, QuoteEventArgs args)
 {
     if (!this.isRunning || !this.cbxQuotes.Checked)
     {
         return;
     }
     this.queue.Enqueue((Action)(() =>
     {
         Instrument local_0 = ((IntradayEventArgs)args).Instrument as Instrument;
         InstrumentRow local_1 = this.instruments[local_0] as InstrumentRow;
         if (local_1 == null)
         {
             return;
         }
         local_0.Add(args.Quote);
         ++local_1.Quotes;
     }));
 }
        private void OnQuotes(QuoteEventArgs obj)
        {
            if (obj.Data.Length == 1)
            {
                Log("ping ....");
                return;
            }

            BinaryQuotes[] quotes = BinaryQuotes.Parse(obj.Data);

            for (int i = 0; i < quotes.Length; i++)
            {
                Level2 l2 = quotes[i] as Level2;
                if (l2 == null)
                {
                    continue;
                }
                Log($"LTT= {l2.LastTradedTime}, TimeStamp= {l2.TimeStamp} LTP={l2.LastTradedPrice}");
            }
        }
        private void Instance_OnQuoteTick(object sender, QuoteEventArgs e)
        {
            List <RecordTransItem> needsTestNextTime = new List <RecordTransItem>();
            RecordTransItem        testItem;

            while (WaitingRecords.TryDequeue(out testItem))
            {
                if (testItem.direction == TransDirection.Buy)
                {
                    if (e.quote.ask_price1 <= testItem.price)
                    {
                        Invoke_OnRemoveWaitingOrder(testItem);
                        //成交
                        _TradedOrder(testItem);
                    }
                    else
                    {
                        needsTestNextTime.Add(testItem);
                    }
                }
                else
                {
                    if (e.quote.bid_price1 >= testItem.price)
                    {
                        Invoke_OnRemoveWaitingOrder(testItem);
                        //成交
                        _TradedOrder(testItem);
                    }
                    else
                    {
                        needsTestNextTime.Add(testItem);
                    }
                }
            }

            foreach (var it in needsTestNextTime)
            {
                WaitingRecords.Enqueue(it);
            }
        }
Example #15
0
        private static void OnNewQuote(object sender, QuoteEventArgs e)
        {
            Instrument instrument = e.Instrument as Instrument ?? InstrumentManager.Instruments[e.Instrument.Symbol, e.Provider.Name];

            if (instrument == null)
            {
                return;
            }

            Quote quote = e.Quote;

            if (DataManager.quoteArrayLength != 0)
            {
                QuoteArray quoteArray = DataManager.quoteArrayList[instrument];
                quoteArray.Add(quote);
                if (DataManager.quoteArrayLength != -1 && quoteArray.Count > DataManager.quoteArrayLength)
                {
                    quoteArray.RemoveAt(0);
                }
            }
            instrument.EmitNewQuote(new QuoteEventArgs(quote, instrument, e.Provider));
        }
Example #16
0
        public void OnNewQuote(object sender, QuoteEventArgs args)
        {
            if (((IntradayEventArgs)args).Instrument != this.instrument)
            {
                return;
            }
            if (((DataArray)DataManager.Quotes[this.instrument]).Count == 1 && ((DataArray)DataManager.Trades[this.instrument]).Count == 0)
            {
                this.isFirstTime = true;
            }
            DateTime lastDateTime = ((DataArray)DataManager.Quotes[this.instrument]).LastDateTime;
            int      num          = ((DataArray)DataManager.Quotes[this.instrument]).Count - 2;

            while (num >= 0 && DataManager.Quotes[this.instrument][num].DateTime == lastDateTime)
            {
                --num;
            }
            if (num < 0)
            {
                return;
            }
//			DataManager.Quotes[this.instrument][num].DateTime;
            if (lastDateTime >= this.lastUpdateDate)
            {
                if (this.isFirstTime)
                {
                    this.pad.SetRangeX((double)(((DataArray)DataManager.Quotes[this.instrument]).LastDateTime.Ticks - 9000000000L), (double)((DataArray)DataManager.Quotes[this.instrument]).LastDateTime.Ticks);
                    this.isFirstTime = false;
                }
                else
                {
                    this.pad.SetRangeX((double)((DataArray)DataManager.Quotes[this.instrument]).LastDateTime.Ticks + this.pad.XMin - (double)this.lastUpdateDate.Ticks, (double)((DataArray)DataManager.Quotes[this.instrument]).LastDateTime.Ticks + (this.pad.XMax - (double)this.lastUpdateDate.Ticks));
                }
            }
            this.lastUpdateDate = lastDateTime;
        }
Example #17
0
        private void OnNewQuote(object sender, QuoteEventArgs args)
        {
            SingleOrder singleOrder = this.fOrder as SingleOrder;
            Quote       quote       = args.Quote;

            switch (singleOrder.Side)
            {
            case Side.Buy:
                if (quote.Ask != this.fQuote.Ask || quote.AskSize != this.fQuote.AskSize)
                {
                    this.Process(quote, null, null);
                }
                break;

            case Side.Sell:
            case Side.SellShort:
                if (quote.Bid != this.fQuote.Bid || quote.BidSize != this.fQuote.BidSize)
                {
                    this.Process(quote, null, null);
                }
                break;
            }
            this.fQuote = quote;
        }
Example #18
0
 private void ProviderManager_NewQuote(object sender, QuoteEventArgs args)
 {
     this.counter.Add(args);
 }
Example #19
0
        private void PyJFklA8yp(object obj0, QuoteEventArgs obj1)
        {
            SingleOrder singleOrder = this.PYBF7sahqY as SingleOrder;
            Quote       quote       = obj1.Quote;

            if (this.A8bFJItyyx.FillAtWorstQuoteRate || this.smCF4MYTNu.Bid <= this.smCF4MYTNu.Ask || quote.Bid <= quote.Ask)
            {
                switch (singleOrder.Side)
                {
                case Side.Buy:
                    if (quote.Ask != this.smCF4MYTNu.Ask || quote.AskSize != this.smCF4MYTNu.AskSize)
                    {
                        this.Y18FFPmDy5(quote, (Trade)null, (Bar)null);
                        break;
                    }
                    else
                    {
                        break;
                    }

                case Side.Sell:
                case Side.SellShort:
                    if (quote.Bid != this.smCF4MYTNu.Bid || quote.BidSize != this.smCF4MYTNu.BidSize)
                    {
                        this.Y18FFPmDy5(quote, (Trade)null, (Bar)null);
                        break;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else
            {
                switch (singleOrder.Side)
                {
                case Side.Buy:
                    if (quote.Bid != this.smCF4MYTNu.Bid || quote.BidSize != this.smCF4MYTNu.BidSize)
                    {
                        this.Y18FFPmDy5(quote, (Trade)null, (Bar)null);
                        break;
                    }
                    else
                    {
                        break;
                    }

                case Side.Sell:
                case Side.SellShort:
                    if (quote.Ask != this.smCF4MYTNu.Ask || quote.AskSize != this.smCF4MYTNu.AskSize)
                    {
                        this.Y18FFPmDy5(quote, (Trade)null, (Bar)null);
                        break;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            this.smCF4MYTNu = quote;
        }
 private void pub_Available(object sender, QuoteEventArgs e)
 {
     Console.WriteLine("Quote recieved with value = {0}", e.Value);
 }
        private void m_messageUtilities_OnQuote(object sender, QuoteEventArgs e)
        {
            string ticker = null;

            try
            {
                if (IsSubscribed)
                {
                    ticker = e.Quote.Ticker;

                    IQuoteRow row = e.ClientObject as IQuoteRow;

                    lock (m_portfolioLock)
                    {
                        bool bUpdated = false;
                        if (e.Quote.SubscriptionStatus != SubscriptionStatus.Unchanged)
                        {
                            row.SubscriptionStatus = e.Quote.SubscriptionStatus.ToString();
                            bUpdated = true;
                        }

                        if (e.Quote.OpenStatus == OpenStatus.Closed)
                        {
                            row.Closed = true;
                            bUpdated   = true;
                        }
                        else if (e.Quote.OpenStatus == OpenStatus.Open)
                        {
                            row.Closed = false;
                            bUpdated   = true;
                        }

                        if (e.Quote.HasOpen)
                        {
                            row.Open = e.Quote.Open;
                            bUpdated = true;
                        }

                        if (e.Quote.HasPrevClose)
                        {
                            row.PrevClose = e.Quote.PrevClose;
                            bUpdated      = true;
                        }

                        if (!row.Closed)
                        {
                            if (e.Quote.HasLast)
                            {
                                row.LastPrice = e.Quote.Last;
                                bUpdated      = true;
                            }

                            if (e.Quote.HasBid)
                            {
                                row.Bid  = e.Quote.Bid;
                                bUpdated = true;
                            }
                            if (e.Quote.HasAsk)
                            {
                                row.Ask  = e.Quote.Ask;
                                bUpdated = true;
                            }
                            if (e.Quote.HasDelta)
                            {
                                row.Delta = e.Quote.Delta;
                                bUpdated  = true;
                            }
                            if (e.Quote.HasGamma)
                            {
                                row.Gamma = e.Quote.Gamma;
                                bUpdated  = true;
                            }
                            if (e.Quote.HasTheta)
                            {
                                row.Theta = e.Quote.Theta;
                                bUpdated  = true;
                            }
                            if (e.Quote.HasVega)
                            {
                                row.Vega = e.Quote.Vega;
                                bUpdated = true;
                            }
                            if (e.Quote.HasImpliedVol)
                            {
                                row.ImpliedVol = e.Quote.ImpliedVol;
                                bUpdated       = true;
                            }
                        }

                        else // i.e., if row.Closed
                        {
                            if (e.Quote.HasClose)
                            {
                                row.ClosingPrice = e.Quote.Close;
                                bUpdated         = true;
                            }
                        }

                        if (bUpdated)
                        {
                            LastQuoteTime = row.UpdateTime = DateTime.Now.TimeOfDay;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                PositionMonitorUtilities.Error(Name + " unable to process quote for " + (ticker ?? "<NULL>"), ex);
            }
        }
 private void MT_OnQuote(object sender, QuoteEventArgs args)
 {
     BeginInvoke(new UpdateTextCallback(this.updateTickDisplay),
                 new object[] { args.Ask, args.Bid });
 }
Example #23
0
 private void pub_Available(object sender, QuoteEventArgs e)
 {
     Console.WriteLine($"Received value {e.Value}");
 }
Example #24
0
 void m_reader_OnQuote(object sender, QuoteEventArgs e)
 {
     m_writer.PublishQuote(e.Quote, e.ClientObject);
 }