public Position_KtbSkel GetPosition()
        {
            if (IsDone())
            {
                String futureCode = this.TargetPosition.FutureCode;
                double futureAvgPrice = GetAvgFuturePrice();
                long tmpFutureCount = GetFutureMaxPossibleCount();
                LongShortCount tmpFutureLsc = new LongShortCount(this.TargetPosition.SignedFutureCount);
                LongShortCount futureLsc =
                    new LongShortCount(tmpFutureLsc.LongShort, Convert.ToUInt64(tmpFutureCount));
                long signedFutureCount = futureLsc.GetSignedCount();

                String spotCode = this.TargetPosition.SpotCode;
                double spotAvgPrice = this.TargetPosition.SpotAvgPriceTimeAdjust;
                LongShortCount tmpSpotLsc = new LongShortCount(this.TargetPosition.SignedSpotCount);
                LongShortCount spotLsc =
                    new LongShortCount(tmpSpotLsc.LongShort, Convert.ToUInt64(this.UnsignedSpotContractedCount));
                long signedSpotCount = spotLsc.GetSignedCount();

                DateTime tradingDate = CoreLib.DateUtil.GetTodayDateTime(0, 0, 0);

                Position_KtbSkel position = new Position_KtbSkel(
                    spotCode, signedSpotCount, spotAvgPrice,
                    futureCode, signedFutureCount, futureAvgPrice,
                    tradingDate, 0);

                return position;
            }
            else
            {
                String ex = "Invalid";
                logger.Error(ex.ToString());
                Util.KillWithNotice(ex.ToString());
            }
            return null;
        }
        // 신규 주문을 낼 때
        public LongShortCount GetRemainLongShortCount()
        {
            // 타겟 수량 - 체결된 수량
            LongShortCount lsc = new LongShortCount(this.LongShort, Convert.ToUInt64(this.UnsignedTargetCount));

            long targetSignedCount = lsc.GetSignedCount();
            long totalSignedContractedCount = GetTotalSignedContractedCount();

            long signedRemainCount = targetSignedCount - totalSignedContractedCount;

            LongShortCount remainLongShortCount = new LongShortCount(signedRemainCount);

            if (remainLongShortCount.LongShort != this.LongShort)
            {
                // 이렇게 될리가 없다.
                String ex = "Invalid";
                logger.Error(ex.ToString());
                Util.KillWithNotice(ex.ToString());
            }

            return remainLongShortCount;
        }
예제 #3
0
        public void SetTarget(LongShortCount lsc)
        {
            this.CurSignedTargetCount = lsc.GetSignedCount();

            if (this.InitSignedGoalCount * this.CurSignedTargetCount < 0)
            {
                // 부호가 반대이다.
                logger.Error(
                    "Target count twisted(sign is different) {0:n0}, {1:n0}",
                    this.CurSignedTargetCount,
                    this.InitSignedGoalCount);
                Util.KillWithNotice("Target count twisted(sign is different)");

                Trace.Assert(false);
            }

            if (Math.Abs(this.InitSignedGoalCount) < Math.Abs(this.CurSignedTargetCount))
            {
                logger.Error(
                    "Target count twisted(goal count) {0:n0}, {1:n0}",
                    this.CurSignedTargetCount,
                    this.InitSignedGoalCount);
                Util.KillWithNotice("Target count twisted(goal count)");

                Trace.Assert(false);
            }
        }
        public void SetTarget(LongShortCount lsc)
        {
            this.CurSignedTargetCount = lsc.GetSignedCount();

            if (this.CurSignedTargetCount < 0)
            {
                Trace.Assert(false);
            }
        }