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); }
private decimal GetTradeRate(string stockCode, TradeVector tradeVector) { if (stockCode.StartsWith("6")) { return(0.005m); } if (tradeVector == TradeVector.Sell) { return(0.005m); } return(0m); }
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); } } }