Пример #1
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;
        }
Пример #2
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;
            }
        }
Пример #3
0
 public DefaultStrategy(String strategyName, SimInputData input)
 {
     this.StrategyName = strategyName;
     this.Input = input;
     this._allocBase = new StaticAlloc();
     this._opSet = new OperationSet();
     this._adjustment = new DummyAdjustment();
 }
Пример #4
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;
        }
        public void Build()
        {
            this._allocBase = new StaticAlloc();
            this._opSet = new OperationSet();

            int key = 0;

            this._adjustment = new DummyAdjustment();

            AddAdjustment_Static(key++, this._adjustment);
            AddAdjustment_WithMA(key++, this._adjustment, 1);
        }
Пример #6
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;
        }
Пример #7
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;
        }
Пример #8
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;
            }
        }
Пример #9
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);
 }
Пример #10
0
 public AdjRateDatum CalculateAssetWeight(OperationSet opSet, DateTime targetDate, MarketDataSet data)
 {
     return new AdjRateDatum(1, 1, 1);
 }