Exemplo n.º 1
0
        public override void partialRollback(DiscretizedAsset asset, double to)
        {
            double from = asset.time();

            if (Utils.close(from, to))
            {
                return;
            }

            Utils.QL_REQUIRE(from > to, () => "cannot roll the asset back to" + to + " (it is already at t = " + from + ")");

            int iFrom = t_.index(from);
            int iTo   = t_.index(to);

            for (int i = iFrom - 1; i >= iTo; --i)
            {
                Vector newValues = new Vector(impl().size(i));
                impl().stepback(i, asset.values(), newValues);
                asset.setTime(t_[i]);
                asset.setValues(newValues);
                // skip the very last adjustment
                if (i != iTo)
                {
                    asset.adjustValues();
                }
            }
        }
Exemplo n.º 2
0
        //! Computes the present value of an asset using Arrow-Debrew prices
        public override double presentValue(DiscretizedAsset asset)
        {
            int i = t_.index(asset.time());

            return(Vector.DotProduct(asset.values(), statePrices(i)));
        }