/// <summary> /// Initialize <see cref="Trade"/> class. /// </summary> /// <param name="clientName">Client name.</param> public Trade(string clientName, IDigicoinBroker broker, TradeType type, int order, decimal value) { ClientName = clientName; Broker = broker; Type = type; Order = order; Value = value; }
/// <summary> /// Initialize <see cref="DigicoinBrokerSelector"/> class. /// </summary> /// <param name="brokers">Digicoin trading brokers.</param> public DigicoinBrokerSelector(IDigicoinBroker[] brokers) { if (brokers == null) { throw new ArgumentNullException("brokers"); } _brokers = new Dictionary<int, IDigicoinBrokerQuote>(); _brokers.Add(0, new DigicoinBrokerQuote(null, 0)); Initialize(brokers); }
/// <summary> /// Adds new trade to repository. /// </summary> /// <param name="clientName">Client name.</param> /// <param name="broker">Broker.</param> /// <param name="type">Trade type.</param> /// <param name="order">Trade order.</param> /// <param name="value">Trade value.</param> /// <exception cref="ArgumentException">Client name must be provided.</exception> /// <exception cref="ArgumentException">Broker must be provided.</exception> public void Add(string clientName, IDigicoinBroker broker, TradeType type, int order, decimal value) { if (string.IsNullOrWhiteSpace(clientName)) { throw new ArgumentException("Client name must be provided!"); } if (broker == null) { throw new ArgumentException("Broker must be provided!"); } var trade = new Trade(clientName, broker, type, order, value); _trades.Add(trade); }
/// <summary> /// Generate broker transactions report. /// </summary> /// <param name="broker">Broker.</param> /// <returns>Returns null when not broker trades.</returns> public int? BrokerTransactions(IDigicoinBroker broker) { var trades = _trades.GetAllBy(broker); if (trades != null && trades.Count() > 0) { int result = 0; foreach (var item in trades) { result += item.Order; } return result; } return null; }
private void Initialize(IDigicoinBroker[] brokers) { for (int i = 1 ; i <= 10 ; i++) { IDigicoinBrokerQuote quote = null; for (int b = 0 ; b < brokers.Length ; b++) { var q = brokers[b].GetQuote(i * 10); if (q.HasValue && (quote == null || quote.Value > q.Value)) { quote = new DigicoinBrokerQuote(brokers[b], q.Value); } } if (quote != null) { _brokers.Add(i * 10, quote); } } }
public void Initialize() { _brokerA = Substitute.For<IDigicoinBroker>(); _brokerB = Substitute.For<IDigicoinBroker>(); }
/// <summary> /// Initialize <see cref="DigicoinBrokerQuote"/> class. /// </summary> /// <param name="broker"></param> /// <param name="value"></param> public DigicoinBrokerQuote(IDigicoinBroker broker, decimal value) { Broker = broker; Value = value; }
/// <summary> /// Gets all trades of broker. /// </summary> /// <param name="broker">Broker.</param> /// <returns>All broker trades.</returns> public IEnumerable<ITrade> GetAllBy(IDigicoinBroker broker) { return _trades.Where(x => x.Broker == broker).OfType<ITrade>(); }