Example #1
0
        public void Download_two_symbols()
        {
            var key    = ConfigurationManager.AppSettings["dukascopy"];
            var date   = new DateTime(2019, 05, 01);
            var market = new ProviderModel
            {
                Active     = true,
                Name       = "Dukascopy",
                Provider   = "dukascopy",
                LastDate   = date,
                Resolution = Resolution.Daily,
                ApiKey     = key
            };

            market.Symbols.Add(new SymbolModel("EURUSD", "Dukascopy", SecurityType.Forex));
            market.Symbols.Add(new SymbolModel("GBPUSD", "Dukascopy", SecurityType.Forex));

            // Dwonload symbol and update list
            using IProvider provider = ProviderFactory.CreateProvider(market.Provider, _settings);
            provider.GetMarketData(market);

            Assert.IsTrue(market.Active);
            Assert.AreEqual(date.AddDays(1), market.LastDate);
            Assert.AreEqual(78, market.Symbols.Count);
            Assert.AreEqual(2, market.Symbols.Where(m => m.Active).Count());
            Assert.IsTrue(File.Exists(Path.Combine(_forexFolder, "daily", "eurusd.zip")));
            Assert.IsTrue(File.Exists(Path.Combine(_forexFolder, "daily", "gbpusd.zip")));
        }
Example #2
0
        public void Download_invalid_symbol()
        {
            var utcStart = new DateTime(2019, 05, 01, 0, 0, 0, DateTimeKind.Utc);
            var date     = utcStart.ToLocalTime();
            var market   = new ProviderModel
            {
                Active     = true,
                Name       = "Dukascopy",
                Provider   = "dukascopy",
                LastDate   = date,
                Resolution = Resolution.Daily
            };

            market.Symbols.Add(new SymbolModel("noname", "Dukascopy", SecurityType.Forex));

            // Dwonload symbol and update list
            using IProvider provider = ProviderFactory.CreateProvider(market.Provider, _settings);
            Assert.IsNotNull(provider);

            provider.GetMarketData(market);
            Assert.IsFalse(market.Active);
            Assert.AreEqual(market.LastDate, date);
            Assert.AreEqual(78, market.Symbols.Count);
            Assert.AreEqual(0, market.Symbols.Where(m => m.Active).Count());
        }
    public string RegisterProvider(List <string> arguments)
    {
        try
        {
            var type         = arguments[0];
            var id           = arguments[1];
            var energyOutput = double.Parse(arguments[2]);

            switch (type)
            {
            case "Solar":
                this.providers.Add(id, ProviderFactory.CreateProvider(type, id, energyOutput));
                break;

            case "Pressure":
                this.providers.Add(id, ProviderFactory.CreateProvider(type, id, energyOutput));
                break;
            }

            return($"Successfully registered {type} Provider - {id}");
        }
        catch (ArgumentException ae)
        {
            return(ae.Message);
        }
    }
Example #4
0
        public void Download_yesterday()
        {
            var      key    = ConfigurationManager.AppSettings["dukascopy"];
            DateTime today  = DateTime.Today;
            var      market = new ProviderModel
            {
                Active     = true,
                Name       = "Dukascopy",
                Provider   = "dukascopy",
                LastDate   = today.AddDays(-1),
                Resolution = Resolution.Second,
                ApiKey     = key
            };

            market.Symbols.Add(new SymbolModel("EURUSD", "Dukascopy", SecurityType.Forex));

            // Dwonload symbol and update list
            using IProvider provider = ProviderFactory.CreateProvider(market.Provider, _settings);
            provider.GetMarketData(market);

            Assert.IsTrue(market.Active);
            Assert.AreEqual(today, market.LastDate);
            Assert.AreEqual(78, market.Symbols.Count);
            Assert.AreEqual(1, market.Symbols.Where(m => m.Active).Count());
        }
    public string RegisterProvider(List <string> arguments)
    {
        Provider provider = ProviderFactory.CreateProvider(arguments);

        this.providers.Add(provider);
        return($"Successfully registered {provider.GetType().Name.Replace("Provider", "")} Provider - {provider.Id}");
    }
Example #6
0
        public void Download_today()
        {
            DateTime today  = DateTime.Today;
            var      market = new ProviderModel
            {
                Active     = true,
                Name       = "Fxcm",
                Provider   = "fxcm",
                LastDate   = today,
                Resolution = Resolution.Minute,
                Access     = _access,
                Login      = _user,
                Password   = _pass
            };

            market.Symbols.Add(new SymbolModel("EURUSD", "fxcm", SecurityType.Forex));

            using IProvider provider = ProviderFactory.CreateProvider(market.Provider, _settings);
            provider.GetMarketData(market);

            Assert.IsFalse(market.Active);
            Assert.AreEqual(today, market.LastDate);
            Assert.AreEqual(75, market.Symbols.Count);
            Assert.AreEqual(1, market.Symbols.Where(m => m.Active).Count());
        }
Example #7
0
        public void Download_one_symbol(Resolution resolution, string filename)
        {
            var      date    = new DateTime(2019, 05, 01);
            DateTime nextDay = date.AddDays(1);
            var      market  = new ProviderModel
            {
                Active     = true,
                Name       = "Fxcm",
                Provider   = "fxcm",
                LastDate   = date,
                Resolution = resolution,
                Access     = _access,
                Login      = _user,
                Password   = _pass
            };

            market.Symbols.Add(new SymbolModel("EURUSD", "fxcm", SecurityType.Forex));

            using IProvider provider = ProviderFactory.CreateProvider(market.Provider, _settings);
            provider.GetMarketData(market);

            Assert.IsTrue(market.Active);
            Assert.AreEqual(nextDay, market.LastDate);
            Assert.AreEqual(75, market.Symbols.Count);
            Assert.AreEqual(1, market.Symbols.Where(m => m.Active).Count());
            Assert.IsTrue(File.Exists(Path.Combine(_forexFolder, resolution.ResolutionToLower(), filename)));
        }
Example #8
0
        public void Download_one_symbol()
        {
            var utcStart = new DateTime(2019, 05, 01, 0, 0, 0, DateTimeKind.Utc);
            var date     = utcStart.ToLocalTime();
            var market   = new ProviderModel
            {
                Active     = true,
                Name       = "Dukascopy",
                Provider   = "dukascopy",
                LastDate   = date,
                Resolution = Resolution.Daily
            };

            market.Symbols.Add(new SymbolModel("EURUSD", "Dukascopy", SecurityType.Forex));

            // Dwonload symbol and update list
            using IProvider provider = ProviderFactory.CreateProvider(market.Provider, _settings);
            provider.GetMarketData(market);

            Assert.IsTrue(market.Active);
            Assert.AreEqual(date.AddDays(1), market.LastDate);
            Assert.AreEqual(78, market.Symbols.Count);
            Assert.AreEqual(1, market.Symbols.Where(m => m.Active).Count());
            Assert.IsTrue(File.Exists(Path.Combine(_forexFolder, "daily", "eurusd.zip")));
        }
Example #9
0
        internal ParseResult ParseExpression(Expression expression)
        {
            var base1 = ProviderFactory.CreateProvider(dc.dbconn(string.Empty).Reader.DatabaseType).CreateParser();

            base1.ElementType = _elementType;
            base1.Parse(expression);
            return(base1.Result);
        }
    public string RegisterProvider(List <string> arguments)
    {
        var provider = providerFactory.CreateProvider(arguments);

        providers.Add(provider);

        return($"Successfully registered {arguments[0]} Provider - {arguments[1]}");
    }
Example #11
0
    public string RegisterProvider(List <string> arguments)
    {
        Provider provider = factoryProvider.CreateProvider(arguments);

        providers.Add(provider);

        return($"Successfully registered {provider.Type} Provider - {provider.Id}");
    }
Example #12
0
    public string RegisterProvider(List <string> arguments)
    {
        var provider = providerFactory.CreateProvider(arguments);
        var type     = arguments[0];
        var id       = arguments[1];
        var result   = $"Successfully registered {provider.Type} Provider - {provider.Id}";

        return(result);
    }
Example #13
0
        public void Login()
        {
            // Act
            using IProvider provider = ProviderFactory.CreateProvider(_broker.Provider, _settings);
            Assert.IsNotNull(provider);

            provider.Login(_broker);
            provider.Logout();
        }
Example #14
0
    public string RegisterProvider(List <string> arguments)
    {
        var providerFactory = new ProviderFactory();
        var provider        = providerFactory.CreateProvider(arguments);

        this.providers.Add(provider);

        return($"Successfully registered {arguments[0]} Provider - {provider.Id}");
    }
Example #15
0
        public void ShouldInstantiateSupportedProviders()
        {
            var factory  = new ProviderFactory(_authenticator, _blobCache);
            var provider = factory.CreateProvider(new ProviderParameters {
                Type = ProviderType.Local
            });

            provider.Should().NotBeNull();
            provider.Name.Should().Be(ProviderType.Local.ToString());
        }
Example #16
0
    public string RegisterProvider(List <string> arguments)
    {
        Provider provider = providerFactory.CreateProvider(arguments);
        string   id       = arguments[1];

        providers.Add(id, provider);

        result = $"Successfully registered {arguments[0]} Provider - {id}";
        return(result);
    }
Example #17
0
        /// <summary>
        /// See <see cref="M:Microsoft.Practices.RecipeFramework.IAction.Execute"/>.
        /// </summary>
        public override void Execute()
        {
            CodeDomProvider provider = this.codeProvider ?? ProviderFactory.CreateProvider(this.language);

            CodeGeneratorOptions options = new CodeGeneratorOptions();

            using (StringWriter tw = new StringWriter(CultureInfo.InvariantCulture))
            {
                provider.GenerateCodeFromCompileUnit(this.compileUnit, tw, options);
                this._class = tw.ToString();
            }
        }
Example #18
0
 public string RegisterProvider(List <string> arguments)
 {
     try
     {
         var provider = ProviderFactory.CreateProvider(arguments);
         this.providers[provider.Id] = provider;
         return($"Successfully registered {provider.Type} Provider - {provider.Id}");
     }
     catch (Exception e)
     {
         return(e.Message);
     }
 }
Example #19
0
 public string RegisterProvider(List <string> arguments)
 {
     try
     {
         IProvider provider = providerFactory.CreateProvider(arguments);
         providers.Add(provider);
     }
     catch (TargetInvocationException tie)
     {
         return(string.Format("Provider is not registered, because of it's {0}", tie.InnerException.Message));
     }
     return($"Successfully registered {arguments[0]} Provider - {arguments[1]}");
 }
    public string RegisterProvider(List <string> arguments)
    {
        try
        {
            provFact.CreateProvider(arguments);
        }
        catch (ArgumentException exception)
        {
            return(exception.Message);
        }

        return($"Successfully registered {arguments[0]} Provider - {arguments[1]}");
    }
Example #21
0
 public string RegisterProvider(List <string> arguments)
 {
     try
     {
         Provider newProvider = ProviderFactory.CreateProvider(arguments);
         this.providers.Add(newProvider);
         return($"Successfully registered {newProvider.Type} Provider - {newProvider.Id}");
     }
     catch (ArgumentException ex)
     {
         return($"Provider is not registered, because of it's {ex.Message}");
     }
 }
Example #22
0
 public string RegisterProvider(List <string> arguments)
 {
     try
     {
         var provider = ProviderFactory.CreateProvider(arguments);
         this.providers.Add(provider);
         return($"Successfully registered {provider.GetType()} Provider - {provider.Id}\n");
     }
     catch (Exception ex)
     {
         return(ex.Message + Environment.NewLine);
     }
 }
Example #23
0
 public string RegisterProvider(List <string> arguments)
 {
     try
     {
         var provider = providerFactory.CreateProvider(arguments);
         providers.Add(provider.Id, provider);
         return($"Successfully registered {provider.Type} Provider - {provider.Id}");
     }
     catch (ArgumentException argEx)
     {
         return($"Provider is not registered, because of it's {argEx.Message}");
     }
 }
 public string RegisterProvider(List <string> arguments)
 {
     try
     {
         var provider = providerFactory.CreateProvider(arguments);
         allProviders.Add(provider);
         return($"Successfully registered {provider.Type} Provider - {provider.Id}");
     }
     catch (ArgumentException ex)
     {
         return(ex.Message);
     }
 }
Example #25
0
 public string RegisterProvider(List <string> arguments)
 {
     try
     {
         var provider = ProviderFactory.CreateProvider(arguments);
         this.Providers[arguments[1]] = provider;
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
     return($"Successfully registered {arguments[0]} Provider - {arguments[1]}");
 }
Example #26
0
 public string RegisterProvider(List <string> arguments)
 {
     try
     {
         Provider provider = ProviderFactory.CreateProvider(arguments);
         this.providers.Add(arguments[1], provider);
         return($"Successfully registered {arguments[0]} Provider - {arguments[1]}");
     }
     catch (ArgumentException ae)
     {
         return(ae.Message);
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionProperties"></param>
        public OpenConnectionForm(ConnectionProperties connectionProperties)
        {
            InitializeComponent();
            HandleCreated += OpenConnectionForm_HandleCreated;

            _stopwatch.Start();
            _timer.Enabled = true;

            var dbConnectionStringBuilder = new DbConnectionStringBuilder();

            dbConnectionStringBuilder.ConnectionString = connectionProperties.ConnectionString;
            object dataSourceObject;
            var    contains = dbConnectionStringBuilder.TryGetValue(ConnectionStringKeyword.DataSource, out dataSourceObject);
            object userId;

            dbConnectionStringBuilder.TryGetValue(ConnectionStringKeyword.UserId, out userId);
            var dataSource = (string)dataSourceObject;

            _textBox.Text         = $@"Connection name: {connectionProperties.ConnectionName}
Provider name: {connectionProperties.ProviderName}
{ConnectionStringKeyword.DataSource}: {dataSource}
{ConnectionStringKeyword.UserId}: {userId}";
            _connectionProperties = connectionProperties;
            Cursor = Cursors.AppStarting;

            if (_connectionProperties.Provider == null)
            {
                _connectionProperties.Provider = ProviderFactory.CreateProvider(_connectionProperties.ProviderName);
            }

            var connection = _connectionProperties.Provider.CreateConnection(connectionProperties.ConnectionString);

            _cancellationTokenSource = new CancellationTokenSource();

            var stopwatch = Stopwatch.StartNew();

            _task = Task.Factory.StartNew(() =>
            {
                var task = connection.OpenAsync(_cancellationTokenSource.Token);
                task.ContinueWith(t =>
                {
                    Duration = stopwatch.ElapsedTicks;

                    if (!_cancellationTokenSource.IsCancellationRequested)
                    {
                        connectionProperties.Connection = connection;
                        EndConnectionOpen(task.Exception);
                    }
                });
            });
        }
Example #28
0
 public string RegisterProvider(List <string> arguments)
 {
     try
     {
         Provider provider = providerFactory.CreateProvider(arguments);
         this.Providers.Add(provider);
         //return $"Successfully registered {provider.Type} Provider - {provider.Id}";
         return(string.Format(Messages.RegisterProviderMessage, provider.Type, provider.Id));
     }
     catch (ArgumentException e)
     {
         return(e.Message);
     }
 }
 public string RegisterProvider(List <string> arguments)
 {
     try
     {
         var provider = ProviderFactory.CreateProvider(arguments);
         this.providers.Add(provider);
         return($"Successfully registered {provider.GetType().Name.Replace("Provider", "")}" +
                $" Provider - {provider.Id}");
     }
     catch (ArgumentException e)
     {
         return(e.Message);
     }
 }
Example #30
0
 public string RegisterProvider(List <string> arguments)
 {
     try
     {
         Provider provider = providerFactory.CreateProvider(arguments);
         providers.Add(provider);
         string message = $"Successfully registered {provider.Type} Provider - {provider.Id}";
         return(message);
     }
     catch (ArgumentException argEx)
     {
         return(argEx.Message);
     }
 }