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); }
void MonitorDataThisTurnTest( EDoorEachMonitorEnterController_Accessor each, MonitorState_Accessor ms, EDoorCenterData centerData) { MonitorState.MonitorDataThisTurn monitorData = EDoorUtil.CreateThisTurnInput(each._data); // 1. IsAllValid test monitorData.RmdKoi_0.BidPrice1 = 0; Assert.AreEqual(EDoorUtil.IsAllValid(monitorData), false); MakeValidRMD(ref monitorData); Assert.AreEqual(EDoorUtil.IsAllValid(monitorData), true); // 2. IsAllRefOK test Assert.AreEqual(EDoorUtil.IsAllRefOK(monitorData), false); MakeRefOKRMD_01(ref monitorData); Assert.AreEqual(EDoorUtil.IsAllRefOK(monitorData), false); MakeRefOKRMD_2(ref monitorData); Assert.AreEqual(EDoorUtil.IsAllRefOK(monitorData), false); MakeRefOKRMD_3(ref monitorData); Assert.AreEqual(EDoorUtil.IsAllRefOK(monitorData), false); // AllRefOK case MakeRefOKRMD_4(ref monitorData); Assert.AreEqual(EDoorUtil.IsAllRefOK(monitorData), true); }
void MonitorStateRunTest( EDoorEachMonitorEnterController_Accessor each, MonitorState_Accessor ms, EDoorCenterData centerData) { MonitorState.MonitorDataThisTurn monitorData = EDoorUtil.CreateThisTurnInput(each._data); MakeRefOKRMD_01(ref monitorData); MakeRefOKRMD_2(ref monitorData); MakeRefOKRMD_3(ref monitorData); MakeRefOKRMD_4(ref monitorData); CalculateElwReqPriceTest(ms, monitorData, each._data); SetAsDefaultPrice(monitorData); each._monitorEnter = ms.Run(centerData, each._data, monitorData); Assert.AreEqual(each._monitorEnter.GetState(), EDoorEachMonitorEnterState.EnteringState); }
void EDoorOrderTest(STR_EDoor_Accessor edoor) { // 주문이 안나가는 경우에 대해서 꼼꼼히 점검해본다. EDoorMonitorEnterController_Accessor controller = new EDoorMonitorEnterController_Accessor( new PrivateObject(edoor._monitorController)); controller.BlockAfterCancel = false; EDoorEachMonitorEnterController_Accessor callEach_0 = new EDoorEachMonitorEnterController_Accessor( new PrivateObject(GetController(controller._eachControllers, CallPutFlag.Call, 0))); EDoorEachMonitorEnterController_Accessor callEach_1 = new EDoorEachMonitorEnterController_Accessor( new PrivateObject(GetController(controller._eachControllers, CallPutFlag.Call, 1))); EDoorEachMonitorEnterController_Accessor putEach_0 = new EDoorEachMonitorEnterController_Accessor( new PrivateObject(GetController(controller._eachControllers, CallPutFlag.Put, 0))); EDoorCenterData centerData = edoor._centerData; // run test Assert.AreEqual(controller._eachControllers.Count, controller.Run(centerData)); MonitorState rawMS_0 = callEach_0._monitorEnter as MonitorState; MonitorState_Accessor msCallEach_0 = new MonitorState_Accessor(new PrivateObject(rawMS_0)); MonitorState rawMS_1 = callEach_1._monitorEnter as MonitorState; MonitorState_Accessor msCallEach_1 = new MonitorState_Accessor(new PrivateObject(rawMS_1)); MonitorState rawMS_2 = putEach_0._monitorEnter as MonitorState; MonitorState_Accessor msPutEach_0 = new MonitorState_Accessor(new PrivateObject(rawMS_2)); MonitorDataThisTurnTest(callEach_0, msCallEach_0, centerData); MonitorDataThisTurnTest(putEach_0, msPutEach_0, centerData); MonitorStateRunTest(callEach_0, msCallEach_0, centerData); Assert.AreEqual(1, centerData.GetAvailableChannelCount()); MonitorStateRunTest(putEach_0, msPutEach_0, centerData); Assert.AreEqual(0, centerData.GetAvailableChannelCount()); // 2개 다 나갔다. Valid하지 않다. Assert.AreEqual(false, controller.IsValid(centerData)); // run test Assert.AreEqual(0, controller.Run(centerData)); // entering test EnteringStateTest(callEach_0, centerData); Assert.AreEqual(true, controller.IsValid(centerData)); EnteringStateTest(putEach_0, centerData); Assert.AreEqual(true, controller.IsValid(centerData)); // rebalance test RebalanceStateTest(callEach_0, centerData); Assert.AreEqual(true, controller.IsValid(centerData)); RebalanceStateTest(putEach_0, centerData); Assert.AreEqual(false, controller.IsValid(centerData)); // cancel done test CencelOrderDoneTest(centerData, callEach_0); }