public static async Task <TradeEntrySubscription> Start(MarketProviderConfiguration forProvider, String forTradingPair)
        {
            TradeEntrySubscription instance = new TradeEntrySubscription();

            instance._Crawler = new TradingEntryCrawler(forProvider, forTradingPair);

            CancellationTokenSource timeOutProvider = new CancellationTokenSource(TimeSpan.FromSeconds(5));

            await instance._Crawler.Initiate(timeOutProvider.Token);

            if (timeOutProvider.IsCancellationRequested)
            {
                throw new WebSocketException("could not start the web socket connection");
            }

            return(instance);
        }
예제 #2
0
        public TradingEntryCrawler(MarketProviderConfiguration forProvider, String forTradingPair)
        {
            if (forProvider == null || forProvider.TradesConfiguration == null || !forProvider.TradesConfiguration.IsValid())
            {
                throw new MissingMemberException("trades are not configured well");
            }

            if (String.IsNullOrEmpty(forTradingPair))
            {
                throw new MissingMemberException("subscription trading pair is missing");
            }

            _Configuration = forProvider;
            _TradingPair   = forTradingPair;

            _Client = new ClientWebSocket();
        }