public virtual decimal GetAbsoluteGain(decimal?curPrice, decimal?clPrice, decimal opPrice, int opWeight, decimal dividends, TradeTypesDTO type) { var usePrice = curPrice ?? clPrice.Value; decimal absGain; if (type == TradeTypesDTO.Long) { absGain = (usePrice + dividends - opPrice) * opWeight; } else { absGain = (opPrice - dividends - usePrice) * opWeight; } return(absGain); }
public decimal GetGain(decimal?curPrice, decimal?clPrice, decimal opPrice, int opWeight, decimal dividends, TradeTypesDTO type) { decimal gain; if (opPrice == 0 || opWeight == 0) { gain = 0; } else { var absGain = GetAbsoluteGain(curPrice, clPrice, opPrice, opWeight, dividends, type); gain = absGain / (opPrice * opWeight); } return(gain); }
public TradeInforamation GetMaxGainForSymbolBetweenDate(DateTime dateFrom, DateTime dateTo, int symbolId, TradeTypesDTO type) { var tradeDates = db.TradeSybols.GetMaxDateForGainForSymbol(dateFrom, dateTo, symbolId); if (type == TradeTypesDTO.Long) { return(tradeDates.FirstOrDefault()); } else { return(tradeDates.Skip(1).FirstOrDefault()); } }