private void ExecuteSell(ForexTreeData record) { if (BuyQuantities.Count < 1) { throw new BllException("You have no open positions to close for sell."); } var tradeUnits = BidSize / MarginRatio; var unitsSold = BuyQuantities[0]; var profit = MathHelpers.GreedyCurrencyPrecision(unitsSold / record.Ask - tradeUnits); Profits.Add(profit); BuyQuantities.RemoveAt(0); SaveLogRecord(0.0, unitsSold, profit, MarketAction.Sell, record.Action); }
public void EvaluateCostsAndProfits() { if (!Totals.Any()) // Totals need to be evaluated beforehand { EvaluateTotals(); } Costs.Clear(); Profits.Clear(); for (var index = 0; index <= _diffMonths; index++) { var period = _from.AddMonths(index); var ordersInMonth = _orders.Where(IsInMonth(period.Month)); Costs.Add(ordersInMonth.Sum(order => order.OrderTotalCost)); Profits.Add(Totals[index] - Costs[index]); } }