Example #1
0
        void stiQuote_OnSTIQuoteUpdate(ref structSTIQuoteUpdate q)
        {
            Tick k = new TickImpl(q.bstrSymbol);

            k.bid = (decimal)q.fBidPrice;
            k.ask = (decimal)q.fAskPrice;
            k.bs  = q.nBidSize / 100;
            k.os  = q.nAskSize / 100;
            if (q.bstrExch != "*")
            {
                k.ex = q.bstrExch;
            }
            if (q.bstrBidExch != "*")
            {
                k.be = q.bstrBidExch;
            }
            if (q.bstrAskExch != "*")
            {
                k.oe = q.bstrAskExch;
            }
            int now = Convert.ToInt32(q.bstrUpdateTime);

            k.date = Util.ToTLDate(DateTime.Now);
            int sec = now % 100;

            k.time  = now;
            k.trade = (decimal)q.fLastPrice;
            k.size  = q.nLastSize;
            tl.newTick(k);
            if ((q.bValidMktImb == 0) || !imbalance)
            {
                return;
            }
            tl.newImbalance(new ImbalanceImpl(k.symbol, k.ex, q.nMktImbalance, k.time, 0, 0, 0));
        }
Example #2
0
 void stiQuote_OnSTIQuoteUpdate(ref structSTIQuoteUpdate q)
 {
     if (UseXmlMode)
     {
         return;
     }
     doquote(ref q);
 }
		private void SessionOnStiQuoteUpdate(ref structSTIQuoteUpdate structQuoteUpdate)
		{
			var message = new Level1ChangeMessage
			{
				SecurityId = new SecurityId
				{
					SecurityCode = structQuoteUpdate.bstrSymbol,
					BoardCode = structQuoteUpdate.bstrExch,
				},
				ServerTime = structQuoteUpdate.bstrUpdateTime.StrToTime(),
			};

			if (structQuoteUpdate.bAskPrice != 0)
				message.TryAdd(Level1Fields.BestAskPrice, (decimal)structQuoteUpdate.fAskPrice);

			if (structQuoteUpdate.bBidPrice != 0)
				message.TryAdd(Level1Fields.BestBidPrice, (decimal)structQuoteUpdate.fBidPrice);

			message.TryAdd(Level1Fields.BestAskVolume, (decimal)structQuoteUpdate.nAskSize);
			message.TryAdd(Level1Fields.BestBidVolume, (decimal)structQuoteUpdate.nBidSize);

			if (structQuoteUpdate.bOpenPrice != 0)
				message.TryAdd(Level1Fields.OpenPrice, (decimal)structQuoteUpdate.fOpenPrice);
			
			if (structQuoteUpdate.bHighPrice != 0)
				message.TryAdd(Level1Fields.HighPrice, (decimal)structQuoteUpdate.fHighPrice);
			
			if (structQuoteUpdate.bLowPrice != 0)
				message.TryAdd(Level1Fields.LowPrice, (decimal)structQuoteUpdate.fLowPrice);

			if (structQuoteUpdate.bLastPrice != 0)
				message.TryAdd(Level1Fields.LastTradePrice, (decimal)structQuoteUpdate.fLastPrice);

			message.TryAdd(Level1Fields.LastTradeVolume, (decimal)structQuoteUpdate.nLastSize);

			message.TryAdd(Level1Fields.OpenInterest, (decimal)structQuoteUpdate.nOpenInterest);
			message.TryAdd(Level1Fields.Volume, (decimal)structQuoteUpdate.nCumVolume);
			message.TryAdd(Level1Fields.VWAP, (decimal)structQuoteUpdate.fVwap);
			
			SendOutMessage(message);

			if (_subscribedSecuritiesToTrade.Cache.Contains(structQuoteUpdate.bstrSymbol) && structQuoteUpdate.fLastPrice != 0)
			{
				var tickMsg = new ExecutionMessage
				{
					ExecutionType = ExecutionTypes.Tick,
					SecurityId = new SecurityId { SecurityCode = structQuoteUpdate.bstrSymbol, BoardCode = structQuoteUpdate.bstrExch },
					//TradeId = structQuoteSnap.,
					TradePrice = (decimal)structQuoteUpdate.fLastPrice,
					Volume = structQuoteUpdate.nLastSize,
					//OriginSide = action.ToSide(),
					ServerTime = structQuoteUpdate.bstrUpdateTime.StrToTime()
				};

				SendOutMessage(tickMsg);
			}
		}
Example #4
0
 void stiQuote_OnSTIQuoteUpdateXML(ref string bstrQuote)
 {
     try
     {
         XmlSerializer        xs = new XmlSerializer(typeof(SterlingLib.structSTIQuoteUpdate));
         structSTIQuoteUpdate q  = (structSTIQuoteUpdate)xs.Deserialize(new System.IO.StringReader(bstrQuote));
         doquote(ref q);
     }
     catch (Exception ex)
     {
         debug("Error deserializing quote: " + bstrQuote);
         debug(ex.Message + ex.StackTrace);
     }
 }
Example #5
0
        private void SessionOnStiQuoteUpdate(ref structSTIQuoteUpdate structQuoteUpdate)
        {
            var message = new Level1ChangeMessage
            {
                SecurityId = new SecurityId
                {
                    SecurityCode = structQuoteUpdate.bstrSymbol,
                    BoardCode    = structQuoteUpdate.bstrExch,
                },
                ServerTime = structQuoteUpdate.bstrUpdateTime.StrToTime(),
            };

            message.TryAdd(Level1Fields.BestAskPrice, (decimal)structQuoteUpdate.fAskPrice);
            message.TryAdd(Level1Fields.BestBidPrice, (decimal)structQuoteUpdate.fAskPrice);
            message.TryAdd(Level1Fields.BestAskVolume, (decimal)structQuoteUpdate.nAskSize);
            message.TryAdd(Level1Fields.BestBidVolume, (decimal)structQuoteUpdate.nBidSize);

            message.TryAdd(Level1Fields.OpenPrice, (decimal)structQuoteUpdate.fOpenPrice);
            message.TryAdd(Level1Fields.HighPrice, (decimal)structQuoteUpdate.fHighPrice);
            message.TryAdd(Level1Fields.LowPrice, (decimal)structQuoteUpdate.fLowPrice);

            message.TryAdd(Level1Fields.LastTradePrice, (decimal)structQuoteUpdate.fLastPrice);
            message.TryAdd(Level1Fields.LastTradeVolume, (decimal)structQuoteUpdate.nLastSize);

            message.TryAdd(Level1Fields.OpenInterest, (decimal)structQuoteUpdate.nOpenInterest);
            message.TryAdd(Level1Fields.Volume, (decimal)structQuoteUpdate.nCumVolume);
            message.TryAdd(Level1Fields.VWAP, (decimal)structQuoteUpdate.fVwap);

            SendOutMessage(message);

            if (_subscribedSecuritiesToTrade.Cache.Contains(structQuoteUpdate.bstrSymbol) && structQuoteUpdate.fLastPrice != 0)
            {
                var tickMsg = new ExecutionMessage
                {
                    ExecutionType = ExecutionTypes.Tick,
                    SecurityId    = new SecurityId {
                        SecurityCode = structQuoteUpdate.bstrSymbol, BoardCode = structQuoteUpdate.bstrExch
                    },
                    //TradeId = structQuoteSnap.,
                    TradePrice = (decimal)structQuoteUpdate.fLastPrice,
                    Volume     = structQuoteUpdate.nLastSize,
                    //OriginSide = action.ToSide(),
                    ServerTime = structQuoteUpdate.bstrUpdateTime.StrToTime()
                };

                SendOutMessage(tickMsg);
            }
        }
Example #6
0
        void doquote(ref structSTIQuoteUpdate q)
        {
            Tick k = new TickImpl(q.bstrSymbol);
            k.bid = (decimal)q.fBidPrice;
            k.ask = (decimal)q.fAskPrice;
            k.bs = q.nBidSize / 100;
            k.os = q.nAskSize / 100;
            k.ex = GetExPretty(q.bstrExch);
            k.be = GetExPretty(q.bstrBidExch);
            k.oe = GetExPretty(q.bstrAskExch);
            int now = Convert.ToInt32(q.bstrUpdateTime);
            k.date = Util.ToTLDate(DateTime.Now);
            //int sec = now % 100;
            k.time = now;

            // we don't want to simply return on out-of-order ticks because it'll prevent processing
            // of the mdx messages further in this function.
            if (!IgnoreOutOfOrderTicks || (k.time > _lasttime))
            {
                _lasttime = k.time;
                k.trade = (decimal)q.fLastPrice;
                k.size = q.nLastSize;
                // execute orders if papertrade is enabled
                if (isPaperTradeEnabled)
                    ptt.newTick(k);
                // notify clients of tick
                if (!_imbalance || (_imbalance && k.isValid))
                    tl.newTick(k);
            }

            /////////////////////////
            // MDX Processing
            /////////////////////////
            if (q.nMdxMsgType == 1)
            {
                if (VerboseDebugging)
                    debug(q.bstrUpdateTime
                    + "  Received Regulatory Imbalance for: " + q.bstrSymbol
                    + "  ValidIntradayMarketImb: " + q.bValidIntradayMktImb
                    + "  ValidMktImb: " + q.bValidMktImb
                    + "  Imbalance: " + q.nImbalance
                    + "  iMktImbalance: " + q.nIntradayMktImbalance
                    + "  MktImbalance: " + q.nMktImbalance);

                int time;
                if (int.TryParse(q.bstrUpdateTime, out time))
                {
                    Imbalance imb = new ImbalanceImpl(q.bstrSymbol, GetExPretty(q.bstrExch), q.nIntradayMktImbalance, time, 0, 0, 0);
                    tl.newImbalance(imb);
                }
            }
            else if (q.nMdxMsgType == 2)
            {
                if (VerboseDebugging)
                    debug(q.bstrUpdateTime
                    + "  Received Informational Imbalance for: " + q.bstrSymbol
                    + "  ValidIntradayMarketImb: " + q.bValidIntradayMktImb
                    + "  ValidMktImb: " + q.bValidMktImb
                    + "  Imbalance: " + q.nImbalance
                    + "  iMktImbalance: " + q.nIntradayMktImbalance
                    + "  MktImbalance: " + q.nMktImbalance);

                int time;
                if (int.TryParse(q.bstrUpdateTime, out time))
                {
                    Imbalance imb = new ImbalanceImpl(q.bstrSymbol, GetExPretty(q.bstrExch), 0, time, 0, 0, q.nIntradayMktImbalance);
                    tl.newImbalance(imb);
                }
            }
            else if (q.nMdxMsgType == 3)
            {
                if (VerboseDebugging)
                    debug(q.bstrUpdateTime
                    + "  Received Halt/Delay for: " + q.bstrSymbol
                    + "  Status: " + q.bstrHaltResumeStatus
                    + "  Reason: " + q.bstrHaltResumeReason);

                int time;
                if (int.TryParse(q.bstrUpdateTime, out time))
                {
                    HaltResume h = new HaltResumeImpl(q.bstrSymbol, GetExPretty(q.bstrExch), time, q.bstrHaltResumeStatus, q.bstrHaltResumeReason);
                    for (int clientNumber = 0; clientNumber < tl.NumClients; clientNumber++)
                        tl.TLSend(HaltResumeImpl.Serialize(h), MessageTypes.HALTRESUME, clientNumber);
                }
            }
            else if (q.nMdxMsgType == 4)
            {
                if (VerboseDebugging)
                    debug(q.bstrUpdateTime
                    + "  Received Indication for: " + q.bstrSymbol
                    + "  ValidIndicators: " + q.bValidIndicators
                    + "  IndicatorHigh: " + q.fIndicatorHigh
                    + "  IndicatorLow: " + q.fIndicatorLow);

                int time;
                if (int.TryParse(q.bstrUpdateTime, out time))
                {
                    Indication ind = new IndicationImpl(q.bstrSymbol, GetExPretty(q.bstrExch), time, q.bValidIndicators, (decimal)q.fIndicatorHigh, (decimal)q.fIndicatorLow);
                    for (int clientNumber = 0; clientNumber < tl.NumClients; clientNumber++)
                        tl.TLSend(IndicationImpl.Serialize(ind), MessageTypes.INDICATION, clientNumber);
                }
            }
        }
Example #7
0
 void stiQuote_OnSTIQuoteUpdate(ref structSTIQuoteUpdate q)
 {
     if (UseXmlMode) return;
     doquote(ref q);
 }
Example #8
0
        void doquote(ref structSTIQuoteUpdate q)
        {
            Tick k = new TickImpl(q.bstrSymbol);

            k.bid = (decimal)q.fBidPrice;
            k.ask = (decimal)q.fAskPrice;
            k.bs  = q.nBidSize / 100;
            k.os  = q.nAskSize / 100;
            k.ex  = GetExPretty(q.bstrExch);
            k.be  = GetExPretty(q.bstrBidExch);
            k.oe  = GetExPretty(q.bstrAskExch);
            int now = Convert.ToInt32(q.bstrUpdateTime);

            k.date = Util.ToTLDate(DateTime.Now);
            //int sec = now % 100;
            k.time = now;

            // we don't want to simply return on out-of-order ticks because it'll prevent processing
            // of the mdx messages further in this function.
            if (!IgnoreOutOfOrderTicks || (k.time > _lasttime))
            {
                _lasttime = k.time;
                k.trade   = (decimal)q.fLastPrice;
                k.size    = q.nLastSize;
                // execute orders if papertrade is enabled
                if (isPaperTradeEnabled)
                {
                    ptt.newTick(k);
                }
                // notify clients of tick
                if (!_imbalance || (_imbalance && k.isValid))
                {
                    tl.newTick(k);
                }
            }

            /////////////////////////
            // MDX Processing
            /////////////////////////
            if (q.nMdxMsgType == 1)
            {
                if (VerboseDebugging)
                {
                    debug(q.bstrUpdateTime
                          + "  Received Regulatory Imbalance for: " + q.bstrSymbol
                          + "  ValidIntradayMarketImb: " + q.bValidIntradayMktImb
                          + "  ValidMktImb: " + q.bValidMktImb
                          + "  Imbalance: " + q.nImbalance
                          + "  iMktImbalance: " + q.nIntradayMktImbalance
                          + "  MktImbalance: " + q.nMktImbalance);
                }

                int time;
                if (int.TryParse(q.bstrUpdateTime, out time))
                {
                    Imbalance imb = new ImbalanceImpl(q.bstrSymbol, GetExPretty(q.bstrExch), q.nIntradayMktImbalance, time, 0, 0, 0);
                    tl.newImbalance(imb);
                }
            }
            else if (q.nMdxMsgType == 2)
            {
                if (VerboseDebugging)
                {
                    debug(q.bstrUpdateTime
                          + "  Received Informational Imbalance for: " + q.bstrSymbol
                          + "  ValidIntradayMarketImb: " + q.bValidIntradayMktImb
                          + "  ValidMktImb: " + q.bValidMktImb
                          + "  Imbalance: " + q.nImbalance
                          + "  iMktImbalance: " + q.nIntradayMktImbalance
                          + "  MktImbalance: " + q.nMktImbalance);
                }

                int time;
                if (int.TryParse(q.bstrUpdateTime, out time))
                {
                    Imbalance imb = new ImbalanceImpl(q.bstrSymbol, GetExPretty(q.bstrExch), 0, time, 0, 0, q.nIntradayMktImbalance);
                    tl.newImbalance(imb);
                }
            }
            else if (q.nMdxMsgType == 3)
            {
                if (VerboseDebugging)
                {
                    debug(q.bstrUpdateTime
                          + "  Received Halt/Delay for: " + q.bstrSymbol
                          + "  Status: " + q.bstrHaltResumeStatus
                          + "  Reason: " + q.bstrHaltResumeReason);
                }

                int time;
                if (int.TryParse(q.bstrUpdateTime, out time))
                {
                    HaltResume h = new HaltResumeImpl(q.bstrSymbol, GetExPretty(q.bstrExch), time, q.bstrHaltResumeStatus, q.bstrHaltResumeReason);
                    for (int clientNumber = 0; clientNumber < tl.NumClients; clientNumber++)
                    {
                        tl.TLSend(HaltResumeImpl.Serialize(h), MessageTypes.HALTRESUME, clientNumber);
                    }
                }
            }
            else if (q.nMdxMsgType == 4)
            {
                if (VerboseDebugging)
                {
                    debug(q.bstrUpdateTime
                          + "  Received Indication for: " + q.bstrSymbol
                          + "  ValidIndicators: " + q.bValidIndicators
                          + "  IndicatorHigh: " + q.fIndicatorHigh
                          + "  IndicatorLow: " + q.fIndicatorLow);
                }

                int time;
                if (int.TryParse(q.bstrUpdateTime, out time))
                {
                    Indication ind = new IndicationImpl(q.bstrSymbol, GetExPretty(q.bstrExch), time, q.bValidIndicators, (decimal)q.fIndicatorHigh, (decimal)q.fIndicatorLow);
                    for (int clientNumber = 0; clientNumber < tl.NumClients; clientNumber++)
                    {
                        tl.TLSend(IndicationImpl.Serialize(ind), MessageTypes.INDICATION, clientNumber);
                    }
                }
            }
        }
Example #9
0
 void stiQuote_OnSTIQuoteUpdate(ref structSTIQuoteUpdate q)
 {
     Tick k = new TickImpl(q.bstrSymbol);
     k.bid = (decimal)q.fBidPrice;
     k.ask = (decimal)q.fAskPrice;
     k.bs = q.nBidSize / 100;
     k.os = q.nAskSize / 100;
     if (q.bstrExch!="*")
         k.ex = q.bstrExch;
     if (q.bstrBidExch != "*")
         k.be = q.bstrBidExch;
     if (q.bstrAskExch != "*")
         k.oe = q.bstrAskExch;
     int now = Convert.ToInt32(q.bstrUpdateTime);
     k.date = Util.ToTLDate(DateTime.Now);
     int sec = now % 100;
     k.time = now;
     k.trade = (decimal)q.fLastPrice;
     k.size = q.nLastSize;
     tl.newTick(k);
     if ((q.bValidMktImb==0)||!imbalance) return;
     tl.newImbalance(new ImbalanceImpl(k.symbol, k.ex, q.nMktImbalance, k.time, 0, 0,0));
    
 }