private void HeapSort(List <AccountValue> unsortedList) { BuildMaxHeap(unsortedList); for (int i = unsortedList.Count; i > 1; --i) { AccountValue temp = unsortedList[0]; unsortedList[0] = unsortedList[i - 1]; unsortedList[i - 1] = temp; --heapSize; MaxHeapify(unsortedList, 1); } }
private List <AccountValue> CreateExitedPositionRealizedList() { List <AccountValue> exitedPositionGainLoss = new List <AccountValue>(); foreach (Position pos_i in ExitedPositions) { AccountValue posGrossDate = new AccountValue(); posGrossDate.time = pos_i.GetLastTrade().TradeDate; posGrossDate.value = pos_i.GrossProfit; exitedPositionGainLoss.Add(posGrossDate); } return(exitedPositionGainLoss); }
private void CalcCumulativePerformance(List <AccountValue> exitedPositions) { double sum = 0; HeapSort(exitedPositions); foreach (AccountValue val in exitedPositions) { sum += val.value; AccountValue cumVal = new AccountValue(); cumVal.time = val.time; cumVal.value = sum; CumulativeRealized.Add(cumVal); } //HeapSort(CumulativeRealized); }