public static async Task <Market> FromAccessService(IExchangeAccessService exchangeAccessService, int exchangeId, string baseCurrency, string quoteCurrency) { //Ensure the exchange does exist. var availbleExchanges = exchangeAccessService.GetAvailableExchanges(); var exchange = availbleExchanges.Where(e => e.ExchangeId == exchangeId).SingleOrDefault(); if (exchange == null) { throw new ExchangeAccessDomainException($"Exchange not found. Exchange Id: {exchangeId}. \n" + $"Available exchanges can be found with function GetAvailableExchanges."); } //Ensure the market info is right. OrderBook orderBook = null; try { orderBook = await exchangeAccessService.GetMarketData(exchange.ExchangeId, baseCurrency, quoteCurrency); } catch (Exception ex) { throw new ExchangeAccessDomainException( $"There are errors when trying to get market data on exchange {exchange.ExchangeName} with currency pair {baseCurrency + quoteCurrency}.", ex); } return(new Market( Guid.NewGuid().ToString(), exchange, baseCurrency, quoteCurrency )); }
public LiveRoundtripExitOrderSubmittedIntegrationEventHandler(IExchangeAccessIntegrationEventService exchangeAccessIntegrationEventService, IMarketRepository marketRepository, IBalanceRepository balanceRepository, IExchangeAccessService exchangeAccessService) { _exchangeAccessIntegrationEventService = exchangeAccessIntegrationEventService ?? throw new ArgumentNullException(nameof(exchangeAccessIntegrationEventService)); _marketRepository = marketRepository ?? throw new ArgumentNullException(nameof(marketRepository)); _balanceRepository = balanceRepository ?? throw new ArgumentNullException(nameof(balanceRepository)); _exchangeAccessService = exchangeAccessService ?? throw new ArgumentNullException(nameof(exchangeAccessService)); }
public void CancelOrder(Account account, string orderId, IExchangeAccessService exchangeAccessService) { if (!exchangeAccessService.CancelOrder(account, this.Exchange.ExchangeId, orderId, this.BaseCurrency, this.QuoteCurrency).Result) { throw new ExchangeAccessDomainException($"There are errors when attempting to cancel order. Order Id: {orderId}, Exchange: {this.Exchange.ExchangeName}."); } }
public BacktesingTraceStartedIntegrationEventHandler( ICandleChartRepository candleChartRepository, IExchangeAccessIntegrationEventService exchangeAccessIntegrationEventService, IExchangeAccessService exchangeAccessService ) { this._candleChartRepository = candleChartRepository ?? throw new ArgumentNullException(nameof(candleChartRepository)); this._exchangeAccessIntegrationEventService = exchangeAccessIntegrationEventService ?? throw new ArgumentNullException(nameof(exchangeAccessIntegrationEventService)); this._exchangeAccessService = exchangeAccessService ?? throw new ArgumentNullException(nameof(exchangeAccessService)); }
public TraceDataRequestedIntegrationEventHandler(ICandleChartRepository candleChartRepository, IExchangeAccessIntegrationEventService exchangeAccessIntegrationEventService, IExchangeAccessService exchangeAccessService) { _candleChartRepository = candleChartRepository ?? throw new ArgumentNullException(nameof(candleChartRepository)); _exchangeAccessIntegrationEventService = exchangeAccessIntegrationEventService ?? throw new ArgumentNullException(nameof(exchangeAccessIntegrationEventService)); _exchangeAccessService = exchangeAccessService ?? throw new ArgumentNullException(nameof(exchangeAccessService)); }
public CandleChartsController(ExchangeAccessContext context, ICandleChartRepository candleChartRepository, IExchangeAccessService exchangeAccessService) { _context = context; _candleChartRepository = candleChartRepository ?? throw new ArgumentNullException(nameof(candleChartRepository)); this._exchangeAccessService = exchangeAccessService ?? throw new ArgumentNullException(nameof(exchangeAccessService)); }
public IEnumerable <Order> GetOpenOrdeer(Account account, IExchangeAccessService exchangeAccessService) { return(exchangeAccessService.GetOpenOrders(account, this.Exchange.ExchangeId).Result); }
public string CreateSellOrder(Balance balance, string baseCurrency, string quoteCurrency, decimal price, decimal quantity, IExchangeAccessService exchangeAccessService) { if (balance.ExchangeId != this.Exchange.ExchangeId) { throw new ExchangeAccessDomainException("The balance provided doesn't match the exchange this market on."); } if (balance.GetAvailableBalance(baseCurrency) < quantity) { throw new ExchangeAccessDomainException("The account's balances isn't efficient to create sell order."); } var orderId = exchangeAccessService.CreateSellOrder(balance.Account, balance.ExchangeId, baseCurrency, quoteCurrency, price, quantity).Result; if (orderId == null) { throw new ExchangeAccessDomainException("There are errors when attempting to create sell order."); } return(orderId); }
public MarketsController(ExchangeAccessContext context, IMarketRepository marketRepository, IExchangeAccessService exchangeAccessService) { _context = context; this._marketRepository = marketRepository ?? throw new ArgumentNullException(nameof(marketRepository)); this._exchangeAccessService = exchangeAccessService ?? throw new ArgumentNullException(nameof(exchangeAccessService)); }