Beispiel #1
0
        void RebalanceStateTest_RebalanceRun(
            EDoorEachMonitorEnterController_Accessor each,
            RebalanceState_Accessor rsa,
            EDoorCenterData centerData)
        {
            //Run실행 후 sweeper, state, availableCount check
            MonitorState.MonitorDataThisTurn monitorData = EDoorUtil.CreateThisTurnInput(each._data);
            SetAsDefaultPrice(monitorData);

            String elwCode = each._data.LiveOrder.Code;
            double elwReqPrice = each._data.LiveOrder.ReqPrice;
            double optionPriceOfElwReqPrice = ElwOptionUtil.ConvertToOptionPrice(elwCode, elwReqPrice);

            RawMarketData rmdElw = monitorData.RmdElw;
            RawMarketData rmd_2 = monitorData.RmdKoi_2;
            RawMarketData rmd_3 = monitorData.RmdKoi_3;
            RawMarketData rmd_4 = monitorData.RmdKoi_4;

            TickValue tvElw = ProductUtil.Ins().GetTick(rmdElw.Code, elwReqPrice);

            double oneTickUpElwPrice = elwReqPrice + tvElw.UpTickValue;
            double oneTickDownElwPrice = elwReqPrice - tvElw.DownTickValue;

            double optionPriceOfOneTickUpElwReqPrice =
                ElwOptionUtil.ConvertToOptionPrice(elwCode, oneTickUpElwPrice);

            TickValue tv = ProductUtil.Ins().GetTick(rmd_3.Code, optionPriceOfOneTickUpElwReqPrice);

            double oneTickUpOptionPrice = optionPriceOfOneTickUpElwReqPrice + tv.UpTickValue;

            double oneTickDownOptionPrice = optionPriceOfOneTickUpElwReqPrice - tv.DownTickValue;

            rmd_3.BidPrice1 = oneTickUpOptionPrice;
            rmdElw.BidPrice1 = oneTickUpElwPrice;
            String log = "";
            Assert.AreEqual(true,  rsa.IsRebalanceCondition(centerData, each._data, monitorData, ref log));

            int prevChannel = centerData.GetAvailableChannelCount();
            POrder o = each._data.LiveOrder;

            IEDoorEachMonitorEnterState next = rsa.Run(centerData, each._data, monitorData);

            Assert.AreEqual(next.GetState(), EDoorEachMonitorEnterState.MonitorState);

            Assert.AreEqual(prevChannel - 1, centerData.GetAvailableChannelCount());

            Assert.AreEqual(true, o.IsCancelRemains());
        }
Beispiel #2
0
        void RebalanceStateTest_NoRebalanceCase(
            EDoorEachMonitorEnterController_Accessor each,
            RebalanceState_Accessor rsa,
            EDoorCenterData centerData)
        {
            MonitorState.MonitorDataThisTurn monitorData = EDoorUtil.CreateThisTurnInput(each._data);
            SetAsDefaultPrice(monitorData);

            String log = "";
            Boolean actual = rsa.IsRebalanceCondition(centerData, each._data, monitorData, ref log);
            Assert.AreEqual(false, actual);
        }
Beispiel #3
0
 void InvalidRMDCase_RebalanceStateTest(
     EDoorEachMonitorEnterController_Accessor each,
     RebalanceState_Accessor rsa,
     EDoorCenterData centerData)
 {
     MonitorState.MonitorDataThisTurn monitorData = EDoorUtil.CreateThisTurnInput(each._data);
     String log = "";
     Boolean actual = rsa.IsRebalanceCondition(centerData, each._data, monitorData, ref log);
     Assert.AreEqual(true, actual);
 }
Beispiel #4
0
        void NotFrontBidAndLowerPrice_RebalanceStateTest(
            EDoorEachMonitorEnterController_Accessor each,
            RebalanceState_Accessor rsa,
            EDoorCenterData centerData)
        {
            MonitorState.MonitorDataThisTurn monitorData = EDoorUtil.CreateThisTurnInput(each._data);
            SetAsDefaultPrice(monitorData);

            String elwCode = each._data.LiveOrder.Code;
            double elwReqPrice = each._data.LiveOrder.ReqPrice;
            double optionPriceOfElwReqPrice = ElwOptionUtil.ConvertToOptionPrice(elwCode, elwReqPrice);

            RawMarketData rmdElw = monitorData.RmdElw;
            RawMarketData rmd_2 = monitorData.RmdKoi_2;
            RawMarketData rmd_3 = monitorData.RmdKoi_3;
            RawMarketData rmd_4 = monitorData.RmdKoi_4;

            TickValue tvElw = ProductUtil.Ins().GetTick(rmdElw.Code, elwReqPrice);

            double oneTickUpElwPrice = elwReqPrice + tvElw.UpTickValue;
            double oneTickDownElwPrice = elwReqPrice - tvElw.DownTickValue;

            double optionPriceOfOneTickUpElwReqPrice =
                ElwOptionUtil.ConvertToOptionPrice(elwCode, oneTickUpElwPrice);

            TickValue tv = ProductUtil.Ins().GetTick(rmd_3.Code, optionPriceOfOneTickUpElwReqPrice);

            double oneTickUpOptionPrice = optionPriceOfOneTickUpElwReqPrice + tv.UpTickValue;

            double oneTickDownOptionPrice = optionPriceOfOneTickUpElwReqPrice - tv.DownTickValue;

            // Elw가격이 FrontBid가 되도록 설정
            // 같아도 FrontBid이다.
            rmdElw.BidPrice1 = elwReqPrice;
            Assert.AreEqual(true, rsa.IsFrontBidPrice(each._data, monitorData));

            rmdElw.BidPrice1 = oneTickDownElwPrice;
            Assert.AreEqual(true, rsa.IsFrontBidPrice(each._data, monitorData));

            // Elw가격이 FrontBid가 아니도록 설정
            rmdElw.BidPrice1 = oneTickUpElwPrice;
            Assert.AreEqual(false, rsa.IsFrontBidPrice(each._data, monitorData));

            //Elw가격 + 1tick < 3's bid case
            rmd_3.BidPrice1 = oneTickUpOptionPrice;
            Assert.AreEqual(true, rsa.IsReqPricePlusOneLowerThanKoi_3(each._data, monitorData));

            //Elw가격 + 1tick == 3's bid case
            //같을 때는 기본적으로 리밸런스를 하지 않는다.
            rmd_3.BidPrice1 = optionPriceOfOneTickUpElwReqPrice;
            Assert.AreEqual(false, rsa.IsReqPricePlusOneLowerThanKoi_3(each._data, monitorData));

            //Elw가격 + 1tick > 3's bid case
            rmd_3.BidPrice1 = oneTickDownOptionPrice;
            Assert.AreEqual(false, rsa.IsReqPricePlusOneLowerThanKoi_3(each._data, monitorData));

            //1. 3's Bid > elw && Not frontBid
            // rebalance case
            rmd_3.BidPrice1 = oneTickUpOptionPrice;
            rmdElw.BidPrice1 = oneTickUpElwPrice;
            String log = "";
            Assert.AreEqual(true, rsa.IsRebalanceCondition(centerData, each._data, monitorData, ref log));

            //2. 3's Bid == elw && Not frontBid
            // No rebalance case
            rmd_3.BidPrice1 = optionPriceOfOneTickUpElwReqPrice;
            rmdElw.BidPrice1 = oneTickUpElwPrice;
            Assert.AreEqual(false, rsa.IsRebalanceCondition(centerData, each._data, monitorData, ref log));

            //3. 3's Bid < elw && Not front Bid
            rmd_3.BidPrice1 = oneTickDownOptionPrice;
            rmdElw.BidPrice1 = oneTickUpElwPrice;
            Assert.AreEqual(false, rsa.IsRebalanceCondition(centerData, each._data, monitorData, ref log));

            //4. 3's Bid > elw && frontBid
            rmd_3.BidPrice1 = oneTickUpOptionPrice;
            rmdElw.BidPrice1 = elwReqPrice;
            Assert.AreEqual(false, rsa.IsRebalanceCondition(centerData, each._data, monitorData, ref log));

            //5. 3's Bid == elw && frontBid
            rmd_3.BidPrice1 = optionPriceOfOneTickUpElwReqPrice;
            rmdElw.BidPrice1 = elwReqPrice;
            Assert.AreEqual(false, rsa.IsRebalanceCondition(centerData, each._data, monitorData, ref log));

            //6. 3's Bid < elw && frontBid
            rmd_3.BidPrice1 = oneTickDownOptionPrice;
            rmdElw.BidPrice1 = elwReqPrice;
            Assert.AreEqual(false, rsa.IsRebalanceCondition(centerData, each._data, monitorData, ref log));
        }
Beispiel #5
0
        void HigherThanKoi_2_RebalanceStateTest(
            EDoorEachMonitorEnterController_Accessor each,
            RebalanceState_Accessor rsa,
            EDoorCenterData centerData)
        {
            MonitorState.MonitorDataThisTurn monitorData = EDoorUtil.CreateThisTurnInput(each._data);
            SetAsDefaultPrice(monitorData);

            String elwCode = each._data.LiveOrder.Code;
            double elwReqPrice = each._data.LiveOrder.ReqPrice;
            double optionPriceOfElwReqPrice = ElwOptionUtil.ConvertToOptionPrice(elwCode, elwReqPrice);

            RawMarketData rmd_2 = monitorData.RmdKoi_2;
            RawMarketData rmd_3 = monitorData.RmdKoi_3;
            RawMarketData rmd_4 = monitorData.RmdKoi_4;

            TickValue tv = ProductUtil.Ins().GetTick(rmd_2.Code, optionPriceOfElwReqPrice);

            double oneTickUpOptionPrice = optionPriceOfElwReqPrice + tv.UpTickValue;

            double oneTickDownOptionPrice = optionPriceOfElwReqPrice - tv.DownTickValue;

            // Elw가격보다 아직은 2's Bid가 높다.
            // Rebalance 필요 없다.
            SetAsDefaultPrice(monitorData);
            rmd_2.BidPrice1 = oneTickUpOptionPrice;
            rmd_3.BidPrice1 = rmd_2.BidPrice1 - 0.05;
            rmd_4.BidPrice1 = rmd_3.BidPrice1 - 0.05;

            String log = "";
            Boolean actual = rsa.IsRebalanceCondition(centerData, each._data, monitorData, ref log);
            Assert.AreEqual(false, actual);

            // Elw가격이 2's bid보다 높다.
            // Elw가 너무 높은 가격인 상태이므로 리밸런스 해주어야 한다.
            rmd_2.BidPrice1 = oneTickDownOptionPrice;
            rmd_3.BidPrice1 = rmd_2.BidPrice1 - 0.05;
            rmd_4.BidPrice1 = rmd_3.BidPrice1 - 0.05;

            actual = rsa.IsRebalanceCondition(centerData, each._data, monitorData, ref log);
            Assert.AreEqual(true, actual);
        }