当前位置: 首页>>代码示例>>C#>>正文


C# POrder.Update方法代码示例

本文整理汇总了C#中MadViper.POrder.Update方法的典型用法代码示例。如果您正苦于以下问题:C# POrder.Update方法的具体用法?C# POrder.Update怎么用?C# POrder.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MadViper.POrder的用法示例。


在下文中一共展示了POrder.Update方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestCheckArbChance_NoArbCase3

        void TestCheckArbChance_NoArbCase3(MonitorEnter_BondArb_Accessor me, ref int innerKillWithNoticeCallingCount)
        {
            BondPair housingBondPair = null;
            RawMarketData rmdNormal = null;
            RawMarketData rmdSmall = null;

            SetHousingBondPairAndRmds(ref housingBondPair, ref rmdNormal, ref rmdSmall);

            int ret = 0;

            // 5000에 사서 15000에 팔 수 있는 기회이다
            SetImmeLongPart(rmdNormal, 100 * CommonConst._1_000 * CommonConst._1_000, 5000);
            SetImmeShortPart(rmdNormal, 0, 0);
            SetImmeLongPart(rmdSmall, 0, 0);
            SetImmeShortPart(rmdSmall, 100 * CommonConst._1_000 * CommonConst._1_000, 15000);

            me.BeforeEnterSweeperChance();
            ret = me.CheckArbChance(housingBondPair);
            Assert.AreEqual(0, ret);

            POrder o = new POrder(TradingDirection.Long, rmdNormal.Code, 50 * CommonConst._1_000 * CommonConst._1_000, rmdNormal.AskPrice1, me._bondAccount, rmdNormal, MarketType._0_Bond_일반, false);
            POrderUtil.RequestOrder(o, null);

            me.BeforeEnterSweeperChance();
            ret = me.CheckArbChance(housingBondPair);
            Assert.AreEqual(-208, ret);

            o.Update(o.ReqCount, 0, true);
            POrderLegalManager.Ins().Remove(o);
            POrderBidAskCountManager.Ins().Unregister(o);

            me.BeforeEnterSweeperChance();
            ret = me.CheckArbChance(housingBondPair);
            Assert.AreEqual(0, ret);

            Sweeper_BondArb sweeper = new Sweeper_BondArb(housingBondPair, me._bondAccount);
            me._node.GetSweeperCollection().Add(sweeper);

            // long쪽에 많지만 sweeper에서 short쪽을 잡아주었기 때문에 이 경우 arb이 성립되지 않는다.
            SetImmeLongPart(rmdNormal, 100 * CommonConst._1_000 * CommonConst._1_000 * CommonConst._1_000, 5000);
            SetImmeShortPart(rmdNormal, 0, 0);
            SetImmeLongPart(rmdSmall, 0, 0);
            SetImmeShortPart(rmdSmall, 150 * CommonConst._1_000 * CommonConst._1_000, 15000);

            me.BeforeEnterSweeperChance();
            ret = me.CheckArbChance(housingBondPair);
            Assert.AreEqual(-208, ret);

            // 다음 테스트 등을 위해서 깨끗이 지워준다.
            Unittest_BondArbUtil.ClearBondAccount(me._bondAccount);

            // rmd도 깨끗이 정리한다.
            SetImmeLongPart(rmdNormal, 0, 0);
            SetImmeShortPart(rmdNormal, 0, 0);
            SetImmeLongPart(rmdSmall, 0, 0);
            SetImmeShortPart(rmdSmall, 0, 0);

            Unittest_BondArbUtil.ClearSweeperCollection(me);
            Unittest_BondArbUtil.ForcedClearPOrderBidAskManager();
        }
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:60,代码来源:BondArbTest.cs

示例2: TestPOrderLongBlockManagerBondSpot

        public void TestPOrderLongBlockManagerBondSpot()
        {
            // 채권 매수 매도 생성 등 테스트
            Account simAccount = StrategyManager.Ins().GetAccount("SimBond");

            POrderLongBlockManager manager = simAccount.LongBlockManager;

            String codeNoTail = BondUtil.GetCodeNoTail(BondUtil.HouseBond_1.Code);
            // 일반 등록
            String codeNormal = BondUtil.GetCodeWithMarketType(BondUtil.HouseBond_1.Code, MarketType._0_Bond_일반);
            RmdManager.Ins().BondSpot.Register(codeNormal);

            RawMarketData rmdNormal = RmdManager.Ins().BondSpot.GetData(codeNormal);
            const long kReqNormalCount = CommonConst._1_000 * CommonConst._1_000 * CommonConst._1_000;

            // 1. 매수전
            long possibleShortCount = manager.GetPossibleShortCountUsingCodeNoTail(codeNoTail);
            Assert.AreEqual(0, possibleShortCount);

            POrder o = new POrder(TradingDirection.Long, codeNormal, kReqNormalCount, 8888, simAccount, rmdNormal, MarketType._0_Bond_일반, false);
            o.Update(kReqNormalCount, 8888, true);

            // 2. 매수 완료
            possibleShortCount = manager.GetPossibleShortCountUsingCodeNoTail(codeNoTail);
            Assert.AreEqual(kReqNormalCount, possibleShortCount);

            // 소액 등록
            String codeSmall = BondUtil.GetCodeWithMarketType(BondUtil.HouseBond_1.Code, MarketType._1_Bond_소액);
            RmdManager.Ins().BondSpot.Register(codeSmall);
            RawMarketData rmdSmall = RmdManager.Ins().BondSpot.GetData(codeSmall);

            const long kReqSmallCount = CommonConst._1_000;
            o = new POrder(TradingDirection.Short, codeSmall, kReqSmallCount, 8888, simAccount, rmdSmall, MarketType._1_Bond_소액, false);

            // 3. 매도 주문
            possibleShortCount = manager.GetPossibleShortCountUsingCodeNoTail(codeNoTail);
            Assert.AreEqual(kReqNormalCount - kReqSmallCount, possibleShortCount);

            // 4. 매도 주문 일부체결
            o.Update(kReqSmallCount / 2, 8888, false);
            possibleShortCount = manager.GetPossibleShortCountUsingCodeNoTail(codeNoTail);
            Assert.AreEqual(kReqNormalCount - kReqSmallCount, possibleShortCount);

            // 5. 매도 주문 완료
            o.Update(kReqSmallCount / 2, 8888, false);
            o.UpdateCancelMessage(o.ReqCount - o.ContractedCount);
            possibleShortCount = manager.GetPossibleShortCountUsingCodeNoTail(codeNoTail);
            Assert.AreEqual(kReqNormalCount - kReqSmallCount / 2, possibleShortCount);

            o.Update(kReqSmallCount, 8888, true);

            long curPossibleShortCount = manager.GetPossibleShortCountUsingCodeNoTail(codeNoTail);

            // 6. 매수 일부 완료, 매도 주문
            POrder oLong = new POrder(TradingDirection.Long, codeNormal, kReqNormalCount, 8888, simAccount, rmdNormal, MarketType._0_Bond_일반, false);

            possibleShortCount = manager.GetPossibleShortCountUsingCodeNoTail(codeNoTail);
            Assert.AreEqual(curPossibleShortCount, possibleShortCount);

            oLong.Update(kReqSmallCount / 2, 8888, false);

            possibleShortCount = manager.GetPossibleShortCountUsingCodeNoTail(codeNoTail);
            Assert.AreEqual(curPossibleShortCount + kReqSmallCount / 2, possibleShortCount);

            oLong.Update(oLong.ReqCount, 8888, true);

            possibleShortCount = manager.GetPossibleShortCountUsingCodeNoTail(codeNoTail);
            Assert.AreEqual(curPossibleShortCount + kReqNormalCount, possibleShortCount);
        }
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:69,代码来源:POrderLongBlockManagerTest.cs

示例3: TestCheckArbChance_NoArbCase2

        void TestCheckArbChance_NoArbCase2(MonitorEnter_BondArb_Accessor me, ref int innerKillWithNoticeCallingCount)
        {
            BondPair housingBondPair = null;
            RawMarketData rmdNormal = null;
            RawMarketData rmdSmall = null;

            SetHousingBondPairAndRmds(ref housingBondPair, ref rmdNormal, ref rmdSmall);

            int ret = 0;

            // 9999에 사서 10000에 팔 수 있는 기회이다. (100)
            SetImmeLongPart(rmdNormal, 100, 9999);
            SetImmeShortPart(rmdSmall, 100, 10000);

            // 1. rmdNormal에서 10000에 사자 주문이 working중인데 short을 하려고 하는 경우
            RawMarketData rmdNormalForOrder = rmdNormal.Clone() as RawMarketData;
            SetImmeLongPart(rmdNormalForOrder, 100, 10000);

            // 수량이 적어 내부에서 에러난다

            Util.LogOutCriticalError("\t\t# POrder.Invalid ReqCount 1 permitted.");
            innerKillWithNoticeCallingCount++;
            POrder o = new POrder(
                TradingDirection.Long,
                rmdNormalForOrder.Code,
                rmdNormalForOrder.AskCount1,
                rmdNormalForOrder.AskPrice1,
                me._bondAccount,
                rmdNormalForOrder,
                MarketType._0_Bond_일반,
                false);

            POrderUtil.RequestOrder(o, null);

            ret = me.CheckArbChance(housingBondPair);
            Assert.AreEqual(-197, ret);

            // 주문 넣는다
            o.Update(100, 10000, true);
            POrderLegalManager.Ins().Remove(o);
            POrderBidAskCountManager.Ins().Unregister(o);

            // 더 이상 Legal 이슈가 없다.
            ret = me.CheckArbChance(housingBondPair);
            Assert.AreNotEqual(-197, ret);

            // 2. rmdNormal에서 9999에 팔자 주문이 working중인데 long을 하려고 하는 경우
            rmdNormalForOrder = rmdNormal.Clone() as RawMarketData;
            SetImmeLongPart(rmdNormalForOrder, 0, 0);
            SetImmeShortPart(rmdNormalForOrder, 100, 9999);
            //수량이 적어 내부에서 에러난다
            Util.LogOutCriticalError("\t\t# POrder.Invalid ReqCount 1 permitted.");
            innerKillWithNoticeCallingCount++;
            o = new POrder(TradingDirection.Short, rmdNormalForOrder.Code, rmdNormalForOrder.BidCount1, rmdNormalForOrder.BidPrice1, me._bondAccount, rmdNormalForOrder, MarketType._0_Bond_일반, false);
            POrderUtil.RequestOrder(o, null);

            ret = me.CheckArbChance(housingBondPair);
            Assert.AreEqual(-197, ret);

            // 주문 넣는다
            o.Update(100, 9999, true);
            POrderLegalManager.Ins().Remove(o);
            POrderBidAskCountManager.Ins().Unregister(o);

            // 더 이상 Legal 이슈가 없다.
            ret = me.CheckArbChance(housingBondPair);
            Assert.AreNotEqual(-197, ret);

            // 3. rmdSmall에서 10000에 사자 주문이 working중인데 short을 하려고 하는 경우
            RawMarketData rmdSmallForOrder = rmdSmall.Clone() as RawMarketData;
            SetImmeLongPart(rmdSmallForOrder, 100, 10000);
            //수량이 적어 내부에서 에러난다.
            Util.LogOutCriticalError("\t\t# POrder.Invalid ReqCount 1 permitted.");
            innerKillWithNoticeCallingCount++;
            o = new POrder(
                TradingDirection.Long,
                rmdSmallForOrder.Code,
                rmdSmallForOrder.AskCount1,
                rmdSmallForOrder.AskPrice1,
                me._bondAccount,
                rmdSmallForOrder,
                MarketType._1_Bond_소액,
                false);
            POrderUtil.RequestOrder(o, null);

            ret = me.CheckArbChance(housingBondPair);
            Assert.AreEqual(-197, ret);

            // 주문 넣는다
            o.Update(100, 10000, true);
            POrderLegalManager.Ins().Remove(o);
            POrderBidAskCountManager.Ins().Unregister(o);

            // 더 이상 Legal 이슈가 없다.
            ret = me.CheckArbChance(housingBondPair);
            Assert.AreNotEqual(-197, ret);

            // 4. rmdSmall에서 9999에 팔자 주문이 working중인데 long을 하려고 하는 경우
            rmdSmallForOrder = rmdSmall.Clone() as RawMarketData;
            SetImmeLongPart(rmdSmallForOrder, 0, 0);
//.........这里部分代码省略.........
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:101,代码来源:BondArbTest.cs

示例4: GetSignedReqCount100kTest

        public void GetSignedReqCount100kTest()
        {
            long k = 1000;

            {
                //100
                String code = GetFirstElwCode(100);
                Account simAccount = AccountManager.Ins().CreateSimSpotAccount();
                RawMarketData rmd = new RawMarketData(code, Detail.ProductType.ELW);
                rmd.BidPrice1 = 10;
                rmd.BidCount1 = 1000;
                rmd.AskPrice1 = 15;
                rmd.AskCount1 = 1000;

                {
                    POrder o = new POrder(TradingDirection.Long, code, 10, 10, simAccount, rmd);
                    Assert.AreEqual(o.IsInputValidated, true);
                    long expected = 1000;
                    long actual;
                    actual = ElwOptionUtil.GetSignedReqCount100k(o);
                    Assert.AreEqual(expected, actual);

                    o.Update(10, 10, true);
                }

                {
                    POrder o = new POrder(TradingDirection.Long, code, 1000, 10, simAccount, rmd);
                    Assert.AreEqual(o.IsInputValidated, true);
                    long expected = 100 * k;
                    long actual;
                    actual = ElwOptionUtil.GetSignedReqCount100k(o);
                    Assert.AreEqual(expected, actual);

                    o.Update(1000, 10, true);
                }
                {
                    POrder o = new POrder(TradingDirection.Long, code, 1990, 10, simAccount, rmd);
                    Assert.AreEqual(o.IsInputValidated, true);
                    long expected = 199 * k;
                    long actual;
                    actual = ElwOptionUtil.GetSignedReqCount100k(o);
                    Assert.AreEqual(expected, actual);

                    o.Update(1990, 10, true);
                }
                {
                    POrder o = new POrder(TradingDirection.Short, code, 1000, 10, simAccount, rmd);
                    Assert.AreEqual(o.IsInputValidated, true);
                    long expected = 100 * k * (-1);
                    long actual;
                    actual = ElwOptionUtil.GetSignedReqCount100k(o);
                    Assert.AreEqual(expected, actual);
                }
                {
                    POrder o = new POrder(TradingDirection.Short, code, 1990, 10, simAccount, rmd);
                    Assert.AreEqual(o.IsInputValidated, true);
                    long expected = 199 * k * (-1);
                    long actual;
                    actual = ElwOptionUtil.GetSignedReqCount100k(o);
                    Assert.AreEqual(expected, actual);
                }
            }

            {
                //200
                String code = GetFirstElwCode(200);
                if (code.Length > 0)
                {
                    Account simAccount = AccountManager.Ins().CreateSimSpotAccount();
                    RawMarketData rmd = new RawMarketData(code, Detail.ProductType.ELW);
                    rmd.BidPrice1 = 10;
                    rmd.BidCount1 = 1000;
                    rmd.AskPrice1 = 15;
                    rmd.AskCount1 = 1000;

                    {
                        POrder o = new POrder(TradingDirection.Long, code, 10, 10, simAccount, rmd);
                        Assert.AreEqual(o.IsInputValidated, true);
                        long expected = 2000;
                        long actual;
                        actual = ElwOptionUtil.GetSignedReqCount100k(o);
                        Assert.AreEqual(expected, actual);

                        o.Update(10, 10, true);
                    }
                    {
                        POrder o = new POrder(TradingDirection.Long, code, 1000, 10, simAccount, rmd);
                        Assert.AreEqual(o.IsInputValidated, true);
                        long expected = 200 * k;
                        long actual;
                        actual = ElwOptionUtil.GetSignedReqCount100k(o);
                        Assert.AreEqual(expected, actual);

                        o.Update(1000, 10, true);
                    }
                    {
                        POrder o = new POrder(TradingDirection.Long, code, 1990, 10, simAccount, rmd);
                        Assert.AreEqual(o.IsInputValidated, true);
                        long expected = 398 * k;
                        long actual;
//.........这里部分代码省略.........
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:101,代码来源:ElwOptionUtilTest.cs

示例5: TestPOrderLongBlockManagerKtbSpot

        public void TestPOrderLongBlockManagerKtbSpot()
        {
            Account simAccount = StrategyManager.Ins().GetAccount("SimBond");
            POrderLongBlockManager manager = simAccount.LongBlockManager;

            String code = KtbSpotUtil.Ins().KtbSpot_10yr.Code;
            //매수전
            long possibleShortCount = manager.GetPossibleShortCountUsingCodeNoTail(code);
            Assert.AreEqual(0, possibleShortCount);

            RawMarketData rmd = new RawMarketData(code, Detail.ProductType.KtbSpot);

            //매수 1억
            POrder o = new POrder(TradingDirection.Long, code, CommonConst._100_000_000, 8888,
                simAccount, rmd);
            o.Update(CommonConst._100_000_000, 8888, true);

            possibleShortCount = manager.GetPossibleShortCountUsingCodeNoTail(code);
            Assert.AreEqual(CommonConst._100_000_000, possibleShortCount);

            o = new POrder(TradingDirection.Short, code, CommonConst._100_000_000, 8888, simAccount, rmd);

            // 3. 매도 주문
            possibleShortCount = manager.GetPossibleShortCountUsingCodeNoTail(code);
            Assert.AreEqual(0, possibleShortCount);

            // 4. 매도 주문 일부체결
            o.Update(CommonConst._10_000_000, 8888, false);
            possibleShortCount = manager.GetPossibleShortCountUsingCodeNoTail(code);
            Assert.AreEqual(0, possibleShortCount);

            // 5. 매도 주문 완료
            o.UpdateCancelMessage(CommonConst._100_000_000 - CommonConst._10_000_000);
            possibleShortCount = manager.GetPossibleShortCountUsingCodeNoTail(code);
            Assert.AreEqual(CommonConst._100_000_000 - CommonConst._10_000_000, possibleShortCount);
        }
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:36,代码来源:POrderLongBlockManagerTest.cs

示例6: GetSignedGoodChanceCount100kTest

        public void GetSignedGoodChanceCount100kTest()
        {
            String elwCode = GetFirstElwCode(100);
            ElwInfo ei = ElwUtil.GetElwInfo(elwCode);
            long elwCountOfOneOption = ElwOptionUtil.GetElwCountOfOneOption(elwCode);
            Account simAccountElw = AccountManager.Ins().CreateSimSpotAccount();
            RawMarketData rmdElw = RmdManager.Ins().GetData(elwCode);
            double elwPrice = 10;
            long elwCount = 1000;
            SetAsValidValue(rmdElw, TradingDirection.Long, elwPrice);

            Account simAccountFO = AccountManager.Ins().CreateSimFOAccount();
            String optionCode = ElwOptionUtil.ToOptionCode(elwCode);
            KospiOptionInfo koi = OptionUtil.GetKOI(optionCode);
            Detail.ProductType pt = OptionUtil.ConvertToDetailProductType(koi.CallPut);
            RawMarketData rmdOption = RmdManager.Ins().GetData(optionCode);
            double optionPrice = 0.1;
            long optionCount = 1;
            SetAsValidValue(rmdOption, TradingDirection.Short, optionPrice);

            List<POrder> arr = new List<POrder>();

            POrder elwOrder = new POrder(TradingDirection.Long, elwCode, elwCount, elwPrice, simAccountElw, rmdElw);
            Assert.AreEqual(elwOrder.IsInputValidated, true);
            arr.Add(elwOrder);
            {
                long expected = 100000;
                long actual;
                actual = ElwOptionUtil.GetSignedGoodChanceCount100k(arr);
                Assert.AreEqual(expected, actual);
            }

            rmdElw.BidPrice1 = 15;
            rmdElw.AskPrice1 = 20;

            {
                long expected = 0;
                long actual;
                actual = ElwOptionUtil.GetSignedGoodChanceCount100k(arr);
                Assert.AreEqual(expected, actual);
            }

            POrder optionOrder = new POrder(TradingDirection.Short, optionCode, optionCount, optionPrice, simAccountFO, rmdOption);
            Assert.AreEqual(optionOrder.IsInputValidated, true);
            arr.Add(optionOrder);

            {
                long expected = -100000;
                long actual;
                actual = ElwOptionUtil.GetSignedGoodChanceCount100k(arr);
                Assert.AreEqual(expected, actual);
            }

            rmdOption.BidPrice1 = 0.08;
            rmdOption.AskPrice1 = 0.09;

            {
                long expected = 0;
                long actual;
                actual = ElwOptionUtil.GetSignedGoodChanceCount100k(arr);
                Assert.AreEqual(expected, actual);
            }

            SetAsValidValue(rmdOption, TradingDirection.Short, optionPrice);
            {
                long expected = -100000;
                long actual;
                actual = ElwOptionUtil.GetSignedGoodChanceCount100k(arr);
                Assert.AreEqual(expected, actual);
            }

            optionOrder.Update(optionOrder.ReqCount, optionPrice, true);
            {
                long expected = 0;
                long actual;
                actual = ElwOptionUtil.GetSignedGoodChanceCount100k(arr);
                Assert.AreEqual(expected, actual);
            }
        }
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:79,代码来源:ElwOptionUtilTest.cs

示例7: GetSignedMaxPossibleExposureCount100kTest

        public void GetSignedMaxPossibleExposureCount100kTest()
        {
            String elwCode = GetFirstElwCode(100);
            ElwInfo ei = ElwUtil.GetElwInfo(elwCode);
            long elwCountOfOneOption = ElwOptionUtil.GetElwCountOfOneOption(elwCode);
            Account simAccountElw = AccountManager.Ins().CreateSimSpotAccount();
            RawMarketData rmdElw = new RawMarketData(elwCode, Detail.ProductType.ELW);

            Account simAccountFO = AccountManager.Ins().CreateSimFOAccount();
            String optionCode = ElwOptionUtil.ToOptionCode(elwCode);
            KospiOptionInfo koi = OptionUtil.GetKOI(optionCode);
            Detail.ProductType pt = OptionUtil.ConvertToDetailProductType(koi.CallPut);
            RawMarketData rmdOption = new RawMarketData(optionCode, pt);

            // elw 1000,000개 매수 상태로 설정
            POrder preOrderElw = new POrder(TradingDirection.Long, elwCode, 1000000, 10, simAccountElw, rmdElw);
            preOrderElw.OrderNumber = 0;
            Assert.AreEqual(preOrderElw.IsInputValidated, true);
            preOrderElw.Update(preOrderElw.ReqCount, 10, true);

            List<POrder> arr = new List<POrder>();

            POrder elwOrder1 = new POrder(TradingDirection.Long, elwCode, elwCountOfOneOption, 10, simAccountElw, rmdElw);
            elwOrder1.OrderNumber = 0;
            Assert.AreEqual(elwOrder1.IsInputValidated, true);
            POrder elwOrder2 = new POrder(TradingDirection.Short, elwCode, elwCountOfOneOption, 10, simAccountElw, rmdElw);
            elwOrder2.OrderNumber = 0;
            Assert.AreEqual(elwOrder2.IsInputValidated, true);

            arr.Add(elwOrder1);
            arr.Add(elwOrder2);

            // 0인지 검사 한번 한다.
            {
                long actual = ElwOptionUtil.GetSignedMaxPossibleExposureCount100k(arr);
                long expected = 0;
                Assert.AreEqual(expected, actual);
            }

            // 옵션도 한번 더해본다.
            POrder optionOrder1 = new POrder(TradingDirection.Long, optionCode, 1, 10, simAccountFO, rmdOption);
            optionOrder1.OrderNumber = 0;
            Assert.AreEqual(optionOrder1.IsInputValidated, true);
            arr.Add(optionOrder1);

            // 100,000 인지 검사 한번 한다.
            {
                long actual = ElwOptionUtil.GetSignedMaxPossibleExposureCount100k(arr);
                long expected = 100000;
                Assert.AreEqual(expected, actual);
            }

            // 옵션 매도를 한번 더해본다. 수량은 2개
            POrder optionOrder2 = new POrder(TradingDirection.Short, optionCode, 2, 10, simAccountFO, rmdOption);
            optionOrder2.OrderNumber = 0;
            Assert.AreEqual(optionOrder2.IsInputValidated, true);
            arr.Add(optionOrder2);

            // -100,000 인지 검사 한번 한다.
            {
                long actual = ElwOptionUtil.GetSignedMaxPossibleExposureCount100k(arr);
                long expected = -100000;
                Assert.AreEqual(expected, actual);
            }

            elwOrder1.Update(elwOrder1.ReqCount, 10, true);

            // -100,000 인지 검사 한번 한다.
            {
                long actual = ElwOptionUtil.GetSignedMaxPossibleExposureCount100k(arr);
                long expected = -100000;
                Assert.AreEqual(expected, actual);
            }

            elwOrder2.UpdateCancelMessage(elwOrder2.ReqCount);
            // 0 인지 검사 한번 한다.
            {
                long actual = ElwOptionUtil.GetSignedMaxPossibleExposureCount100k(arr);
                long expected = 0;
                Assert.AreEqual(expected, actual);
            }
        }
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:82,代码来源:ElwOptionUtilTest.cs

示例8: GetOptionCount_DoubleTest

        public void GetOptionCount_DoubleTest()
        {
            String elwCode = GetFirstElwCode(100);
            ElwInfo ei = ElwUtil.GetElwInfo(elwCode);
            long elwCountOfOneOption = ElwOptionUtil.GetElwCountOfOneOption(elwCode);
            Account simAccountElw = AccountManager.Ins().CreateSimSpotAccount();
            RawMarketData rmdElw = RmdManager.Ins().GetData(elwCode);
            double elwPrice = 10;
            long elwCount = 1000;
            SetAsValidValue(rmdElw, TradingDirection.Long, elwPrice);

            Account simAccountFO = AccountManager.Ins().CreateSimFOAccount();
            String optionCode = ElwOptionUtil.ToOptionCode(elwCode);
            KospiOptionInfo koi = OptionUtil.GetKOI(optionCode);
            Detail.ProductType pt = OptionUtil.ConvertToDetailProductType(koi.CallPut);
            RawMarketData rmdOption = RmdManager.Ins().GetData(optionCode);
            double optionPrice = 0.1;
            SetAsValidValue(rmdOption, TradingDirection.Short, optionPrice);

            List<POrder> arr = new List<POrder>();
            {
                POrder elwOrder = new POrder(TradingDirection.Long, elwCode, elwCount, elwPrice, simAccountElw, rmdElw);
                Assert.AreEqual(elwOrder.IsInputValidated, true);
                arr.Add(elwOrder);

                {
                    double expected = 0;
                    double actual;
                    actual = ElwOptionUtil.GetSignedContractedCountOption_Double(arr);
                    Assert.AreEqual(Util.IsSameDouble(expected, actual), true);
                }

                {
                    elwOrder.Update(10, elwPrice, false);
                    double expected = 0.01;
                    double actual;
                    actual = ElwOptionUtil.GetSignedContractedCountOption_Double(arr);
                    Assert.AreEqual(Util.IsSameDouble(expected, actual), true);
                }

                {
                    elwOrder.Update(500, elwPrice, false);
                    double expected = 0.5;
                    double actual;
                    actual = ElwOptionUtil.GetSignedContractedCountOption_Double(arr);
                    Assert.AreEqual(Util.IsSameDouble(expected, actual), true);
                }
                {
                    elwOrder.Update(1000, elwPrice, true);
                    double expected = 1;
                    double actual;
                    actual = ElwOptionUtil.GetSignedContractedCountOption_Double(arr);
                    Assert.AreEqual(Util.IsSameDouble(expected, actual), true);
                }
                arr.Remove(elwOrder);
            }
            {
                POrder elwOrder = new POrder(TradingDirection.Short, elwCode, elwCount, elwPrice, simAccountElw, rmdElw);
                Assert.AreEqual(elwOrder.IsInputValidated, true);
                arr.Add(elwOrder);

                {
                    double expected = 0;
                    double actual;
                    actual = ElwOptionUtil.GetSignedContractedCountOption_Double(arr);
                    Assert.AreEqual(Util.IsSameDouble(expected, actual), true);
                }

                {
                    elwOrder.Update(10, elwPrice, false);
                    double expected = -0.01;
                    double actual;
                    actual = ElwOptionUtil.GetSignedContractedCountOption_Double(arr);
                    Assert.AreEqual(Util.IsSameDouble(expected, actual), true);
                }

                {
                    elwOrder.Update(500, elwPrice, false);
                    double expected = -0.5;
                    double actual;
                    actual = ElwOptionUtil.GetSignedContractedCountOption_Double(arr);
                    Assert.AreEqual(Util.IsSameDouble(expected, actual), true);
                }
                {
                    elwOrder.Update(1000, elwPrice, false);
                    double expected = -1;
                    double actual;
                    actual = ElwOptionUtil.GetSignedContractedCountOption_Double(arr);
                    Assert.AreEqual(Util.IsSameDouble(expected, actual), true);
                }
                arr.Remove(elwOrder);
            }
        }
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:93,代码来源:ElwOptionUtilTest.cs

示例9: GetParticleElwCountTest1

        public void GetParticleElwCountTest1()
        {
            String elwCode = GetFirstElwCode(100);
            ElwInfo ei = ElwUtil.GetElwInfo(elwCode);
            long elwCountOfOneOption = ElwOptionUtil.GetElwCountOfOneOption(elwCode);
            Account simAccountElw = AccountManager.Ins().CreateSimSpotAccount();
            RawMarketData rmdElw = RmdManager.Ins().GetData(elwCode);
            double elwPrice = 10;
            long elwCount = 3000;
            SetAsValidValue(rmdElw, TradingDirection.Long, elwPrice);

            Account simAccountFO = AccountManager.Ins().CreateSimFOAccount();
            String optionCode = ElwOptionUtil.ToOptionCode(elwCode);
            KospiOptionInfo koi = OptionUtil.GetKOI(optionCode);
            Detail.ProductType pt = OptionUtil.ConvertToDetailProductType(koi.CallPut);
            RawMarketData rmdOption = RmdManager.Ins().GetData(optionCode);
            double optionPrice = 0.1;
            long optionCount = 3;
            SetAsValidValue(rmdOption, TradingDirection.Short, optionPrice);

            POrder bufferOrder = new POrder(
                TradingDirection.Long, elwCode, elwCount, elwPrice, simAccountElw, rmdElw);
            POrder_UnittestUtil.GetFakeOrderNumber(bufferOrder);
            bufferOrder.Update(bufferOrder.ReqCount, elwPrice, true);

            {
                POrder o = new POrder(TradingDirection.Long, elwCode, elwCount, elwPrice, simAccountElw, rmdElw);
                Assert.AreEqual(o.IsInputValidated, true);
                o.Update(o.ReqCount, elwPrice, true);
            }

            List<POrder> arr = new List<POrder>();
            POrder optionOrder = new POrder(
                TradingDirection.Short, optionCode, optionCount, optionPrice, simAccountFO, rmdOption);
            Assert.AreEqual(optionOrder.IsInputValidated, true);
            arr.Add(optionOrder);

            {
                long expected = 0;
                long actual;
                actual = ElwOptionUtil.GetSignedParticleElwCount(ei, arr);
                Assert.AreEqual(expected, actual);
            }

            {
                POrder elwOrder = new POrder(
                    TradingDirection.Short, elwCode, elwCount, elwPrice, simAccountElw, rmdElw);
                Assert.AreEqual(elwOrder.IsInputValidated, true);
                arr.Add(elwOrder);
                {
                    long expected = 0;
                    long actual;
                    actual = ElwOptionUtil.GetSignedParticleElwCount(ei, arr);
                    Assert.AreEqual(expected, actual);
                }

                elwOrder.OrderNumber = 0;
                elwOrder.Update(10, elwPrice, false);
                elwOrder.UpdateCancelMessage(elwOrder.ReqCount - elwOrder.ContractedCount);

                {
                    long expected = -10;
                    long actual;
                    actual = ElwOptionUtil.GetSignedParticleElwCount(ei, arr);
                    Assert.AreEqual(expected, actual);
                }
                arr.Remove(elwOrder);
            }

            {
                POrder elwOrder = new POrder(
                    TradingDirection.Short, elwCode, elwCount, elwPrice, simAccountElw, rmdElw);
                elwOrder.OrderNumber = 0;
                Assert.AreEqual(elwOrder.IsInputValidated, true);
                arr.Add(elwOrder);
                {
                    long expected = 0;
                    long actual;
                    actual = ElwOptionUtil.GetSignedParticleElwCount(ei, arr);
                    Assert.AreEqual(expected, actual);
                }

                elwOrder.Update(990, elwPrice, false);
                elwOrder.UpdateCancelMessage(elwOrder.ReqCount - elwOrder.ContractedCount);

                {
                    long expected = -990;
                    long actual;
                    actual = ElwOptionUtil.GetSignedParticleElwCount(ei, arr);
                    Assert.AreEqual(expected, actual);
                }
                arr.Remove(elwOrder);
            }

            {
                POrder elwOrder = new POrder(
                    TradingDirection.Short, elwCode, elwCount, elwPrice, simAccountElw, rmdElw);
                Assert.AreEqual(elwOrder.IsInputValidated, true);
                arr.Add(elwOrder);
                {
//.........这里部分代码省略.........
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:101,代码来源:ElwOptionUtilTest.cs

示例10: getSignedRemainCount100kTest_Option

        void getSignedRemainCount100kTest_Option()
        {
            String elwCode = GetFirstElwCode(100);
            Account simAccount = AccountManager.Ins().CreateSimFOAccount();
            String optionCode = ElwOptionUtil.ToOptionCode(elwCode);
            KospiOptionInfo koi = OptionUtil.GetKOI(optionCode);
            Detail.ProductType pt = OptionUtil.ConvertToDetailProductType(koi.CallPut);

            RawMarketData rmdOption = new RawMarketData(optionCode, pt);

            {
                TradingDirection ls = TradingDirection.Long;
                double price = 10;
                SetAsValidValue(rmdOption, ls, price);

                List<POrder> arr = new List<POrder>();
                for (int i = 0; i < 10; ++i)
                {
                    int index = i + 1;
                    POrder o = new POrder(ls, optionCode, 1 * index, 10, simAccount, rmdOption);
                    Assert.AreEqual(o.IsInputValidated, true);
                    arr.Add(o);
                }

                {
                    long actual = ElwOptionUtil.GetSignedRemainCount100k(arr);
                    long expected = 5500000;
                    Assert.AreEqual(expected, actual);
                }

                long total_contracted_count = 0;
                foreach (POrder o in arr)
                {
                    long contracted_count = (long)(o.ReqCount / 2);
                    total_contracted_count += contracted_count;
                    o.Update(contracted_count, price, false);
                }

                {
                    total_contracted_count = ElwOptionUtil.ConvertRealToCount100k(optionCode, total_contracted_count);
                    long remain_count = 5500000 - total_contracted_count;
                    long actual = ElwOptionUtil.GetSignedRemainCount100k(arr);
                    Assert.AreEqual(remain_count, actual);
                }

                foreach (POrder o in arr)
                {
                    o.Update(o.ReqCount, price, true);
                }
            }

            {
                TradingDirection ls = TradingDirection.Short;
                double price = 10;
                SetAsValidValue(rmdOption, ls, price);

                List<POrder> arr = new List<POrder>();
                for (int i = 0; i < 10; ++i)
                {
                    int index = i + 1;
                    POrder o = new POrder(ls, optionCode, 1 * index, 10, simAccount, rmdOption);
                    Assert.AreEqual(o.IsInputValidated, true);
                    arr.Add(o);
                }

                {
                    long actual = ElwOptionUtil.GetSignedRemainCount100k(arr);
                    long expected = -5500000;
                    Assert.AreEqual(expected, actual);
                }

                long total_contracted_count = 0;
                foreach (POrder o in arr)
                {
                    long contracted_count = (long)(o.ReqCount / 2);
                    total_contracted_count -= contracted_count;
                    o.Update(contracted_count, price, false);
                }

                {
                    total_contracted_count = ElwOptionUtil.ConvertRealToCount100k(optionCode, total_contracted_count);
                    long remain_count = -5500000 - total_contracted_count;
                    long actual = ElwOptionUtil.GetSignedRemainCount100k(arr);
                    Assert.AreEqual(remain_count, actual);
                }
                foreach (POrder o in arr)
                {
                    o.Update(o.ReqCount, price, true);
                }
            }
        }
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:91,代码来源:ElwOptionUtilTest.cs

示例11: getSignedRemainCount100kTest_ElwOption

        void getSignedRemainCount100kTest_ElwOption()
        {
            String elwCode = GetFirstElwCode(100);
            ElwInfo ei = ElwUtil.GetElwInfo(elwCode);
            long elwCountOfOneOption = ElwOptionUtil.GetElwCountOfOneOption(elwCode);
            Account simAccountElw = AccountManager.Ins().CreateSimSpotAccount();
            RawMarketData rmdElw = new RawMarketData(elwCode, Detail.ProductType.ELW);

            Account simAccountFO = AccountManager.Ins().CreateSimFOAccount();
            String optionCode = ElwOptionUtil.ToOptionCode(elwCode);
            KospiOptionInfo koi = OptionUtil.GetKOI(optionCode);
            Detail.ProductType pt = OptionUtil.ConvertToDetailProductType(koi.CallPut);
            RawMarketData rmdOption = new RawMarketData(optionCode, pt);

            List<POrder> arr = new List<POrder>();

            // elw 1000,000개 매수 상태로 설정
            POrder preOrderElw = new POrder(TradingDirection.Long, elwCode, 1000000, 10, simAccountElw, rmdElw);
            Assert.AreEqual(preOrderElw.IsInputValidated, true);
            preOrderElw.Update(preOrderElw.ReqCount, 10, true);

            POrder elwOrder = null;
            POrder optionOrder = null;

            // elw 10단위 매수
            // 옵션 9단위 매도

            {
                elwOrder = new POrder(TradingDirection.Long, elwCode, 10 * elwCountOfOneOption, 10, simAccountElw, rmdElw);
                Assert.AreEqual(elwOrder.IsInputValidated, true);
                arr.Add(elwOrder);
            }

            {
                optionOrder = new POrder(TradingDirection.Short, optionCode, 9, 10, simAccountFO, rmdOption);
                Assert.AreEqual(optionOrder.IsInputValidated, true);
                arr.Add(optionOrder);
            }

            // validation한번 하자
            {
                long actual = ElwOptionUtil.GetSignedRemainCount100k(arr);
                long expected = 1 * 100000;
                Assert.AreEqual(expected, actual);
            }

            // elw를 하나 채결시킨다.

            {
                elwOrder.Update(elwCountOfOneOption, 10, false);

                long actual = ElwOptionUtil.GetSignedRemainCount100k(arr);
                long expected = 0;
                Assert.AreEqual(expected, actual);
            }

            {
                elwOrder.Update((long)(elwCountOfOneOption * 1.5), 10, false);

                long actual = ElwOptionUtil.GetSignedRemainCount100k(arr);
                long expected = -50000;
                Assert.AreEqual(expected, actual);
            }
        }
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:64,代码来源:ElwOptionUtilTest.cs

示例12: getSignedRemainCount100kTest_Elw

        void getSignedRemainCount100kTest_Elw()
        {
            String elwCode = GetFirstElwCode(100);
            ElwInfo ei = ElwUtil.GetElwInfo(elwCode);
            long elwCountOfOneOption = ElwOptionUtil.GetElwCountOfOneOption(elwCode);
            Account simAccount = AccountManager.Ins().CreateSimSpotAccount();
            RawMarketData rmdElw = new RawMarketData(elwCode, Detail.ProductType.ELW);

            // long only
            {
                TradingDirection ls = TradingDirection.Long;
                double price = 10;
                SetAsValidValue(rmdElw, ls, price);

                List<POrder> arr = new List<POrder>();
                for (int i = 0; i < 10; ++i)
                {
                    int index = i + 1;
                    POrder o = new POrder(ls, elwCode, elwCountOfOneOption * index, 10, simAccount, rmdElw);
                    Assert.AreEqual(o.IsInputValidated, true);
                    arr.Add(o);
                }

                {
                    long actual = ElwOptionUtil.GetSignedRemainCount100k(arr);
                    long expected = 5500000;
                    Assert.AreEqual(expected, actual);
                }

                long total_contracted_count = 0;
                foreach (POrder o in arr)
                {
                    long contracted_count = (long)(o.ReqCount / 2);
                    total_contracted_count += contracted_count;
                    o.Update(contracted_count, price, false);
                }

                {
                    total_contracted_count = ElwOptionUtil.ConvertElwCountTo100k(ei, total_contracted_count);
                    long actual = ElwOptionUtil.GetSignedRemainCount100k(arr);
                    Assert.AreEqual(total_contracted_count, actual);
                }

                foreach (POrder o in arr)
                {
                    o.Update(o.ReqCount, price, true);
                }
            }

            // short only
            {
                TradingDirection ls = TradingDirection.Short;
                double price = 10;
                SetAsValidValue(rmdElw, ls, price);

                List<POrder> arr = new List<POrder>();
                for (int i = 0; i < 10; ++i)
                {
                    int index = i + 1;
                    POrder o = new POrder(ls, elwCode, elwCountOfOneOption * index, 10, simAccount, rmdElw);
                    Assert.AreEqual(o.IsInputValidated, true);
                    arr.Add(o);
                }

                {
                    long actual = ElwOptionUtil.GetSignedRemainCount100k(arr);
                    long expected = -5500000;
                    Assert.AreEqual(expected, actual);
                }

                long total_contracted_count = 0;
                foreach (POrder o in arr)
                {
                    long contracted_count = (long)(o.ReqCount / 2);
                    total_contracted_count -= contracted_count;
                    o.Update(contracted_count, price, false);
                }

                {
                    total_contracted_count = ElwOptionUtil.ConvertElwCountTo100k(ei, total_contracted_count);
                    long actual = ElwOptionUtil.GetSignedRemainCount100k(arr);
                    Assert.AreEqual(total_contracted_count, actual);
                }
                foreach (POrder o in arr)
                {
                    o.Update(o.ReqCount, price, true);
                }
            }

            // long short mix
            {
                double price = 10;
                SetAsValidValue(rmdElw, TradingDirection.Long, price);

                List<POrder> arrPre = new List<POrder>();
                for (int i = 0; i < 10; ++i)
                {
                    int index = i + 1;
                    POrder o = new POrder(TradingDirection.Long, elwCode, elwCountOfOneOption, price, simAccount, rmdElw);
                    Assert.AreEqual(o.IsInputValidated, true);
//.........这里部分代码省略.........
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:101,代码来源:ElwOptionUtilTest.cs

示例13: LimOrderLimitIsOKTest

        public void LimOrderLimitIsOKTest()
        {
            {
                // IsOK, FilterOrderLimitCount에서 값을 root에 잘 전달하는지를 테스트한다.
                Account accountFO = AccountManager.Ins().CreateSimFOAccount();
                String code = KospiFutureUtil.Ins().KFI.Code;
                double reqPrice = KospiFutureUtil.Ins().KFI.UpLimit;
                long reqCount = 1;
                TradingDirection ls = TradingDirection.Long;

                // 여기서는 rmd값이 존재하는 경우의 테스트이다.
                RawMarketData rmd = RmdManager.Ins().GetData(code);
                rmd.BidPrice1 = KospiFutureUtil.Ins().KFI.DownLimit;
                rmd.AskPrice1 = KospiFutureUtil.Ins().KFI.UpLimit;

                rmd.BidCount1 = 500;
                rmd.AskCount1 = 500;

                POrder o = new POrder(ls, code, reqCount, reqPrice, accountFO, rmd);
                Assert.AreEqual(o.IsInputValidated, true);

                // pass test
                {
                    Boolean bActual = g_lim_ol_with_default.IsOK(o);
                    Assert.AreEqual(true, bActual);
                }
                {
                    Util.LogOutCriticalError("\t\t# DummyOrderLimit 1 permitted.");
                    Boolean bActual = g_lim_ol_with_dummy.IsOK(o);
                    Assert.AreEqual(false, bActual);
                }

                {
                    long actual = g_lim_ol_with_default.GetPossibleReqCount(o.RMDClone.Code, o.RMDClone.AskPrice1, 100);
                    Assert.AreEqual(100, actual);
                }
                {
                    Util.LogOutCriticalError("\t\t# DummyOrderLimit 1 permitted.");
                    long actual = g_lim_ol_with_dummy.GetPossibleReqCount(o.RMDClone.Code, o.RMDClone.AskPrice1, 100);
                    Assert.AreEqual(long.MinValue, actual);
                }

                // lim order limit에서 pivot이 0이 되는 상황을 테스트한다. long의 경우이다.
                // pivot 0 case

                o.RMDClone.AskPrice1 = 0;
                {
                    Boolean defaultSuccess = g_default_orderlimit.IsOK(o);
                    Assert.AreEqual(true, defaultSuccess);

                    Util.LogOutCriticalError("\t\t# LimOrderLimit 1 permitted.");
                    Boolean limSuccess = g_lim_ol_with_default.IsOK(o);
                    Assert.AreEqual(false, limSuccess);
                }

                // RMD 가격이 존재하는 경우 자동적으로 범위 안으로 SetReqPrice가 된다.
                o.RMDClone.AskPrice1 = KospiFutureUtil.Ins().KFI.UpLimit;
                o.SetReqPrice(o.ReqPrice + 0.20);
                {
                    Boolean defaultSuccess = g_default_orderlimit.IsOK(o);
                    Boolean limSuccess = g_lim_ol_with_default.IsOK(o);

                    Assert.AreEqual(true, defaultSuccess);
                    Assert.AreEqual(true, limSuccess);
                }
                o.SetReqPrice(o.ReqPrice + 0.05);
                {
                    Boolean defaultSuccess = g_default_orderlimit.IsOK(o);
                    Boolean limSuccess = g_lim_ol_with_default.IsOK(o);

                    Assert.AreEqual(true, defaultSuccess);
                    Assert.AreEqual(true, limSuccess);
                }
                o.SetReqPrice(o.ReqPrice + 0.05);
                {
                    Boolean defaultSuccess = g_default_orderlimit.IsOK(o);
                    Assert.AreEqual(true, defaultSuccess);

                    Util.LogOutCriticalError("\t\t# LimOrderLimit 1 permitted.");
                    Boolean limSuccess = g_lim_ol_with_default.IsOK(o);
                    Assert.AreEqual(false, limSuccess);
                }

                o.Update(o.ReqCount, 0, true);
            }

            //long
            {
                Account accountFO = AccountManager.Ins().CreateSimFOAccount();
                String code = KospiFutureUtil.Ins().KFI.Code;
                double reqPrice = KospiFutureUtil.Ins().KFI.UpLimit;
                long reqCount = 1;
                TradingDirection ls = TradingDirection.Long;

                RawMarketData rmd = RmdManager.Ins().GetData(code);
                rmd.BidPrice1 = 0;
                rmd.AskPrice1 = 0;

                rmd.BidCount1 = 0;
                rmd.AskCount1 = 0;
//.........这里部分代码省略.........
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:101,代码来源:LimOrderLimitTest.cs

示例14: TestPOrderBidAskCountManagerAll

        public void TestPOrderBidAskCountManagerAll()
        {
            POrderBidAskCountManager manager = POrderBidAskCountManager.Ins();
            Assert.AreEqual(POrderBidAskCountManager.Ins().IsDirty(), false);
            Assert.AreEqual(POrder_UnittestUtil.IsPOrderCommonResourceDirty(), false);

            POrderBidAskCountManager_Accessor accessor =
                new POrderBidAskCountManager_Accessor(new PrivateObject(manager));

            Account simAccount = StrategyManager.Ins().GetAccount("SimBond");

            String codeNoTail = BondUtil.GetCodeNoTail(BondUtil.HouseBond_1.Code);

            // 일반 등록
            String codeNormal =
                BondUtil.GetCodeWithMarketType(BondUtil.HouseBond_1.Code, MarketType._0_Bond_일반);
            RmdManager.Ins().BondSpot.Register(codeNormal);
            RawMarketData rmdNormal = RmdManager.Ins().BondSpot.GetData(codeNormal);

            // 소액 등록
            String codeSmall =
                BondUtil.GetCodeWithMarketType(BondUtil.HouseBond_1.Code, MarketType._1_Bond_소액);
            RmdManager.Ins().BondSpot.Register(codeSmall);
            RawMarketData rmdSmall = RmdManager.Ins().BondSpot.GetData(codeSmall);

            POrder oNormal_0 = new POrder(TradingDirection.Long, codeNormal, 100 * CommonConst._1_000_000, 8888, simAccount, rmdNormal, MarketType._0_Bond_일반, true);
            oNormal_0.Update(oNormal_0.ReqCount, 0, true);

            // 100개 매수 등록해놓고
            manager.Register(oNormal_0);
            long registeredReqCount = manager.GetRegisteredReqCount(codeNormal, TradingDirection.Long, 8888);
            Assert.AreEqual(registeredReqCount, 100 * CommonConst._1_000_000);

            // 200개 더 등록해보고
            POrder oNormal_1 = new POrder(TradingDirection.Long, codeNormal, 200 * CommonConst._1_000_000, 8888, simAccount, rmdNormal, MarketType._0_Bond_일반, true);
            oNormal_1.Update(oNormal_1.ReqCount, 0, true);
            manager.Register(oNormal_1);
            registeredReqCount = manager.GetRegisteredReqCount(codeNormal, TradingDirection.Long, 8888);
            Assert.AreEqual(registeredReqCount, 300 * CommonConst._1_000_000);

            // 다른 가격(8889)에서 어떤지 보고
            registeredReqCount = manager.GetRegisteredReqCount(codeNormal, TradingDirection.Long, 8889);
            Assert.AreEqual(registeredReqCount, 0 * CommonConst._1_000_000);

            // 다른 가격에 등록한 것이 영향을 안주는지 확인하고
            POrder oNormal_2 = new POrder(TradingDirection.Long, codeNormal, 200 * CommonConst._1_000_000, 8889, simAccount, rmdNormal, MarketType._0_Bond_일반, true);
            oNormal_2.Update(oNormal_2.ReqCount, 0, true);
            manager.Register(oNormal_2);
            registeredReqCount = manager.GetRegisteredReqCount(codeNormal, TradingDirection.Long, 8888);
            Assert.AreEqual(registeredReqCount, 300 * CommonConst._1_000_000);

            // Short으로도 같은 가격에 넣어보고
            POrder oNormal_3 = new POrder(TradingDirection.Short, codeNormal, 100 * CommonConst._1_000_000, 8888, simAccount, rmdNormal, MarketType._0_Bond_일반, true);
            oNormal_3.Update(oNormal_3.ReqCount, 0, true);
            manager.Register(oNormal_3);
            registeredReqCount = manager.GetRegisteredReqCount(codeNormal, TradingDirection.Long, 8888);
            Assert.AreEqual(registeredReqCount, 300 * CommonConst._1_000_000);
            registeredReqCount = manager.GetRegisteredReqCount(codeNormal, TradingDirection.Short, 8888);
            Assert.AreEqual(registeredReqCount, 100 * CommonConst._1_000_000);

            // 다른 코드(소액)으로 테스트 시작

            registeredReqCount = manager.GetRegisteredReqCount(codeSmall, TradingDirection.Short, 8888);
            Assert.AreEqual(registeredReqCount, 0);

            POrder oSmall_0 = new POrder(TradingDirection.Long, codeSmall, 100 * CommonConst._1_000, 8888, simAccount, rmdSmall, MarketType._1_Bond_소액, true);
            oSmall_0.Update(oSmall_0.ReqCount, 0, true);

            // 100개 넣어보고
            manager.Register(oSmall_0);
            registeredReqCount = manager.GetRegisteredReqCount(codeSmall, TradingDirection.Short, 8888);
            Assert.AreEqual(registeredReqCount, 0 * CommonConst._1_000);

            registeredReqCount = manager.GetRegisteredReqCount(codeSmall, TradingDirection.Long, 8888);
            Assert.AreEqual(registeredReqCount, 100 * CommonConst._1_000);

            registeredReqCount = manager.GetRegisteredReqCount(codeNormal, TradingDirection.Long, 8888);
            Assert.AreEqual(registeredReqCount, 300 * CommonConst._1_000_000);

            manager.Unregister(oNormal_0);
            manager.Unregister(oNormal_1);
            manager.Unregister(oNormal_2);
            manager.Unregister(oNormal_3);
            registeredReqCount = manager.GetRegisteredReqCount(codeNormal, TradingDirection.Long, 8888);
            Assert.AreEqual(registeredReqCount, 0);

            manager.Unregister(oSmall_0);
            registeredReqCount = manager.GetRegisteredReqCount(codeNormal, TradingDirection.Long, 8888);
            Assert.AreEqual(registeredReqCount, 0);

            // AdjustRmdCountWithoutMine 테스트

            rmdNormal.BidPrice1 = 8887;
            rmdNormal.BidCount1 = 1000 * CommonConst._1_000_000;
            rmdNormal.AskPrice1 = 8888;
            rmdNormal.AskCount1 = 1000 * CommonConst._1_000_000;

            manager.AdjustRmdCountWithoutMine(ref rmdNormal);

            Assert.AreEqual(rmdNormal.BidCount1, 1000 * CommonConst._1_000_000);
//.........这里部分代码省略.........
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:101,代码来源:POrderBidAskCountManagerTest.cs


注:本文中的MadViper.POrder.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。