예제 #1
0
        public void InitFutureOrderLimit_3(String maxValuePerOnce)
        {
            IOrderLimit orderLimit = new DefaultOrderLimit(FutureAccount);
            orderLimit = new CountBidAskRangeOrderLimit(orderLimit);
            orderLimit = new PriceBidAskRangeOrderLimit(orderLimit);
            orderLimit = new ValuePerOnceOrderLimit(Util.ConvertFormatStringToInt64(maxValuePerOnce), orderLimit);
            orderLimit = new LimOrderLimit(orderLimit);
            //TODO
            // MaxNotionalLimit

            FutureAccount.SetOrderLimit(orderLimit);
            _bReadyFutureOrderLimit = true;
        }
예제 #2
0
        public void InitDefaultFutureOrderLimit_3_3(String maxCountPerOnce)
        {
            long maxCount = Util.ConvertFormatStringToInt64(maxCountPerOnce);
            Trace.Assert(maxCount < Const.kFutureLimitCountPerOnce);

            IOrderLimit orderLimit = new DefaultOrderLimit(this.FutureAccount);
            orderLimit = new CountBidAskRangeOrderLimit(orderLimit);
            orderLimit = new PriceBidAskRangeOrderLimit(orderLimit);
            orderLimit = new CountPerOnceOrderLimit(maxCount, orderLimit);
            orderLimit = new LimOrderLimit(orderLimit);

            this.FutureAccount.SetOrderLimit(orderLimit);
            _bReadyFutureOrderLimit_3_3 = true;
        }
예제 #3
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);
            }
        }
예제 #4
0
        public void InitDefaultBondOrderLimit_3_1(String maxNotionalPerOnce)
        {
            IOrderLimit orderLimit = new DefaultOrderLimit(this.BondAccount);
            orderLimit = new CountBidAskRangeOrderLimit(orderLimit);
            orderLimit = new PriceBidAskRangeOrderLimit(orderLimit);
            orderLimit = new ValuePerOnceOrderLimit(Util.ConvertFormatStringToInt64(maxNotionalPerOnce), orderLimit);
            orderLimit = new LimOrderLimit(orderLimit);

            this.BondAccount.SetOrderLimit(orderLimit);
            _bReadyBondOrderLimit_3_1 = true;
        }