예제 #1
0
        public static Boolean IsAllRefOK(
            MonitorState.MonitorDataThisTurn monitorData)
        {
            if (monitorData.RmdKoi_0.BidPrice1 <= monitorData.RmdKoi_1.BidPrice1)
            {
                return false;
            }
            //else if가 아니다. if가 맞다.
            if (monitorData.RmdKoi_1.BidPrice1 <= monitorData.RmdKoi_2.BidPrice1)
            {
                return false;
            }

            if (monitorData.RmdKoi_2.BidPrice1 <= monitorData.RmdKoi_3.BidPrice1)
            {
                return false;
            }

            if (monitorData.RmdKoi_3.BidPrice1 <= monitorData.RmdKoi_4.BidPrice1)
            {
                return false;
            }

            return true;
        }
예제 #2
0
 public static Boolean IsAllValid(
     MonitorState.MonitorDataThisTurn monitorData)
 {
     if (!Util.IsValidFullRMD(monitorData.RmdKoi_0))
     {
         return false;
     }
     if (!Util.IsValidFullRMD(monitorData.RmdKoi_1))
     {
         return false;
     }
     if (!Util.IsValidFullRMD(monitorData.RmdKoi_2))
     {
         return false;
     }
     if (!Util.IsValidFullRMD(monitorData.RmdKoi_3))
     {
         return false;
     }
     if (!Util.IsValidFullRMD(monitorData.RmdKoi_4))
     {
         return false;
     }
     return true;
 }
예제 #3
0
        Boolean IsFrontBidPrice(
            EDoorEachMonitorEnterData eachData,
            MonitorState.MonitorDataThisTurn monitorData)
        {
            double reqPrice = eachData.LiveOrder.ReqPrice;
            double marketBidPrice = monitorData.RmdElw.BidPrice1;

            Boolean bSame = Util.IsSameDouble(reqPrice, marketBidPrice, 2);

            if (bSame || reqPrice > marketBidPrice)
            {
                return true;
            }
            return false;
        }
예제 #4
0
        Boolean IsOrderHigherThanKoi_2(
            EDoorCenterData centerData,
            EDoorEachMonitorEnterData eachData,
            MonitorState.MonitorDataThisTurn monitorData)
        {
            double reqPrice = ElwOptionUtil.ConvertToOptionPrice(
                eachData.EI.Code, eachData.LiveOrder.ReqPrice);

            double bidPriceOfKoi_2 = monitorData.RmdKoi_2.BidPrice1;

            if (reqPrice > bidPriceOfKoi_2)
            {
                return true;
            }
            return false;
        }
예제 #5
0
        Boolean IsRebalanceCondition(
            EDoorCenterData centerData,
            EDoorEachMonitorEnterData eachData,
            MonitorState.MonitorDataThisTurn monitorData,
            ref String log)
        {
            if (_parent.Parent.BlockAfterCancel)
            {
                return true;
            }

            // 1. 옵션시세가 정상적인지 확인한다.
            if (EDoorUtil.IsAllValid(monitorData) &&
                EDoorUtil.IsAllRefOK(monitorData))
            {
                // 2. koi 2's bidPrice < optionPriceOfReqPrice라면 리밸런스
                if (IsOrderHigherThanKoi_2(centerData, eachData, monitorData))
                {
                    log += "IsOrderHigherThanKoi_2 is true, ";
                    return true;
                }

                // 3. 최전방 주문이 아니고
                // 최전방 주문 + 1tick가격이 koi 3's bidPrice보다 작으면
                // 리밸런싱
                if (!IsFrontBidPrice(eachData, monitorData) &&
                    IsReqPricePlusOneLowerThanKoi_3(eachData, monitorData))
                {
                    log += "!IsFrontBidPrice and IsReqPricePlusOneLowerThanKoi_3 is true, ";
                    return true;
                }
                return false;
            }
            else
            {
                // 옵션 시세가 정상적이지 않으면 리밸런스 케이스이다.
                log += "Market data is not valid, ";
                return true;
            }
        }
예제 #6
0
        IEDoorEachMonitorEnterState Run(
            EDoorCenterData centerData,
            EDoorEachMonitorEnterData eachData,
            MonitorState.MonitorDataThisTurn monitorData)
        {
            // 리밸런스 해야 하는 상황인지 확인한다.

            String log = "";

            if (IsRebalanceCondition(centerData, eachData, monitorData, ref log))
            {
                // sweeper로 남은 주문 처리하고 모리터링 다시 시작
                EDoorEachSweeperController sweeper =
                    new EDoorEachSweeperController(
                        eachData.LiveOrder,
                        _parent.Parent.Parent.GetCenterData());

                // sweeper 등록
                _parent.Parent.Parent.GetSweeperController().Add(sweeper);

                eachData.ClearLiveOrder();
                logger.Info("Change State Rebalance to MonitorState {0} ({1})", eachData.EI.Name, log);
                IEDoorEachMonitorEnterState next = new MonitorState(_parent);
                return next;
            }
            return this;
        }
예제 #7
0
        Boolean IsReqPricePlusOneLowerThanKoi_3(
            EDoorEachMonitorEnterData eachData,
            MonitorState.MonitorDataThisTurn monitorData)
        {
            // 1. 주문한 elw 가격 + 1tick 가격을 구한다.
            String elwCode = eachData.LiveOrder.Code;
            double elwReqPrice = eachData.LiveOrder.ReqPrice;

            TickValue tv = ProductUtil.Ins().GetTick(elwCode, elwReqPrice);

            double elwReqPricePlusOne = elwReqPrice + tv.UpTickValue;

            // 2. elw가격 + 1tick 가격을 옵션 가격으로 바꾼다.
            double optionPriceOfReqPricePlusOne =
                ElwOptionUtil.ConvertToOptionPrice(elwCode, elwReqPricePlusOne);

            // 3. koi 3's bidPrice를 구한다.
            double bidPriceOfKoi_3 = monitorData.RmdKoi_3.BidPrice1;

            // 4. 비교한다.
            if (optionPriceOfReqPricePlusOne < bidPriceOfKoi_3)
            {
                return true;
            }
            return false;
        }
예제 #8
0
        void CalculateElwReqPriceTest(
            MonitorState_Accessor ms,
            MonitorState.MonitorDataThisTurn monitorData,
            EDoorEachMonitorEnterData eachData)
        {
            String elwCode = monitorData.RmdElw.Code;
            ElwInfo ei = ElwUtil.GetElwInfo(elwCode);

            //1. Elw 가격이 없는 경우
            // 4's koi가격
            SetAsDefaultPrice(monitorData);
            double actual = ms.CalculateElwReqPrice(monitorData, eachData);
            double expected =
                ElwOptionUtil.ConvertOptionPriceToElwPrice(ei, 0.8);
            Assert.AreEqual(expected, actual);

            //2. Elw 가격이 있는데 4's koi가격보다 낮은 경우
            // 4's koi가격
            double elwPrice =
                ElwOptionUtil.ConvertOptionPriceToElwPrice(ei, 0.5);
            monitorData.RmdElw.BidPrice1 = elwPrice;
            actual = ms.CalculateElwReqPrice(monitorData, eachData);
            expected =
                ElwOptionUtil.ConvertOptionPriceToElwPrice(ei, 0.8);
            Assert.AreEqual(expected, actual);

            //3. Elw 가격이 3's koi bidPrice보다 작은 경우
            // Elw BidPrice + 1tick 가격이 리턴
            double elwPriceOfKoi_3 = ElwOptionUtil.ConvertOptionPriceToElwPrice(
                ei, monitorData.RmdKoi_3.BidPrice1);
            TickValue tv = ProductUtil.Ins().GetTick(elwCode, elwPriceOfKoi_3);
            double elwBidPrice = elwPriceOfKoi_3 - tv.DownTickValue * 2;
            expected = elwPriceOfKoi_3 - tv.DownTickValue;
            monitorData.RmdElw.BidPrice1 = elwBidPrice;
            actual = ms.CalculateElwReqPrice(monitorData, eachData);
            Assert.AreEqual(expected, actual);

            //4. Elw 가격이 2's koi bidPrice보다 작은 경우(3's koi 초과)
            // 3's koi BidPrice해당 BidPrice
            double elwPriceOfKoi_2 = ElwOptionUtil.ConvertOptionPriceToElwPrice(
                ei, monitorData.RmdKoi_2.BidPrice1);
            tv = ProductUtil.Ins().GetTick(elwCode, elwPriceOfKoi_2);
            elwBidPrice = elwPriceOfKoi_2 - tv.DownTickValue * 2;
            expected = ElwOptionUtil.ConvertOptionPriceToElwPrice(
                ei, monitorData.RmdKoi_3.BidPrice1);
            monitorData.RmdElw.BidPrice1 = elwBidPrice;
            actual = ms.CalculateElwReqPrice(monitorData, eachData);
            Assert.AreEqual(expected, actual);

            //5. Elw 가격이 너무 낮은 경우(4's koi)
            SetAsDefaultPrice(monitorData);
            actual = ms.CalculateElwReqPrice(monitorData, eachData);
            expected =
                ElwOptionUtil.ConvertOptionPriceToElwPrice(ei, 0.8);
            Assert.AreEqual(expected, actual);

            //6. Koi 0's 가격이 너무 낮은 경우(-1)
            SetAsDefaultPrice(monitorData);
            monitorData.RmdKoi_0.BidPrice1 = 0.69;
            actual = ms.CalculateElwReqPrice(monitorData, eachData);
            Assert.AreEqual(-1, actual);

            //7. Koi 1's 가격이 너무 낮은 경우(해당사항 없음)
            //8. Koi 2's 가격이 너무 낮은 경우(해당사항 없음)

            //9. Koi 3's 가격이 너무 낮은 경우(-1)
            SetAsDefaultPrice(monitorData);
            monitorData.RmdKoi_3.BidPrice1 = 0.19;
            actual = ms.CalculateElwReqPrice(monitorData, eachData);
            Assert.AreEqual(-1, actual);

            //10. Koi 4's 가격이 너무 낮은 경우(-1)
            SetAsDefaultPrice(monitorData);
            monitorData.RmdKoi_4.BidPrice1 = 0.19;
            actual = ms.CalculateElwReqPrice(monitorData, eachData);
            Assert.AreEqual(-1, actual);

            //11. 0's 매수호가 - 0.5 경우
            SetAsDefaultPrice(monitorData);
            monitorData.RmdKoi_0.BidPrice1 = 1.4;
            actual = ms.CalculateElwReqPrice(monitorData, eachData);
            expected =
                ElwOptionUtil.ConvertOptionPriceToElwPrice(ei, 1.4 - 0.5);
        }
예제 #9
0
        void SetAsDefaultPrice(MonitorState.MonitorDataThisTurn monitorData)
        {
            // 기본 옵션 가격은 3.0, 2.5, 2, 1.5, 0.8이 되도록 한다.

            monitorData.RmdKoi_0.BidPrice1 = 3.0;
            monitorData.RmdKoi_0.AskPrice1 = 3.1;

            monitorData.RmdKoi_1.BidPrice1 = 2.5;
            monitorData.RmdKoi_1.AskPrice1 = 2.6;

            monitorData.RmdKoi_2.BidPrice1 = 2.0;
            monitorData.RmdKoi_2.AskPrice1 = 2.1;

            monitorData.RmdKoi_3.BidPrice1 = 1.5;
            monitorData.RmdKoi_3.AskPrice1 = 1.6;

            monitorData.RmdKoi_4.BidPrice1 = 0.8;
            monitorData.RmdKoi_4.AskPrice1 = 0.9;

            monitorData.RmdElw.BidPrice1 = 0;
            monitorData.RmdElw.AskPrice1 = 0;
        }
예제 #10
0
        void MakeValidRMD(ref MonitorState.MonitorDataThisTurn data)
        {
            data.RmdElw.BidPrice1 = 0;
            data.RmdElw.AskPrice1 = 100;

            data.RmdKoi_0.BidPrice1 = 10.1;
            data.RmdKoi_0.AskPrice1 = 10.2;

            data.RmdKoi_1.BidPrice1 = 10.2;
            data.RmdKoi_1.AskPrice1 = 10.3;

            data.RmdKoi_2.BidPrice1 = 10.3;
            data.RmdKoi_2.AskPrice1 = 10.4;

            data.RmdKoi_3.BidPrice1 = 10.4;
            data.RmdKoi_3.AskPrice1 = 10.5;

            data.RmdKoi_4.BidPrice1 = 10.5;
            data.RmdKoi_4.AskPrice1 = 10.6;
        }
예제 #11
0
        void MakeRefOKRMD_4(ref MonitorState.MonitorDataThisTurn data)
        {
            // call인 경우 strike가 작을수록 값이 크다.
            // put인 경우 strike가 클수록 값이 크다.

            data.RmdElw.BidPrice1 = 5;
            data.RmdElw.AskPrice1 = 10;

            data.RmdKoi_4.BidPrice1 = 0.6;
            data.RmdKoi_4.AskPrice1 = 0.7;
        }
예제 #12
0
        void MakeRefOKRMD_01(ref MonitorState.MonitorDataThisTurn data)
        {
            // call인 경우 strike가 작을수록 값이 크다.
            // put인 경우 strike가 클수록 값이 크다.

            data.RmdElw.BidPrice1 = 5;
            data.RmdElw.AskPrice1 = 10;

            data.RmdKoi_0.BidPrice1 = 1.0;
            data.RmdKoi_0.AskPrice1 = 1.1;

            data.RmdKoi_1.BidPrice1 = 0.9;
            data.RmdKoi_1.AskPrice1 = 1.0;
        }