Beispiel #1
0
        private decimal GetCommission(string stockCode, decimal amount, TradeVector tradeVector)
        {
            var commission = Math.Min(5, amount * _serviceRate);
            var trade      = amount * GetTradeRate(stockCode, tradeVector);

            if (trade > 0)
            {
                trade = Math.Min(5, trade);
            }
            return(commission + trade);
        }
Beispiel #2
0
 private decimal GetTradeRate(string stockCode, TradeVector tradeVector)
 {
     if (stockCode.StartsWith("6"))
     {
         return(0.005m);
     }
     if (tradeVector == TradeVector.Sell)
     {
         return(0.005m);
     }
     return(0m);
 }
Beispiel #3
0
 public void Trade(Account account, StockEntity daily, TradeVector tradeVector)
 {
     if (tradeVector == TradeVector.Buy)
     {
         if (account.HoldQty == 0)
         {
             account.Buy(daily, (int)(account.Balance / daily.Close.Value), daily.Close.Value);
         }
     }
     else
     {
         if (account.HoldQty > 0)
         {
             account.Sell(daily, account.HoldQty, daily.Close.Value);
         }
     }
 }