Example #1
0
 public AccountTradeModel(IAccountTradeEntity entity)
 {
     if (entity != null)
     {
         TradeId     = entity.TradeId;
         AccountId   = entity.AccountId;
         EntryPrice  = entity.EntryPrice;
         EntryDate   = entity.EntryDate;
         Direction   = entity.Direction;
         CloseDate   = entity.CloseDate;
         SharesCount = entity.SharesCount;
         ClosePrice  = entity.ClosePrice;
     }
 }
Example #2
0
        private decimal CalculateTradeAmount(IAccountTradeEntity entity)
        {
            decimal result;

            if (entity.Direction == TradeDirection.Long)
            {
                result = Math.Round((entity.ClosePrice - entity.EntryPrice) * entity.SharesCount, 2);
            }
            else
            {
                result = Math.Round((entity.EntryPrice - entity.ClosePrice) * entity.SharesCount, 2);
            }
            return(result);
        }