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; } }
void DecodeAndUpdate_Contract(InPacket iPacket) { try { //A3 iPacket.SkipDecode(10); // 시간, 1057523068 //종목코드 X 12 //KR4167F90003 iPacket.SkipDecode(3); String code = iPacket.DecodeString(8); iPacket.SkipDecode(1); //종목SEQ 9 3 iPacket.SkipDecode(3); //현재가격부호 X 1 iPacket.SkipDecode(1); //현재가격 9 8 double curPrice = ((double)iPacket.DecodeInt(8)) / 100.0; //체결수량 9 6 long contractedCount = iPacket.DecodeLong(6); RawMarketData rmd = GetData(code); if (rmd != null) { rmd.CurPrice = curPrice; rmd.LastUpdatedTime = DateTime.Now; _lastUpdated = DateTime.Now; } } 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()); } }
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()); } }
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()); } }
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; } }
RawMarketData Decode_Raw(String line, String targetCode) { // Decode time InPacket inPacket = new InPacket(); inPacket.ForcedEncode(line); String timeString = inPacket.DecodeString(24); DateTime curDateTime = DateTime.ParseExact(timeString, "[yyyyMMdd HH:mm:ss.fff]\t", null); RawMarketData rmd = Decode_Raw(inPacket, targetCode, curDateTime); return rmd; }
RawMarketData Decode_BidAsk(InPacket iPacket, String targetCode, DateTime curDateTime) { try { //B60161057523068KR4167FC000300740000280 00010578000050 00010577000040 00010576000060 00010575000100 00010574000030000326 00010580000071 00010581000036 00010582000045 00010583000102 000105840000720001800040003000400050002000220007000200030006000410575227? iPacket.SkipDecode(10); // 시간, 1057523068 //종목코드 X 12 //KR4167FC0003 iPacket.SkipDecode(3); String code = iPacket.DecodeString(8); if (code != targetCode) { return null; } iPacket.SkipDecode(1); //종목SEQ 9 3 iPacket.SkipDecode(3); //장상태구분코드 X 2 iPacket.SkipDecode(2); //매수총호가잔량 9 6 long totalBidCount = iPacket.DecodeLong(6); //매수1단계부호 X 1 iPacket.SkipDecode(1); //매수1단계우선호가가격 9 8 double bidPrice1 = ((double)iPacket.DecodeInt(8)) / 100.0; //매수1단계우선호가잔량 9 6 long bidCount1 = iPacket.DecodeLong(6); //매수2단계부호 X 1 iPacket.SkipDecode(1); //매수2단계우선호가가격 9 8 double BidPrice2 = ((double)iPacket.DecodeInt(8)) / 100.0; //매수2단계우선호가잔량 9 6 long BidCount2 = iPacket.DecodeLong(6); //매수3단계부호 X 1 iPacket.SkipDecode(1); //매수3단계우선호가가격 9 8 double BidPrice3 = ((double)iPacket.DecodeInt(8)) / 100.0; //매수3단계우선호가잔량 9 6 long BidCount3 = iPacket.DecodeLong(6); //매수4단계부호 X 1 iPacket.SkipDecode(1); //매수4단계우선호가가격 9 8 double BidPrice4 = ((double)iPacket.DecodeInt(8)) / 100.0; //매수4단계우선호가잔량 9 6 long BidCount4 = iPacket.DecodeLong(6); //매수5단계부호 X 1 iPacket.SkipDecode(1); //매수5단계우선호가가격 9 8 double BidPrice5 = ((double)iPacket.DecodeInt(8)) / 100.0; //매수5단계우선호가잔량 9 6 long BidCount5 = iPacket.DecodeLong(6); //매도총호가잔량 9 6 long totalAskCount = iPacket.DecodeLong(6); //매도1단계부호 X 1 iPacket.SkipDecode(1); //매도1단계우선호가가격 9 8 double AskPrice1 = ((double)iPacket.DecodeInt(8)) / 100.0; //매도1단계우선호가잔량 9 6 long AskCount1 = iPacket.DecodeLong(6); //매도2단계부호 X 1 iPacket.SkipDecode(1); //매도2단계우선호가가격 9 8 double AskPrice2 = ((double)iPacket.DecodeInt(8)) / 100.0; //매도2단계우선호가잔량 9 6 long AskCount2 = iPacket.DecodeLong(6); //매도3단계부호 X 1 iPacket.SkipDecode(1); //매도3단계우선호가가격 9 8 double AskPrice3 = ((double)iPacket.DecodeInt(8)) / 100.0; //매도3단계우선호가잔량 9 6 long AskCount3 = iPacket.DecodeLong(6); //매도4단계부호 X 1 iPacket.SkipDecode(1); //매도4단계우선호가가격 9 8 double AskPrice4 = ((double)iPacket.DecodeInt(8)) / 100.0; //매도4단계우선호가잔량 9 6 long AskCount4 = iPacket.DecodeLong(6); //매도5단계부호 X 1 iPacket.SkipDecode(1); //매도5단계우선호가가격 9 8 double AskPrice5 = ((double)iPacket.DecodeInt(8)) / 100.0; //매도5단계우선호가잔량 9 6 long AskCount5 = iPacket.DecodeLong(6); RawMarketData rmd = new RawMarketData(code, Detail.ProductType.Unknown); rmd.AskPrice1 = AskPrice1; rmd.BidPrice1 = bidPrice1; rmd.AskCount1 = AskCount1; rmd.BidCount1 = bidCount1; rmd.AskPrice2 = AskPrice2; rmd.BidPrice2 = BidPrice2; rmd.AskCount2 = AskCount2; rmd.BidCount2 = BidCount2; rmd.AskPrice3 = AskPrice3; rmd.BidPrice3 = BidPrice3; rmd.AskCount3 = AskCount3; rmd.BidCount3 = BidCount3; rmd.AskPrice4 = AskPrice4; rmd.BidPrice4 = BidPrice4; rmd.AskCount4 = AskCount4; rmd.BidCount4 = BidCount4; rmd.AskPrice5 = AskPrice5; rmd.BidPrice5 = BidPrice5; rmd.AskCount5 = AskCount5; rmd.BidCount5 = BidCount5; rmd.TotalBidCount = totalBidCount; rmd.TotalAskCount = totalAskCount; rmd.LastUpdatedTime = curDateTime; return rmd; } catch (System.Exception ex) { logger.Error(ex.ToString()); ProcessUtil.Kill(); } return null; }
RawMarketData Decode_Contract(InPacket iPacket, String targetCode, DateTime curDateTime) { try { //A3 iPacket.SkipDecode(10); // 시간, 1057523068 //종목코드 X 12 //KR4167FC0003 iPacket.SkipDecode(3); String code = iPacket.DecodeString(8); if (code != targetCode) { return null; } iPacket.SkipDecode(1); //종목SEQ 9 3 iPacket.SkipDecode(3); //현재가격부호 X 1 iPacket.SkipDecode(1); //현재가격 9 8 double curPrice = ((double)iPacket.DecodeInt(8)) / 100.0; //체결수량 9 6 long contractedCount = iPacket.DecodeLong(6); RawMarketData rmd = new RawMarketData(code, Detail.ProductType.Unknown); rmd.CurPrice = curPrice; rmd.LastUpdatedTime = curDateTime; return rmd; } catch (System.Exception ex) { logger.Error(ex.ToString()); ProcessUtil.Kill(); } return null; }
RawMarketData Decode_BidAskContract(InPacket iPacket, String targetCode, DateTime curDateTime) { try { //G7 iPacket.SkipDecode(10); // 시간, 1057523068 //종목코드 X 12 //KR4167FC0003 iPacket.SkipDecode(3); String code = iPacket.DecodeString(8); if (code != targetCode) { return null; } iPacket.SkipDecode(1); //종목SEQ 9 3 iPacket.SkipDecode(3); //현재가격부호 X 1 iPacket.SkipDecode(1); //현재가격 9 8 double curPrice = ((double)iPacket.DecodeInt(8)) / 100.0; //체결수량 9 6 long contractedCount = iPacket.DecodeLong(6); //체결유형코드 X 2 iPacket.SkipDecode(2); //체결시각 X 8 iPacket.SkipDecode(8); //최근월물의제약정가격 9 8 iPacket.SkipDecode(8); //원월물의제약정가격 9 8 iPacket.SkipDecode(8); //시가부호 X 1 iPacket.SkipDecode(1); //시가 9 8 iPacket.SkipDecode(8); //고가부호 X 1 iPacket.SkipDecode(1); //고가 9 8 iPacket.SkipDecode(8); //저가부호 X 1 iPacket.SkipDecode(1); //저가 9 8 iPacket.SkipDecode(8); //직전가격부호 X 1 iPacket.SkipDecode(1); //직전가격 9 8 iPacket.SkipDecode(8); //누적체결수량 9 7 iPacket.SkipDecode(7); //누적거래대금(단위:원) 9 15 iPacket.SkipDecode(15); //협의대량누적체결수량 9 7 iPacket.SkipDecode(7); //EFP누적체결수량 9 7 iPacket.SkipDecode(7); //장상태구분코드 X 2 iPacket.SkipDecode(2); //매수총호가잔량 9 6 long totalBidCount = iPacket.DecodeLong(6); //매수1단계부호 X 1 iPacket.SkipDecode(1); //매수1단계우선호가가격 9 8 double 매수1가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매수1단계우선호가잔량 9 6 long 매수1잔량 = iPacket.DecodeLong(6); //매수2단계부호 X 1 iPacket.SkipDecode(1); //매수2단계우선호가가격 9 8 double 매수2가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매수2단계우선호가잔량 9 6 long 매수2잔량 = iPacket.DecodeLong(6); //매수3단계부호 X 1 iPacket.SkipDecode(1); //매수3단계우선호가가격 9 8 double 매수3가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매수3단계우선호가잔량 9 6 long 매수3잔량 = iPacket.DecodeLong(6); //매수4단계부호 X 1 iPacket.SkipDecode(1); //매수4단계우선호가가격 9 8 double 매수4가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매수4단계우선호가잔량 9 6 long 매수4잔량 = iPacket.DecodeLong(6); //매수5단계부호 X 1 iPacket.SkipDecode(1); //매수5단계우선호가가격 9 8 double 매수5가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매수5단계우선호가잔량 9 6 long 매수5잔량 = iPacket.DecodeLong(6); //매도총호가잔량 9 6 long totalAskCount = iPacket.DecodeLong(6); //매도1단계부호 X 1 iPacket.SkipDecode(1); //매도1단계우선호가가격 9 8 double 매도1가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매도1단계우선호가잔량 9 6 long 매도1잔량 = iPacket.DecodeLong(6); //매도2단계부호 X 1 iPacket.SkipDecode(1); //매도2단계우선호가가격 9 8 double 매도2가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매도2단계우선호가잔량 9 6 long 매도2잔량 = iPacket.DecodeLong(6); //매도3단계부호 X 1 iPacket.SkipDecode(1); //매도3단계우선호가가격 9 8 double 매도3가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매도3단계우선호가잔량 9 6 long 매도3잔량 = iPacket.DecodeLong(6); //매도4단계부호 X 1 iPacket.SkipDecode(1); //매도4단계우선호가가격 9 8 double 매도4가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매도4단계우선호가잔량 9 6 long 매도4잔량 = iPacket.DecodeLong(6); //매도5단계부호 X 1 iPacket.SkipDecode(1); //매도5단계우선호가가격 9 8 double 매도5가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매도5단계우선호가잔량 9 6 long 매도5잔량 = iPacket.DecodeLong(6); RawMarketData rmd = new RawMarketData(code, Detail.ProductType.Unknown); rmd.CurPrice = curPrice; rmd.AskPrice1 = 매도1가격; rmd.BidPrice1 = 매수1가격; rmd.AskCount1 = 매도1잔량; rmd.BidCount1 = 매수1잔량; rmd.AskPrice2 = 매도2가격; rmd.BidPrice2 = 매수2가격; rmd.AskCount2 = 매도2잔량; rmd.BidCount2 = 매수2잔량; rmd.AskPrice3 = 매도3가격; rmd.BidPrice3 = 매수3가격; rmd.AskCount3 = 매도3잔량; rmd.BidCount3 = 매수3잔량; rmd.AskPrice4 = 매도4가격; rmd.BidPrice4 = 매수4가격; rmd.AskCount4 = 매도4잔량; rmd.BidCount4 = 매수4잔량; rmd.AskPrice5 = 매도5가격; rmd.BidPrice5 = 매수5가격; rmd.AskCount5 = 매도5잔량; rmd.BidCount5 = 매수5잔량; rmd.TotalBidCount = totalBidCount; rmd.TotalAskCount = totalAskCount; rmd.LastUpdatedTime = curDateTime; return rmd; } catch (System.Exception ex) { logger.Error(ex.ToString()); ProcessUtil.Kill(); } return null; }
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) { Detail.ProductType dpt = RmdManager.Ins().GetProductType(code); if (dpt != Detail.ProductType.Unknown) { Register(code, code, dpt); } } 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; } } catch (System.Exception ex) { logger.Error(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) { Detail.ProductType dpt = RmdManager.Ins().GetProductType(code); if (dpt != Detail.ProductType.Unknown) { Register(code, code, dpt); } } rmd = GetData(code); if (rmd != null) { rmd.CurAmount = amount; rmd.LastUpdatedTime = DateTime.Now; rmd.CurPrice = price; } } catch (System.Exception ex) { logger.Error(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) { Detail.ProductType dpt = RmdManager.Ins().GetProductType(code); if (dpt != Detail.ProductType.Unknown) { Register(code, code, dpt); } } 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; rmd.CurAmount = amount; rmd.CurPrice = price; } } catch (System.Exception ex) { logger.Error(ex.ToString()); } }
void DecodeAndUpdate_BidAsk(InPacket iPacket) { try { //B60161057523068KR4167F9000300740000280 00010578000050 00010577000040 00010576000060 00010575000100 00010574000030000326 00010580000071 00010581000036 00010582000045 00010583000102 000105840000720001800040003000400050002000220007000200030006000410575227? iPacket.SkipDecode(10); // 시간, 1057523068 //종목코드 X 12 //KR4167F90003 iPacket.SkipDecode(3); String code = iPacket.DecodeString(8); iPacket.SkipDecode(1); //종목SEQ 9 3 iPacket.SkipDecode(3); //장상태구분코드 X 2 iPacket.SkipDecode(2); //매수총호가잔량 9 6 long totalBidCount = iPacket.DecodeLong(6); //매수1단계부호 X 1 iPacket.SkipDecode(1); //매수1단계우선호가가격 9 8 double 매수1가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매수1단계우선호가잔량 9 6 long 매수1잔량 = iPacket.DecodeLong(6); //매수2단계부호 X 1 iPacket.SkipDecode(1); //매수2단계우선호가가격 9 8 double 매수2가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매수2단계우선호가잔량 9 6 long 매수2잔량 = iPacket.DecodeLong(6); //매수3단계부호 X 1 iPacket.SkipDecode(1); //매수3단계우선호가가격 9 8 double 매수3가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매수3단계우선호가잔량 9 6 long 매수3잔량 = iPacket.DecodeLong(6); //매수4단계부호 X 1 iPacket.SkipDecode(1); //매수4단계우선호가가격 9 8 double 매수4가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매수4단계우선호가잔량 9 6 long 매수4잔량 = iPacket.DecodeLong(6); //매수5단계부호 X 1 iPacket.SkipDecode(1); //매수5단계우선호가가격 9 8 double 매수5가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매수5단계우선호가잔량 9 6 long 매수5잔량 = iPacket.DecodeLong(6); //매도총호가잔량 9 6 long totalAskCount = iPacket.DecodeLong(6); //매도1단계부호 X 1 iPacket.SkipDecode(1); //매도1단계우선호가가격 9 8 double 매도1가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매도1단계우선호가잔량 9 6 long 매도1잔량 = iPacket.DecodeLong(6); //매도2단계부호 X 1 iPacket.SkipDecode(1); //매도2단계우선호가가격 9 8 double 매도2가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매도2단계우선호가잔량 9 6 long 매도2잔량 = iPacket.DecodeLong(6); //매도3단계부호 X 1 iPacket.SkipDecode(1); //매도3단계우선호가가격 9 8 double 매도3가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매도3단계우선호가잔량 9 6 long 매도3잔량 = iPacket.DecodeLong(6); //매도4단계부호 X 1 iPacket.SkipDecode(1); //매도4단계우선호가가격 9 8 double 매도4가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매도4단계우선호가잔량 9 6 long 매도4잔량 = iPacket.DecodeLong(6); //매도5단계부호 X 1 iPacket.SkipDecode(1); //매도5단계우선호가가격 9 8 double 매도5가격 = ((double)iPacket.DecodeInt(8)) / 100.0; //매도5단계우선호가잔량 9 6 long 매도5잔량 = iPacket.DecodeLong(6); RawMarketData rmd = GetData(code); if (rmd != null) { rmd.AskPrice1 = 매도1가격; rmd.BidPrice1 = 매수1가격; rmd.AskCount1 = 매도1잔량; rmd.BidCount1 = 매수1잔량; rmd.AskPrice2 = 매도2가격; rmd.BidPrice2 = 매수2가격; rmd.AskCount2 = 매도2잔량; rmd.BidCount2 = 매수2잔량; rmd.AskPrice3 = 매도3가격; rmd.BidPrice3 = 매수3가격; rmd.AskCount3 = 매도3잔량; rmd.BidCount3 = 매수3잔량; rmd.AskPrice4 = 매도4가격; rmd.BidPrice4 = 매수4가격; rmd.AskCount4 = 매도4잔량; rmd.BidCount4 = 매수4잔량; rmd.AskPrice5 = 매도5가격; rmd.BidPrice5 = 매수5가격; rmd.AskCount5 = 매도5잔량; rmd.BidCount5 = 매수5잔량; rmd.TotalBidCount = totalBidCount; rmd.TotalAskCount = totalAskCount; rmd.LastUpdatedTime = DateTime.Now; _lastUpdated = DateTime.Now; } } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
void DecodeAndUpdate_B7_BidAsk(InPacket iPacket) { try { //코드: KRA643212WC2 (12) String longCode = iPacket.DecodeString(12); RawMarketData rmd = GetData(longCode); if (rmd == null) { rmd = RmdManager.Register(longCode, "", Detail.ProductType.Stock, _rmdDict); } 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); //매도호가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); //매도호가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); //매도호가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); //매도호가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); rmd.LastUpdatedTime = DateTime.Now; _lastUpdated = DateTime.Now; } } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
void DecodeAndUpdate_A3_Contract(InPacket iPacket) { try { //코드: KRA643212WC2 (12) String longCode = iPacket.DecodeString(12); //정규시간외구분코드 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(longCode); if (rmd == null) { rmd = RmdManager.Register(longCode, "", Detail.ProductType.Stock, _rmdDict); } if (rmd != null) { rmd.CurPrice = curPrice; //매도1호가 9 rmd.AskPrice1 = iPacket.DecodeInt(9); //매수1호가 9 rmd.BidPrice1 = iPacket.DecodeInt(9); rmd.LastUpdatedTime = DateTime.Now; _lastUpdated = DateTime.Now; } } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
void Handle_Elw_B7_BidAsk(InPacket iPacket) { try { //코드: KRA643212WC2 (12) String longCode = iPacket.DecodeString(12); RawMarketData rmd = GetData(longCode); 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; _lastUpdated = DateTime.Now; } } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
void Handle_Stock_B7_BidAsk(InPacket iPacket) { try { //코드: KRA643212WC2 (12) String longCode = iPacket.DecodeString(12); if (MarketDataLogOn) { logger.Info("Stock_B7(호가데이터) {0}, A3({1:n0}), B7({2:n0})", longCode, _stock_A3_Count, ++_stock_B7_Count); } String shortCode = StockUtil.Ins().LongCodeToShortCode(longCode); if (shortCode == null) { return; } RawMarketData rmd = GetData(shortCode); if (rmd == null) { rmd = Register(shortCode, "", Detail.ProductType.Stock); } 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); //매도호가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); //매도호가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); //매도호가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); //매도호가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); rmd.LastUpdatedTime = DateTime.Now; MarketDelayManager.Ins().SetStockLastUpdatedTime(DateTime.Now); 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_Contract_Raw(InPacket iPacket) { try { // 종목코드 앞에 3 iPacket.SkipDecode(3); String code = iPacket.DecodeString(8); iPacket.SkipDecode(1); // 종목 seq iPacket.SkipDecode(3); // 현재 가격 5 double price = ((double)iPacket.DecodeInt(5)) / 100.0; // 체결 수량 7 int amount = iPacket.DecodeInt(7); RawMarketData rmd = GetData(code); if (rmd != null) { rmd.CurAmount = amount; rmd.LastUpdatedTime = DateTime.Now; _lastUpdated = DateTime.Now; rmd.CurPrice = price; } } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
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 Handle_Index_Option_BidAsk_Contract_Raw(InPacket iPacket) { try { // 종목코드 앞에 3 iPacket.SkipDecode(3); String code = iPacket.DecodeString(8); iPacket.SkipDecode(1); // 종목 seq iPacket.SkipDecode(3); // 현재 가격 5 double price = ((double)iPacket.DecodeInt(5)) / 100.0; // 체결 수량 7 int amount = iPacket.DecodeInt(7); // 체결유형코드 2 iPacket.SkipDecode(2); // 체결시각 8 iPacket.SkipDecode(8); // 시가 iPacket.SkipDecode(5); // 고가 iPacket.SkipDecode(5); // 저가 iPacket.SkipDecode(5); // 직전가 iPacket.SkipDecode(5); // 누적체결수량 8 iPacket.SkipDecode(8); // 누적거래대금 11 iPacket.SkipDecode(11); // 정상태구분코드 2 iPacket.SkipDecode(2); // 매수 총 호가 잔량 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.TotalBidCount = bidTotalAmount; rmd.TotalAskCount = offerTotalAmount; rmd.LastUpdatedTime = DateTime.Now; _lastUpdated = DateTime.Now; rmd.CurAmount = amount; rmd.CurPrice = price; } } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
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()); } }
void DecodeBody(InPacket iPacket) { //주문체결유형코드 X 2 this.주문체결유형코드 = iPacket.DecodeString(2); //01 주문 //02 정정 //03 취소 //11 체결 //12 정정확인 //13 취소확인 //14, 15, 16 거부 //21 승인확인중 if (this.주문체결유형코드.CompareTo("01") == 0 || this.주문체결유형코드.CompareTo("03") == 0) { DecodeBody_주문(iPacket); } else if (this.주문체결유형코드.CompareTo("11") == 0 || this.주문체결유형코드.CompareTo("12") == 0 || this.주문체결유형코드.CompareTo("13") == 0 || this.주문체결유형코드.CompareTo("14") == 0) { DecodeBody_체결(iPacket); } else { Trace.Assert(false); // 일단 죽이고 본다. } }
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()); } }
void DecodeBody_주문(InPacket iPacket) { //주문시장코드 X 2 this.주문시장코드 = iPacket.DecodeString(2); //주문유형코드 X 2 this.주문유형코드 = iPacket.DecodeString(2); //원주문번호 9 10 this.원주문번호 = iPacket.DecodeLong(10); //계좌번호(11) X 20 iPacket.SkipDecode(20); //종목번호 X 12 this.종목번호 = iPacket.DecodeString(12); //주문수량 9 16 this.주문수량 = iPacket.DecodeLong(16); //주문가격 9 13 this.주문가격 = iPacket.DecodeLong(13); //회원사번호 9 3 iPacket.SkipDecode(3); //수수료징수구분 9 1 iPacket.SkipDecode(1); //매수일자 X 8 iPacket.SkipDecode(8); //과세구분 X 1 iPacket.SkipDecode(1); //소액매매조건 X 1 iPacket.SkipDecode(1); //소액동시매매참여구분 X 1 iPacket.SkipDecode(1); //대행사반대매도구분 X 1 iPacket.SkipDecode(1); //채권종류코드 X 3 iPacket.SkipDecode(3); //선물옵션대용반대매매구분 X 1 iPacket.SkipDecode(1); //선물계좌번호 X 20 iPacket.SkipDecode(20); //선물시장구분 X 1 iPacket.SkipDecode(1); //주문금액 9 16 iPacket.SkipDecode(16); //변동수량 9 16 iPacket.SkipDecode(16); //주문번호 9 10 this.주문번호 = iPacket.DecodeLong(10); //총매도체결금액 9 61 iPacket.SkipDecode(61); //총매수체결금액 9 16 iPacket.SkipDecode(16); //매도체결수량 9 16 iPacket.SkipDecode(16); //미체결매도수량(종목) 9 16 iPacket.SkipDecode(16); //원주문미체결수량 9 16 this.원주문미체결수량 = iPacket.DecodeLong(16); //원주문정정수량 9 16 this.원주문정정수량 = iPacket.DecodeLong(16); //원주문취소수량 9 16 this.원주문취소수량 = iPacket.DecodeLong(16); //비회원사송신번호 9 10 iPacket.SkipDecode(10); //주문가능수량 9 16 iPacket.SkipDecode(16); //사용수량 9 16 iPacket.SkipDecode(16); //주문가능현금 9 16 iPacket.SkipDecode(16); //사용현금 9 16 iPacket.SkipDecode(16); //주문가능대용 9 16 iPacket.SkipDecode(16); //사용대용 9 16 iPacket.SkipDecode(16); //매도수구분 X 1 this.매도수구분 = iPacket.DecodeString(1); }
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 DecodeBody_체결(InPacket iPacket) { //주문시장코드 X 2 this.주문시장코드 = iPacket.DecodeString(2); //주문유형코드 X 2 this.주문유형코드 = iPacket.DecodeString(2); //계좌번호 X 20 iPacket.SkipDecode(20); //종목번호 X 12 this.종목번호 = iPacket.DecodeString(12); //주문번호 9 10 this.주문번호 = iPacket.DecodeLong(10); //원주문번호 9 10 this.원주문번호 = iPacket.DecodeLong(10); //주문수량 9 16 this.주문수량 = iPacket.DecodeLong(16); //주문가격 9 13 this.주문가격 = iPacket.DecodeLong(13); //체결수량 9 16 this.체결수량 = iPacket.DecodeLong(16); //체결가격 9 16 this.체결가격 = iPacket.DecodeLong(16); //정정확인수량 9 16 iPacket.SkipDecode(16); //정정확인가격 9 13 iPacket.SkipDecode(13); //취소확인수량 9 16 this.취소확인수량 = iPacket.DecodeLong(16); //총매도체결금액(채권) 9 16 iPacket.SkipDecode(16); //총매수체결금액(채권) 9 16 iPacket.SkipDecode(16); //미체결매도수량(종목) 9 16 iPacket.SkipDecode(16); //매도가능수량(종목) 9 16 iPacket.SkipDecode(16); //미체결수량(주문) 9 16 iPacket.SkipDecode(16); //원주문미체결수량 9 16 this.원주문미체결수량 = iPacket.DecodeLong(16); //원주문정정수량 9 16 iPacket.SkipDecode(16); //원주문취소수량 9 16 this.원주문취소수량 = iPacket.DecodeLong(16); //주문금액 9 16 iPacket.SkipDecode(16); //변동수량 9 16 iPacket.SkipDecode(16); //매도수구분 X 1 this.매도수구분 = iPacket.DecodeString(1); //주문거래유형코드 X 2 //합산구분 X 2 //거부사유 9 4 //회원/비회원사번호 9 3 //계좌명 X 20 //체결수익율 9 6 //현금체결금액 9 16 //대용체결금액 9 16 //선물연계지점번호 X 3 //선물계좌번호 X 20 //선물시장구분 X 1 //증거금현금율 9 7 //증거금대용율 9 9 //체결번호 9 10 }
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()); } }
void DecodeHeader(InPacket iPacket) { //6 전문길이 (AP) 전문길이 제외 long packetLenWithoutSixBytes = iPacket.DecodeLong(6); //1 전문구분 (AP) iPacket.SkipDecode(1); //1 압축구분 (FEP/PWB) iPacket.SkipDecode(1); //1 암호화구분 (FEP/PWB) iPacket.SkipDecode(1); //3 데이터 옵셋 (FEP/PWB) iPacket.SkipDecode(3); //8 서비스코드 (Client) this.ServiceCode = iPacket.DecodeString(8); //3 회사번호 (AP) iPacket.SkipDecode(3); //16 사용자ID (Client) iPacket.SkipDecode(16); //2 접속분류코드 (Client) iPacket.SkipDecode(2); //3 접속채널번호 (FEP/PWB) iPacket.SkipDecode(3); //9 트랜잭션순차번호 (FEP/PWB) iPacket.SkipDecode(9); //16 트랜잭션추적ID (공통) iPacket.SkipDecode(16); //12 공인IP (AP) iPacket.SkipDecode(12); //12 사설IP (Client) iPacket.SkipDecode(12); //3 처리지점 번호(000) (AP) iPacket.SkipDecode(3); //3 지점번호 (000) (AP) iPacket.SkipDecode(3); //8 단말번호 (매체(3)+화면번호(4)+fi(1))) iPacket.SkipDecode(8); //1 언어구분 (Client) iPacket.SkipDecode(1); //9 AP처리시각 (AP) iPacket.SkipDecode(9); //4 메시지코드(요청시SPACE) iPacket.SkipDecode(4); //1 출력메시지구분((요청시SPACE) iPacket.SkipDecode(1); //1 압축요청구분 (FEP/PWB) iPacket.SkipDecode(1); //4 기능키목록 (Client) iPacket.SkipDecode(4); //4 요청 레코드 개수 (Client) iPacket.SkipDecode(4); //2 예외처리 (default) iPacket.SkipDecode(2); //4 예비영역 (default) iPacket.SkipDecode(4); //1 연속여부 (Client) iPacket.SkipDecode(1); //18 연속키 (Client) iPacket.SkipDecode(18); //2 가변시스템정보길이 (FEP/PWB) iPacket.SkipDecode(2); //2 가변헤더정보길이 (default) iPacket.SkipDecode(2); //2 가변메시지길이 (default) iPacket.SkipDecode(2); //1 KB 가변해더 (공동) iPacket.SkipDecode(1); }