Пример #1
0
        // Compute Slow prices per Gunther's notes
        internal static void MakeSlowPrices(ref AllTable[] bands, SlowPriceParam spp, int startRow, int endRow, out string[] auditSummary)
        {
            auditSummary = new string[] { };

            int numBands = endRow - startRow + 1; // normally 1040 bands = 10 days

            if (numBands > 0)
            {
                //init slow prices to 1 in the starting row
                bands[startRow].SPa = 1; bands[startRow].SPb = 1; bands[startRow].SPc = 1; bands[startRow].SPd = 1;

                for (int f = startRow + 1; f <= endRow; f++)
                {
                    //SPa,Ya
                    if (bands[f].FP >= bands[f - 1].SPa)
                    {
                        bands[f].SPa = bands[f - 1].SPa + Math.Pow(spp.Z * (bands[f].FP - bands[f - 1].SPa), spp.Ya) / spp.Z; //Z wont be zero
                    }
                    else
                    {
                        bands[f].SPa = bands[f - 1].SPa - Math.Pow(spp.Z * (bands[f - 1].SPa - bands[f].FP), spp.Ya) / spp.Z;
                    }
                    //SPb,Yb
                    if (bands[f].FP >= bands[f - 1].SPb)
                    {
                        bands[f].SPb = bands[f - 1].SPb + Math.Pow(spp.Z * (bands[f].FP - bands[f - 1].SPb), spp.Yb) / spp.Z; //Z wont be zero
                    }
                    else
                    {
                        bands[f].SPb = bands[f - 1].SPb - Math.Pow(spp.Z * (bands[f - 1].SPb - bands[f].FP), spp.Yb) / spp.Z;
                    }
                    //SPc,Yc
                    if (bands[f].FP >= bands[f - 1].SPc)
                    {
                        bands[f].SPc = bands[f - 1].SPc + Math.Pow(spp.Z * (bands[f].FP - bands[f - 1].SPc), spp.Yc) / spp.Z; //Z wont be zero
                    }
                    else
                    {
                        bands[f].SPc = bands[f - 1].SPc - Math.Pow(spp.Z * (bands[f - 1].SPc - bands[f].FP), spp.Yc) / spp.Z;
                    }
                    //SPd,Yd
                    if (bands[f].FP >= bands[f - 1].SPd)
                    {
                        bands[f].SPd = bands[f - 1].SPd + Math.Pow(spp.Z * (bands[f].FP - bands[f - 1].SPd), spp.Yd) / spp.Z; //Z wont be zero
                    }
                    else
                    {
                        bands[f].SPd = bands[f - 1].SPd - Math.Pow(spp.Z * (bands[f - 1].SPd - bands[f].FP), spp.Yd) / spp.Z;
                    }
                }
                auditSummary = $"MakeSlowPrices results:\n{numBands} processed\nInspect the view.".Split('\n');
            }
            else
            {
                auditSummary = $"MakeSlowPrices: No bands to work with".Split('\n');
            }
        }
Пример #2
0
        // CALCULATION HANDLING
        internal static PropertyGrid PropertyGridParams(SlowPriceParam param, int height)
        {
            var pg = new PropertyGrid();

            pg.ToolbarVisible        = false;
            pg.PropertySort          = PropertySort.NoSort;
            pg.Size                  = new Size(150, height);
            pg.Location              = new Point(20, 12);
            pg.SelectedObject        = param;
            pg.PropertyValueChanged += OnParamSettingChange;
            return(pg);
        }