Example #1
0
        public AssetAdjustment CalculateAssetWeight(OperationSet opSet, DateTime targetDate, MarketDataSet data)
        {
            OperationRow opData = opSet.GetData(_key);
            Boolean on = opData.On;
            AssetAdjustment others = _nextAdjustment.CalculateAssetWeight(opSet, targetDate, data);

            if (on)
            {
                AssetAdjustment mine = new AssetAdjustment(_kospiAdjustment, _bondAdjustment, _dollarAdjustment);
                Operation op = opData.Op;
                if (op == Operation.Multiply)
                {
                    AssetAdjustment ret = AdjustmentUtil.Multiply(mine, others);
                    return ret;
                }
                else
                {
                    logger.Warn("Multiply 이외의 기능은 아직 제공하고 있지 않음");
                    return others;
                }
            }
            else
            {
                return others;
            }
        }
Example #2
0
        public AssetAdjustment CalculateAssetWeight_Raw(OperationSet opSet, DateTime targetDate, MarketDataSet data)
        {
            MarketData md = data.GetData(MarketDataSetKey.KospiFuture);
            DOHLC dohlc = md.GetData(targetDate);
            double curValue = dohlc.OHLC.Close;

            AssetAdjustment 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 AssetAdjustment(kospiFactor * _weight, 1, 1);
            }
            else
            {
                ret = new AssetAdjustment(1, 1, 1);
            }
            _prevValue = curValue;

            return ret;
        }
Example #3
0
        public static AssetAdjustment Multiply(AssetAdjustment a, AssetAdjustment b)
        {
            double kospiAdjustment = a.KospiAdjustment * b.KospiAdjustment;
            double bondAdjustment = a.KtbAdjustment * b.KtbAdjustment;
            double dollarAdjustment = a.DollarAdjustment * b.DollarAdjustment;

            AssetAdjustment aa = new AssetAdjustment(kospiAdjustment, bondAdjustment, dollarAdjustment);
            return aa;
        }
Example #4
0
        public AssetAdjustment CalculateAssetWeight_Raw(OperationSet opSet, DateTime targetDate, MarketDataSet data)
        {
            if (_adjs.ContainsKey(targetDate))
            {
                Tuple<double, double, double> t = _adjs[targetDate];
                AssetAdjustment aa = new AssetAdjustment(t);
                _prev = aa;

                return aa;
            }
            return _prev;
        }
        public AssetAdjustment CalculateAssetWeight(OperationSet opSet, DateTime targetDate, MarketDataSet data)
        {
            AssetAdjustment adj = new AssetAdjustment(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);

                adj = new AssetAdjustment(kospiAdjustment, 1, 1);
            }
            return adj;
        }
Example #6
0
        public AssetAdjustment CalculateAssetWeight_Raw(OperationSet opSet, DateTime targetDate, MarketDataSet data)
        {
            MarketData md = data.GetData(MarketDataSetKey.BokRate);
            DOHLC dohlc = md.GetData(targetDate);

            AssetAdjustment ret = null;

            if (_prevMarketData == null)
            {
                ret = new AssetAdjustment(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;
        }
        public AssetWeightLog Execute(long caseNumber)
        {
            IAllocBase allocBase = this._allocBases[(int)caseNumber];
            DateTime curDate = this.Input.StartDate;
            AssetWeightLog log = new AssetWeightLog();

            _curKey = String.Format("SAO({0})", allocBase.GetKey());

            while (curDate <= this.Input.EndDate)
            {
                if (this._readyData.IsExistDate(curDate))
                {
                    AssetWeight aw = allocBase.CalculateAssetWeight(curDate, this._readyData);
                    AssetAdjustment aa = new AssetAdjustment(1, 1, 1);
                    aw.Multiply(aa);
                    aw.SetScale();
                    log.Add(curDate, aw);
                }

                curDate = curDate.AddDays(1);
            }

            return log;
        }
Example #8
0
        public static AssetAdjustment Calculate(
            int key, 
            AssetAdjustment mine, 
            IAdjustment next, 
            OperationSet opSet, 
            DateTime targetDate, 
            MarketDataSet data)
        {
            if (next == null)
            {
                return mine;
            }

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

            if (on)
            {
                Operation op = opData.Op;
                if (op == Operation.Multiply)
                {
                    AssetAdjustment ret = AdjustmentUtil.Multiply(mine, others);
                    return ret;
                }
                else
                {
                    Trace.Assert(false);
                    return others;
                }
            }
            else
            {
                return others;
            }
        }
Example #9
0
 public void Sum(AssetAdjustment input)
 {
     this.KospiWeight += input.KospiAdjustment;
     this.BondWeight += input.KtbAdjustment;
     this.DollarWeight += input.DollarAdjustment;
 }
Example #10
0
 public void Multiply(AssetAdjustment input)
 {
     this.KospiWeight *= input.KospiAdjustment;
     this.BondWeight *= input.KtbAdjustment;
     this.DollarWeight *= input.DollarAdjustment;
 }