public AdjRateDatum CalculateAdjRateDatum(DateTime targetDate, MarketDataSet data)
        {
            LogRow row = new LogRow();
            row.CurDate = targetDate;
            row.PrevAreaNumber = _prevAreaNumber;
            row.PrevUpDown = _prevUpDown;

            MarketData md = data.GetData(MarketDataSetKey.KrxCreditDepositRate);
            DOHLC dohlc = md.GetData(targetDate);

            _ma.Add(dohlc.OHLC.Close);
            double ma = _ma.GetCurMA();
            int areaNumber = GetAreaNumber(ma);

            double kospiWeight = GetKospiWeight(areaNumber, row);

            _logs.Add(row);

            if (targetDate > new DateTime(2007, 6, 1))
            {
                kospiWeight = MathUtil.CapAndFloor(kospiWeight);
                return new AdjRateDatum(kospiWeight, 1, 1);
            }
            else
            {
                _prevUpDown = UpDown.Unknown;
            }
            return new AdjRateDatum(1, 1, 1);
        }
Exemplo n.º 2
0
        public AdjRateDatum CalculateAssetWeight_Raw(DateTime targetDate, MarketDataSet data)
        {
            MarketData md = data.GetData(MarketDataSetKey.KospiFuture);
            DOHLC dohlc = md.GetData(targetDate);
            double curValue = dohlc.OHLC.Close;

            AdjRateDatum ret = null;

            if (_prevValue > 0)
            {
                // 평균 변동성을 구한다.
                double increment = (curValue - _prevValue) / _prevValue;
                _ma.Add(Math.Abs(increment));
                double avgIncrement = _ma.GetCurMA();

                int level = (int)(avgIncrement * 200);

                double kospiFactor = 1.3 - 0.1 * level;
                kospiFactor *= _weight;
                kospiFactor = MathUtil.CapAndFloor(kospiFactor);

                ret = new AdjRateDatum(kospiFactor, 1, 1);
            }
            else
            {
                ret = new AdjRateDatum(1, 1, 1);
            }
            _prevValue = curValue;

            return ret;
        }
Exemplo n.º 3
0
        MarketDataSet GetNewMarketDataSet(DateTime curDate, Dictionary<string, double> priceData)
        {
            DateTime StartDate = EquityVolPredefinedVariables.ReadStartDate;
            DateTime EndDate = EquityVolPredefinedVariables.ReadEndDate;

            MarketDataSet mds  = new MarketDataSet();
            double curPrice = 0;
            foreach (KeyValuePair<string, double> pair in priceData)
            {
                curPrice = pair.Value;
                MarketDataSetKey key = DataUtil.GetMarketDataKeyFromTicker(pair.Key);
                if (EquityMarketDataManager.Ins().ContainsMarketPriceData(key))
                {
                    MarketData mdCache = EquityMarketDataManager.Ins().GetMarketPriceData(key);

                    MarketData md = GetNewMarketData(StartDate, EndDate, mdCache);
                    if (!md.IsExistDate(curDate))
                    {
                        md.AddDatum(curDate, new OHLC(0, 0, 0, curPrice));
                        mds.Add(key, md);
                    }
                }
            }

            MarketData mdKospi =
                DataUtil.GetKeyMarketData(MarketDataSetKey.KospiFuture, StartDate, EndDate);
            if (!mdKospi.IsExistDate(curDate))
            {
                DOHLC lastPrice = mdKospi.GetByIndex((int)mdKospi.GetTotalCount() - 1);
                mdKospi.AddDatum(curDate, lastPrice.OHLC);
            }

            mds.RegisterPivotData(mdKospi);
            return mds;
        }
Exemplo n.º 4
0
        public AdjRateDatum CalculateAssetWeight_Raw(OperationSet opSet, DateTime targetDate, MarketDataSet data)
        {
            MarketData md = data.GetData(MarketDataSetKey.KospiFuture);
            DOHLC dohlc = md.GetData(targetDate);
            double curValue = dohlc.OHLC.Close;

            AdjRateDatum ret = null;

            if (_prevValue > 0)
            {
                // 평균 변동성을 구한다.
                double increment = (curValue - _prevValue) / _prevValue;
                _ma.Add(increment);
                double avgIncrement = _ma.GetCurMA();

                int level = (int)(avgIncrement * 100);

                double kospiFactor = 1.3 - 0.1 * level;
                ret = new AdjRateDatum(kospiFactor * _weight, 1, 1);
            }
            else
            {
                ret = new AdjRateDatum(1, 1, 1);
            }
            _prevValue = curValue;

            return ret;
        }
Exemplo n.º 5
0
        public AdjRateDatum CalculateAdjRateDatum(DateTime targetDate, MarketDataSet data)
        {
            if (_ismAdjDic == null || _ismAdjDic.Count == 0)
            {
                LoadISMEqAdjs();
                //TODO: ism 데이터를 월말이 아닌 매일 DB에 넣어준 후에 아래 함수를 사용.
                //LoadBSIEqAdjs(data);
            }

            // ISM 매달초 당월 말일날짜로 발표 -> 당월 중에는 전월 말일날짜 이용가능.
            DateTime dataAvailableDate = targetDate.AddDays( - 1 * targetDate.Day); //전월 말일

            double curAdj = 1;
            if (_ismAdjDic.ContainsKey(dataAvailableDate))
            {
                curAdj = _ismAdjDic[dataAvailableDate];
                _lastReturnedAdjRate = curAdj;
            }
            else
            {
                curAdj = _lastReturnedAdjRate;
            }

            AdjRateDatum ret = new AdjRateDatum(curAdj * _weight, 1, 1);

            return ret;
        }
Exemplo n.º 6
0
        public AdjRateDatum CalculateAdjRateDatum(DateTime targetDate, MarketDataSet data)
        {
            RowInfo curRow = GetCurRowWithBasicInfo(targetDate, data);

            //MovingAverage 계산
            SetSpotDataMinMaxRange(curRow);

            //포지션 정보를 설정한다.
            SetPositionInfo(targetDate, data, curRow);

            // 전일대비 변동율을 구한다.
            SetFutureIncrement(curRow, _prevRow);

            this._cumData.Add(curRow);

            // 코스피 선물 평균 변동성을 구한다.
            curRow.KospiVol = this._cumData.GetKospiAvgVol();

            // 비중을 구한다.
            AdjRateDatum adj = GetAdj(curRow);
            curRow.AssetAdj = adj;

            this._prevRow = curRow;

            return adj;
        }
Exemplo n.º 7
0
        public AdjRateDatum CalculateAssetWeight(OperationSet opSet, DateTime targetDate, MarketDataSet data)
        {
            OperationRow opData = opSet.GetData(_key);
            Boolean on = opData.On;
            AdjRateDatum others = _nextAdjustment.CalculateAssetWeight(opSet, targetDate, data);

            if (on)
            {
                AdjRateDatum mine = new AdjRateDatum(_kospiAdjustment, _bondAdjustment, _dollarAdjustment);
                Operation op = opData.Op;
                if (op == Operation.Multiply)
                {
                    AdjRateDatum ret = AdjUtil.Multiply(mine, others);
                    return ret;
                }
                else
                {
                    logger.Warn("Multiply 이외의 기능은 아직 제공하고 있지 않음");
                    return others;
                }
            }
            else
            {
                return others;
            }
        }
Exemplo n.º 8
0
        public InsertCurDataUI(MarketDataSet marketDataSet, List<String> tickers)
        {
            InitializeComponent();
            this.Load += new System.EventHandler(this.Form_Load);

            _prevMarketDataSet = marketDataSet;
            _tickers = tickers;
        }
Exemplo n.º 9
0
 AdjRateDatum GetAdjRateDatum(DateTime curDate, MarketDataSet marketData, AdjRateDataLog adjLog)
 {
     AdjRateDatum ret = SetBaseAdjRateDatum();
     foreach (IAdj adj in this.Adjs)
     {
         AdjRateDatum datum = adj.CalculateAdjRateDatum(curDate, marketData);
         adjLog.Add(adj.GetKey(), curDate, datum.Clone());
         ret = GetOperatedAdjRateDatum(ret, datum);
     }
     return ret;
 }
Exemplo n.º 10
0
        public AdjRateDatum CalculateAssetWeight_Raw(OperationSet opSet, DateTime targetDate, MarketDataSet data)
        {
            if (_adjs.ContainsKey(targetDate))
            {
                Tuple<double, double, double> t = _adjs[targetDate];
                AdjRateDatum aa = new AdjRateDatum(t);
                _prev = aa;

                return aa;
            }
            return _prev;
        }
Exemplo n.º 11
0
        public SimCase(String name, IAlloc alloc, List<IAdj> adjs, SimInputData inputData, MixupRule rule, MarketDataSet marketData)
        {
            Trace.Assert(name != null);
            Trace.Assert(alloc != null);
            Trace.Assert(adjs != null);
            Trace.Assert(inputData != null);
            Trace.Assert(marketData != null);

            this.Name = name;
            this.Alloc = alloc;
            this.Adjs = adjs;
            this.InputData = inputData;
            this.Rule = rule;
            this.Calculator = new AssetRateCalculator(alloc, adjs, inputData, rule);
            this.MarketData = marketData;
        }
Exemplo n.º 12
0
        public AdjRateDatum CalculateAdjRateDatum(DateTime targetDate, MarketDataSet data)
        {
            if (_RealIrAdjDic == null || _RealIrAdjDic.Count == 0)
            {
                LoadRealIrAdjs(data);
            }

            double curAdj = 1;
            if (_RealIrAdjDic.ContainsKey(targetDate))
            {
                curAdj = _RealIrAdjDic[targetDate];
            }

            AdjRateDatum ret = new AdjRateDatum(1, curAdj * _weight, 1);

            return ret;
        }
Exemplo n.º 13
0
        public AdjRateDatum CalculateAdjRateDatum(DateTime targetDate, MarketDataSet data)
        {
            AdjRateDatum adj = new AdjRateDatum(1, 1, 1);
            if (targetDate > new DateTime(2007, 6, 1))
            {
                DateTime twoTradingDaysAgo = DataUtil.GetPivotTradingDate(-2, targetDate, data.PivotData);
                MarketData mdCreditDepositRate = data.GetData(MarketDataSetKey.KrxCreditDepositRate);

                DOHLC dohlc = mdCreditDepositRate.GetData(twoTradingDaysAgo);
                double rate = dohlc.OHLC.Close;

                double kospiAdjustment = GetKospiAdjustment(rate);

                kospiAdjustment = MathUtil.CapAndFloor(kospiAdjustment);

                adj = new AdjRateDatum(kospiAdjustment, 1, 1);
            }
            return adj;
        }
Exemplo n.º 14
0
        public AssetRateDatum CalculateAndGetAssetRateDatum(DateTime targetDate, MarketDataSet data)
        {
            if (_cache.ContainsKey(targetDate))
            {
                return _cache[targetDate].Clone();
            }

            _marketData = data;

            AssetRateDatum assetDatum = _staticAlloc.CalculateAndGetAssetRateDatum(targetDate, data);
            AdjRateDatum adjDatum = GetAdjRateDatum(targetDate, data);
            assetDatum.Multiply(adjDatum);
            assetDatum.SetScale();

            if (!_cache.ContainsKey(targetDate))
            {
                _cache.Add(targetDate, assetDatum.Clone());
            }
            return assetDatum;
        }
Exemplo n.º 15
0
        public AdjRateDatum CalculateAdjRateDatum(DateTime targetDate, MarketDataSet data)
        {
            if (_kospiFutureWeight == null || _kospiFutureWeight.Count == 0)
            {
                LoadDeltaVolAdjRates(data);
                //LoadDeltaVolAdjRates();
            }

            double kospiWeight = 1;
            double ktbWeight = 1;
            double dollarWeight = 1;
            if (_kospiFutureWeight.ContainsKey(targetDate))
            {
                kospiWeight = _kospiFutureWeight[targetDate] * _weight;
                if (_ktbFutureWeight.ContainsKey(targetDate))
                {
                    ktbWeight = _ktbFutureWeight[targetDate] * _weight;
                }
                else
                {
                    ktbWeight = _prev.KtbRate;
                }

                if (_dollarFutreWeight != null && _dollarFutreWeight.ContainsKey(targetDate))
                {
                    dollarWeight = _dollarFutreWeight[targetDate] * _weight;
                }
                else
                {
                    dollarWeight = _prev.DollarRate;
                }

                Tuple<double, double, double> t =
                    new Tuple<double, double, double>(kospiWeight, ktbWeight, dollarWeight);
                AdjRateDatum adjRateDatum = new AdjRateDatum(t);
                _prev = adjRateDatum;
                return adjRateDatum;
            }

            return _prev;
        }
Exemplo n.º 16
0
        AdjRateDatum CalculateAssetWeight_Raw(DateTime targetDate, MarketDataSet data)
        {
            MarketData md = data.GetData(MarketDataSetKey.DollarSpot);
            DOHLC dohlc = md.GetData(targetDate);
            double cur = dohlc.OHLC.Close;

            const double kMax = 1800;
            const double kMin = 900;

            double rate = (kMax - cur) / (kMax - kMin);
            rate = Math.Max(0, rate);
            rate = Math.Min(1, rate);

            rate = 0.5 + rate;

            rate *= _weight;

            rate = MathUtil.CapAndFloor(rate);

            return new AdjRateDatum(1, 1, rate);
        }
Exemplo n.º 17
0
        public AdjRateDatum CalculateAssetWeight_Raw(OperationSet opSet, DateTime targetDate, MarketDataSet data)
        {
            RowInfo curRow = GetCurRowWithBasicInfo(targetDate, data);
            //포지션 정보를 설정한다.
            SetPositionInfo(targetDate, data, curRow);

            // 전일대비 변동율을 구한다.
            SetFutureIncrement(curRow, _prevRow);

            this._cumData.Add(curRow);

            // 코스피 선물 평균 변동성을 구한다.
            curRow.KospiVol = this._cumData.GetKospiAvgVol();

            // 비중을 구한다.
            AdjRateDatum adj = GetAdj(curRow);
            curRow.AssetAdj = adj;

            this._prevRow = curRow;

            return adj;
        }
Exemplo n.º 18
0
        public Tuple<AssetRateDataLog, AdjRateDataLog> Calculate(MarketDataSet marketData)
        {
            DateTime curDate = this.InputData.StartDate;

            AssetRateDataLog assetLog = new AssetRateDataLog();
            AdjRateDataLog adjLog = new AdjRateDataLog();

            while (curDate <= this.InputData.EndDate)
            {
                if (marketData.IsExistDate(curDate))
                {
                    AssetRateDatum assetDatum = this.Alloc.CalculateAndGetAssetRateDatum(curDate, marketData);
                    AdjRateDatum adjDatum = GetAdjRateDatum(curDate, marketData, adjLog);
                    assetDatum.Multiply(adjDatum);
                    assetDatum.SetScale();
                    assetLog.Add(curDate, assetDatum);
                }
                curDate = curDate.AddDays(1);
            }

            return new Tuple<AssetRateDataLog, AdjRateDataLog>(assetLog, adjLog);
        }
        public AdjRateDatum CalculateAdjRateDatum(DateTime targetDate, MarketDataSet data)
        {
            if (targetDate < new DateTime(2007, 6, 1))
            {
                return new AdjRateDatum(1, 1, 1);
            }

            MarketData md = data.GetData(MarketDataSetKey.KrxCreditDepositRate);
            DOHLC dohlc = md.GetData(targetDate);

            _ma.Add(dohlc.OHLC.Close);
            double ma = _ma.GetCurMA();
            int areaNumber = GetAreaNumber(ma);

            _switch.Update(areaNumber);

            int investmentArea = _switch.InvestmentArea;

            double kospiWeight = GetKospiWeight(investmentArea);
            kospiWeight = MathUtil.CapAndFloor(kospiWeight);
            return new AdjRateDatum(kospiWeight, 1, 1);
        }
Exemplo n.º 20
0
        public static MarketDataSet GetMarketDataSet(SimInputData input)
        {
            List<MarketData> l = new List<MarketData>();
            MarketData mdKospiFuture = DataUtil.LoadDataAndAddToList("KM1 R:00_0_R Index", input.StartDate, input.EndDate, l);

            MarketData mdBond = DataUtil.LoadDataAndAddToList("KE1 R:00_0_R Comdty", input.ReadStartDate, input.EndDate, l);
            MarketData mdDollar = DataUtil.LoadDataAndAddToList("KU1 R:00_0_R Curncy", input.ReadStartDate, input.EndDate, l);
            MarketData mdKrxCreditDepositRate = DataUtil.LoadDataAndAddToList("KrxCreditDepositRate", input.ReadStartDate, input.EndDate, l);
            MarketData mdUsdKrwCurncy = DataUtil.LoadDataAndAddToList("USDKRW Curncy", input.ReadStartDate, input.EndDate, l);
            MarketData mdBokRate = DataUtil.LoadDataAndAddToList("KORP7D Index", input.ReadStartDate, input.EndDate, l);

            MarketData mdKospiIndex = DataUtil.LoadDataAndAddToList("KOSPI Index", input.ReadStartDate, input.EndDate, l);
            MarketData mdKtbSpotRate = DataUtil.LoadDataAndAddToList("KOTB3YR Index", input.ReadStartDate, input.EndDate, l);

            MarketData mdCycleLeadingIndex = DataUtil.LoadDataAndAddToList("SKLILY Index", input.ReadStartDate, input.EndDate, l);
            MarketData mdConsumerPriceIndex = DataUtil.LoadDataAndAddToList("KOCPI Index", input.ReadStartDate, input.EndDate, l);

            List<MarketData> alignedData = DataUtil.FillByPivotData(mdKospiFuture, l);
            Boolean arranged = DataUtil.IsArrangedDateAndIndex(alignedData);
            Trace.Assert(arranged);

            //Set data
            MarketDataSet data = new MarketDataSet();
            data.Add(MarketDataSetKey.KospiFuture, alignedData[0]);
            data.Add(MarketDataSetKey.KtbFuture, alignedData[1]);
            data.Add(MarketDataSetKey.DollarFuture, alignedData[2]);
            data.Add(MarketDataSetKey.KrxCreditDepositRate, alignedData[3]);
            data.Add(MarketDataSetKey.DollarSpot, alignedData[4]);
            data.Add(MarketDataSetKey.BokRate, alignedData[5]);
            data.Add(MarketDataSetKey.KospiSpot, alignedData[6]);
            data.Add(MarketDataSetKey.KtbSpot, alignedData[7]);
            data.Add(MarketDataSetKey.CycleLeadingIndex, alignedData[8]);
            data.Add(MarketDataSetKey.ConsumerPriceIndex, alignedData[9]);

            data.RegisterPivotData(alignedData[0]);

            return data;
        }
Exemplo n.º 21
0
        public AdjRateDatum CalculateAssetWeight_Raw(OperationSet opSet, DateTime targetDate, MarketDataSet data)
        {
            MarketData md = data.GetData(MarketDataSetKey.BokRate);
            DOHLC dohlc = md.GetData(targetDate);

            AdjRateDatum ret = null;

            if (_prevMarketData == null)
            {
                ret = new AdjRateDatum(1, 1, 1);
            }
            else
            {
                double prevValue = _prevMarketData.OHLC.Close;
                double curValue = dohlc.OHLC.Close;

                // changed more than 1 bp
                if (Math.Abs(prevValue - curValue) > 0.01)
                {
                    double increment = curValue / prevValue - 1;
                    // 금리 변동이 있다.
                    BokRateEvent ev = new BokRateEvent();
                    ev.TargetIncrement = increment;
                    ev.StartDate = targetDate;
                    ev.EndDate = targetDate.AddYears(kEventDuration);
                    ev.EventKey = _eventKeyGenerator++;
                    ev.UpDown = increment > 0 ? UpDown.Up : UpDown.Down;

                    _events.Add(ev);
                    _lastEvent = ev;
                }
                ret = GetIncrement(targetDate);
            }
            _prevMarketData = dohlc;

            return ret;
        }
Exemplo n.º 22
0
        public AdjRateDatum CalculateAdjRateDatum(DateTime targetDate, MarketDataSet data)
        {
            if (_cycleAdjDic == null || _cycleAdjDic.Count == 0)
            {
                LoadCycleEqAdjs();
                //TODO: cycle 데이터를 월말이 아닌 매일 DB에 넣어준 후에 아래 함수를 사용.
                //LoadCycleEqAdjs(data);
            }

            // 경기선행지수 매달 말일 발표 -> 당월에는 전전월 말일자 데이터를 이용할 수 있다.
            DateTime dataAvailableDate = targetDate.AddDays(1 - 1 * targetDate.Day).AddMonths(-1); //전월 1일
            dataAvailableDate = dataAvailableDate.AddDays(-1); //전전월 말일

             // 당월 말일에는 전월 말일자
            if (targetDate == DataUtil.GetMonthEndWeekDay(targetDate))
            {
                dataAvailableDate = DataUtil.GetMonthEndDate(dataAvailableDate.AddDays(1));
            }

            dataAvailableDate = DataUtil.GetLastTradingDay(_mdPivot, dataAvailableDate); // 월말이 주말인 경우 마지막 금요일로 변환

            double curAdj = 1;
            if (_cycleAdjDic.ContainsKey(dataAvailableDate))
            {
                curAdj = _cycleAdjDic[dataAvailableDate];
                _lastReturnedAdjRate = curAdj;
            }
            else
            {
                curAdj = _lastReturnedAdjRate;
            }

            AdjRateDatum ret = new AdjRateDatum(curAdj * _weight, 1, 1);

            return ret;
        }
Exemplo n.º 23
0
        public static AdjRateDatum Calculate(
            int key, 
            AdjRateDatum mine, 
            IAdjustment next, 
            OperationSet opSet, 
            DateTime targetDate, 
            MarketDataSet data)
        {
            if (next == null)
            {
                return mine;
            }

            OperationRow opData = opSet.GetData(key);
            Boolean on = opData.On;
            AdjRateDatum others = next.CalculateAssetWeight(opSet, targetDate, data);

            if (on)
            {
                Operation op = opData.Op;
                if (op == Operation.Multiply)
                {
                    AdjRateDatum ret = AdjUtil.Multiply(mine, others);
                    return ret;
                }
                else
                {
                    Trace.Assert(false);
                    return others;
                }
            }
            else
            {
                return others;
            }
        }
Exemplo n.º 24
0
        void SetPositionInfo(DateTime curDate, MarketDataSet data, RowInfo row)
        {
            MarketData mdKospiSpot = data.GetData(MarketDataSetKey.KospiSpot);
            MarketData mdKtbSpot = data.GetData(MarketDataSetKey.KtbSpot);
            MarketData mdDollarSpot = data.GetData(MarketDataSetKey.DollarSpot);

            DOHLC kospiSpot = mdKospiSpot.GetData(curDate);
            DOHLC ktbSpot = mdKtbSpot.GetData(curDate);
            DOHLC dollarSpot = mdDollarSpot.GetData(curDate);

            double kospiSpotPos = (kospiSpot.OHLC.Close - _kospiSpotMinRange) /
                (_kospiSpotMaxRange - _kospiSpotMinRange);

            double ktbSpotPos = (_ktbSpotMaxRange - ktbSpot.OHLC.Close) /
                (_ktbSpotMaxRange - _ktbSpotMinRange);

            double dollarSpotPos = (dollarSpot.OHLC.Close - _dollarSpotMinRange) /
                (_dollarSpotMaxRange - _dollarSpotMinRange);

            if (bRateRange)
            {
                kospiSpotPos = (kospiSpot.OHLC.Close / _maKospiSpot.GetCurMA());
                //dollarSpotPos = (dollarSpot.OHLC.Close / _maDollarSpot.GetCurMA());
            }

            row.KospiSpotPosition = kospiSpotPos;
            row.KtbSpotPosition = ktbSpotPos;
            row.DollarSpotPosition = dollarSpotPos;
        }
Exemplo n.º 25
0
        RowInfo GetCurRowWithBasicInfo(DateTime curDate, MarketDataSet data)
        {
            MarketData mdKospiFuture = data.GetData(MarketDataSetKey.KospiFuture);
            MarketData mdKtbFuture = data.GetData(MarketDataSetKey.KtbFuture);
            MarketData mdDollarFuture = data.GetData(MarketDataSetKey.DollarFuture);

            MarketData mdKospiSpot = data.GetData(MarketDataSetKey.KospiSpot);
            MarketData mdKtbSpot = data.GetData(MarketDataSetKey.KtbSpot);
            MarketData mdDollarSpot = data.GetData(MarketDataSetKey.DollarSpot);

            DOHLC kospiFuture = mdKospiFuture.GetData(curDate);
            DOHLC ktbFuture = mdKtbFuture.GetData(curDate);
            DOHLC dollarFuture = mdDollarFuture.GetData(curDate);

            DOHLC kospiSpot = mdKospiSpot.GetData(curDate);
            DOHLC ktbSpot = mdKtbSpot.GetData(curDate);
            DOHLC dollarSpot = mdDollarSpot.GetData(curDate);

            RowInfo row = new RowInfo();

            row.CurDate = curDate;

            row.KospiFuturePrice = kospiFuture.OHLC.Close;
            row.KtbFuturePrice = ktbFuture.OHLC.Close;
            row.DollarFuturePrice = dollarFuture.OHLC.Close;

            row.KospiSpotPrice = kospiSpot.OHLC.Close;
            row.KtbSpotPrice = ktbSpot.OHLC.Close;
            row.DollarSpotPrice = dollarSpot.OHLC.Close;

            return row;
        }
Exemplo n.º 26
0
        void LoadISMEqAdjs(MarketDataSet dataSet)
        {
            MarketData md = dataSet.GetData(MarketDataSetKey.CycleLeadingIndex);

            _ismAdjDic = new Dictionary<DateTime, double>();
            long totalCount = md.GetTotalCount();
            for (int i = 0; i < totalCount; i++)
            {
                DOHLC dohlc = md.GetByIndex(i);
                DateTime curDate = dohlc.CurDate;
                double curValue = dohlc.OHLC.Close;
                double curAdj = CalculateISMAdjValue(curValue, kMaxValue, kMinValue);
                curAdj = GetSwitchUpDownAdjValue(curAdj);
                _ismAdjDic.Add(curDate, curAdj);
            }
        }
Exemplo n.º 27
0
 public AdjRateDatum CalculateAssetWeight(OperationSet opSet, DateTime targetDate, MarketDataSet data)
 {
     AdjRateDatum adj = CalculateAssetWeight_Raw(opSet, targetDate, data);
     return AdjUtil.Calculate(_key, adj, _nextAdj, opSet, targetDate, data);
 }
Exemplo n.º 28
0
 public void ReadyData()
 {
     this._readyData = DataUtil.GetBaseMarketData(this.Input);
 }
Exemplo n.º 29
0
        void LoadRealIrAdjs(MarketDataSet dataSet)
        {
            MarketData mdPivot =
                DataUtil.GetKeyMarketData(MarketDataSetKey.KospiFuture, _startDate, _endDate);
            MarketData mdCPI = dataSet.GetData(MarketDataSetKey.ConsumerPriceIndex);
            MarketData mdKtbR = dataSet.GetData(MarketDataSetKey.KtbSpot);
            _RealIrAdjDic = new Dictionary<DateTime, double>();

            double prevCpiValue = 0;
            long totalCount = mdKtbR.GetTotalCount();
            for (int i = 0; i < totalCount; i++)
            {
                DOHLC dohlcKtbR = mdKtbR.GetByIndex(i);
                DateTime curDate = dohlcKtbR.CurDate;
                double curKtbRValue = dohlcKtbR.OHLC.Close;
                double cpiValue = 0;

                // CPI 매달 1일 발표 -> 당월에는 전월 말일자 데이터를 이용할 수 있다.
                DateTime availableCpiDate = curDate.AddDays(1 - 1 * curDate.Day); //당월 1일
                availableCpiDate = availableCpiDate.AddDays(-1); //전월 말일

                availableCpiDate = DataUtil.GetLastTradingDay(mdPivot, availableCpiDate); // 월말이 주말인 경우 마지막 금요일로 변환

                if (mdCPI.IsExistDate(availableCpiDate))
                {
                    cpiValue = mdCPI.GetData(availableCpiDate).OHLC.Close;
                    prevCpiValue = cpiValue;
                }
                else
                {
                    cpiValue = prevCpiValue;
                }

                double realIrValue = curKtbRValue - cpiValue;

                double curAdj = CalculateRealIrAdjValue(realIrValue, kMaxValue, kMinValue);
                curAdj = GetSwitchUpDownAdjValue(curAdj);
                _RealIrAdjDic.Add(curDate, curAdj);
            }
        }
Exemplo n.º 30
0
 public AdjRateDatum CalculateAdjRateDatum(DateTime targetDate, MarketDataSet data)
 {
     AdjRateDatum adj = CalculateAssetWeight_Raw(targetDate, data);
     return adj;
 }