コード例 #1
0
ファイル: POrderTest.cs プロジェクト: HongSeokHwan/legacy
        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_ol_with_dummy = new ValuePerOnceOrderLimit(kValuePerOnce, dummy);
            g_account_fo = AccountManager.Ins().CreateSimFOAccount();
            g_default_orderlimit = new DefaultOrderLimit(g_account_fo);
            g_ol_with_default = new ValuePerOnceOrderLimit(kValuePerOnce, g_default_orderlimit);
        }
コード例 #3
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;
        }
コード例 #4
0
ファイル: POrderTest.cs プロジェクト: HongSeokHwan/legacy
        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
 IOrderLimit CreateOrderLimit_FO()
 {
     IOrderLimit orderLimit = new DefaultOrderLimit(this.OptionAccount);
     orderLimit = new OutOfRangeOrderLimit(orderLimit);
     return orderLimit;
 }
コード例 #6
0
ファイル: SimHTSTest.cs プロジェクト: HongSeokHwan/legacy
        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);
            }
        }
コード例 #7
0
 IOrderLimit CreateOrderLimit_ELW()
 {
     IOrderLimit orderLimit = new DefaultOrderLimit(this.ElwAccount);
     orderLimit = new OutOfRangeOrderLimit(orderLimit);
     return orderLimit;
 }
コード例 #8
0
ファイル: STR_Arb.cs プロジェクト: HongSeokHwan/legacy
        public void InitEmptyRMDBondOrderLimit_3_2(String maxNotionalPerOnce)
        {
            IOrderLimit orderLimit = new DefaultOrderLimit(this.BondAccount);
            orderLimit = new ValuePerOnceOrderLimit(Util.ConvertFormatStringToInt64(maxNotionalPerOnce), orderLimit);
            const int longUpperLimit = 12000;
            const int shortLowerLimit = 8000;
            orderLimit = new StaticBoundaryOrderLimit(orderLimit, longUpperLimit, shortLowerLimit);

            this.BondAccount.SetOrderLimitEmptyRMD(orderLimit);
            _bReadyBondOrderLimit_3_2 = true;
        }
コード例 #9
0
ファイル: STR_Arb.cs プロジェクト: HongSeokHwan/legacy
        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;
        }
コード例 #10
0
ファイル: STR_Arb.cs プロジェクト: HongSeokHwan/legacy
        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;
        }
コード例 #11
0
ファイル: STR_OOR.cs プロジェクト: HongSeokHwan/legacy
 public void InitEmptyRMDElwOrderLimit_3_2()
 {
     IOrderLimit orderLimit = new DefaultOrderLimit(this.ElwAccount);
     orderLimit = new BeforeMarketOpenOrderLimit(orderLimit);
     this.ElwAccount.SetOrderLimitEmptyRMD(orderLimit);
     _bReadyElwOrderLimit_3_2 = true;
 }