Beispiel #1
0
        public Level1SummaryUpdateEventArgs(string line)
        {
            try
            {                
                var fields = line.Split(',');
                _summary = fields[0] == "P";
                _symbol = fields[1];
                _notFound = line.Contains("Not Found");

                if (_notFound) return;
                if (!double.TryParse(fields[3], out _last)) _last = 0;
                if (!double.TryParse(fields[4], out _change)) _change = 0;
                if (!double.TryParse(fields[5], out _change)) _percentChange = 0;
                if (!int.TryParse(fields[6], out _totalVolume)) _totalVolume = 0;
                if (!int.TryParse(fields[7], out _incrementalVolume)) _incrementalVolume = 0;
                if (!double.TryParse(fields[8], out _high)) _high = 0;
                if (!double.TryParse(fields[9], out _low)) _low = 0;
                if (!double.TryParse(fields[10], out _bid)) _bid = 0;
                if (!double.TryParse(fields[11], out _ask)) _ask = 0;
                if (!int.TryParse(fields[12], out _bidSize)) _bidSize = 0;
                if (!int.TryParse(fields[13], out _askSize)) _askSize = 0;
                if (!int.TryParse(fields[14], out _tick)) _tick = 0;
                if (!int.TryParse(fields[15], out _bidTick)) _bidTick = 0;
                if (!double.TryParse(fields[16], out _range)) _range = 0;
                if (!string.IsNullOrEmpty(fields[17]))
                {
                    switch (fields[17].Substring(fields[17].Length - 1, 1))
                    {
                        case "t":
                            _updateType = UpdateType.Trade;
                            break;
                        case "T":
                            _updateType = UpdateType.ExtendedTrade;
                            break;
                        case "b":
                            _updateType = UpdateType.Bid;
                            break;
                        case "a":
                            _updateType = UpdateType.Ask;
                            break;
                        default:
                            _updateType = UpdateType.Other;
                            break;
                    }
                }
                else
                {
                    return;
                }
                if (!int.TryParse(fields[18], out _openInterest)) _openInterest = 0;
                if (!double.TryParse(fields[19], out _open)) _open = 0;
                if (!double.TryParse(fields[20], out _close)) _close = 0;
                if (!double.TryParse(fields[21], out _spread)) _spread = 0;
                if (!double.TryParse(fields[23], out _settle)) _settle = 0;
                if (!int.TryParse(fields[24], out _delay)) _delay = 0;
                _shortRestricted = false;
                if (fields[26] == "R") _shortRestricted = true;
                if (!double.TryParse(fields[27], out _netAssetValue)) _netAssetValue = 0;
                if (!double.TryParse(fields[28], out _averageMaturity)) _averageMaturity = 0;
                if (!double.TryParse(fields[29], out _7DayYield)) _7DayYield = 0;
                if (!DateTime.TryParseExact(fields[30], "MM/dd/yyyy", _enUS, DateTimeStyles.None, out _lastTradeDate)) _lastTradeDate = DateTime.MinValue;
                if (!double.TryParse(fields[32], out _extendedTradingLast)) _extendedTradingLast = 0;
                if (!int.TryParse(fields[34], out _regionalVolume)) _regionalVolume = 0;
                if (!double.TryParse(fields[35], out _netAssetValue2)) _netAssetValue2 = 0;
                if (!double.TryParse(fields[36], out _extendedTradingChange)) _extendedTradingChange = 0;
                if (!double.TryParse(fields[37], out _extendedTradingDifference)) _extendedTradingDifference = 0;
                if (!double.TryParse(fields[38], out _priceEarningsRatio)) _priceEarningsRatio = 0;
                if (!double.TryParse(fields[39], out _percentOffAverageVolume)) _percentOffAverageVolume = 0;
                if (!double.TryParse(fields[40], out _bidChange)) _bidChange = 0;
                if (!double.TryParse(fields[41], out _askChange)) _askChange = 0;
                if (!double.TryParse(fields[42], out _changeFromOpen)) _changeFromOpen = 0;
                _marketOpen = false;
                if (fields[43] == "1") _marketOpen = true;
                if (!double.TryParse(fields[44], out _volatility)) _volatility = 0;
                if (!double.TryParse(fields[45], out _marketCapitalization)) _marketCapitalization = 0;
                _fractionDisplayCode = fields[46];
                _decimalPrecision = fields[47];
                _daysToExpiration = fields[48];
                if (!int.TryParse(fields[49], out _previousDayVolume)) _previousDayVolume = 0;
                if (!double.TryParse(fields[51], out _openRange1)) _openRange1 = 0;
                if (!double.TryParse(fields[52], out _closeRange1)) _closeRange1 = 0;
                if (!double.TryParse(fields[53], out _openRange2)) _openRange2 = 0;
                if (!double.TryParse(fields[54], out _closeRange2)) _closeRange2 = 0;
                if (!int.TryParse(fields[55], out _numberOfTradesToday)) _numberOfTradesToday = 0;
                _bidTime = new Time(fields[56]);
                _askTime = new Time(fields[57]);
                if (!double.TryParse(fields[58], out _vwap)) _vwap = 0;
                if (!int.TryParse(fields[59], out _tickId)) _tickId = 0;
                _financialStatusIndicator = fields[60];
                if (!DateTime.TryParseExact(fields[61], "MM/dd/yyyy", _enUS, DateTimeStyles.None, out _settlementDate)) _settlementDate = DateTime.MinValue;
                if (!int.TryParse(fields[62], out _tradeMarketCenter)) _tradeMarketCenter = 0;
                if (!int.TryParse(fields[63], out _bidMarketCenter)) _bidMarketCenter = 0;
                if (!int.TryParse(fields[64], out _askMarketCenter)) _askMarketCenter = 0;
                _tradeTime = new Time(fields[65]);
                _availableRegions = fields[66];
            }
            catch (Exception err)
            {
                Logging.Log.Debug("IQLevel1Client.Init(): " + err.Message);
            }
        }
Beispiel #2
0
        public int RequestIntervalData(string symbol, Interval interval, DateTime start, DateTime?end, bool oldToNew, Time timeStartInDay = null, Time timeEndInDay = null)
        {
            _lastRequestNumber++;
            var reqNo = LookupType.REQ_HST_INT.ToString() + _lastRequestNumber.ToString("0000000");
            //if (timeStartInDay == null) timeStartInDay = _timeMarketOpen;
            //if (timeEndInDay == null) timeEndInDay = _timeMarketClose;

            var reqString = string.Format("HIT,{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}\r\n", symbol, interval.Seconds.ToString("0000000"),
                                          start.ToString("yyyyMMdd HHmmss"), end.HasValue ? end.Value.ToString("yyyyMMdd HHmmss") : "",
                                          "", timeStartInDay == null ? "" : timeStartInDay.IQFeedFormat, timeEndInDay == null ? "" : timeEndInDay.IQFeedFormat, oldToNew ? "1" : "0",
                                          reqNo, _histDataPointsPerSend.ToString("0000000"));

            Send(reqString);
            OnLookupEvent(new LookupEventArgs(reqNo, LookupType.REQ_HST_INT, LookupSequence.MessageStart));

            return(_lastRequestNumber);
        }
Beispiel #3
0
 public Level1RegionalEventArgs(string line)
 {
     var fields = line.Split(',');
     _symbol = fields[1];
     if (!double.TryParse(fields[3], out _regionalBid)) _regionalBid = 0;
     if (!int.TryParse(fields[4], out _regionalBidSize)) _regionalBidSize = 0;
     _regionalBidTime = new Time(fields[5]);
     if (!double.TryParse(fields[6], out _regionalAsk)) _regionalAsk = 0;
     if (!int.TryParse(fields[7], out _regionalAskSize)) _regionalAskSize = 0;
     _regionalAskTime = new Time(fields[8]);
     _fractionDisplayCode = fields[9];
     _decimalPrecision = fields[10];
     _marketCenter = fields[11];
 }
Beispiel #4
0
        public int RequestIntervalData(string symbol, Interval interval, int days, bool oldToNew, Time timeStartInDay = null, Time timeEndInDay = null)
        {
            _lastRequestNumber++;
            var reqNo = LookupType.REQ_HST_INT.ToString() + _lastRequestNumber.ToString("0000000");

            if (timeStartInDay == null)
            {
                timeStartInDay = _timeMarketOpen;
            }
            if (timeEndInDay == null)
            {
                timeEndInDay = _timeMarketClose;
            }

            var reqString = string.Format("HID,{0},{1},{2},{3},{4},{5},{6},{7},{8}\r\n", symbol, interval.Seconds.ToString("0000000"),
                                          days.ToString("0000000"), _histMaxDataPoints.ToString("0000000"), timeStartInDay.IQFeedFormat, timeEndInDay.IQFeedFormat,
                                          oldToNew ? "1" : "0", reqNo, _histDataPointsPerSend.ToString("0000000"));

            Send(reqString);
            OnLookupEvent(new LookupEventArgs(reqNo, LookupType.REQ_HST_INT, LookupSequence.MessageStart));

            return(_lastRequestNumber);
        }
        public Level1SummaryUpdateEventArgs(string line)
        {
            try
            {
                var fields = line.Split(',');
                _summary  = fields[0] == "P";
                _symbol   = fields[1];
                _notFound = line.Contains("Not Found");

                if (_notFound)
                {
                    return;
                }
                if (!double.TryParse(fields[3], out _last))
                {
                    _last = 0;
                }
                if (!double.TryParse(fields[4], out _change))
                {
                    _change = 0;
                }
                if (!double.TryParse(fields[5], out _change))
                {
                    _percentChange = 0;
                }
                if (!int.TryParse(fields[6], out _totalVolume))
                {
                    _totalVolume = 0;
                }
                if (!int.TryParse(fields[7], out _incrementalVolume))
                {
                    _incrementalVolume = 0;
                }
                if (!double.TryParse(fields[8], out _high))
                {
                    _high = 0;
                }
                if (!double.TryParse(fields[9], out _low))
                {
                    _low = 0;
                }
                if (!double.TryParse(fields[10], out _bid))
                {
                    _bid = 0;
                }
                if (!double.TryParse(fields[11], out _ask))
                {
                    _ask = 0;
                }
                if (!int.TryParse(fields[12], out _bidSize))
                {
                    _bidSize = 0;
                }
                if (!int.TryParse(fields[13], out _askSize))
                {
                    _askSize = 0;
                }
                if (!int.TryParse(fields[14], out _tick))
                {
                    _tick = 0;
                }
                if (!int.TryParse(fields[15], out _bidTick))
                {
                    _bidTick = 0;
                }
                if (!double.TryParse(fields[16], out _range))
                {
                    _range = 0;
                }
                if (!string.IsNullOrEmpty(fields[17]))
                {
                    switch (fields[17].Substring(fields[17].Length - 1, 1))
                    {
                    case "t":
                        _updateType = UpdateType.Trade;
                        break;

                    case "T":
                        _updateType = UpdateType.ExtendedTrade;
                        break;

                    case "b":
                        _updateType = UpdateType.Bid;
                        break;

                    case "a":
                        _updateType = UpdateType.Ask;
                        break;

                    default:
                        _updateType = UpdateType.Other;
                        break;
                    }
                }
                else
                {
                    return;
                }
                if (!int.TryParse(fields[18], out _openInterest))
                {
                    _openInterest = 0;
                }
                if (!double.TryParse(fields[19], out _open))
                {
                    _open = 0;
                }
                if (!double.TryParse(fields[20], out _close))
                {
                    _close = 0;
                }
                if (!double.TryParse(fields[21], out _spread))
                {
                    _spread = 0;
                }
                if (!double.TryParse(fields[23], out _settle))
                {
                    _settle = 0;
                }
                if (!int.TryParse(fields[24], out _delay))
                {
                    _delay = 0;
                }
                _shortRestricted = false;
                if (fields[26] == "R")
                {
                    _shortRestricted = true;
                }
                if (!double.TryParse(fields[27], out _netAssetValue))
                {
                    _netAssetValue = 0;
                }
                if (!double.TryParse(fields[28], out _averageMaturity))
                {
                    _averageMaturity = 0;
                }
                if (!double.TryParse(fields[29], out _7DayYield))
                {
                    _7DayYield = 0;
                }
                if (!DateTime.TryParseExact(fields[30], "MM/dd/yyyy", _enUS, DateTimeStyles.None, out _lastTradeDate))
                {
                    _lastTradeDate = DateTime.MinValue;
                }
                if (!double.TryParse(fields[32], out _extendedTradingLast))
                {
                    _extendedTradingLast = 0;
                }
                if (!int.TryParse(fields[34], out _regionalVolume))
                {
                    _regionalVolume = 0;
                }
                if (!double.TryParse(fields[35], out _netAssetValue2))
                {
                    _netAssetValue2 = 0;
                }
                if (!double.TryParse(fields[36], out _extendedTradingChange))
                {
                    _extendedTradingChange = 0;
                }
                if (!double.TryParse(fields[37], out _extendedTradingDifference))
                {
                    _extendedTradingDifference = 0;
                }
                if (!double.TryParse(fields[38], out _priceEarningsRatio))
                {
                    _priceEarningsRatio = 0;
                }
                if (!double.TryParse(fields[39], out _percentOffAverageVolume))
                {
                    _percentOffAverageVolume = 0;
                }
                if (!double.TryParse(fields[40], out _bidChange))
                {
                    _bidChange = 0;
                }
                if (!double.TryParse(fields[41], out _askChange))
                {
                    _askChange = 0;
                }
                if (!double.TryParse(fields[42], out _changeFromOpen))
                {
                    _changeFromOpen = 0;
                }
                _marketOpen = false;
                if (fields[43] == "1")
                {
                    _marketOpen = true;
                }
                if (!double.TryParse(fields[44], out _volatility))
                {
                    _volatility = 0;
                }
                if (!double.TryParse(fields[45], out _marketCapitalization))
                {
                    _marketCapitalization = 0;
                }
                _fractionDisplayCode = fields[46];
                _decimalPrecision    = fields[47];
                _daysToExpiration    = fields[48];
                if (!int.TryParse(fields[49], out _previousDayVolume))
                {
                    _previousDayVolume = 0;
                }
                if (!double.TryParse(fields[51], out _openRange1))
                {
                    _openRange1 = 0;
                }
                if (!double.TryParse(fields[52], out _closeRange1))
                {
                    _closeRange1 = 0;
                }
                if (!double.TryParse(fields[53], out _openRange2))
                {
                    _openRange2 = 0;
                }
                if (!double.TryParse(fields[54], out _closeRange2))
                {
                    _closeRange2 = 0;
                }
                if (!int.TryParse(fields[55], out _numberOfTradesToday))
                {
                    _numberOfTradesToday = 0;
                }
                _bidTime = new Time(fields[56]);
                _askTime = new Time(fields[57]);
                if (!double.TryParse(fields[58], out _vwap))
                {
                    _vwap = 0;
                }
                if (!int.TryParse(fields[59], out _tickId))
                {
                    _tickId = 0;
                }
                _financialStatusIndicator = fields[60];
                if (!DateTime.TryParseExact(fields[61], "MM/dd/yyyy", _enUS, DateTimeStyles.None, out _settlementDate))
                {
                    _settlementDate = DateTime.MinValue;
                }
                if (!int.TryParse(fields[62], out _tradeMarketCenter))
                {
                    _tradeMarketCenter = 0;
                }
                if (!int.TryParse(fields[63], out _bidMarketCenter))
                {
                    _bidMarketCenter = 0;
                }
                if (!int.TryParse(fields[64], out _askMarketCenter))
                {
                    _askMarketCenter = 0;
                }
                _tradeTime        = new Time(fields[65]);
                _availableRegions = fields[66];
            }
            catch (Exception err)
            {
                Logging.Log.Debug("IQLevel1Client.Init(): " + err.Message);
            }
        }
        public int RequestIntervalData(string symbol, Interval interval, DateTime start, DateTime? end, bool oldToNew, Time timeStartInDay = null, Time timeEndInDay = null)
        {
            _lastRequestNumber++;
            var reqNo = LookupType.REQ_HST_INT.ToString() + _lastRequestNumber.ToString("0000000");
            //if (timeStartInDay == null) timeStartInDay = _timeMarketOpen;
            //if (timeEndInDay == null) timeEndInDay = _timeMarketClose;

            var reqString = string.Format("HIT,{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}\r\n", symbol, interval.Seconds.ToString("0000000"),
                start.ToString("yyyyMMdd HHmmss"), end.HasValue ? end.Value.ToString("yyyyMMdd HHmmss") : "",
                "", timeStartInDay == null ? "" : timeStartInDay.IQFeedFormat, timeEndInDay == null ? "" : timeEndInDay.IQFeedFormat,  oldToNew ? "1" : "0",
                 reqNo, _histDataPointsPerSend.ToString("0000000"));

            Send(reqString);
            OnLookupEvent(new LookupEventArgs(reqNo, LookupType.REQ_HST_INT, LookupSequence.MessageStart));

            return _lastRequestNumber;
        }
        public int RequestIntervalData(string symbol, Interval interval, int days, bool oldToNew, Time timeStartInDay = null, Time timeEndInDay = null)
        {
            _lastRequestNumber++;
            var reqNo = LookupType.REQ_HST_INT.ToString() + _lastRequestNumber.ToString("0000000");
            if (timeStartInDay == null) timeStartInDay = _timeMarketOpen;
            if (timeEndInDay == null) timeEndInDay = _timeMarketClose;

            var reqString = string.Format("HID,{0},{1},{2},{3},{4},{5},{6},{7},{8}\r\n", symbol, interval.Seconds.ToString("0000000"),
                days.ToString("0000000"), _histMaxDataPoints.ToString("0000000"), timeStartInDay.IQFeedFormat, timeEndInDay.IQFeedFormat,
                oldToNew ? "1" : "0", reqNo, _histDataPointsPerSend.ToString("0000000"));
                 
            Send(reqString);
            OnLookupEvent(new LookupEventArgs(reqNo, LookupType.REQ_HST_INT, LookupSequence.MessageStart));

            return _lastRequestNumber;
        }
 // Constructor
 public IQLookupHistorySymbolClient(int bufferSize)
     : base(IQSocket.GetEndPoint(PortType.Lookup), bufferSize)
 {
     _histDataPointsPerSend = 500;
     _timeMarketOpen = new Time(09, 30, 00);
     _timeMarketClose = new Time(16, 00, 00);
     _lastRequestNumber = -1;
     _histMaxDataPoints = 5000;
  }