Exemplo n.º 1
0
		private static ZBuffer Decode(string content) {
			ZBuffer cBuffer = null;
			string[] sDatas = content.Split(new char[] { '\r', '\n' });
			if (sDatas[0].Length == 0) {
				return cBuffer;
			}

			int iLength = sDatas.Length;
			if (iLength > 1) {
				cBuffer = new ZBuffer(iLength * 20);

				int iIndexM = -1, iIndexW = -1;
				bool bWeek = false;
				string sSymbolId = null;
				string sSymbol = string.Empty;
				string sContract = string.Empty;
				for (int i = 1; i < iLength; i++) {
					string sData = sDatas[i];
					if (sData.Length > 0) {
						string[] sItems = sData.Split(',');
						int iInterest = int.Parse(sItems[11]);
						if (iInterest > 0) {
							bWeek = sItems[2][6] == 'W';
							float fTarget = float.Parse(sItems[3]);
							char chCallOrPut = sItems[4].Equals("買權") ? 'C' : 'P';

							if (!sSymbol.Equals(sItems[1])) {
								iIndexW = -1;
								iIndexM = -1;
								sSymbol = sItems[1];
								sContract = string.Empty;
							} 
							
							if (!sContract.Equals(sItems[2])) {
								if (bWeek) {
									++iIndexW;
								} else {
									++iIndexM;
								}
								sContract = sItems[2];
							}
							sSymbolId = string.Format("{0}{1}{2}{3}", (bWeek) ? "TXW" : sSymbol, (bWeek) ? iIndexW : iIndexM, chCallOrPut, fTarget);

							cBuffer.Add(sSymbolId);
							cBuffer.Add(iInterest);
						}
					}

				}
			}
			return cBuffer;
		}
Exemplo n.º 2
0
		private static ZBuffer Decode(string content) {
			ZBuffer cBuffer = null;
			string[] sDatas = content.Split(new char[] { '\r', '\n' });
			if (sDatas[0][0] == '<') {
				return cBuffer;
			}

			int iLength = sDatas.Length;
			if (iLength > 1) {
				int iCount = 0;
				cBuffer = new ZBuffer(iLength * 20);

				for (int i = 1; i < iLength; i++) {
					string sData = sDatas[i];
					if (sData.Length > 0) {
						string sSymbolId = null;
						string[] sItems = sData.Split(',');
						if (__cSymbols.TryGetValue(sItems[1], out sSymbolId)) {
							if (iCount == 0) {
								cBuffer.Add(sSymbolId);
							}

							cBuffer.Add(int.Parse(sItems[3]));  //多方交易量
							cBuffer.Add(int.Parse(sItems[5]));  //空方交易量
							cBuffer.Add(int.Parse(sItems[9]));  //多方留倉口
							cBuffer.Add(int.Parse(sItems[11])); //空方留倉口

							if (++iCount == 3) {
								iCount = 0;
							}
						}
					}
				}
			}
			return cBuffer;
		}