Beispiel #1
0
        public RiskParameters(LinearRegression regression, double weight,
                              double tradeLimit, double risk, double commission)
        {
            if (regression == null)
            {
                throw new ArgumentNullException(nameof(regression));
            }

            Regression = regression;
            Weight     = weight;
            TradeLimit = tradeLimit;
            Risk       = risk;
            Commission = commission;
        }
Beispiel #2
0
        private void SetRegressions(double rValueMinimum)
        {
            double[] indexValues = historicalPrices[indexSymbol];

            foreach (var item in historicalPrices)
            {
                if (item.Key != indexSymbol)
                {
                    double[] prices = historicalPrices[item.Key];
                    var      lr     = new LinearRegression(prices, indexValues);
                    lr.Calculate();
                    if (Math.Abs(lr.R) >= Math.Abs(rValueMinimum))
                    {
                        CreateRiskParameter(item.Key, lr);
                    }
                }
            }
        }
Beispiel #3
0
 private void CreateRiskParameter(string symbol, LinearRegression regression)
 {
     riskParameters.Add(symbol, new RiskParameters(regression, 0, 0, 0, 0));
 }