private async Task RetryTimeGappedMarkets(List <MarketQueryResponse> markets) { do { var mkQueries = new List <MarketQueryResponse>(markets); foreach (MarketQueryResponse mk in mkQueries) { bool opened = await BtrexData.TryOpenMarket(mk); if (opened) { markets.Remove(mk); } } if (markets.Count == 0) { break; } for (int i = 10; i > 0; i--) { Trace.Write(string.Format("\r ({0}) TimeGapped Markets (TradeFills->Candles), Retry in {1} seconds...\r", markets.Count, i)); Thread.Sleep(1000); } Trace.Write("\r \r"); } while (markets.Count > 0); }
public static async Task <List <MarketQueryResponse> > SubscribeMarketsList(List <string> deltas) { List <MarketQueryResponse> failedList = new List <MarketQueryResponse>(); var subList = deltas.Select(d => WSSharpTransport.HubProxy.Invoke("SubscribeToExchangeDeltas", d)).ToArray(); await Task.WhenAll(subList); foreach (string d in deltas) { var delta = "BTC-" + d; Trace.Write("\rSUBBING: " + delta + " \r"); await WSSharpTransport.HubProxy.Invoke("SubscribeToExchangeDeltas", delta); MarketQueryResponse marketQuery = await WSSharpTransport.HubProxy.Invoke <MarketQueryResponse>("QueryExchangeState", delta); marketQuery.MarketName = delta; bool opened = await BtrexData.TryOpenMarket(marketQuery); if (!opened) { failedList.Add(marketQuery); } } return(failedList); }