Ejemplo n.º 1
0
 public IncrementData(DataFromDB data_from_db)
 {
     this.ActiveDays = data_from_db.ActiveDays;
       Init(data_from_db);
 }
Ejemplo n.º 2
0
        public Weight(
      DataFromDB data_from_db, 
      RangeData rng_data,
      VolData vol_data)
        {
            this.ActiveDays = data_from_db.ActiveDays;

              this.KospiBasic = new SortedList<DateTime, double>();
              this.KospiPriceBoost = new SortedList<DateTime, double>();
              this.KospiVolBoost = new SortedList<DateTime, double>();
              this.KospiWeight = new SortedList<DateTime, double>();
              this.KtbWeight = new SortedList<DateTime, double>();
              this.UsdkrwWeight = new SortedList<DateTime, double>();

              this.KospiVolAdjustedWeight = new SortedList<DateTime, double>();
              this.KtbVolAdjustedWeight = new SortedList<DateTime, double>();
              this.UsdkrwVolAdjustedWeight = new SortedList<DateTime, double>();

              foreach (DateTime cur_dt in this.ActiveDays.Keys)
              {
            if (rng_data.Ktb.ContainsKey(cur_dt))
            {
              double bond_pos = rng_data.Ktb[cur_dt];
              double bond_reverse = 1.0 - bond_pos;
              double basic_weight = bond_reverse *
            (100 - MacroAAMagicNumber.AGE) / 100;

              if (rng_data.Kospi.ContainsKey(cur_dt))
              {
            double kospi_pos = rng_data.Kospi[cur_dt];
            double kospi_price_boost = 1.5 - kospi_pos;

            if (vol_data.Kospi.ContainsKey(cur_dt))
            {
              double kospi_vol_boost = MacroAAMagicNumber.KOSPI_VOL_PIVOT +
                1 - vol_data.Kospi[cur_dt];

              double kospi_weight = basic_weight * kospi_price_boost *
                kospi_vol_boost;

              if (rng_data.Usdkrw.ContainsKey(cur_dt))
              {
                double usdkrw_pos = rng_data.Usdkrw[cur_dt];
                double usdkrw_weight = bond_pos *
                  MacroAAMagicNumber.USDKRW_MAX_WEIGHT * (1.0 - usdkrw_pos);

                double bond_weight = 1.0 - kospi_weight - usdkrw_weight;

                this.KospiBasic.Add(cur_dt, basic_weight);
                this.KospiPriceBoost.Add(cur_dt, kospi_price_boost);
                this.KospiVolBoost.Add(cur_dt, kospi_vol_boost);
                this.KospiWeight.Add(cur_dt, kospi_weight);
                this.UsdkrwWeight.Add(cur_dt, usdkrw_weight);
                this.KtbWeight.Add(cur_dt, bond_weight);

                double bond_weight_per_vol =
                  bond_weight / MacroAAMagicNumber.BOND_VOL_PIVOT;
                double kospi_weight_per_vol =
                  kospi_weight / MacroAAMagicNumber.KOSPI_VOL_PIVOT;
                double usdkrw_weight_per_vol =
                  usdkrw_weight / MacroAAMagicNumber.USDKRW_VOL_PIVOT;

                double weight_per_vol_sum = bond_weight_per_vol +
                  kospi_weight_per_vol + usdkrw_weight_per_vol;

                double bond_vol_adj_weight =
                  bond_weight_per_vol / weight_per_vol_sum;
                double kospi_vol_adj_weight =
                  kospi_weight_per_vol / weight_per_vol_sum;
                double usdkrw_vol_adj_weight =
                  usdkrw_weight_per_vol / weight_per_vol_sum;

                this.KospiVolAdjustedWeight.Add(cur_dt, kospi_vol_adj_weight);
                this.KtbVolAdjustedWeight.Add(cur_dt, bond_vol_adj_weight);
                this.UsdkrwVolAdjustedWeight.Add(cur_dt, usdkrw_vol_adj_weight);

                //logger.Info("{0} - [{1:n2} - {2:n2} - {3:n2}] - " +
                //  "[{4:n2} - {5:n2} - {6:n2}] - [{7:n2} - {8:n2} - {9:n2}]",
                //  cur_dt,

                //  bond_weight,
                //  kospi_weight,
                //  usdkrw_weight,

                //  bond_weight_per_vol,
                //  kospi_weight_per_vol,
                //  usdkrw_weight_per_vol,

                //  bond_vol_adj_weight,
                //  kospi_vol_adj_weight,
                //  usdkrw_vol_adj_weight);
              }
            }
              }
            }
              }
        }
Ejemplo n.º 3
0
 public VolData(DataFromDB data_from_db, IncrementData inc_data)
 {
     this.ActiveDays = data_from_db.ActiveDays;
       SetKospiVolData(inc_data);
 }
Ejemplo n.º 4
0
        public RangeData(DataFromDB data_from_db)
        {
            this.ActiveDays = data_from_db.ActiveDays;

              this.Kospi = SetRangeData(
            MacroAAMagicNumber.KOSPI_PRICE_MAX,
            MacroAAMagicNumber.KOSPI_PRICE_MIN,
            data_from_db.Kospi);

              this.Ktb = SetRangeData(
            MacroAAMagicNumber.BOND_RATE_MAX,
            MacroAAMagicNumber.BOND_RATE_MIN,
            data_from_db.Ktb);

              this.Usdkrw = SetRangeData(
            MacroAAMagicNumber.USDKRW_PRICE_MAX,
            MacroAAMagicNumber.USDKRW_PRICE_MIN,
            data_from_db.Usdkrw);
        }
Ejemplo n.º 5
0
        DataFromDB LoadDataFromDB(MacroSpotData last_data, int limit)
        {
            DBManager manager = new DBManager();
              MySqlConnection con = manager.OpenConnection(Const.DATABASE_NAME);

              SortedList<DateTime, double> kospi_data =
            LoadDataFromDB_Raw(con, "KOSPI Index", limit);

              SortedList<DateTime, double> ktb_data =
            LoadDataFromDB_Raw(con, "KWNDF3 CMPN CURNCY", limit);

              SortedList<DateTime, double> usdkrw_data =
            LoadDataFromDB_Raw(con, "USDKRW Curncy", limit);

              SortedList<DateTime, double> kospi_future_data =
            LoadDataFromDB_Raw(con, "KM1 R:00_0_R Index", limit);

              SortedList<DateTime, double> ktb_future_data =
            LoadDataFromDB_Raw(con, "KE1 R:00_0_R Comdty", limit);

              SortedList<DateTime, double> usdkrw_future_data =
            LoadDataFromDB_Raw(con, "KU1 R:00_0_R Curncy", limit);

              SortedList<DateTime, double> active_days =
            new SortedList<DateTime, double>();

              active_days = GetActiveDays(kospi_data, ktb_data);
              active_days = GetActiveDays(active_days, usdkrw_data);
              active_days = GetActiveDays(active_days, kospi_future_data);
              active_days = GetActiveDays(active_days, ktb_future_data);
              active_days = GetActiveDays(active_days, usdkrw_future_data);

              DataFromDB output = new DataFromDB();
              output.ActiveDays = active_days;
              output.Kospi = kospi_data;
              output.Ktb = ktb_data;
              output.Usdkrw = usdkrw_data;
              output.KospiFuture = kospi_future_data;
              output.KtbFuture = ktb_future_data;
              output.UsdkrwFuture = usdkrw_future_data;

              if (last_data != null)
              {
            DateTime key = last_data.CurDateTime;
            output.ActiveDays.Add(key, 0);
            output.Kospi.Add(key, last_data.KospiPrice);
            output.KospiFuture.Add(key, last_data.KospiFuturePrice);
            output.Ktb.Add(key, last_data.BondRate);
            output.KtbFuture.Add(key, last_data.BondFuturePrice);
            output.Usdkrw.Add(key, last_data.UsdkrwPrice);
            output.UsdkrwFuture.Add(key, last_data.UsdkrwFuturePrice);
              }

              con.Close();
              return output;
        }
Ejemplo n.º 6
0
 void Init(DataFromDB data_from_db)
 {
     this.Kospi = Init_Raw(data_from_db.Kospi);
       this.Ktb = Init_Raw(data_from_db.Ktb);
       this.Usdkrw = Init_Raw(data_from_db.Usdkrw);
       this.KospiFuture = Init_Raw(data_from_db.KospiFuture);
       this.KtbFuture = Init_Raw(data_from_db.KtbFuture);
       this.UsdkrwFuture = Init_Raw(data_from_db.UsdkrwFuture);
 }