public void Login() { try { var config = new ConfigurationBuilder().AddJsonFile("IGSettings.json").Build(); string env = config["environment"]; string userName = config["username"]; string password = config["password"]; string apiKey = config["apikey"]; IgRestApiClient igRestApiClient = new IgRestApiClient(env); var ar = new AuthenticationRequest { identifier = userName, password = password, encryptedPassword = false }; AuthenticationResponse response = igRestApiClient.SecureAuthenticate(ar, apiKey).Result; if ((response != null) && (response.accounts.Count > 0)) { foreach (var account in response.accounts) { //Accounts.Add(igAccount); } } } catch (Exception ex) { string a = ex.Message; } }
public DemoDotNetClientForm() { InitializeComponent(); _accountIds = new Dictionary <string, string>(); _accountsStk = new SubscribedTableKey(); EnableCommandButtons(false); _watchlists = new List <Watchlist>(); _watchlistMarkets = new List <WatchlistMarket>(); _orders = new List <WorkingOrder>(); _positions = new List <OpenPosition>(); cbPositions.Enabled = false; cbOrders.Enabled = false; cbWatchlistItems.Enabled = false; _igRestApiClient = new IgRestApiClient(); _igStreamApiClient = new IGStreamingApiClient(); _APIKey = "8d341413c2eae2c35bb5b47a594ef08ae18cb3b7"; // *** TODO ENTER YOUR API KEY HERE *** passwordTextbox.Text = "Kotik0483"; // *** TODO Enter your password here *** identifierTextbox.Text = "ksbitlsoftdemo"; // *** TODO Enter your user name here *** }
public void InitialiseViewModel() { var igWebApiConnectionConfig = ConfigurationManager.GetSection("IgWebApiConnection") as NameValueCollection; var env = igWebApiConnectionConfig["environment"]; var smartDispatcher = (SmartDispatcher)SmartDispatcher.GetInstance(); smartDispatcher.SetViewModel(ApplicationViewModel.getInstance()); IgRestApiClient = new IgRestApiClient(env, igWebApiConnectionConfig["account"], smartDispatcher); }
public void InitialiseViewModel() { var igWebApiConnectionConfig = ConfigurationManager.GetSection("IgWebApiConnection") as NameValueCollection; string env = igWebApiConnectionConfig["environment"]; SmartDispatcher smartDispatcher = (SmartDispatcher)SmartDispatcher.getInstance(); smartDispatcher.setViewModel(ApplicationViewModel.getInstance()); igRestApiClient = new IgRestApiClient(env, smartDispatcher); igStreamApiClient = new IGStreamingApiClient(); }
public void Connect(string username, string password, string apiKey, IgRestApiClient igRestApiClient) { if (Config.Settings.ContainsKey("PUBLISHING_START_TIME")) { _startTime = Config.ParseDateTimeLocal(Config.Settings["PUBLISHING_START_TIME"]); } if (Config.Settings.ContainsKey("PUBLISHING_STOP_TIME")) { _stopTime = Config.ParseDateTimeLocal(Config.Settings["PUBLISHING_STOP_TIME"]); } if (Config.Settings.ContainsKey("SAMPLING_MS")) { _samplingMs = int.Parse(Config.Settings["SAMPLING_MS"]); } _testReplayFiles.Clear(); _igRestApiClient = igRestApiClient; if (Config.Settings.ContainsKey("DELETEDB")) { _deleteDB = true; _testReplayFiles.Add(null); // Add a fake element to trigger the replay from db _deleter = new CassandraConnection(); _reader = _deleter; _readerExpectedResults = _deleter; _hasExpectedResults = true; } else { if (Config.Settings["REPLAY_MODE"] == "DB") { _testReplayFiles.Add(null); // Add a fake element to trigger the replay from db _reader = new CassandraConnection(); } else if (Config.Settings["REPLAY_MODE"] == "CSV") { if (Config.Settings.ContainsKey("REPLAY_CSV")) { _testReplayFiles = Config.Settings["REPLAY_CSV"].Split(';').ToList(); if (_reader != null) { _reader.CloseConnection(); } _reader = new CsvReader(_testReplayFiles[0]); } else { _reader = new CsvReader(null); } } else { _reader = null; } _hasExpectedResults = Config.TestReplayEnabled || Config.CalibratorEnabled; if (_hasExpectedResults) { if (Config.Settings.ContainsKey("EXPECTEDRESULTS_CSV")) { _readerExpectedResults = new CsvReader(Config.Settings["EXPECTEDRESULTS_CSV"]); } else { _readerExpectedResults = new CsvReader(_testReplayFiles[0]); } } } _numId = 1; _numRef = 1; }
public void InitialiseViewModel() { igRestApiClient = new IgRestApiClient(); igStreamApiClient = new IGStreamingApiClient(); }
public IGConnection() { _igRestApiClient = new IgRestApiClient(); _apiStreamingClient = new IGTradingStreamingClient(); }
public async void Connect(string username, string password, string apikey, IgRestApiClient igRestApiClient) { if (String.IsNullOrEmpty(apikey) || String.IsNullOrEmpty(password) || String.IsNullOrEmpty(username)) { Log.Instance.WriteEntry("Please enter API key, Password and Username", EventLogEntryType.Error); return; } _igRestApiClient = igRestApiClient; // use v1 login... var ar = new AuthenticationRequest(); ar.identifier = username; ar.password = password; //log in... var authenticationResponse = await _igRestApiClient.SecureAuthenticate(ar, apikey); if (authenticationResponse && (authenticationResponse.Response != null) && (authenticationResponse.Response.accounts != null)) { if (authenticationResponse.Response.accounts.Count > 0) { Log.Instance.WriteEntry(JsonConvert.SerializeObject(authenticationResponse, Formatting.Indented), EventLogEntryType.Information); Log.Instance.WriteEntry("Logged in, current account: " + authenticationResponse.Response.currentAccountId, EventLogEntryType.Information); _currentAccount = authenticationResponse.Response.currentAccountId; ConversationContext context = _igRestApiClient.GetConversationContext(); Log.Instance.WriteEntry("establishing streaming data connection", EventLogEntryType.Information); if ((context != null) && (authenticationResponse.Response.currentAccountId != null) && (authenticationResponse.Response.lightstreamerEndpoint != null)) { if (_igStreamApiClient != null) { _igStreamApiClient.ConnectionClosed = ConnectionClosed; var connectionEstablished = _igStreamApiClient.Connect(authenticationResponse.Response.currentAccountId, context.cst, context.xSecurityToken, context.apiKey, authenticationResponse.Response.lightstreamerEndpoint); if (connectionEstablished) { Log.Instance.WriteEntry("streaming data connection established", EventLogEntryType.Information); } else { Log.Instance.WriteEntry("streaming data connection could NOT be established", EventLogEntryType.Error); } } } else { Log.Instance.WriteEntry("Could not establish streaming data connection.", EventLogEntryType.Error); } } else { Log.Instance.WriteEntry("no accounts", EventLogEntryType.Error); } } else { Log.Instance.WriteEntry("Authentication Rest Response error : " + authenticationResponse.StatusCode, EventLogEntryType.Error); } }