public RawMarketData Decode_Raw(InPacket iPacket, String targetCode, DateTime curDateTime) { try { StringPacket sp = new StringPacket(iPacket.ToString().Substring(24)); String code = sp.Decode(); if (code != targetCode) { return null; } RawMarketData rmd = new RawMarketData(targetCode, Detail.ProductType.Unknown); String type = sp.Decode(); double value = Convert.ToDouble(sp.Decode()); DateTime dt = DateTime.ParseExact(sp.Decode(), "yyyyMMdd HH:mm:ss.fff", null); SetData_Raw(rmd, type, value, dt); return rmd; } catch (System.Exception ex) { logger.Warn(ex.ToString()); } return null; }
public void OutPacketEncodeTest() { OutPacket target = new OutPacket(); target.ReserveForPacketLength(6, 6); target.Encode32(100, 10); target.EncodeStr("test", 10); target.BuildPacketWithPacketLength(); InPacket iPacket = new InPacket(target); String strPacket = iPacket.ToString(); int result = strPacket.CompareTo("20 100 test "); Assert.AreEqual(0, result); }
public void SetData(InPacket iPacket) { try { StringPacket sp = new StringPacket(iPacket.ToString()); String code = sp.Decode(); RawMarketData rmd = RmdManager.Ins().KtbSpot.GetData(code); if (rmd == null) { return; } String type = sp.Decode(); double value = Convert.ToDouble(sp.Decode()); DateTime dt = DateTime.ParseExact(sp.Decode(), "yyyyMMdd HH:mm:ss.fff", null); SetData_Raw(rmd, type, value, dt); } catch (System.Exception ex) { logger.Warn(ex.ToString()); } }
private void SetUsdFutureDataUsingInfomaxData(InPacket iPacket) { try { StringPacket sp = new StringPacket(iPacket.ToString()); String code = sp.Decode(); RawMarketData rmd = RmdManager.Ins().GetData(code); if (rmd == null) { return; } if (rmd.DPT == Detail.ProductType.KospiFuture || rmd.DPT == Detail.ProductType.KospiFutureSpread) { // Kospi 관련 데이터는 신한에서 받는다. return; } String type = sp.Decode(); double value = Convert.ToDouble(sp.Decode()); DateTime dt = DateTime.ParseExact(sp.Decode(), "yyyyMMdd HH:mm:ss.fff", null); InfomaxDataToRawMarketData(rmd, type, value, dt); } catch (System.Exception ex) { logger.Warn(ex.ToString()); } }