Esempio n. 1
0
        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());
            }
        }
        Boolean UpdateBondNormalSmallData(ref InPacket iPacket, String targetCode, String curTimeStringWithFormat)
        {
            //DATA구분	2 - HEADER
            //정보구분	2 - HEADER
            //시장구분	1 - HEADER

            //종목코드	12
            String code = iPacket.DecodeString(12);
            if (targetCode.CompareTo(code) != 0)
            {
                return false;
            }
            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");
            }

            RawMarketData rmd = new RawMarketData(code, code, Detail.ProductType.BondSpot);

            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;

            if (small == 0)
            {
                // Normal
                textBox4.Text = curTimeStringWithFormat;
                textBox5.Text = BondUtil.GetRmdTextFormString(rmd);
            }
            else
            {
                //Small
                textBox11.Text = curTimeStringWithFormat;
                textBox12.Text = BondUtil.GetRmdTextFormString(rmd);
            }
            return true;
        }
Esempio n. 3
0
        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 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());
            }
        }
Esempio n. 5
0
        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 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_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());
            }
        }
Esempio n. 8
0
        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());

            }
        }
        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;
        }
Esempio n. 10
0
        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());

            }
        }
Esempio n. 11
0
        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());

            }
        }
Esempio n. 12
0
        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());
            }
        }
Esempio n. 13
0
        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());
            }
        }
Esempio n. 14
0
        void DecodeAndUpdate_BidAskContract(InPacket iPacket)
        {
            try
            {
                //G7
                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);
            //체결유형코드	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 = GetData(code);

                if (rmd != null)
                {
                    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 = 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());
            }
        }
Esempio n. 16
0
        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;
        }
        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;
            }
        }
Esempio n. 18
0
        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;
        }
        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());
            }
        }
Esempio n. 20
0
        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());
            }
        }
        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());
            }
        }
Esempio n. 22
0
        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());
            }
        }
Esempio n. 23
0
        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());
            }
        }
Esempio n. 24
0
        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());
            }
        }
Esempio n. 25
0
        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());
            }
        }
Esempio n. 26
0
        Boolean UpdateBondRetailData(ref InPacket iPacket, String targetCode, String curTimeStringWithFormat)
        {
            //DATA구분	2 - HEADER
            //정보구분	2 - HEADER
            //시장구분	1 - HDADER

            //종목코드	12
            String code = iPacket.DecodeString(12);
            if (targetCode.CompareTo(code) != 0)
            {
                return false;
            }
            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);

            RawMarketData rmd = new RawMarketData(code, code, Detail.ProductType.BondSpot);

            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;

            textBox15.Text = curTimeStringWithFormat;
            textBox16.Text = BondUtil.GetRmdTextFormString(rmd);
            return true;
        }