Exemplo n.º 1
0
    public void SaveWeights(ConstructGen<double> wts_, IProductID[] products_, bool obliterateCurrent_, bool overwrite_)
    {
      var sqls = new List<string>();

      if (obliterateCurrent_)
        sqls.Add(string.Format("delete from weights where signalID ={0}", OwningSignal.ID));

      var current = GetData(
        startDate_: DateTime.Today.AddMonths(-3),
        endDate_: DateTime.Today);

      foreach (var date in wts_.Dates)
      {
        if (!obliterateCurrent_ && current != null && current.Dates != null && current.Dates.Last() > date)
          continue;

        var dateWts = wts_.GetValues(date);

        if (!obliterateCurrent_ && overwrite_)
        {
          sqls.Add(string.Format("delete from weights where signalID={0} and markDate='{1}'", OwningSignal.ID,
            date.ToString("dd-MMM-yyyy")));
        }

        for (int i = 0; i < wts_.ArrayLength; ++i)
        {
          sqls.Add(string.Format("saveSignalWeights {0}, '{1}', {2}, {3}",
            OwningSignal.ID,
            date.ToString("dd-MMM-yyyy"),
            products_[i].ID,
            dateWts[i]
            ));
        }
      }

      Singleton<DB.ConnMngr>.Instance.ExecuteNonQuery(DBNames.SQLSERVER_DBAGHLA_HK, sqls);

    }
    public override void SaveWeights(ConstructGen<double> wts_, IProductID[] products_, bool obliterateCurrent_, bool overwrite_)
    {
      var sqls = new List<string>();

      if (obliterateCurrent_)
        sqls.Add(string.Format("delete from wts where signalID ={0}", OwningSignal.ID));

      foreach (var date in wts_.Dates)
      {
        var dateWts = wts_.GetValues(date);

        if (!obliterateCurrent_ && overwrite_)
        {
          sqls.Add(string.Format("delete from wts where signalID={0} and markDate='{1}'", OwningSignal.ID,
            date.ToString("dd-MMM-yyyy")));
        }

        for (int i = 0; i < wts_.ArrayLength; ++i)
        {
          var ccy = Singleton<FXIDs>.Instance[wts_.ColumnHeadings[i]];

          sqls.Add(string.Format("saveSignalWts '{0}', '{1}', {2}, {3}",
            OwningSignal.Name,
            date.ToString("dd-MMM-yyyy"),
            ccy.ID,
            dateWts[i]
            ));
        }
      }

      Singleton<DB.ConnMngr>.Instance.ExecuteNonQuery(DBNames.SQLSERVER_DBAGHLA_HK, sqls);

    }
 public abstract void SaveWeights(ConstructGen<double> wts_, IProductID[] products_, bool obliterateCurrent_,
   bool overwrite_);