public void FormatTimeSpanWithMinutePrecisionIsMinuteFormat()
        {
            var timespan = TimeSpan.FromMinutes(4);
            var actual   = RequestFormatter.Format(timespan);

            Assert.Equal(timespan.TotalMinutes.ToString(CultureInfo.InvariantCulture) + "m", actual);
        }
        public static LookupClient CreateNew(string host   = IQFeedDefault.Hostname, int port = IQFeedDefault.LookupPort,
                                             int timeoutMs = LookupDefault.TimeoutMs, int numberOfClients = 1, int bufferSize = LookupDefault.BufferSize)
        {
            // Common
            var requestFormatter    = new RequestFormatter();
            var lookupDispatcher    = new LookupDispatcher(host, port, bufferSize, IQFeedDefault.ProtocolVersion, numberOfClients, requestFormatter);
            var errorMessageHandler = new ErrorMessageHandler();
            var rawMessageHandler   = new RawMessageHandler(lookupDispatcher, errorMessageHandler, timeoutMs);

            // Historical
            var historicalDataRequestFormatter = new HistoricalRequestFormatter();
            var historicalRawFace = new HistoricalRawFacade(historicalDataRequestFormatter, rawMessageHandler);
            var historicalFacade  = new HistoricalFacade(
                historicalDataRequestFormatter,
                lookupDispatcher,
                errorMessageHandler,
                new HistoricalMessageHandler(),
                historicalRawFace,
                timeoutMs
                );

            // News
            var newsFacade = new NewsFacade();

            // Symbol
            var symbolFacade = new SymbolFacade(new MarketSymbolDownloader(), new MarketSymbolReader(), new ExpiredOptionDownloader(), new ExpiredOptionReader());

            // Chains
            var chainsFacade = new ChainsFacade(new ChainsRequestFormatter(), new ChainsMessageHandler(), lookupDispatcher, errorMessageHandler, timeoutMs);

            return(new LookupClient(lookupDispatcher, historicalFacade, newsFacade, symbolFacade, chainsFacade));
        }
        public void FormatTimeSpanWithSecondPrecisionIsSecondFormat()
        {
            var timespan = TimeSpan.FromSeconds(3);
            var actual   = RequestFormatter.Format(timespan);

            Assert.Equal(timespan.TotalSeconds.ToString(CultureInfo.InvariantCulture) + "s", actual);
        }
        public void FormatTimeSpanWithMillisecondPrecisionIsUnquantifiedFormat()
        {
            var timespan = TimeSpan.FromMilliseconds(1500);
            var actual   = RequestFormatter.Format(timespan);

            Assert.Equal(timespan.TotalMilliseconds.ToString(CultureInfo.InvariantCulture), actual);
        }
Exemple #5
0
 public ToStringRequestBuilder AppendPrice(String key, String value)
 {
     if (value != null)
     {
         AppendKeyValue(key, RequestFormatter.FormatPrice(value));
     }
     return(this);
 }
        /*
         * Pobiera jako parametr wspolrzedne urzytkownika korzystajacego z aplikacji oraz klucz API
         * ustawia obecna droge liczona w czasie oraz dystancie od wybranego parkingu "this", zwraca obiekt z API Google
         *
         * */
        public DistanceMatrixObject distanceFromUserLocation(Location location, string path)
        {
            string origin               = RequestFormatter.geometryLocationFormatter(location.lat, location.lng);
            string destination          = RequestFormatter.geometryLocationFormatter(this.GpsLat, this.GpsLng);
            DistanceMatrixObject result = GoogleMapsClient.GetDistanceMatrixAsync(origin, destination, path).Result;

            this.DurationToUserPlace = result.Rows[0].Elements[0].Duration.Value;
            this.DistanceToUserPlace = result.Rows[0].Elements[0].Distance.Value;
            return(result);
        }
        public static LookupClient CreateNew(
            string host,
            int port,
            int numberOfClients,
            TimeSpan timeout,
            int bufferSize)
        {
            // Common
            var requestFormatter         = new RequestFormatter();
            var lookupDispatcher         = new LookupDispatcher(host, port, bufferSize, IQFeedDefault.ProtocolVersion, numberOfClients, requestFormatter);
            var exceptionFactory         = new ExceptionFactory();
            var lookupMessageFileHandler = new LookupMessageFileHandler(lookupDispatcher, exceptionFactory, timeout);
            var historicalMessageHandler = new HistoricalMessageHandler();

            // Historical
            var historicalDataRequestFormatter = new HistoricalRequestFormatter();
            var historicalFileFacade           = new HistoricalFileFacade(historicalDataRequestFormatter, lookupMessageFileHandler);
            var historicalFacade = new HistoricalFacade(
                historicalDataRequestFormatter,
                lookupDispatcher,
                exceptionFactory,
                historicalMessageHandler,
                historicalFileFacade,
                timeout
                );

            // News
            var newsFacade = new NewsFacade(
                new NewsRequestFormatter(),
                lookupDispatcher,
                exceptionFactory,
                new NewsMessageHandler(),
                timeout);

            // Symbol
            var symbolFacade = new SymbolFacade(
                new SymbolRequestFormatter(),
                lookupDispatcher,
                exceptionFactory,
                new SymbolMessageHandler(),
                new MarketSymbolDownloader(),
                new MarketSymbolReader(),
                new ExpiredOptionDownloader(),
                new ExpiredOptionReader(),
                timeout);

            // Chains
            var chainsFacade = new ChainsFacade(new ChainsRequestFormatter(), new ChainsMessageHandler(), lookupDispatcher, exceptionFactory, timeout);

            return(new LookupClient(lookupDispatcher, historicalFacade, newsFacade, symbolFacade, chainsFacade));
        }
Exemple #8
0
 public void Should_Format_Price_Given_String_Value()
 {
     Assert.AreEqual("0.0", RequestFormatter.FormatPrice("0"));
     Assert.AreEqual("0.0", RequestFormatter.FormatPrice("0.0"));
     Assert.AreEqual("1.0", RequestFormatter.FormatPrice("1"));
     Assert.AreEqual("1.0", RequestFormatter.FormatPrice("1.0"));
     Assert.AreEqual("1.0", RequestFormatter.FormatPrice("1.000"));
     Assert.AreEqual("-1.0", RequestFormatter.FormatPrice("-1"));
     Assert.AreEqual("-1.0", RequestFormatter.FormatPrice("-1.0"));
     Assert.AreEqual("-1.0", RequestFormatter.FormatPrice("-1.000"));
     Assert.AreEqual("0.3", RequestFormatter.FormatPrice("0.3"));
     Assert.AreEqual("-0.3", RequestFormatter.FormatPrice("-0.3"));
     Assert.AreEqual("10000.0", RequestFormatter.FormatPrice("10000"));
     Assert.AreEqual("-10000.0", RequestFormatter.FormatPrice("-10000"));
     Assert.AreEqual("99999999999999999999999999.99999999999999999999999", RequestFormatter.FormatPrice("99999999999999999999999999.99999999999999999999999"));
     Assert.AreEqual("-99999999999999999999999999.99999999999999999999999", RequestFormatter.FormatPrice("-99999999999999999999999999.99999999999999999999999"));
 }