mathpaquette / IQFeed.CSharpApiClient

IQFeed.CSharpApiClient is fastest and the most well-designed C# DTN IQFeed socket API connector available
MIT License
120 stars 43 forks source link

appsettings.json in .net core 3 #132

Closed SuperDaveOsbourne closed 2 years ago

SuperDaveOsbourne commented 2 years ago

System.ComponentModel.Win32Exception: 'The system cannot find the file specified.' at IQFeedLauncher.Start(); This is in .NET Core 3.1. VS 2019

{ "AppSettings": { "IQConnect": { "login": "Bob", "password": "myPassword", "product_id": "MyId", "product_version": "1", "connectionTimeOutMs": "30", "retry": "50" } } }

using IQFeed.CSharpApiClient;
using IQFeed.CSharpApiClient.Lookup;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            var configuration = new ConfigurationBuilder()
                .AddJsonFile("appsettings.json", false, true)
                .Build();

            var IQCONNECT_LOGIN = configuration.GetSection("AppSettings:IQConnect:login").Value;
            var IQCONNECT_PASSWORD = configuration.GetSection("AppSettings:IQConnect:password").Value;
            var IQCONNECT_PRODUCT_ID = configuration.GetSection("AppSettings:IQConnect:product_id").Value;
            var IQCONNECT_PRODUCT_VERSION = configuration.GetSection("AppSettings:IQConnect:product_version").Value;
            //var timeOutMs = int.Parse(configuration.GetSection("AppSettings:IQConnect:connectionTimeOutMs").Value);
            //var retry = int.Parse(configuration.GetSection("AppSettings:IQConnect:retry").Value);

            Environment.SetEnvironmentVariable("IQCONNECT_LOGIN", IQCONNECT_LOGIN);
            Environment.SetEnvironmentVariable("IQCONNECT_PASSWORD", IQCONNECT_PASSWORD);
            Environment.SetEnvironmentVariable("IQCONNECT_PRODUCT_ID", IQCONNECT_PRODUCT_ID);
            Environment.SetEnvironmentVariable("IQCONNECT_PRODUCT_VERSION", IQCONNECT_PRODUCT_VERSION);

            foreach (DictionaryEntry dic in Environment.GetEnvironmentVariables())
            {
                if (dic.Key.ToString().Contains("IQCONNECT"))
                {
                    Console.WriteLine("  {0} = {1}", dic.Key, dic.Value);
                }
            }

            IQFeedLauncher.Start();
            var lookupClient = LookupClientFactory.CreateNew();
            lookupClient.Connect();
            var tickMessages = lookupClient.Historical.GetHistoryTickDatapointsAsync("AAPL", 100);
        }

    }
}
mathpaquette commented 2 years ago

really?

mathpaquette commented 2 years ago

also I wanted to make sure to test properly on Linux and remove incompatible code.

SuperDaveOsbourne commented 2 years ago

Sorry I am confused. Maybe I am stuck on stupid as I have been at it straight for a few days without sleep. Please let me know as sometimes I am. Not sure why we would get a file not found error at the packages inception? Its not the environments settings as they are there as shown in the loop as have loaded.

Also adding the parameters to the IQFeedLauncher.Start(parms); doesn't seem to work either with intellisence suggesting that they should. It just reverts to reporting cant find the values in the user environment variables or app.config. example

mathpaquette commented 2 years ago

@SuperDaveOsbourne sorry, whats the outcome ?

SuperDaveOsbourne commented 2 years ago

I updated the repo to .Net 6 using VS 2019 preview. Fixed the environmental variables by hard coding them for the moment. Directly there are 453 Warnings and 3 messages. 99% of these are about nulls.

Warning CS8600 Converting null literal or possible null value to non-nullable type.

One that I fixed was updating the Webclient. to HttpClient. But it compiles and works. I am on the trial which I guess doesn't work on the API until you are already fully subscribed(?) so just get a status = waitingforactivation.

Anyway more interested in the snapshot feature which I left a message in the gitter forum.