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 HandlePacket(Byte[] buf, int streamLength) { InPacket iPacket = new InPacket(); iPacket.ForcedEncode(buf, streamLength); RmdManager.Ins().SetMarketDataUsingKrxData(iPacket, RmdManager.MarketDataType.KOSPI_FUTURE); }
public void HandlePacket(Byte[] buf, int streamLength) { int len = MiniLzo.MiniLzo.Decompress(buf, original); InPacket iPacket = new InPacket(); iPacket.ForcedEncode(original, len); int repeat = 0; while (true) { if (iPacket.End()) { break; } int packetLen = iPacket.Decode16(); int totalPacketLen = (int)(packetLen + 2); String packet = iPacket.DecodeString(packetLen); _sw.Write("[{0}]\t", DateTime.Now.ToString("yyyyMMdd HH:mm:ss.fff")); _sw.Write(packet); _sw.Write("\r\n"); iPacket.AdvancePivot(totalPacketLen); ++repeat; } }
public void SetData(InPacket iPacket) { iPacket.SkipDecode(5); iPacket.SkipDecode(10); String usdPacketType = iPacket.DecodeString(4); if (!_usdSpotPacketDict.ContainsKey(usdPacketType)) { _usdSpotPacketDict.Add(usdPacketType, 0); } _usdSpotPacketDict[usdPacketType]++; switch (usdPacketType) { case "FOE1": // 원달러 기일물별 체결 현황 DecodeAndUpdate_FOE1(iPacket); break; case "FOD1": // 원달러 기일물별 접수 현황 DecodeAndUpdate_FOD1(iPacket); break; case "FOC1": // 원달러 시간대별 거래현황 //DecodeAndUpdate_FOC1(iPacket); break; default: break; } }
public void Decode(InPacket iPacket, int len) { for (int i = 0; i < len; ++i) { iPacket.BufBytes.Add((byte)_aBuf_Bytes[_offset + i]); } _offset += len; }
public void HandlePacket(Byte[] buf, int streamLength) { InPacket iPacket = new InPacket(); iPacket.ForcedEncode(buf, streamLength); lock (_lock) { _board.SetData(iPacket); } }
public KBHTS_ReceiveData(long packetID, String inString) { this.PacketID = packetID; InPacket iPacket = new InPacket(); iPacket.ForcedEncode(inString); iPacket.SkipDecode(9); // 앞의 9자리 DecodeHeader(iPacket); DecodeBody(iPacket); }
public void HandlePacket(Byte[] buf, int streamLength) { InPacket iPacket = new InPacket(); iPacket.ForcedEncode(buf, streamLength); _bondBoard.SetData(iPacket); if (_bSave) { _data.Buffer.Add(new MarketDataRawPacket(streamLength, buf)); } }
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 BondPacketType EncodeHeaderAndGetHeaderType_Bond(ref InPacket iPacket) { const int nSize = 5; byte[] head = new byte[nSize]; iPacket.Decode(head, nSize); System.Text.Encoding enc = System.Text.Encoding.ASCII; String headStr = enc.GetString(head); if (headStr.CompareTo("B6067") == 0) { return BondPacketType.Normal_Small; } else if (headStr.CompareTo("B6027") == 0) { return BondPacketType.Retail; } return BondPacketType.Unknown; }
public void SetData(InPacket iPacket) { const int kSize = 5; byte[] head = new byte[kSize]; iPacket.Decode(head, kSize); KrxPacketUtil.SpotPacketType packetType = KrxPacketUtil.GetSpotPacketType(head); switch (packetType) { case KrxPacketUtil.SpotPacketType._A3_Contract: DecodeAndUpdate_A3_Contract(iPacket); break; case KrxPacketUtil.SpotPacketType._B7_BidAsk: DecodeAndUpdate_B7_BidAsk(iPacket); break; default: break; } }
public void SetData(InPacket iPacket) { const int nSize = 5; byte[] head = new byte[nSize]; iPacket.Decode(head, nSize); KrxPacketUtil.FutureOptionPacketType packetType = KrxPacketUtil.GetFutureOptionPacketType(head); switch (packetType) { case KrxPacketUtil.FutureOptionPacketType.Index_BidAsk: DecodeAndUpdate_BidAsk(iPacket); break; case KrxPacketUtil.FutureOptionPacketType.Index_Contract: DecodeAndUpdate_Contract(iPacket); break; case KrxPacketUtil.FutureOptionPacketType.Index_BidAsk_Contract: DecodeAndUpdate_BidAsk_Contract(iPacket); break; default: break; } }
public void SetData(InPacket iPacket) { const int nSize = 5; byte[] head = new byte[nSize]; iPacket.Decode(head, nSize); KrxPacketUtil.SpotPacketType nType = KrxPacketUtil.GetSpotPacketType(head); lock (_rmdDict) { switch (nType) { case KrxPacketUtil.SpotPacketType._A3_Contract: Handle_Elw_A3_Contract(iPacket); break; case KrxPacketUtil.SpotPacketType._B7_BidAsk: Handle_Elw_B7_BidAsk(iPacket); break; default: break; } } }
public void SetData(InPacket iPacket) { const int nSize = 5; byte[] head = new byte[nSize]; iPacket.Decode(head, nSize); KrxPacketUtil.FutureOptionPacketType nType = KrxPacketUtil.GetFutureOptionPacketType(head); switch (nType) { case KrxPacketUtil.FutureOptionPacketType.Index_BidAsk: Handle_Index_Option_BidAsk_Raw(iPacket); break; case KrxPacketUtil.FutureOptionPacketType.Index_Contract: Handle_Index_Option_Contract_Raw(iPacket); break; case KrxPacketUtil.FutureOptionPacketType.Index_BidAsk_Contract: Handle_Index_Option_BidAsk_Contract_Raw(iPacket); break; default: break; } }
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()); } }
void Handle_Elw_A3_Contract(InPacket iPacket) { try { //코드: KRA643212WC2 (12) String longCode = iPacket.DecodeString(12); String shortCode = ElwUtil.ConvertToShortCode(longCode); if (MarketDataLogOn) { logger.Info("Elw_A3(체결데이터) {0}, A3({1:n0}), B7({2:n0})", shortCode, ++_stock_A3_Count, _stock_B7_Count); } if (shortCode.Length == 0) { return; } //정규시간외구분코드 1 //"전일대비(기준가대비) 1 //전일대비 9 iPacket.SkipDecode(1 + 1 + 9); //체결가격 9 double curPrice = iPacket.DecodeInt(9); //체결수량 10 long contractCount = iPacket.DecodeLong(10); //체결유형코드 2 //시가 9 //고가 9 //저가 9 //누적체결수량 12 //누적거래대금 18 //최종매도매수구분코드 1 //체결가와1호가일치여부 1 iPacket.SkipDecode(2 + 9 + 9 + 9 + 12 + 18 + 1 + 1); //체결시각 6 int time = iPacket.DecodeInt(6); //LP보유수량 15 iPacket.SkipDecode(15); RawMarketData rmd = GetData(shortCode); if (rmd != null) { rmd.CurPrice = curPrice; //매도1호가 9 rmd.AskPrice1 = iPacket.DecodeInt(9); //매수1호가 9 rmd.BidPrice1 = iPacket.DecodeInt(9); rmd.LastUpdatedTime = DateTime.Now; MarketDelayManager.Ins().SetElwLastUpdatedTime(DateTime.Now); if (RMDModifier.Ins().IsOn()) { RMDModifier.Ins().UpdateRMD(ref rmd); } } } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
private void DecodeAndUpdate_Contract(InPacket iPacket) { try { // 종목코드 앞에 3 iPacket.SkipDecode(3); String code = iPacket.DecodeString(8); iPacket.SkipDecode(1); // 종목 seq iPacket.SkipDecode(2); // 현재 가격 부호 iPacket.SkipDecode(1); // 현재 가격 5 double price = ((double)iPacket.DecodeInt(5)) / 100.0; // 체결 수량 6 int amount = iPacket.DecodeInt(6); RawMarketData rmd = GetData(code); if (rmd != null) { rmd.CurAmount = amount; rmd.LastUpdatedTime = DateTime.Now; rmd.CurPrice = price; MarketDelayManager.Ins().SetFutureOptionLastUpdatedTime(DateTime.Now); } } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
void DecodeAndUpdate_BidAsk_Contract(InPacket iPacket) { try { // 종목코드 앞에 3 iPacket.SkipDecode(3); String code = iPacket.DecodeString(8); iPacket.SkipDecode(1); // 종목 seq iPacket.SkipDecode(2); // 현재 가격 부호 iPacket.SkipDecode(1); // 현재 가격 5 double price = ((double)iPacket.DecodeInt(5)) / 100.0; // 체결 수량 6 int amount = iPacket.DecodeInt(6); // 체결유형코드 2 iPacket.SkipDecode(2); // 체결시각 8 iPacket.SkipDecode(8); // 최근월물의 제약정가격 5 iPacket.SkipDecode(5); // 원월물의제약정가격 5 iPacket.SkipDecode(5); // 시가부호1 iPacket.SkipDecode(1); // 시가 5 iPacket.SkipDecode(5); // 고가부호 1 iPacket.SkipDecode(1); // 고가 5 iPacket.SkipDecode(5); // 저가부소 1 iPacket.SkipDecode(1); // 저가 5 iPacket.SkipDecode(5); // 직전가격부호 1 iPacket.SkipDecode(1); // 직전가격 5 iPacket.SkipDecode(5); // 누적체결수량 7 iPacket.SkipDecode(7); // 누적거래대금 12 iPacket.SkipDecode(12); // 정상태구분코드 2 iPacket.SkipDecode(2); // 매수 총 호가 잔량 int bidTotalAmount = iPacket.DecodeInt(6); // 매수 1단계 부호 iPacket.SkipDecode(1); double buyPrice = ((double)iPacket.DecodeInt(5)) / 100.0; int buyAmount = iPacket.DecodeInt(6); // 매수 2단계 부호 iPacket.SkipDecode(1); double buyPrice2 = ((double)iPacket.DecodeInt(5)) / 100.0; int buyAmount2 = iPacket.DecodeInt(6); // 매수 3단계 부호 iPacket.SkipDecode(1); double buyPrice3 = ((double)iPacket.DecodeInt(5)) / 100.0; int buyAmount3 = iPacket.DecodeInt(6); // 매수 4단계 부호 iPacket.SkipDecode(1); double buyPrice4 = ((double)iPacket.DecodeInt(5)) / 100.0; int buyAmount4 = iPacket.DecodeInt(6); // 매수 5단계 부호 iPacket.SkipDecode(1); double buyPrice5 = ((double)iPacket.DecodeInt(5)) / 100.0; int buyAmount5 = iPacket.DecodeInt(6); // 매도 총 호가 잔량 int offerTotalAmount = iPacket.DecodeInt(6); // 매도 1단계 부호 iPacket.SkipDecode(1); double sellPrice = ((double)iPacket.DecodeInt(5)) / 100.0; int sellAmount = iPacket.DecodeInt(6); // 매도 2단계 부호 iPacket.SkipDecode(1); double sellPrice2 = ((double)iPacket.DecodeInt(5)) / 100.0; int sellAmount2 = iPacket.DecodeInt(6); // 매도 3단계 부호 iPacket.SkipDecode(1); double sellPrice3 = ((double)iPacket.DecodeInt(5)) / 100.0; int sellAmount3 = iPacket.DecodeInt(6); // 매도 4단계 부호 iPacket.SkipDecode(1); double sellPrice4 = ((double)iPacket.DecodeInt(5)) / 100.0; int sellAmount4 = iPacket.DecodeInt(6); // 매도 5단계 부호 iPacket.SkipDecode(1); double sellPrice5 = ((double)iPacket.DecodeInt(5)) / 100.0; int sellAmount5 = iPacket.DecodeInt(6); // 매수 유효 호가 건수 int bidTotalCount = iPacket.DecodeInt(5); int bidCaseCount = iPacket.DecodeInt(4); int bidCaseCount2 = iPacket.DecodeInt(4); int bidCaseCount3 = iPacket.DecodeInt(4); int bidCaseCount4 = iPacket.DecodeInt(4); int bidCaseCount5 = iPacket.DecodeInt(4); int offerTotalCount = iPacket.DecodeInt(5); // 매도 호가 건수 int offerCaseCount = iPacket.DecodeInt(4); int offerCaseCount2 = iPacket.DecodeInt(4); int offerCaseCount3 = iPacket.DecodeInt(4); int offerCaseCount4 = iPacket.DecodeInt(4); int offerCaseCount5 = iPacket.DecodeInt(4); RawMarketData rmd = GetData(code); if (rmd != null) { rmd.AskPrice1 = sellPrice; rmd.BidPrice1 = buyPrice; rmd.AskCount1 = sellAmount; rmd.BidCount1 = buyAmount; rmd.AskPrice2 = sellPrice2; rmd.BidPrice2 = buyPrice2; rmd.AskCount2 = sellAmount2; rmd.BidCount2 = buyAmount2; rmd.AskPrice3 = sellPrice3; rmd.BidPrice3 = buyPrice3; rmd.AskCount3 = sellAmount3; rmd.BidCount3 = buyAmount3; rmd.AskPrice4 = sellPrice4; rmd.BidPrice4 = buyPrice4; rmd.AskCount4 = sellAmount4; rmd.BidCount4 = buyAmount4; rmd.AskPrice5 = sellPrice5; rmd.BidPrice5 = buyPrice5; rmd.AskCount5 = sellAmount5; rmd.BidCount5 = buyAmount5; //rmd.AskCaseCount1 = offerCaseCount; //rmd.AskCaseCount2 = offerCaseCount2; //rmd.AskCaseCount3 = offerCaseCount3; //rmd.AskCaseCount4 = offerCaseCount4; //rmd.AskCaseCount5 = offerCaseCount5; //rmd.BidCaseCount1 = bidCaseCount; //rmd.BidCaseCount2 = bidCaseCount2; //rmd.BidCaseCount3 = bidCaseCount3; //rmd.BidCaseCount4 = bidCaseCount4; //rmd.BidCaseCount5 = bidCaseCount5; rmd.TotalBidCount = bidTotalAmount; rmd.TotalAskCount = offerTotalAmount; //rmd.TotalBidCaseCount = bidTotalCount; //rmd.TotalAskCaseCount = offerTotalCount; rmd.LastUpdatedTime = DateTime.Now; MarketDelayManager.Ins().SetFutureOptionLastUpdatedTime(DateTime.Now); rmd.CurAmount = amount; rmd.CurPrice = price; if (RMDModifier.Ins().IsOn()) { RMDModifier.Ins().UpdateRMD(ref rmd); } } } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
void Handle_Index_Option_BidAsk_Raw(InPacket iPacket) { try { // 종목코드 앞에 3 iPacket.SkipDecode(3); String code = iPacket.DecodeString(8); iPacket.SkipDecode(1); // 종목 seq iPacket.SkipDecode(3); // 장상태구분코드 iPacket.SkipDecode(2); // 40 접속 if (MarketDataLogOn) { logger.Info("Option_H0 {0}, H0({1:n0}), C0({2:n0}), H0C0({3:n0})", code, ++_option_H0_Count, _option_C0_Count, _option_H0C0_Count); } // 매수 총 호가 잔량 int bidTotalAmount = iPacket.DecodeInt(7); double buyPrice = ((double)iPacket.DecodeInt(5)) / 100.0; int buyAmount = iPacket.DecodeInt(7); double buyPrice2 = ((double)iPacket.DecodeInt(5)) / 100.0; int buyAmount2 = iPacket.DecodeInt(7); double buyPrice3 = ((double)iPacket.DecodeInt(5)) / 100.0; int buyAmount3 = iPacket.DecodeInt(7); double buyPrice4 = ((double)iPacket.DecodeInt(5)) / 100.0; int buyAmount4 = iPacket.DecodeInt(7); double buyPrice5 = ((double)iPacket.DecodeInt(5)) / 100.0; int buyAmount5 = iPacket.DecodeInt(7); // 매도 총 호가 잔량 int offerTotalAmount = iPacket.DecodeInt(7); double sellPrice = ((double)iPacket.DecodeInt(5)) / 100.0; int sellAmount = iPacket.DecodeInt(7); double sellPrice2 = ((double)iPacket.DecodeInt(5)) / 100.0; int sellAmount2 = iPacket.DecodeInt(7); double sellPrice3 = ((double)iPacket.DecodeInt(5)) / 100.0; int sellAmount3 = iPacket.DecodeInt(7); double sellPrice4 = ((double)iPacket.DecodeInt(5)) / 100.0; int sellAmount4 = iPacket.DecodeInt(7); double sellPrice5 = ((double)iPacket.DecodeInt(5)) / 100.0; int sellAmount5 = iPacket.DecodeInt(7); // 매수 유효 호가 건수 int bidTotalCount = iPacket.DecodeInt(5); int bidCaseCount = iPacket.DecodeInt(4); int bidCaseCount2 = iPacket.DecodeInt(4); int bidCaseCount3 = iPacket.DecodeInt(4); int bidCaseCount4 = iPacket.DecodeInt(4); int bidCaseCount5 = iPacket.DecodeInt(4); int offerTotalCount = iPacket.DecodeInt(5); // 매도 호가 건수 int offerCaseCount = iPacket.DecodeInt(4); int offerCaseCount2 = iPacket.DecodeInt(4); int offerCaseCount3 = iPacket.DecodeInt(4); int offerCaseCount4 = iPacket.DecodeInt(4); int offerCaseCount5 = iPacket.DecodeInt(4); RawMarketData rmd = GetData(code); if (rmd != null) { rmd.AskPrice1 = sellPrice; rmd.BidPrice1 = buyPrice; rmd.AskCount1 = sellAmount; rmd.BidCount1 = buyAmount; rmd.AskPrice2 = sellPrice2; rmd.BidPrice2 = buyPrice2; rmd.AskCount2 = sellAmount2; rmd.BidCount2 = buyAmount2; rmd.AskPrice3 = sellPrice3; rmd.BidPrice3 = buyPrice3; rmd.AskCount3 = sellAmount3; rmd.BidCount3 = buyAmount3; rmd.AskPrice4 = sellPrice4; rmd.BidPrice4 = buyPrice4; rmd.AskCount4 = sellAmount4; rmd.BidCount4 = buyAmount4; rmd.AskPrice5 = sellPrice5; rmd.BidPrice5 = buyPrice5; rmd.AskCount5 = sellAmount5; rmd.BidCount5 = buyAmount5; //rmd.AskCaseCount1 = offerCaseCount; //rmd.AskCaseCount2 = offerCaseCount2; //rmd.AskCaseCount3 = offerCaseCount3; //rmd.AskCaseCount4 = offerCaseCount4; //rmd.AskCaseCount5 = offerCaseCount5; //rmd.BidCaseCount1 = bidCaseCount; //rmd.BidCaseCount2 = bidCaseCount2; //rmd.BidCaseCount3 = bidCaseCount3; //rmd.BidCaseCount4 = bidCaseCount4; //rmd.BidCaseCount5 = bidCaseCount5; rmd.TotalBidCount = bidTotalAmount; rmd.TotalAskCount = offerTotalAmount; //rmd.TotalBidCaseCount = bidTotalCount; //rmd.TotalAskCaseCount = offerTotalCount; rmd.LastUpdatedTime = DateTime.Now; MarketDelayManager.Ins().SetFutureOptionLastUpdatedTime(DateTime.Now); if (RMDModifier.Ins().IsOn()) { RMDModifier.Ins().UpdateRMD(ref rmd); } } } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
private void Handle_Index_Future_Contract_Raw(InPacket iPacket) { try { // 종목코드 앞에 3 iPacket.SkipDecode(3); String code = iPacket.DecodeString(8); iPacket.SkipDecode(1); // 종목 seq iPacket.SkipDecode(2); // 현재 가격 부호 iPacket.SkipDecode(1); // 현재 가격 5 double price = ((double)iPacket.DecodeInt(5)) / 100.0; // 체결 수량 6 int amount = iPacket.DecodeInt(6); if (MarketDataLogOn) { logger.Info("Future_F1_C0 {0}, H0({1:n0}), C0({2:n0}), H0C0({3:n0})", code, _future_H0_Count, ++_future_C0_Count, _future_H0C0_Count); } RawMarketData rmd = GetData(code); if (rmd != null) { rmd.CurAmount = amount; rmd.LastUpdatedTime = DateTime.Now; rmd.CurPrice = price; MarketDelayManager.Ins().SetFutureOptionLastUpdatedTime(DateTime.Now); } } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
private void SetIndexOptionDataUsingYulchonData(InPacket iPacket) { // logger.Info("Option Data {0:n0}", ++_oDataCount)); short packetLen = iPacket.Decode16(); short totalPacketLen = (short)(packetLen + 2); const int nSize = 5; byte[] head = new byte[nSize]; iPacket.Decode(head, nSize); KrxPacketUtil.FutureOptionPacketType nType = KrxPacketUtil.GetFutureOptionPacketType(head); // 시간 Skip iPacket.SkipDecode(10); switch (nType) { case KrxPacketUtil.FutureOptionPacketType.Index_BidAsk: Handle_Index_Option_BidAsk_Raw(iPacket); break; case KrxPacketUtil.FutureOptionPacketType.Index_Contract: Handle_Index_Option_Contract_Raw(iPacket); break; case KrxPacketUtil.FutureOptionPacketType.Index_BidAsk_Contract: Handle_Index_Option_BidAsk_Contract_Raw(iPacket); break; default: // FormChannel.Error("Broken Packet in RMDManager::SetMarketData..."); break; } iPacket.AdvancePivot(totalPacketLen); }
void SetIndexFutureData_Raw(InPacket iPacket) { const int nSize = 5; byte[] head = new byte[nSize]; iPacket.Decode(head, nSize); KrxPacketUtil.FutureOptionPacketType nType = KrxPacketUtil.GetFutureOptionPacketType(head); // 시간 skip iPacket.SkipDecode(10); switch (nType) { case KrxPacketUtil.FutureOptionPacketType.Index_BidAsk: Handle_Index_Future_BidAsk_Raw(iPacket); break; case KrxPacketUtil.FutureOptionPacketType.Index_Contract: Handle_Index_Future_Contract_Raw(iPacket); break; case KrxPacketUtil.FutureOptionPacketType.Index_BidAsk_Contract: Handle_Index_Future_BidAsk_Contract_Raw(iPacket); break; default: //FormChannel.Error("Broken Packet in RMDManager::SetMarketData..."); break; } }
private void DecodeAndUpdate_BidAsk(InPacket iPacket) { try { // 종목코드 앞에 3 iPacket.SkipDecode(3); String code = iPacket.DecodeString(8); iPacket.SkipDecode(1); // 종목 seq iPacket.SkipDecode(2); // 장상태구분코드 iPacket.SkipDecode(2); // 40 접속 // 매수 총 호가 잔량 int bidTotalAmount = iPacket.DecodeInt(6); // 매수 1단계 부호 iPacket.SkipDecode(1); double buyPrice = ((double)iPacket.DecodeInt(5)) / 100.0; int buyAmount = iPacket.DecodeInt(6); // 매수 2단계 부호 iPacket.SkipDecode(1); double buyPrice2 = ((double)iPacket.DecodeInt(5)) / 100.0; int buyAmount2 = iPacket.DecodeInt(6); // 매수 3단계 부호 iPacket.SkipDecode(1); double buyPrice3 = ((double)iPacket.DecodeInt(5)) / 100.0; int buyAmount3 = iPacket.DecodeInt(6); // 매수 4단계 부호 iPacket.SkipDecode(1); double buyPrice4 = ((double)iPacket.DecodeInt(5)) / 100.0; int buyAmount4 = iPacket.DecodeInt(6); // 매수 5단계 부호 iPacket.SkipDecode(1); double buyPrice5 = ((double)iPacket.DecodeInt(5)) / 100.0; int buyAmount5 = iPacket.DecodeInt(6); // 매도 총 호가 잔량 int offerTotalAmount = iPacket.DecodeInt(6); // 매도 1단계 부호 iPacket.SkipDecode(1); double sellPrice = ((double)iPacket.DecodeInt(5)) / 100.0; int sellAmount = iPacket.DecodeInt(6); // 매도 2단계 부호 iPacket.SkipDecode(1); double sellPrice2 = ((double)iPacket.DecodeInt(5)) / 100.0; int sellAmount2 = iPacket.DecodeInt(6); // 매도 3단계 부호 iPacket.SkipDecode(1); double sellPrice3 = ((double)iPacket.DecodeInt(5)) / 100.0; int sellAmount3 = iPacket.DecodeInt(6); // 매도 4단계 부호 iPacket.SkipDecode(1); double sellPrice4 = ((double)iPacket.DecodeInt(5)) / 100.0; int sellAmount4 = iPacket.DecodeInt(6); // 매도 5단계 부호 iPacket.SkipDecode(1); double sellPrice5 = ((double)iPacket.DecodeInt(5)) / 100.0; int sellAmount5 = iPacket.DecodeInt(6); // 매수 유효 호가 건수 int bidTotalCount = iPacket.DecodeInt(5); int bidCaseCount = iPacket.DecodeInt(4); int bidCaseCount2 = iPacket.DecodeInt(4); int bidCaseCount3 = iPacket.DecodeInt(4); int bidCaseCount4 = iPacket.DecodeInt(4); int bidCaseCount5 = iPacket.DecodeInt(4); int offerTotalCount = iPacket.DecodeInt(5); // 매도 호가 건수 int offerCaseCount = iPacket.DecodeInt(4); int offerCaseCount2 = iPacket.DecodeInt(4); int offerCaseCount3 = iPacket.DecodeInt(4); int offerCaseCount4 = iPacket.DecodeInt(4); int offerCaseCount5 = iPacket.DecodeInt(4); RawMarketData rmd = GetData(code); if (rmd != null) { rmd.AskPrice1 = sellPrice; rmd.BidPrice1 = buyPrice; rmd.AskCount1 = sellAmount; rmd.BidCount1 = buyAmount; rmd.AskPrice2 = sellPrice2; rmd.BidPrice2 = buyPrice2; rmd.AskCount2 = sellAmount2; rmd.BidCount2 = buyAmount2; rmd.AskPrice3 = sellPrice3; rmd.BidPrice3 = buyPrice3; rmd.AskCount3 = sellAmount3; rmd.BidCount3 = buyAmount3; rmd.AskPrice4 = sellPrice4; rmd.BidPrice4 = buyPrice4; rmd.AskCount4 = sellAmount4; rmd.BidCount4 = buyAmount4; rmd.AskPrice5 = sellPrice5; rmd.BidPrice5 = buyPrice5; rmd.AskCount5 = sellAmount5; rmd.BidCount5 = buyAmount5; //rmd.AskCaseCount1 = offerCaseCount; //rmd.AskCaseCount2 = offerCaseCount2; //rmd.AskCaseCount3 = offerCaseCount3; //rmd.AskCaseCount4 = offerCaseCount4; //rmd.AskCaseCount5 = offerCaseCount5; //rmd.BidCaseCount1 = bidCaseCount; //rmd.BidCaseCount2 = bidCaseCount2; //rmd.BidCaseCount3 = bidCaseCount3; //rmd.BidCaseCount4 = bidCaseCount4; //rmd.BidCaseCount5 = bidCaseCount5; rmd.TotalBidCount = bidTotalAmount; rmd.TotalAskCount = offerTotalAmount; //rmd.TotalBidCaseCount = bidTotalCount; //rmd.TotalAskCaseCount = offerTotalCount; rmd.LastUpdatedTime = DateTime.Now; MarketDelayManager.Ins().SetFutureOptionLastUpdatedTime(DateTime.Now); if (RMDModifier.Ins().IsOn()) { RMDModifier.Ins().UpdateRMD(ref rmd); } } } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
private void HandleDefaultData(InPacket iPacket) { short packetLen = iPacket.Decode16(); iPacket.SkipDecode(packetLen); iPacket.AdvancePivot(); }
void UpdateBondRetailData(ref InPacket iPacket) { //DATA구분 2 - HEADER //정보구분 2 - HEADER //시장구분 1 - HDADER //종목코드 12 String code = iPacket.DecodeString(12); String shortCode = code; code += NormalSmallConst.TAIL_RETAIL; //만기년월 4 iPacket.SkipDecode(4); //소매종류코드 2 iPacket.SkipDecode(2); //매도우선가격1 7 int askPrice1 = iPacket.DecodeInt(7); //매도우선수익률1 11 iPacket.SkipDecode(11); //매도우선수량1 20 long askCount1 = iPacket.DecodeLong(20); //매도우선가격2 7 int askPrice2 = iPacket.DecodeInt(7); //매도우선수익률2 11 iPacket.SkipDecode(11); //매도우선수량2 20 long askCount2 = iPacket.DecodeLong(20); //매도우선가격3 7 int askPrice3 = iPacket.DecodeInt(7); //매도우선수익률3 11 iPacket.SkipDecode(11); //매도우선수량3 20 long askCount3 = iPacket.DecodeLong(20); //매도우선가격4 7 int askPrice4 = iPacket.DecodeInt(7); //매도우선수익률4 11 iPacket.SkipDecode(11); //매도우선수량4 20 long askCount4 = iPacket.DecodeLong(20); //매도우선가격5 7 int askPrice5 = iPacket.DecodeInt(7); //매도우선수익률5 11 iPacket.SkipDecode(11); //매도우선수량5 20 long askCount5 = iPacket.DecodeLong(20); //매수우선가격1 7 int bidPrice1 = iPacket.DecodeInt(7); //매수우선수익률1 11 iPacket.SkipDecode(11); //매수우선수량1 20 long bidCount1 = iPacket.DecodeLong(20); //매수우선가격2 7 int bidPrice2 = iPacket.DecodeInt(7); //매수우선수익률2 11 iPacket.SkipDecode(11); //매수우선수량2 20 long bidCount2 = iPacket.DecodeLong(20); //매수우선가격3 7 int bidPrice3 = iPacket.DecodeInt(7); //매수우선수익률3 11 iPacket.SkipDecode(11); //매수우선수량3 20 long bidCount3 = iPacket.DecodeLong(20); //매수우선가격4 7 int bidPrice4 = iPacket.DecodeInt(7); //매수우선수익률4 11 iPacket.SkipDecode(11); //매수우선수량4 20 long bidCount4 = iPacket.DecodeLong(20); //매수우선가격5 7 int bidPrice5 = iPacket.DecodeInt(7); //매수우선수익률5 11 iPacket.SkipDecode(11); //매수우선수량5 20 long bidCount5 = iPacket.DecodeLong(20); //매도총량 20 iPacket.SkipDecode(20); //매수총량 20 iPacket.SkipDecode(20); //현재가 7 iPacket.SkipDecode(7); //거래량 20 iPacket.SkipDecode(20); //거래대금 20 iPacket.SkipDecode(20); //시가 7 iPacket.SkipDecode(7); //고가 7 iPacket.SkipDecode(7); //저가 7 iPacket.SkipDecode(7); //매매일 8 iPacket.SkipDecode(8); //현재가수익률 11 iPacket.SkipDecode(11); //시가수익률 11 iPacket.SkipDecode(11); //고가수익률 11 iPacket.SkipDecode(11); //저가수익률 11 iPacket.SkipDecode(11); //FILLER 6 iPacket.SkipDecode(6); //FF 1 iPacket.SkipDecode(1); RegisterBond(code); lock (_bondLock) { RawMarketData rmd = _bondRmds[code]; rmd.AskPrice1 = (double)askPrice1; rmd.AskCount1 = askCount1 * CommonConst._1_000; rmd.BidPrice1 = (double)bidPrice1; rmd.BidCount1 = bidCount1 * CommonConst._1_000; rmd.AskPrice2 = (double)askPrice2; rmd.AskCount2 = askCount2 * CommonConst._1_000; rmd.BidPrice2 = (double)bidPrice2; rmd.BidCount2 = bidCount2 * CommonConst._1_000; rmd.AskPrice3 = (double)askPrice3; rmd.AskCount3 = askCount3 * CommonConst._1_000; rmd.BidPrice3 = (double)bidPrice3; rmd.BidCount3 = bidCount3 * CommonConst._1_000; rmd.AskPrice4 = (double)askPrice4; rmd.AskCount4 = askCount4 * CommonConst._1_000; rmd.BidPrice4 = (double)bidPrice4; rmd.BidCount4 = bidCount4 * CommonConst._1_000; rmd.AskPrice5 = (double)askPrice5; rmd.AskCount5 = askCount5 * CommonConst._1_000; rmd.BidPrice5 = (double)bidPrice5; rmd.BidCount5 = bidCount5 * CommonConst._1_000; } }
void UpdateBondNormalSmallData(ref InPacket iPacket) { //DATA구분 2 - HEADER //정보구분 2 - HEADER //시장구분 1 - HEADER //종목코드 12 String code = iPacket.DecodeString(12); String shortCode = code; //매도 우선 수익률1 6 iPacket.SkipDecode(6); //매수 우선 수익률1 6 iPacket.SkipDecode(6); //매도 우선 호가1 5 int askPrice1 = iPacket.DecodeInt(5); //매수 우선 호가1 5 int bidPrice1 = iPacket.DecodeInt(5); //매도 우선 호가잔량1 12 long askCount1 = iPacket.DecodeLong(12); //매수 우선 호가잔량1 12 long bidCount1 = iPacket.DecodeLong(12); //매도 우선 수익률2 6 iPacket.SkipDecode(6); //매수 우선 수익률2 6 iPacket.SkipDecode(6); //매도 우선 호가2 5 int askPrice2 = iPacket.DecodeInt(5); //매수 우선 호가2 5 int bidPrice2 = iPacket.DecodeInt(5); //매도 우선 호가잔량2 12 long askCount2 = iPacket.DecodeLong(12); //매수 우선 호가잔량2 12 long bidCount2 = iPacket.DecodeLong(12); //매도 우선 수익률3 6 iPacket.SkipDecode(6); //매수 우선 수익률3 6 iPacket.SkipDecode(6); int askPrice3 = iPacket.DecodeInt(5); //매수 우선 호가3 5 int bidPrice3 = iPacket.DecodeInt(5); //매도 우선 호가잔량3 12 long askCount3 = iPacket.DecodeLong(12); //매수 우선 호가잔량3 12 long bidCount3 = iPacket.DecodeLong(12); //매도 우선 수익률4 6 iPacket.SkipDecode(6); //매수 우선 수익률4 6 iPacket.SkipDecode(6); int askPrice4 = iPacket.DecodeInt(5); //매수 우선 호가4 5 int bidPrice4 = iPacket.DecodeInt(5); //매도 우선 호가잔량4 12 long askCount4 = iPacket.DecodeLong(12); //매수 우선 호가잔량4 12 long bidCount4 = iPacket.DecodeLong(12); //매도 우선 수익률5 6 iPacket.SkipDecode(6); //매수 우선 수익률5 6 iPacket.SkipDecode(6); int askPrice5 = iPacket.DecodeInt(5); //매수 우선 호가5 5 int bidPrice5 = iPacket.DecodeInt(5); //매도 우선 호가잔량5 12 long askCount5 = iPacket.DecodeLong(12); //매수 우선 호가잔량5 12 long bidCount5 = iPacket.DecodeLong(12); //매도 총잔량 12 iPacket.SkipDecode(12); //매수 총잔량 12 iPacket.SkipDecode(12); //소액시장참여여부 1 int small = iPacket.DecodeInt(1); //FILLER 7 //FF 1 if (small == 0) { code += NormalSmallConst.TAIL_NORMAL; } else if (small == 1) { code += NormalSmallConst.TAIL_SMALL; } else { logger.Error("Unknown small value {0}", small); Util.KillWithNotice("Unknown small value"); } RegisterBond(code); lock (_bondLock) { RawMarketData rmd = _bondRmds[code]; rmd.AskPrice1 = (double)askPrice1; rmd.AskCount1 = askCount1 * CommonConst._1_000; rmd.BidPrice1 = (double)bidPrice1; rmd.BidCount1 = bidCount1 * CommonConst._1_000; rmd.AskPrice2 = (double)askPrice2; rmd.AskCount2 = askCount2 * CommonConst._1_000; rmd.BidPrice2 = (double)bidPrice2; rmd.BidCount2 = bidCount2 * CommonConst._1_000; rmd.AskPrice3 = (double)askPrice3; rmd.AskCount3 = askCount3 * CommonConst._1_000; rmd.BidPrice3 = (double)bidPrice3; rmd.BidCount3 = bidCount3 * CommonConst._1_000; rmd.AskPrice4 = (double)askPrice4; rmd.AskCount4 = askCount4 * CommonConst._1_000; rmd.BidPrice4 = (double)bidPrice4; rmd.BidCount4 = bidCount4 * CommonConst._1_000; rmd.AskPrice5 = (double)askPrice5; rmd.AskCount5 = askCount5 * CommonConst._1_000; rmd.BidPrice5 = (double)bidPrice5; rmd.BidCount5 = bidCount5 * CommonConst._1_000; } }
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()); } }
private void SetStockDataUsingKrxData(InPacket iPacket) { const int nSize = 5; byte[] head = new byte[nSize]; iPacket.Decode(head, nSize); KrxPacketUtil.SpotPacketType nType = KrxPacketUtil.GetSpotPacketType(head); switch (nType) { case KrxPacketUtil.SpotPacketType._A3_Contract: Handle_Stock_A3_Contract(iPacket); break; case KrxPacketUtil.SpotPacketType._B7_BidAsk: Handle_Stock_B7_BidAsk(iPacket); break; default: break; } }
public void SetMarketDataUsingYulchonData(InPacket iPacket, MarketDataType type) { ++this.PacketCount; switch (type) { case MarketDataType.KOSPI_FUTURE: { SetIndexFutureDataUsingYulchonData(iPacket); break; } case MarketDataType.CALL: { SetIndexOptionDataUsingYulchonData(iPacket); break; } case MarketDataType.PUT: { SetIndexOptionDataUsingYulchonData(iPacket); break; } case MarketDataType.ELW: { SetIndexElwDataUsingYulchonData(iPacket); break; } default: { HandleDefaultData(iPacket); break; } } }
void Handle_Elw_B7_BidAsk(InPacket iPacket) { try { //코드: KRA643212WC2 (12) String longCode = iPacket.DecodeString(12); String shortCode = ElwUtil.ConvertToShortCode(longCode); if (MarketDataLogOn) { logger.Info("Elw_B7(호가데이터) {0}, A3({1:n0}), B7({2:n0})", shortCode, _elw_A3_Count, ++_elw_B7_Count); } if (shortCode.Length == 0) { return; } RawMarketData rmd = GetData(shortCode); if (rmd != null) { //누적체결수량: 000000000000 (12) iPacket.SkipDecode(12); //매도호가1: 000000570 (9) rmd.AskPrice1 = iPacket.DecodeInt(9); //매수호가1: 000000365 (9) rmd.BidPrice1 = iPacket.DecodeInt(9); //매도호가잔량1: 000000033000 (12) rmd.AskCount1 = iPacket.DecodeLong(12); //매수호가잔량1: 000000031000 (12) rmd.BidCount1 = iPacket.DecodeLong(12); //LP 매도호가 잔량1: 000000000000 (12) //LP 매수호가 잔량1: 000000000000 (12) iPacket.SkipDecode(12 + 12); //매도호가2: 000000570 (9) rmd.AskPrice2 = iPacket.DecodeInt(9); //매수호가2: 000000365 (9) rmd.BidPrice2 = iPacket.DecodeInt(9); //매도호가잔량2: 000000033000 (12) rmd.AskCount2 = iPacket.DecodeLong(12); //매수호가잔량2: 000000031000 (12) rmd.BidCount2 = iPacket.DecodeLong(12); //LP 매도호가 잔량2: 000000000000 (12) //LP 매수호가 잔량2: 000000000000 (12) iPacket.SkipDecode(12 + 12); //매도호가3: 000000570 (9) rmd.AskPrice3 = iPacket.DecodeInt(9); //매수호가3: 000000365 (9) rmd.BidPrice3 = iPacket.DecodeInt(9); //매도호가잔량3: 000000033000 (12) rmd.AskCount3 = iPacket.DecodeLong(12); //매수호가잔량3: 000000031000 (12) rmd.BidCount3 = iPacket.DecodeLong(12); //LP 매도호가 잔량3: 000000000000 (12) //LP 매수호가 잔량3: 000000000000 (12) iPacket.SkipDecode(12 + 12); //매도호가4: 000000570 (9) rmd.AskPrice4 = iPacket.DecodeInt(9); //매수호가4: 000000365 (9) rmd.BidPrice4 = iPacket.DecodeInt(9); //매도호가잔량4: 000000033000 (12) rmd.AskCount4 = iPacket.DecodeLong(12); //매수호가잔량4: 000000031000 (12) rmd.BidCount4 = iPacket.DecodeLong(12); //LP 매도호가 잔량4: 000000000000 (12) //LP 매수호가 잔량4: 000000000000 (12) iPacket.SkipDecode(12 + 12); //매도호가5: 000000570 (9) rmd.AskPrice5 = iPacket.DecodeInt(9); //매수호가5: 000000365 (9) rmd.BidPrice5 = iPacket.DecodeInt(9); //매도호가잔량5: 000000033000 (12) rmd.AskCount5 = iPacket.DecodeLong(12); //매수호가잔량5: 000000031000 (12) rmd.BidCount5 = iPacket.DecodeLong(12); //LP 매도호가 잔량5: 000000000000 (12) //LP 매수호가 잔량5: 000000000000 (12) iPacket.SkipDecode(12 + 12); rmd.LastUpdatedTime = DateTime.Now; MarketDelayManager.Ins().SetElwLastUpdatedTime(DateTime.Now); if (RMDModifier.Ins().IsOn()) { RMDModifier.Ins().UpdateRMD(ref rmd); } } } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }