示例#1
0
        public void CancelRemainsTest()
        {
            long reqCount = 3;
            double reqPrice = 220.0;

            Account account = AccountManager.Ins().CreateSimFOAccount();
            IOrderLimit orderLimit = new DefaultOrderLimit(account);
            orderLimit = new CountBidAskRangeOrderLimit(orderLimit);
            orderLimit = new PriceBidAskRangeOrderLimit(orderLimit);
            orderLimit = new LimOrderLimit(orderLimit);

            account.SetOrderLimit(orderLimit);

            SimHTS target = account.Hts as SimHTS;

            string code = KospiFutureUtil.Ins().KFI.Code;
            string price = reqPrice.ToString("n0");
            string quantity = Convert.ToString(reqCount);

            RawMarketData rmd = RmdManager.Ins().GetData(KospiFutureUtil.Ins().KFI.Code);

            rmd.BidPrice1 = 220;
            rmd.AskPrice1 = 225;
            rmd.BidCount1 = 100;
            rmd.AskCount1 = 101;

            {
                POrder o = new POrder(TradingDirection.Long, code, reqCount, reqPrice, account, rmd);
                Assert.AreEqual(o.IsInputValidated, true);

                bool expected = true;
                bool actual;

                actual = account.RequestOrder(o);

                Assert.AreEqual(expected, actual);

                SimPOrder simOrder = new SimPOrder(o, 1500);

                simOrder.Execute();

                StringPacket inOrderPacket = simOrder.GetContractPacket(SimPOrder.접수);
                target.ReceiveDTRealEventHandler(inOrderPacket.GetStream());

                account.HandleCallBackData();

                o.CancelRemains();
                StringPacket cancelPacket = simOrder.GetCancelPacket();
                target.ReceiveDTRealEventHandler(cancelPacket.GetStream());

                account.HandleCallBackData();

                Assert.AreEqual(o.IsDone(), true);
                Assert.AreEqual(o.CanceledCount, o.ReqCount);

                POrderLegalManager.Ins().Remove(o);
                POrderBidAskCountManager.Ins().Unregister(o);
            }

            {
                POrder o = new POrder(TradingDirection.Long, code, reqCount, reqPrice, account, rmd);
                Assert.AreEqual(o.IsInputValidated, true);

                bool expected = true;
                bool actual;

                actual = account.RequestOrder(o);

                Assert.AreEqual(expected, actual);

                SimPOrder simOrder = new SimPOrder(o, 1500);

                simOrder.Execute();

                StringPacket inOrderPacket = simOrder.GetContractPacket(SimPOrder.접수);
                target.ReceiveDTRealEventHandler(inOrderPacket.GetStream());

                simOrder.CurTotalContractedCount = reqCount;
                StringPacket contractCompletePacket = simOrder.GetContractPacket(SimPOrder.전량체결);
                target.ReceiveDTRealEventHandler(contractCompletePacket.GetStream());

                o.CancelRemains();

                account.HandleCallBackData();

                Assert.AreEqual(o.IsDone(), true);
                Assert.AreEqual(o.CanceledCount, 0);
                Assert.AreEqual(o.ContractedCount, o.ReqCount);

                POrderLegalManager.Ins().Remove(o);
                POrderBidAskCountManager.Ins().Unregister(o);
            }
        }
示例#2
0
        void AddRequest_Raw(SimPOrder so)
        {
            DateTime key = so.SchedulingTime;

            if (!_requestSimPOrders.ContainsKey(key))
            {
                _requestSimPOrders.Add(key, new List<SimPOrder>());
            }

            _requestSimPOrders[key].Add(so);
        }
示例#3
0
 public void AddRequest(POrder o)
 {
     o.RequestTime = DateTime.Now;
     SimPOrder so = new SimPOrder(o, this.PERIOD);
     AddRequest_Raw(so);
 }
示例#4
0
        void EnteringStateTest(
            EDoorEachMonitorEnterController_Accessor each,
            EDoorCenterData centerData)
        {
            EnteringState es = each._monitorEnter as EnteringState;
            EnteringState_Accessor esa = new EnteringState_Accessor(new PrivateObject(es));

            IEDoorEachMonitorEnterState state = esa.Run(centerData, each._data);
            Assert.AreEqual(EDoorEachMonitorEnterState.EnteringState, state.GetState());

            Account account = each._data.LiveOrder.TargetAccount;
            SimHTS target = account.Hts as SimHTS;

            SimPOrder simOrder = new SimPOrder(each._data.LiveOrder, 1500);
            simOrder.Execute();

            StringPacket inOrderPacket = simOrder.GetContractPacket(SimPOrder.접수);
            target.ReceiveDTRealEventHandler(inOrderPacket.GetStream());
            account.HandleCallBackData();

            state = esa.Run(centerData, each._data);
            Assert.AreEqual(EDoorEachMonitorEnterState.RebalanceState, state.GetState());
            each._monitorEnter = state;
        }