コード例 #1
0
        public KtbOrderProcessData(
            String targetCode, 
            TradingDirection longShort, 
            long unsignedInitTargetCount, 
            double initTargetPrice,
            IMarketDataBoard board,
            Account account,
            ISweeper sweeper)
        {
            this.Orders = new List<POrder>();
            this.Code = targetCode;
            this.LongShort = longShort;

            this.InitUnsignedTargetCount = unsignedInitTargetCount;
            this.InitTargetPrice = initTargetPrice;

            this.Board = board;
            this.Account = account;

            this.Sweeper = sweeper;

            this.CurUnsignedTargetCount = unsignedInitTargetCount;
            this.Aging = 0;
            this.MuteSec = 2;
            this.IsReadyForResume = false;
        }
コード例 #2
0
        void UpdateEventPoint(
            String spotCode, String futureCode, TradingDirection spotDirection, 
            DateTime dateTimeFrom, PairTradingData tradingData, EventPoint ep)
        {
            if (spotDirection == TradingDirection.Long)
            {
                ep.LongCode = spotCode;
                ep.ShortCode = futureCode;
            }
            else
            {
                ep.LongCode = futureCode;
                ep.ShortCode = spotCode;
            }
            ep.DateTimeFrom = dateTimeFrom;

            if (tradingData != null)
            {
                ep.DateTimeTo = tradingData.MaxDateTime;

                ep.RangeMax = tradingData.MaxPnL;
                ep.RangeMin = tradingData.MinPnL;
            }
            else
            {
                ep.DateTimeTo = new DateTime(2999, 12, 31);
                ep.RangeMax = double.NaN;
                ep.RangeMin = double.NaN;
            }
        }
コード例 #3
0
        public SweepUnitContext_Bond_Short(
            TradingDirection ls,
            BondPair pair,
            Account bondAccount,
            ISweeper sweeper)
        {
            this.ID = SweepUnitIDManager.NextID++;

            this.LongShort = ls;

            Trace.Assert(this.LongShort == TradingDirection.Short);

            // -15
            this.CurSignedTargetCount = pair.Count * (-1);

            this.EnterCode = pair.EnterCodeWithMarketType;
            this.PairCode = pair.PairCodeWithMarketType;

            this._initSweepPrice = pair.PairPrice;

            this.BondAccount = bondAccount;

            this._enterMarketType = BondUtil.GetMarketType(pair.EnterCodeWithMarketType);
            this._pairMarketType = BondUtil.GetMarketType(pair.PairCodeWithMarketType);

            this._sweeper = sweeper;

            this.RealOrdersShort = new List<POrder>();
        }
コード例 #4
0
        public SweepUnitContext_Bond_Long(
            TradingDirection ls,
            BondPair pair,
            Account bondAccount,
            ISweeper sweeper)
        {
            this.ID = SweepUnitIDManager.NextID++;

            this.LongShort = ls;

            Trace.Assert(this.LongShort == TradingDirection.Long);

            this.InitSignedGoalCount = pair.Count;
            this.CurSignedTargetCount = pair.Count;

            this.EnterCode = pair.EnterCodeWithMarketType;

            this._initEnterPrice = pair.EnterPrice;

            this.BondAccount = bondAccount;

            this._enterMarketType = BondUtil.GetMarketType(pair.EnterCodeWithMarketType);

            this._sweeper = sweeper;

            CreateInitOrders(pair);

            this.RealOrdersLong = new List<POrder>();

            ReadyBidAskCountDataForAllocate(pair);
        }
コード例 #5
0
 public SweepMember_Input(String code, TradingDirection longShort, long targetCount, double initPrice,
     Account tradingAccount)
 {
     this.Code = code;
     this.LongShort = longShort;
     this.InitTargetCount = targetCount;
     this.InitPrice = initPrice;
     this.TradingAccount = tradingAccount;
 }
コード例 #6
0
ファイル: POrder.cs プロジェクト: HongSeokHwan/legacy
 public POrder(
     TradingDirection longShort, 
     String code, 
     long reqCount, 
     double reqPrice, 
     Account account,
     RawMarketData rmdClone)
     : this(longShort, code, reqCount, reqPrice, account, rmdClone, MarketType._3_Default, false)
 {
 }
コード例 #7
0
 public ReqOrderInput_BondArb(double initReqPrice, String codeForEnterSweep, 
     String codeForSweep, TradingDirection longShort, Account acc)
 {
     this.StartDate = DateTime.Now;
     this.InitReqPrice = initReqPrice;
     this.CodeForEnterSweep = codeForEnterSweep;
     this.CodeForSweep = codeForSweep;
     this.LongShort = longShort;
     this.TargetAccount = acc;
 }
コード例 #8
0
        public long GetRegisteredReqCount(String codeWithMarketType, TradingDirection ls, double reqPrice)
        {
            String key = GetKey(codeWithMarketType, ls, reqPrice);

            if (_goalPOrderCount.ContainsKey(codeWithMarketType))
            {
                return GetCount(_goalPOrderCount[codeWithMarketType], key);
            }
            return 0;
        }
コード例 #9
0
ファイル: POrder.cs プロジェクト: HongSeokHwan/legacy
        public POrder(
            TradingDirection longShort, 
            String code, 
            long reqCount, 
            double reqPrice, 
            Account account,
            RawMarketData rmdClone,
            MarketType market,
            Boolean bWeakLongBlock)
        {
            this.LongShort = longShort;
            this.Code = code;
            this.ReqCount = reqCount;
            this.ReqPrice = reqPrice;
            this.TargetAccount = account;
            this.RMDClone = rmdClone.Clone() as RawMarketData; // 밖에서도 열심히 했겠지만 최종적으로 Clone을 저장하도록 한다.
            this.Market = market;
            this.IsWeakLongBlock = bWeakLongBlock;

            this.InitReqPrice = reqPrice;

            this.ContractedCount = 0;
            this.CanceledCount = 0;
            this.OrderNumber = -1;
            this.AvgContractPrice = 0;

            this.IsAllocatedYetRequestOrFree = true;

            this.CreatedTime = DateTime.Now;
            this.NoErrorOrderIn = false;
            this.Comment = "";

            this.ShortCutTargetOfContractCallBack = null;

            this.EarlyUpdatedLongBlockCount = 0;

            _bGotLastPacket = false;

            // dependency가 있음(SetMarketType, SetcodeNoTail, SetLongBlock)
            Boolean bSuccess1 = SetMarketType();
            Boolean bSuccess2 = SetCodeNoTail(bSuccess1);

            ConvertOverPriceToInRMDPriceIfNotZero();

            SetLongBlock(bSuccess2);

            POrderManager.Ins().Add(this);

            ValidateInput();
        }
コード例 #10
0
        public PositionTakerController(String code, TradingDirection longShort, long targetCount, double targetPrice,
            Account targetAccount)
        {
            this.Code = code;
            this.LongShort = longShort;
            this.UnsignedTargetCount = targetCount;
            this.TargetPrice = targetPrice;
            this.RepeatCount = 0;
            this.Orders = new List<POrder>();
            this.TargetAccount = targetAccount;

            // 여기서 주문까지 쏴버린다.
            PTState = new S1_RequestOrder_PositionTakerState(this);
        }
コード例 #11
0
        public void WriteTo(String fileOutPath, PeriodicMarketDataCollection spot, 
            PeriodicMarketDataCollection future, TradingDirection spotDirection)
        {
            EventPointsFinder target = new EventPointsFinder();
            List<EventPoint> eventPoints = target.GetEventPoints(spot, future, spotDirection);
            CsvFileWriter writer = new CsvFileWriter(fileOutPath);

            WriteHeader(writer);
            WriteBody(writer, eventPoints);

            logger.Info("Write {0} complete...", fileOutPath);

            writer.Close();
        }
コード例 #12
0
        public IndividualTradingSimulator(MarketDataSetKey key, double baseInvest, TradingDirection direction,  
            PayOffType payOffType, double strikePriceDiffRate, int livePeriod, double impliedVol, 
            bool bAmountBasis, List<PriceData> prices)
        {
            _key = key;
            _baseInvest = baseInvest;
            _direction = direction;
            _payoffType = payOffType;
            _strikePriceDiffRate = strikePriceDiffRate;
            _livePeriod = livePeriod;
            _impliedVol = impliedVol;
            _bAmountBasis = bAmountBasis;

            _priceDataList = prices;
            _bUseReturnModel = false;
        }
コード例 #13
0
        public List<EventPoint> GetEventPoints(
            PeriodicMarketDataCollection spot, 
            PeriodicMarketDataCollection future,
            TradingDirection spotDirection)
        {
            List<EventPoint> eventPoints = new List<EventPoint>();

            for (int i = 0; i < spot.Rmds.Count - 1; ++i)
            {
                RawMarketData spotStartRmd = spot.Rmds[i];
                RawMarketData futureStartRmd = future.Rmds[i];

                Trace.Assert(spotStartRmd.LastUpdatedTime == futureStartRmd.LastUpdatedTime);

                if (!RawMarketDataUtil.IsValidBidAskCurPrice(spotStartRmd) ||
                    !RawMarketDataUtil.IsValidBidAskCurPrice(futureStartRmd))
                {
                    EventPoint ep = new EventPoint();
                    UpdateEventPoint(spotStartRmd.Code, futureStartRmd.Code, spotDirection,
                        spotStartRmd.LastUpdatedTime, null, ep);
                    eventPoints.Add(ep);
                }
                else
                {
                    PairTradingData tradingData = new PairTradingData(spotDirection);
                    tradingData.SetEnterPrices(spotStartRmd, futureStartRmd, spotDirection);

                    for (int j = i + 1; j < spot.Rmds.Count; ++j)
                    {
                        RawMarketData spotCurRmd = spot.Rmds[j];
                        RawMarketData futureCurRmd = future.Rmds[j];

                        if (!RawMarketDataUtil.IsValidBidAskCurPrice(spotCurRmd) ||
                            !RawMarketDataUtil.IsValidBidAskCurPrice(futureCurRmd))
                        {
                            continue;
                        }
                        tradingData.UpdateExitNowPnL(spotCurRmd, futureCurRmd, spotDirection);
                    }
                    EventPoint ep = new EventPoint();
                    UpdateEventPoint(spotStartRmd.Code, futureStartRmd.Code, spotDirection,
                        spotStartRmd.LastUpdatedTime, tradingData, ep);
                    eventPoints.Add(ep);
                }
            }
            return eventPoints;
        }
コード例 #14
0
ファイル: POrderUtil.cs プロジェクト: HongSeokHwan/legacy
        public static double GetAvgPrice(List<POrder> orders, TradingDirection longShort)
        {
            double score = 0.0;
            long count = 0;
            foreach (POrder o in orders)
            {
                if (o.LongShort == longShort)
                {
                    count += o.GetSignedContractedCount();
                    score += (o.ReqPrice * o.GetSignedContractedCount());
                }
            }

            if (count == 0)
            {
                return double.NaN;
            }
            return score / count;
        }
コード例 #15
0
        public SinglePnLResult(
            MarketDataSetKey key, string name, TradingDirection direction,  
            bool bAmountBasis, List<RawTradingData> tradingDataList)
        {
            this.Key = key;
            this.Name = name;
            this.Direction = direction;
            if (!bAmountBasis)
            {
                _onePointAmount = ProductInfoManager.Ins().GetProductInfo(key).OnePointAmount;
            }

            TradingDataList = tradingDataList;
            TradingDataList.Sort();

            StartDate = DateTime.MaxValue;
            EndDate = DateTime.MinValue;
            TotalPnL = 0;
            AvgInvest = 0;
            MaxInvest = 0;
        }
コード例 #16
0
ファイル: FakePOrder.cs プロジェクト: HongSeokHwan/legacy
 public FakePOrder(
     TradingDirection longShort,
     String code,
     long reqCount,
     long contractedCount,
     long canceledCount,
     int orderNumber,
     double reqPrice,
     String accountName,
     RawMarketData rmd)
 {
     this.LongShort = longShort;
     this.ReqCount = reqCount;
     ReqPrice = reqPrice;
     this.ContractedCount = contractedCount;
     this.CanceledCount = canceledCount;
     this.OrderNumber = orderNumber;
     this.Code = code;
     RMD = rmd;
     AccountName = accountName;
     this.CreatedTime = DateTime.Now;
 }
コード例 #17
0
ファイル: Ktb_SweepOrder.cs プロジェクト: HongSeokHwan/legacy
        double GetAgingCandidate(TradingDirection longShort, RawMarketData rmdClone, long aging)
        {
            if (longShort == TradingDirection.Long)
            {
                double price = rmdClone.BidPrice1;

                for (int i = 0; i < aging; ++i)
                {
                    price = ProductUtil.Ins().GetOneTickUpPrice(rmdClone.Code, price);
                }
                return Math.Min(rmdClone.AskPrice1, price);
            }
            else
            {
                double price = rmdClone.AskPrice1;
                for (int i = 0; i < aging; ++i)
                {
                    price = ProductUtil.Ins().GetOneTickDownPrice(rmdClone.Code, price);
                }
                return Math.Max(rmdClone.BidPrice1, price);
            }
        }
コード例 #18
0
ファイル: ElwArbEach.cs プロジェクト: HongSeokHwan/legacy
        ElwArbSweepUnit EnterPosition_Raw(
            ElwInfo elwInfo,
            String elwCode,

            TradingDirection elwLS,
            long elwEnterCount,
            double elwPrice,
            RawMarketData rmdElw,

            TradingDirection optionLS,
            long optionEnterCount,
            double optionPrice,
            RawMarketData rmdOption)
        {
            POrder optionOrder = null;
            POrder elwOrder = null;

            try
            {
                {
                    // ELW Long
                    // 우선 ELW Long을 진행하도록 한다.
                    Detail.ProductType pt = ProductUtil.Ins().GetProductType(elwCode);

                    if (pt != Detail.ProductType.ELW)
                    {
                        logger.Error(
                            "CRITICAL ERROR!!! 엄청 무서운 일이 벌어졌다. ELW가 아닌 {0} 종목이 {1} 가격에 {2} 개 사려고 했다.",
                            elwCode,
                            elwPrice,
                            elwEnterCount);
                        Util.KillWithNotice("error");

                        _bFinish = true;
                        return null;
                    }
                    else
                    {
                        // ELW 롱
                        elwOrder = new POrder(elwLS, elwCode, elwEnterCount, elwPrice, _elwAccount, rmdElw);
                        elwOrder.AddComment("EAE.EnterPosition_Raw.elwOrder");
                        elwOrder.Free();

                        if (!POrderLegalManager.Ins().IsLegalOrder(elwOrder, false))
                        {
                            return null;
                        }
                    }
                }

                {
                    // 옵션 숏

                    // 그럴리 없겠지만 무서우니까 최종적으로 확인을 한번 더 해보자.
                    Detail.ProductType pt = ProductUtil.Ins().GetProductType(_KospiOptionInfo.Code);

                    if (pt != Detail.ProductType.CallOption && pt != Detail.ProductType.PutOption)
                    {
                        logger.Error(
                            "CRITICAL ERROR!!! 엄청 무서운 일이 벌어졌다. 옵션도 아닌 {0} 종목이 {1} 가격에 {2} 개 사려고 했다.",
                            _KospiOptionInfo.Code,
                            optionPrice,
                            optionEnterCount);
                        Util.KillWithNotice("CRITICAL ERROR!!!");

                        _bFinish = true;
                        return null;
                    }
                    else
                    {
                        optionOrder = new POrder(optionLS, _KospiOptionInfo.Code, optionEnterCount, optionPrice, _optionAccount, rmdOption);
                        optionOrder.AddComment("EAE.EnterPosition_Raw.optionOrder");
                        optionOrder.Free();

                        if (!POrderLegalManager.Ins().IsLegalOrder(optionOrder, false))
                        {
                            return null;
                        }
                    }
                }

                if (optionOrder != null && elwOrder != null)
                {
                    ElwArbSweepUnit eos = new ElwArbSweepUnit(
                        _KospiOptionInfo,
                        elwInfo,
                        _optionAccount,
                        optionOrder,
                        _elwAccount,
                        elwOrder,
                        _parent,
                        MonitoringEndDate);

                    return eos;
                }
                else
                {
                    logger.Error("Unexpected");
                    Util.KillWithNotice("Unexpected");
                }
            }
            catch (System.Exception ex)
            {
                logger.Error(ex.ToString());
                Util.KillWithNotice(ex.ToString());
            }
            return null;
        }
コード例 #19
0
 String GetKey(String code, TradingDirection ls, double reqPrice)
 {
     String key = String.Format("{0}_{1}_{2:n2}", code, ls.ToString(), reqPrice);
     return key;
 }
コード例 #20
0
ファイル: RMDManager.cs プロジェクト: HongSeokHwan/legacy
        public void UpdateViaCancelOrder(
            RawMarketData orderRMDClone, double orderReqPrice, TradingDirection orderLongShort)
        {
            RawMarketData rmd = GetData(orderRMDClone.Code);

            if (rmd == null)
            {
                return;
            }

            if (rmd.LastUpdatedTime >= DateTime.Now.AddSeconds(-2))
            {
                // 현재와 2초전 사이에 RMD를 update했다.
                // ok
            }
            else
            {
                // 2초전보다도 더 오래전에 RMD가 왔다.
                // 호가 딜레이때문에 이렇게 되었을 가능성이 높다. 따라서 RMD를 Reset한다.

                if (orderLongShort == TradingDirection.Long)
                {
                    // 매수 주문가 보다 작거나 같은 매도호가가 있다면 RMD를 지워준다.

                    if (orderReqPrice >= rmd.AskPrice1)
                    {
                        rmd.SetAsZero();
                    }
                }
                else
                {
                    if (orderReqPrice <= rmd.BidPrice1)
                    {
                        rmd.SetAsZero();
                    }
                }
            }
        }
コード例 #21
0
ファイル: ElwArbEach.cs プロジェクト: HongSeokHwan/legacy
        public ElwArbSweepUnit EnterPosition(
            ElwInfo elwInfo,
            String elwCode,
            TradingDirection elwLS,
            double elwPrice,
            long elwCount,
            RawMarketData rmdElw,

            TradingDirection optionLS,
            double optionPrice,
            long optionCount,
            RawMarketData rmdOption)
        {
            long optionEnterCount = optionCount;
            long elwEnterCount = elwCount;

            return EnterPosition_Raw(
                elwInfo,
                elwCode,

                elwLS,
                elwEnterCount,
                elwPrice,
                rmdElw,

                optionLS,
                optionCount,
                optionPrice,
                rmdOption);
        }
コード例 #22
0
        void CreateOptionOrders(TradingDirection ls, long optionCount, double optionPrice1, double optionPrice2, ref List<POrder> output, RawMarketData rmd)
        {
            if (optionCount >= 2)
            {
                double reqPrice1 = optionPrice1;
                double reqPrice2 = optionPrice2;

                reqPrice1 = AdjustPrice(ls, reqPrice1, rmd);
                reqPrice2 = AdjustPrice(ls, reqPrice2, rmd);

                long reqCount2 = optionCount / 2;
                long reqCount1 = optionCount - reqCount2;

                POrder o1 = new POrder(
                    ls,
                    OptionOrderGoal.Code,
                    reqCount1,
                    reqPrice1,
                    OptionOrderGoal.TargetAccount,
                    rmd);

                o1.AddComment(String.Format("EOS#({0}), Sweeper 4", CurID));
                POrder o2 = new POrder(
                    ls,
                    OptionOrderGoal.Code,
                    reqCount2,
                    reqPrice2,
                    OptionOrderGoal.TargetAccount,
                    rmd);
                o2.AddComment(String.Format("EOS#({0}), Sweeper 5", CurID));

                output.Add(o1);
                output.Add(o2);
            }
            else
            {
                double reqPrice1 = optionPrice1;
                reqPrice1 = AdjustPrice(ls, reqPrice1, rmd);

                POrder o1 = new POrder(
                    ls,
                    OptionOrderGoal.Code,
                    optionCount,
                    reqPrice1,
                    OptionOrderGoal.TargetAccount,
                    rmd);

                o1.AddComment(String.Format("EOS#({0}), Sweeper 6", CurID));

                output.Add(o1);
            }
        }
コード例 #23
0
        public ElwOptionArbData(
            ElwInfo elw,
            double elwPrice,
            TradingDirection elwLS,

            KospiOptionInfo koi,
            double optionPrice,
            TradingDirection optionLS,

            long minOptionCount,

            long diff,
            
            RawMarketData rmdOption,
            RawMarketData rmdElw,
            Boolean bForward)
        {
            OptionCode = koi.Code;
            ElwCode = elw.Code;

            OptionCount = minOptionCount;
            ElwCount = ElwOptionUtil.ConvertOptionCountToElwCount(elw, minOptionCount);

            OptionPrice = optionPrice;
            ElwPrice = elwPrice;

            Elw = elw;
            Diff = diff;

            ElwLS = elwLS;
            OptionLS = optionLS;

            IsForward = bForward;

            Key = String.Format("{0};{1}", koi.Code, elw.Code);

            RmdOption = rmdOption;
            RmdElw = rmdElw;
        }
コード例 #24
0
        double AdjustPrice(TradingDirection ls, double reqPrice, RawMarketData rmd)
        {
            if (!IsOverAging())
            {
                return reqPrice;
            }

            if (ls == TradingDirection.Long)
            {
                double tickUpPrice = reqPrice;

                for (int i = 0; i < (int)(_aging / AGING_UINT); ++i)
                {
                    tickUpPrice = ProductUtil.Ins().GetOneTickUpPrice(rmd.Code, tickUpPrice);
                }

                if (rmd.AskPrice1 != 0)
                {
                    tickUpPrice = Math.Min(tickUpPrice, rmd.AskPrice1);
                }

                logger.Debug("{0} AdjustedPrice from {1:n2} to {2:n2} AskPrice1({4:n2}) ({3})", CurID, reqPrice, tickUpPrice, ls, rmd.AskPrice1);

                return tickUpPrice;
            }
            else if (ls == TradingDirection.Short)
            {
                double tickDownPrice = reqPrice;

                for (int i = 0; i < (int)(_aging / AGING_UINT); ++i)
                {
                    tickDownPrice = ProductUtil.Ins().GetOneTickDownPrice(rmd.Code, tickDownPrice);
                }

                if (rmd.BidPrice1 != 0)
                {
                    tickDownPrice = Math.Max(tickDownPrice, rmd.BidPrice1);
                }

                logger.Debug("{0} AdjustedPrice from {1:n2} to {2:n2} BidPrice1({4:n2}) ({3})", CurID, reqPrice, tickDownPrice, ls, rmd.BidPrice1);

                return tickDownPrice;
            }
            return reqPrice;
        }
コード例 #25
0
        void CreateElwOrders(TradingDirection ls, long optionCount, double elwPrice1, double elwPrice2, ref ArrayList output, RawMarketData rmd)
        {
            if (optionCount >= 2)
            {
                double reqPrice1 = elwPrice1;
                double reqPrice2 = elwPrice2;

                reqPrice1 = AdjustPrice(ls, reqPrice1, rmd);
                reqPrice2 = AdjustPrice(ls, reqPrice2, rmd);

                long reqCount2 = optionCount / 2;
                long reqCount1 = optionCount - reqCount2;

                reqCount1 = ElwUtil.RoundElwCount(ElwOptionUtil.ConvertOptionCountToElwCount(_elwInfo, reqCount1));
                reqCount2 = ElwUtil.RoundElwCount(ElwOptionUtil.ConvertOptionCountToElwCount(_elwInfo, reqCount2));

                POrder o1 = new POrder(
                    ls,
                    ElwOrderGoal.Code,
                    reqCount1,
                    reqPrice1,
                    ElwOrderGoal.TargetAccount,
                    rmd);

                o1.AddComment(String.Format("EOS#({0}), Sweeper 1", CurID));

                POrder o2 = new POrder(
                    ls,
                    ElwOrderGoal.Code,
                    reqCount2,
                    reqPrice2,
                    ElwOrderGoal.TargetAccount,
                    rmd);

                o2.AddComment(String.Format("EOS#({0}), Sweeper 2", CurID));

                output.Add(o1);
                output.Add(o2);
            }
            else
            {
                double reqPrice1 = elwPrice1;
                reqPrice1 = AdjustPrice(ls, reqPrice1, rmd);

                long reqCount1 = ElwUtil.RoundElwCount(ElwOptionUtil.ConvertOptionCountToElwCount(_elwInfo, optionCount));

                POrder o1 = new POrder(
                    ls,
                    ElwOrderGoal.Code,
                    reqCount1,
                    reqPrice1,
                    ElwOrderGoal.TargetAccount,
                    rmd);

                o1.AddComment(String.Format("EOS#({0}), Sweeper 3", CurID));

                output.Add(o1);
            }
        }
コード例 #26
0
ファイル: Account.cs プロジェクト: HongSeokHwan/legacy
 public POrderLongBlock AllocLB(String code, String codeNoTail, TradingDirection ls, long unsignedCount)
 {
     return this.LongBlockManager.AllocLB(code, codeNoTail, ls, unsignedCount, this);
 }
コード例 #27
0
ファイル: ProductUtil.cs プロジェクト: HongSeokHwan/legacy
        public double GetSignedBookValue(TradingDirection ls, String code, double reqPrice, long reqCount)
        {
            double onePointAmount = GetOnePointAmount(code);
            double bookValue = Math.Abs(onePointAmount * reqCount * reqPrice);

            if (ls == TradingDirection.Long)
            {
                bookValue *= (-1);
            }
            return bookValue;
        }
コード例 #28
0
            public PairTradingData(TradingDirection spotDirection)
            {
                MaxPnL = double.MinValue;
                MinPnL = double.MaxValue;

                if (spotDirection == TradingDirection.Long)
                {
                    _longMultiplier = 1.0F;
                    _shortMultiplier = 100.0F;
                }
                else
                {
                    _longMultiplier = 100.0F;
                    _shortMultiplier = 1.0F;
                }
            }
コード例 #29
0
 public void SetEnterPrices(RawMarketData spotStartRmd,
     RawMarketData futureStartRmd, TradingDirection spotDirection)
 {
     if (spotDirection == TradingDirection.Long)
     {
         LongEnterPrice = spotStartRmd.AskPrice1;
         ShortEnterPrice = futureStartRmd.BidPrice1;
     }
     else
     {
         LongEnterPrice = futureStartRmd.AskPrice1;
         ShortEnterPrice = spotStartRmd.BidPrice1;
     }
 }
コード例 #30
0
            public void UpdateExitNowPnL(RawMarketData spotRmd,
                RawMarketData futureRmd, TradingDirection spotDirection)
            {
                double longExitPrice = 0;
                double shortExitPrice = 0;

                if (spotDirection == TradingDirection.Long)
                {
                    longExitPrice = spotRmd.BidPrice1;
                    shortExitPrice = futureRmd.AskPrice1;
                }
                else
                {
                    longExitPrice = futureRmd.BidPrice1;
                    shortExitPrice = spotRmd.AskPrice1;
                }
                double exitNowPnL = ExitNowPnL(longExitPrice, shortExitPrice);

                if (exitNowPnL > this.MaxPnL)
                {
                    this.MaxPnL = exitNowPnL;
                    this.MaxDateTime = spotRmd.LastUpdatedTime;
                }

                if (exitNowPnL < this.MinPnL)
                {
                    this.MinPnL = exitNowPnL;
                }
            }