Пример #1
0
        /// <summary>
        /// Winnningses the over loosings.
        /// </summary>
        /// <param name="stock">The stock.</param>
        /// <returns></returns>
        private double WinningsOverLoosings(StockExchange stock)
        {
            var netEarnings = stock.Earnings != 0 ? (stock.Earnings - stock.TransactionCost) : 0;
            var reward      = 0.0;

            if (netEarnings > 0)
            {
                Winnings.Enqueue(netEarnings);
            }
            else
            {
                Loosings.Enqueue(netEarnings);
            }

            var totalWinnings = Winnings.ToList().Sum();
            var totalLoosings = Math.Abs(Loosings.ToList().Sum());

            if (totalLoosings > 0)
            {
                reward = totalWinnings / totalLoosings;
            }
            else
            {
                reward = totalWinnings;
            }

            return(Math.Round(reward, 2));
        }
Пример #2
0
        /// <summary>
        /// Calculates the specified stock.
        /// </summary>
        /// <param name="stock">The stock.</param>
        /// <returns></returns>
        public double Calculate(StockExchange stock)
        {
            var reward = 0.0;

            switch (Type)
            {
            case RewardCalculatorType.Earnings:
                reward = Earnings(stock);
                break;

            case RewardCalculatorType.EarningOverNetCapital:
                reward = EarningOverNetCapital(stock);
                break;

            case RewardCalculatorType.WinningsOverLoosings:
                reward = WinningsOverLoosings(stock);
                break;

            case RewardCalculatorType.AnnualRent:
                reward = AnnualRent(stock);
                break;

            default:
                break;
            }

            return(reward);
        }
Пример #3
0
 /// <summary>
 /// Return Earnings increment over net capital.
 /// </summary>
 /// <param name="stock">The stock.</param>
 /// <returns></returns>
 private double EarningOverNetCapital(StockExchange stock)
 {
     return((stock.Earnings - stock.TransactionCost) / stock.NetCapital);
 }
Пример #4
0
 /// <summary>
 /// Return the earning obtained
 /// remarks: Best performance but big error
 /// </summary>
 /// <param name="stock">The stock.</param>
 /// <returns></returns>
 private double Earnings(StockExchange stock)
 {
     return(stock.Earnings - stock.TransactionCost);
 }
Пример #5
0
 /// <summary>
 /// Winnningses the over loosings.
 /// </summary>
 /// <param name="stock">The stock.</param>
 /// <returns></returns>
 private double AnnualRent(StockExchange stock)
 {
     return(stock.AnnualRent);
 }