Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
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;
            }
        }
        public AssetAdjustment CalculateAssetWeight(OperationSet opSet, 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))
            {
                return new AssetAdjustment(kospiWeight, 1, 1);
            }
            else
            {
                _prevUpDown = UpDown.Unknown;
            }
            return new AssetAdjustment(1, 1, 1);
        }
Ejemplo n.º 4
0
 public DefaultStrategy(String strategyName, StrategyBaseInput input)
 {
     this.StrategyName = strategyName;
     this.Input = input;
     this._allocBase = new StaticAlloc();
     this._opSet = new OperationSet();
     this._adjustment = new DummyAdjustment();
 }
Ejemplo n.º 5
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;
        }
Ejemplo n.º 6
0
        AssetAdjustment CalculateAssetWeight_Raw(OperationSet opSet, 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;

            return new AssetAdjustment(1, 1, rate * _weight);
        }
Ejemplo n.º 7
0
        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;
        }
Ejemplo n.º 8
0
        public AssetAdjustment 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();

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

            this._prevRow = curRow;

            return adj;
        }
Ejemplo n.º 9
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;
        }
Ejemplo n.º 10
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;
            }
        }
Ejemplo n.º 11
0
 public AssetAdjustment CalculateAssetWeight(OperationSet opSet, DateTime targetDate, MarketDataSet data)
 {
     AssetAdjustment adj = CalculateAssetWeight_Raw(opSet, targetDate, data);
     return AdjustmentUtil.Calculate(_key, adj, _nextAdjustment, opSet, targetDate, data);
 }
Ejemplo n.º 12
0
 public AssetAdjustment CalculateAssetWeight(OperationSet opSet, DateTime targetDate, MarketDataSet data)
 {
     return new AssetAdjustment(1, 1, 1);
 }