Ejemplo n.º 1
0
        /// <summary>
        /// Values at.
        /// </summary>
        /// <param name="stock"></param>
        /// <param name="expiries">The expiries.</param>
        /// <param name="strikes">The strikes.</param>
        /// <param name="?">Cache to vol object</param>
        /// <param name="cache"></param>
        /// <returns></returns>
        public List <ForwardExpiry> ValueAt(Stock stock, List <DateTime> expiries, List <Double> strikes, bool cache)
        {
            var forwardExpiries = new List <ForwardExpiry>();

            foreach (DateTime exp in expiries)
            {
                var fwdExpiry = new ForwardExpiry();
                foreach (double str in strikes)
                {
                    var    wingModel = new WingInterp();
                    double forward   = stock.GetForward(stock.Date, exp.Date);
                    double spot      = Convert.ToDouble(stock.Spot);
                    fwdExpiry.FwdPrice = Convert.ToDecimal(forward);
                    double y     = str;
                    double x     = (exp.Subtract(Date)).Days / 365.0;
                    IPoint point = new Point2D(x, y);
                    InterpCurve.Forward = forward;
                    InterpCurve.Spot    = spot;
                    var val             = InterpCurve.Value(point);
                    IVolatilityPoint vp = new VolatilityPoint();
                    vp.SetVolatility(Convert.ToDecimal(val), VolatilityState.Default());
                    fwdExpiry.ExpiryDate = exp;
                    bool node = VolatilitySurfaceHelper.IsMatch(str, exp, NodalExpiries);
                    // copy model used to return ForwardExpiry object
                    var newstrike = new Strike {
                        StrikePrice = str
                    };
                    var wing = (WingModelInterpolation)InterpCurve.GetYAxisInterpolatingFunction();
                    //SABRModelInterpolation wing = (SABRModelInterpolation)_interpCurve.GetYAxisInterpolatingFunction();
                    wingModel.WingParams  = wing.WingParameters;
                    newstrike.InterpModel = wingModel;
                    fwdExpiry.AddStrike(newstrike, node);

                    newstrike.SetVolatility(vp);
                }
                forwardExpiries.Add(fwdExpiry);
            }
            return(forwardExpiries);
        }
Ejemplo n.º 2
0
        public Spline(ExportEntry component, PathingGraphEditor g, ExportEntry nextActor)
        {
            Pickable  = false;
            NextActor = nextActor;
            StructProperty splineInfoProp = component.GetProperty <StructProperty>("SplineInfo");

            if (splineInfoProp != null)
            {
                SplineInfo = InterpCurve <Vector3> .FromStructProperty(splineInfoProp);

                var reparamProp = component.GetProperty <StructProperty>("SplineReparamTable");
                if (reparamProp != null)
                {
                    ReparamTable = InterpCurve <float> .FromStructProperty(reparamProp);
                }
                else
                {
                    ReparamTable = new InterpCurve <float>();
                    RegenerateReparamTable();
                }

                Draw(g);
            }
        }