示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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());
            }
        }