public async Task <ISpotExchangeFacade> CreateExchanges(ExchangeDTO exx) { ISpotExchangeFacade fac = null; if (exx.Name == ExchangeName.Binance.ToString() && this.exchanges.FirstOrDefault(x => x.ExchangeName == ExchangeName.Binance) != null) { UserExchangeSecretDTO secrets = await this.repoExchangeSecrets.GetByExchangeId(exx.ID); fac = new BinanceExchange(exx, secrets, logger); } else if (exx.Name == ExchangeName.HitBTC.ToString() && this.exchanges.FirstOrDefault(x => x.ExchangeName == ExchangeName.Binance) != null) { UserExchangeSecretDTO secrets = await this.repoExchangeSecrets.GetByExchangeId(exx.ID); fac = new HitBTCExchange(exx, secrets, logger); } else if (exx.Name == ExchangeName.KuCoin.ToString() && this.exchanges.FirstOrDefault(x => x.ExchangeName == ExchangeName.Binance) != null) { UserExchangeSecretDTO secrets = await this.repoExchangeSecrets.GetByExchangeId(exx.ID); fac = new KuCoinExchange(exx, secrets, logger); } if (fac != null) { this.exchanges.Add(fac); } else { fac = this.exchanges.FirstOrDefault(x => x.ExchangeName.ToString() == exx.Name); } return(fac); }
public async Task <ISpotExchangeFacade> GetExchange(ExchangeDTO exx) { ISpotExchangeFacade ex = this.exchanges.FirstOrDefault(x => x.ExchangeName.ToString() == exx.Name); if (ex != null) { return(ex); } else { return(await this.CreateExchanges(exx)); } }
public LimitArbitrage4Strategy(LimitArbitrageStrategy4SettingsDTO settings, ISpotExchangeFacade exchangefacade1, ISpotExchangeFacade exchangefacade2, StrategyLogService strategyLogService, SemaphoreSlim baseSemaphore, SemaphoreSlim quoteSemaphore, SemaphoreSlim concurrentSemaphores) { this.IsRunning = false; this.Type = StrategyType.LimitArbitrage4; this.settings = settings; this.exchangefacade1 = exchangefacade1; this.exchangefacade2 = exchangefacade2; this.symbol = settings.Symbol; this.strategyLogService = strategyLogService; this.baseSemaphore = baseSemaphore; this.quoteSemaphore = quoteSemaphore; this.concurrentSemaphores = concurrentSemaphores; this.Name = this.settings.StrategyName; }
public void DisposeOf(ISpotExchangeFacade fac) { this.exchanges.Remove(fac); fac.Dispose(); GC.SuppressFinalize(this); }