void processSecBidAskLine(string line, int date, SecProduct product) { int lineNumber = int.Parse(line.Substring(0, 8).Trim()); int TIME = int.Parse(line.Substring(8, 9)); int sec = (TIME / 1000); int millSec = TIME % 1000; char type = line[17]; string[] arrVBar = line.Substring(19).Split(VBAR); ProductEvent pEvent = null; if (type == 'A' || type == 'B' || type == 'C') { //return;//hack for dayEndOnly pEvent = new BidAskEvent(product, type, date, sec, millSec, 0); } else if (type == 'D' || type == 'E') pEvent = new ProductEvent(product, date, sec, millSec); else return; if (!eventSecondList.ContainsKey(sec)) eventSecondList.Add(sec, new EventInSecond()); eventSecondList[sec].events.Add(pEvent); if (type == 'E') { pEvent.EnablesStatistics(); char ch = arrVBar[1][0]; float val = float.Parse(arrVBar[1].Substring(1)); if (ch == 'C') pEvent.DayClose = val; else { pEvent.PrevClose = val; pEvent.Suspended = (ch == 'S') ? 'Y' : 'N'; } return; } if (arrVBar[0].Length > 0) { string[] arr = arrVBar[0].Split(COMMA); pEvent.EnablesStatistics(); pEvent.Day2SecHighest = float.Parse(arr[0]); pEvent.Day2SecLowest = float.Parse(arr[1]); pEvent.Day2SecTradedShare = float.Parse(arr[2]); pEvent.Day2SecTradedVolume = float.Parse(arr[3]); pEvent.LastPrice = (arr[4] == "-") ? float.NaN : float.Parse(arr[4]); } if (arrVBar.Length == 1) return; BidAskEvent baEvent = pEvent as BidAskEvent; // handle first section { string[] arr1 = arrVBar[1].Split(COMMA); int queueDepth1 = (arr1.Length - 1) / 2; float price1 = float.Parse(arr1[0]); List<PriceQty> pList1 = new List<PriceQty>(); float[] priceSpread = (type == BidAsk.ASK) ? HKExPriceSpreadFunctions.getPriceLevel(price1, true, 10) : HKExPriceSpreadFunctions.getPriceLevel(price1, false, 10); for (int i = 0; i < queueDepth1; i++) { float price = priceSpread[i]; int qLen = int.Parse(arr1[i * 2 + 1]); long LongQty = (int)(float.Parse(arr1[i * 2 + 2])*1000); int qty = (LongQty > int.MaxValue) ? int.MaxValue - 1 :(int) (LongQty); if (qLen > 0 || qty > 0) pList1.Add(new PriceQty(price, qty, qLen)); } if (type == 'A') baEvent.asks = pList1.ToArray(); else baEvent.bids = pList1.ToArray(); } // handle 2nd section if (type == BidAsk.BOTH) { string[] arr2 = arrVBar[2].Split(COMMA); int queueDepth2 = (arr2.Length - 1) / 2; float price2 = float.Parse(arr2[0]); List<PriceQty> pList2 = new List<PriceQty>(); float[] priceSpread = HKExPriceSpreadFunctions.getPriceLevel(price2, true, 10); for (int i = 0; i < queueDepth2; i++) { float price = priceSpread[i]; int qLen = int.Parse(arr2[i * 2 + 1]); int qty = (int)(float.Parse(arr2[i * 2 + 2])*1000); if (qLen > 0 || qty > 0) pList2.Add(new PriceQty(price, qty, qLen)); } baEvent.asks = pList2.ToArray(); } }
void processDevBidAskLineList(List<string> lines, string[] strArgList, int[] intArgList, HashSet<string>[] filters, ConcurrentQueue<Object> queue2) { int date = intArgList[0]; bool readAll = (intArgList[1] == 1); string seriesMain = strArgList[0]; HashSet<string> productFilter = filters[0]; for (int i = 0; i < lines.Count; i++) { string line = lines[i]; string[] val = line.Split(COMMA); string prodkey = seriesMain + val[2]; if (!readAll && !productFilter.Contains(prodkey)) continue; int TIME = int.Parse(val[0]); int lineNum = int.Parse(val[1]); char BID_ASK = val[3][0]; float PRICE = float.Parse(val[4]); int QUANTITY = int.Parse(val[5]); DevProduct product = ProductTable[prodkey] as DevProduct; BidAskEvent bidAskEvent = new BidAskEvent(product, BID_ASK, date, TIME, 0, PRICE, QUANTITY); bidAskEvent.lineNumber = lineNum; if (!eventSecondList.ContainsKey(TIME)) eventSecondList.Add(TIME, new EventInSecond()); EventInSecond eis = eventSecondList[TIME]; eis.events.Add(bidAskEvent); } }