示例#1
0
        void KtbFutureTest()
        {
            String future10yrCode = KtbFutureUtil.Ins().KtbFuture_10yr_1.Code;
            {
                TradingDirection longShort = TradingDirection.Long;
                string code = future10yrCode;
                long reqCount = 10;
                double reqPrice = 105.10;
                Account account = AccountManager.Ins().CreateSimFOAccount();

                IOrderLimit orderLimit = new DefaultOrderLimit(account);
                orderLimit = new LimOrderLimit(orderLimit);

                account.SetOrderLimit(orderLimit);

                RawMarketData rmdClone = new RawMarketData(future10yrCode, Detail.ProductType.KtbFuture);
                rmdClone.BidPrice1 = 105.10;
                rmdClone.AskPrice1 = 105.15;

                POrder target = new POrder(longShort, code, reqCount, reqPrice, account, rmdClone);
                bool success = POrderUtil.RequestOrder(target, null);
                Assert.AreEqual(true, success);

                target.UpdateCancelMessage(target.ReqCount);

                POrder_UnittestUtil.ClearOrder(target);
            }
        }
示例#2
0
        public static void MyClassInitialize(TestContext testContext)
        {
            // 선물, 옵션, Elw 상품 정보를 CP에서 읽어오고 config를 설정한다.
            ConfigManager.Ins().Initialize("c:\\UnittestMadViper\\config.txt");
            DB_DataLoader_Kospi_Future.Ins().Load();
            DB_DataLoader_Option.Ins().Load();
            DB_DataLoader_Elw.Ins().Load();

            // 각각의 OrderLimit이 decorator pattern을 잘 지키고 있는지를 테스트 하기 위해서 TestDummy를 root로 설정하여
            // 테스트를 진행한다.
            OrderLimitPassTestDummy dummy = new OrderLimitPassTestDummy();

            g_lim_ol_with_dummy = new LimOrderLimit(dummy);
            g_account_fo = AccountManager.Ins().CreateSimFOAccount();
            g_default_orderlimit = new DefaultOrderLimit(g_account_fo);
            g_lim_ol_with_default = new LimOrderLimit(g_default_orderlimit);
        }
        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;
        }
示例#4
0
        void KtbSpotTest()
        {
            String spot10yrCode = KtbSpotUtil.Ins().KtbSpot_10yr.Code;

            {
                TradingDirection longShort = TradingDirection.Long;
                string code = spot10yrCode;
                long reqCount = CommonConst._100_000_000;
                double reqPrice = 8000;
                Account account = AccountManager.Ins().CreateSimBondAccount();

                IOrderLimit orderLimit = new DefaultOrderLimit(account);
                orderLimit = new LimOrderLimit(orderLimit);

                account.SetOrderLimit(orderLimit);

                RawMarketData rmdClone = new RawMarketData(spot10yrCode, Detail.ProductType.KtbSpot);
                rmdClone.BidPrice1 = 8000;
                rmdClone.AskPrice1 = 8001;

                POrder target = new POrder(longShort, code, reqCount, reqPrice, account, rmdClone);
                bool success = POrderUtil.RequestOrder(target, null);
                Assert.AreEqual(true, success);

                target.UpdateCancelMessage(target.ReqCount);
                POrder_UnittestUtil.ClearOrder(target);
            }
        }
示例#5
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);
            }
        }
示例#6
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;
        }
示例#7
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;
        }