/* from Gunther's notes * 3. Delete lazy shares: * 1) In the All-table, sum up the volume in column 49 from row 9362 to row 10401, multiply it by 0,1 and then multiply it with the Five-minutes-price(FP) of row 10401 column 11. * (∑V9362-10401) * 0,1 * FP10401 11 = * (V9362 + V9363 + V9364 + … ... + V10400 + V10401) * 0,1 * FP10401 11 =: VP * 2) Then compare the result with the Z chosen by user: * VP<Z? Z = 1000 … 1000.000 * In case the inequality is fulfilled, do not use this share for further calculations. */ // Returns a boolean decision as to whether a share is 'Lazy' or not. // startRow is meant to normally be 9362 and endRow 10401 - covering a 10 trading day span // An average daily price is computed and is then compared to a threshold. If this falls below the threshold // the share is considered 'Lazy' // NOTE.. this must compute the same result as OverviewCalcs.isLazyLast10Days !!!! internal static bool LazyShare(AllTable[] bands, LazyShareParam Z, int startRow, int endRow, out string[] auditSummary) { bool isLazy = false; auditSummary = "".Split('\n'); int numBands = endRow - startRow + 1; // normally 1040 bands = 10 days if (bands.Count() > 0 && numBands > 2) { //we must skip startRow rows because 'Row' starts at -1 double totalFV = bands.Skip(startRow).Take(numBands).Sum(atRec => Math.Sqrt(atRec.FV)); double numDays = numBands / 104; // there are 104 bands per day double avgDailyVolume = totalFV / numDays; double effectivePrice = bands[endRow].FP; double VP = avgDailyVolume * effectivePrice; isLazy = VP < Z.Setting; auditSummary = $@" LazyShare calculation: Period = {numDays} last days Sum of roots of Volume FV = {totalFV} Avg Daily Sum of RootsVolume = {avgDailyVolume} Last price (FP1041) = {effectivePrice} VP (Avg DailyRootsVol x Price) = {VP} Z = {Z.Setting} Result: (VP < Z)? LAZY = {isLazy}".Split('\n'); } else { //throw new Exception("LazyShare: number of bands must be > 0"); } return(isLazy); }
// CALCULATION HANDLING internal static PropertyGrid PropertyGridParams(LazyShareParam 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); }
internal static bool isLazyLast10Days(AllTable[] bands, LazyShareParam Z) { int numBands = bands.Count(); if (numBands == 10402) { double totalFV = bands.Skip(9362).Take(1040).Sum(atRec => Math.Sqrt(atRec.FV)); double avgDailyRootVolume = totalFV / 10; //10 days double effectivePrice = bands[10401].FP; double VP = avgDailyRootVolume * effectivePrice; return(VP < Z.Setting); } else { throw new ArgumentException($"isLazyLast10Days needs 10402 FP bands, got {numBands}"); } }