Example #1
0
        private double[] ComputeVolatility(int window, int deb, int step)
        {//Compute the volatility of all the underlying shares at date deb.
         //Estimate the parameters thanks to the data of the window days before deb.
            var res = new List <double>();

            for (var share = 0; share < Option.UnderlyingShareIds.Length; share++)
            {
                double[,] tab = new double[window - 1, 1];
                for (var k = 1; k < window; k++)
                {
                    tab[k - 1, 0] = Math.Log((double)Spots[deb - window + k][share] / (double)Spots[deb - window + k - 1][share]);
                }
                var B = Math.Sqrt(DayCount.ConvertToDouble(step, 365));
                double[,] myVol = WRE.computeVolatility(tab);
                res.Add(myVol[0, 0] / B);
            }
            return(res.ToArray());
        }
Example #2
0
        public double getPrixPortefeuille(double[] spot, int now, AbstractData donnees)
        {
            // Recupere la valeur du portefeuille à l'instant actuel
            var result = 0.0;
            int i      = 0;

            foreach (var par in this.nbActions)
            {
                result += par * spot[i];
                i++;
            }
            int span = (donnees.listeDate[now] - donnees.listeDate[date]).Days;;

            result += tauxSansRisque * RiskFreeRateProvider.GetRiskFreeRateAccruedValue(DayCount.ConvertToDouble(span, 365));
            return(result);
        }
 public void UpdatePortfolioValue(DataFeed priceAsset_t, int nbJourParAn, int periodeRebalancement)
 {
     this.portfolioValue = 0;
     foreach (string id in priceAsset.Keys)
     {
         this.portfolioValue += Convert.ToDecimal(composition[id]) * priceAsset_t.PriceList[id];
     }
     this.portfolioValue += this.liquidity * Convert.ToDecimal(RiskFreeRateProvider.GetRiskFreeRateAccruedValue(DayCount.ConvertToDouble(periodeRebalancement, nbJourParAn)));
 }