예제 #1
0
        void LoadCycleEqAdjs()
        {
            _mdPivot = DataUtil.GetKeyMarketData(MarketDataSetKey.CycleLeadingIndex, _startDate, _endDate);
            //string marketDataText = DataUtil.GetMarketDataStringFromTextFile(kFileName);
            //MarketData md =
            //    new MarketDataTextReader().ReadMarketData(_key, marketDataText, _startDate, _endDate);

            _cycleAdjDic = new Dictionary<DateTime, double>();
            long totalCount = _mdPivot.GetTotalCount();
            for (int i = 0; i < totalCount; i++)
            {
                DOHLC dohlc = _mdPivot.GetByIndex(i);
                DateTime curDate = dohlc.CurDate;
                double curValue = dohlc.OHLC.Close;
                double curAdj = CalculateCycleAdjValue(curValue, kMaxValue, kMinValue);
                curAdj = GetSwitchUpDownAdjValue(curAdj);
                _cycleAdjDic.Add(curDate, curAdj);
            }
        }
예제 #2
0
        /**
         * Target Date가 비거래일이면, 직전 거래일을 반환한다.
         * */
        public static DateTime GetLastTradingDay(MarketData mdPivot, DateTime targetDate)
        {
            if (mdPivot == null || mdPivot.GetByIndex(0).CurDate >= targetDate)
            {
                if (targetDate.DayOfWeek == DayOfWeek.Sunday)
                {
                    return targetDate.AddDays(-2);
                }
                if (targetDate.DayOfWeek == DayOfWeek.Saturday)
                {
                    return targetDate.AddDays(-1);
                }
                return targetDate;
            }

            DateTime tradingDate = targetDate;
            while (true)
            {
                if (mdPivot.IsExistDate(tradingDate))
                {
                    break;
                }
                tradingDate = tradingDate.AddDays(-1);
            }
            return tradingDate;
        }