public void Run() { // Configure your credentials for IQConnect in user environment variable or app.config !!! // Check the documentation for more information. // Run IQConnect launcher IQFeedLauncher.Start(); // Connect the LookupClient created from the constructor LookupClient.Connect(); // Add 100 symbols to the concurrent queue foreach (var symbol in MarketData.GetSymbols().Skip(100).Take(200)) { Symbols.Enqueue(symbol); } // Download data for all added symbols var sw = Stopwatch.StartNew(); Start(); sw.Stop(); // Count the total of daily messages received var messagesFetched = 0; foreach (var dailyMessages in _dailyMessagesBySymbol) { messagesFetched += dailyMessages.Value.Count; } Console.WriteLine($"\nFetched {messagesFetched} Daily messages for {_dailyMessagesBySymbol.Count} stocks in {sw.Elapsed.TotalMilliseconds} ms."); }
public RealTimeMarketDataService() { IQFeedLauncher.Start("MY_LOGIN", "MY_PASSWORD", "MY_PRODUCT_ID", "MY_PRODUCT_VERSION"); _level1Client = Level1ClientFactory.CreateNew(); _level1Client.Connect(); }
public async Task RunAsync() { // ************************************* // Step 1 - !!! Configure your credentials for IQConnect in user environment variable or app.config !!! // Check the documentation for more information. // Step 2 - Run IQConnect launcher IQFeedLauncher.Start(); // Step 3 - Use the appropriate factory to create the client var lookupClient = LookupClientFactory.CreateNew(); // Step 4 - Connect it lookupClient.Connect(); var tmpFilename = await lookupClient.Historical.File.GetHistoryTickDatapointsAsync(Symbol, 1000); // Step 5 - Make file request! // Step 6 - Move the file var basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, DownloadBasePath); var fullPath = Path.Combine(basePath, $"{DateTime.Now:yyyyMMddHHmmss}-{Symbol}.csv"); Directory.CreateDirectory(basePath); File.Move(tmpFilename, fullPath); // Step 7 - Parse TickMessages from saved file var ticks = TickMessage.ParseFromFile(fullPath).ToList(); Console.WriteLine($"Saved {Symbol} ticks in {fullPath}"); }
public async Task RunAsync() { // ************************************* // Step 1 - !!! Configure your credentials for IQConnect in user environment variable or app.config !!! // Check the documentation for more information. // Step 2 - Run IQConnect launcher IQFeedLauncher.Start(); // Step 3 - Use the appropriate factory to create the client var lookupClient = LookupClientFactory.CreateNew(); // Step 4 - Connect it lookupClient.Connect(); // Step 5 - Make any requests you need or want! var tickMessages = await lookupClient.Historical.GetHistoryTickDatapointsAsync("AAPL", 100); var intervalMessage = await lookupClient.Historical.GetHistoryIntervalDaysAsync("AAPL", 5, 10, 100); var dailyMessages = await lookupClient.Historical.GetHistoryDailyDatapointsAsync("AAPL", 100); Console.WriteLine($"Fetched {tickMessages.Count()} Tick messages"); Console.WriteLine($"Fetched {intervalMessage.Count()} Interval messages"); Console.WriteLine($"Fetched {dailyMessages.Count()} Daily messages"); }
public async Task RunAsync() { // Configure your credentials for IQConnect in user environment variable or app.config !!! // Check the documentation for more information. // Run IQConnect launcher IQFeedLauncher.Start(); // Choose between 3 different handlers: // 1- Level1MessageDecimalHandler (for decimal) // 2- Level1MessageDoubleHandler (for double) - default one through CreateNew // 3- Level1MessageFloatHandler (for float) var level1Client = Level1ClientFactory.CreateNew( IQFeedDefault.Hostname, IQFeedDefault.Level1Port, Level1Default.SnapshotTimeout, new Level1MessageDecimalHandler()); // Connect level1Client.Connect(); // retrieve UpdateSummaryMessage<decimal> var decimalUpdateSummary = await level1Client.GetUpdateSummarySnapshotAsync("AAPL"); // convert UpdateSummaryMessage<decimal> to UpdateSummaryMessage<float> var floatUpdateSummary = decimalUpdateSummary.ToFloat(); }
public async Task RunAsync() { // Configure your credentials for IQConnect in user environment variable or app.config !!! // Check the documentation for more information. // Run IQConnect launcher IQFeedLauncher.Start(); // Choose between 3 different handlers: // 1- HistoricalMessageDecimalHandler (for decimal) // 2- HistoricalMessageDoubleHandler (for double) - default one through CreateNew // 3- HistoricalMessageFloatHandler (for float) var lookupClient = LookupClientFactory.CreateNew( IQFeedDefault.Hostname, IQFeedDefault.LookupPort, 1, LookupDefault.Timeout, LookupDefault.BufferSize, new HistoricalMessageDecimalHandler()); // Connect lookupClient.Connect(); // retrieve IEnumerable<TickMessage<decimal>> var decimalTicks = (await lookupClient.Historical.GetHistoryTickDatapointsAsync("AAPL", 1000)).ToList(); // convert TickMessage<decimal> to TickMessage<float> var floatTick = decimalTicks.First().ToFloat(); // convert IEnumerable<TickMessage<decimal>> to IEnumerable<TickMessage<float>> var floatTicks = decimalTicks.ToFloat().ToList(); }
static async void RunLevel1Example() { // ************************************* // Step 1 - !!! Configure your credentials for IQConnect in user environment variable or app.config !!! // Check the documentation for more information. // Step 2 - Run IQConnect launcher IQFeedLauncher.Start(); // Step 3 - Use the appropriate factory to create the client var level1Client = Level1ClientFactory.CreateNew(); // Step 4 - Connect it level1Client.Connect(); // Step 5 - Register to appropriate events level1Client.Timestamp += timestampMsg => Console.WriteLine(timestampMsg); level1Client.Update += updateMsg => Console.WriteLine(updateMsg); // Step 6 - Make your streaming Leve1 requests level1Client.ReqWatch("AAPL"); await Task.Delay(TimeSpan.FromMinutes(1)); }
public void SetUp() { RestTestDataDirectory(); IQFeedLauncher.Start(); _lookupClient = LookupClientFactory.CreateNew(); _lookupClient.Connect(); }
public async Task RunAsync() { // ************************************* // Step 1 - !!! Configure your credentials for IQConnect in user environment variable or app.config !!! // Check the documentation for more information. // Step 2 - Run IQConnect launcher IQFeedLauncher.Start(); // Step 3 - Use the appropriate factory to create the client and specify which fields are needed var level1DynamicClient = Level1DynamicClientFactory.CreateNew( DynamicFieldset.Symbol, DynamicFieldset.MostRecentTrade, DynamicFieldset.MostRecentTradeSize, DynamicFieldset.MostRecentTradeTime, DynamicFieldset.MostRecentTradeMarketCenter, DynamicFieldset.TotalVolume, DynamicFieldset.Bid, DynamicFieldset.BidSize, DynamicFieldset.Ask, DynamicFieldset.AskSize, DynamicFieldset.Open, DynamicFieldset.High, DynamicFieldset.Low, DynamicFieldset.Close, DynamicFieldset.MessageContents, DynamicFieldset.MostRecentTradeConditions, DynamicFieldset.MostRecentTradeDate, DynamicFieldset.Volatility, DynamicFieldset.VWAP); // Step 4 - Connect it level1DynamicClient.Connect(); // Step 5 - Register to appropriate events level1DynamicClient.Fundamental += Level1ClientOnFundamental; level1DynamicClient.Summary += Level1ClientOnSummary; level1DynamicClient.Update += Level1ClientOnSummary; level1DynamicClient.Timestamp += Level1ClientOnTimestamp; // Step 6 - Make your streaming Level 1 requests level1DynamicClient.ReqWatch("AAPL"); Console.WriteLine("Watching APPL for the next 10 seconds... Please be patient ;-)\n"); await Task.Delay(TimeSpan.FromSeconds(10)); // Step 7 - Unwatch and unregister events level1DynamicClient.ReqUnwatch("AAPL"); level1DynamicClient.Fundamental -= Level1ClientOnFundamental; level1DynamicClient.Summary -= Level1ClientOnSummary; level1DynamicClient.Update -= Level1ClientOnSummary; level1DynamicClient.Timestamp -= Level1ClientOnTimestamp; // Step 8 - Disconnect the client from IQ Feed level1DynamicClient.Disconnect(); }
public static Downloader CreateNew(string dataDirectory, int numberOfClients) { IQFeedLauncher.Start(); var lookupClient = LookupClientFactory.CreateNew("localhost", IQFeedDefault.LookupPort, numberOfClients, TimeSpan.FromMinutes(20)); lookupClient.Connect(); var level1Client = Level1ClientFactory.CreateNew(); level1Client.Connect(); return(new Downloader(dataDirectory, lookupClient, level1Client, numberOfClients)); }
public static void LookupClient_can_connect_and_terminate_without_error_forceIpv4(bool forceIpv4) { // Arrange SocketClient.ForceIpv4 = forceIpv4; // Act IQFeedLauncher.Start(); var client = LookupClientFactory.CreateNew(); client.Connect(); client.Disconnect(); IQFeedLauncher.Terminate(); // Assert Assert.Pass($"IQFeedLauncher and the lookup client were able to connect and disconnect/terminate without error with the 'SocketClient.ForceIpv4' value set to '{forceIpv4}'."); }
static async void RunHistoricalExample() { // ************************************* // Step 1 - !!! Configure your credentials for IQConnect in user environment variable or app.config !!! // Check the documentation for more information. // Step 2 - Run IQConnect launcher IQFeedLauncher.Start(); // Step 3 - Use the appropriate factory to create the client var lookupClient = LookupClientFactory.CreateNew(); // Step 4 - Connect it lookupClient.Connect(); // Step 5 - Make any requests you need or want! var ticksMessages = await lookupClient.Historical.ReqHistoryTickDatapointsAsync("AAPL", 100); var ticksFilename = await lookupClient.Historical.Raw.ReqHistoryTickDaysAsync("AAPL", 100); // ************************************* }
public void Run() { // Configure your credentials for IQConnect in user environment variable or app.config !!! // Check the documentation for more information. // Run IQConnect launcher IQFeedLauncher.Start(); // Connect the LookupClient created from the constructor LookupClient.Connect(); // Add 100 symbols to the concurrent queue foreach (var symbol in MarketData.GetSymbols().Take(100)) { Symbols.Enqueue(symbol); } // Create required directories for saving files CreateDirectories(); // Download data for all added symbols Start(); }
public async Task RunAsync() { // Step 1 - !!! Configure your credentials for IQConnect in user environment variable or app.config !!! // Check the documentation for more information. // Step 2 - Run IQConnect launcher IQFeedLauncher.Start(); // Step 3 - Use the appropriate factory to create the client var level2Client = Level2ClientFactory.CreateNew(); // Step 4 - Connect it level2Client.Connect(); // Step 5 - Register to appropriate events // ** IMPORTANT ** you should always subscribe to System event level2Client.System += Level2ClientOnSystem; level2Client.Error += Level2ClientOnError; level2Client.Summary += Level2ClientOnSummary; level2Client.Update += Level2ClientOnSummary; level2Client.Timestamp += Level2ClientOnTimestamp; // Step 6 - Make your streaming Level 2 requests level2Client.ReqWatch("@ES#"); Console.WriteLine("Watching @ES# for the next 30 seconds... Please be patient ;-)\n"); await Task.Delay(TimeSpan.FromSeconds(30)); // Step 7 - Unwatch and unregister events level2Client.ReqUnwatch("@ES#"); level2Client.Summary -= Level2ClientOnSummary; level2Client.Update -= Level2ClientOnSummary; level2Client.Timestamp -= Level2ClientOnTimestamp; }
public async Task RunAsync() { // ************************************* // Step 1 - !!! Configure your credentials for IQConnect in user environment variable or app.config !!! // Check the documentation for more information. // Step 2 - Run IQConnect launcher IQFeedLauncher.Start(); // Step 3 - Use the appropriate factory to create the client var level1Client = Level1ClientFactory.CreateNew(); // Step 4 - Connect it level1Client.Connect(); // Step 5 - Register to appropriate events level1Client.Fundamental += Level1ClientOnFundamental; level1Client.Summary += Level1ClientOnSummary; level1Client.Update += Level1ClientOnSummary; level1Client.Timestamp += Level1ClientOnTimestamp; // Step 6 - Make your streaming Leve1 requests level1Client.ReqWatch("AAPL"); Console.WriteLine("Watching APPL for the next 30 seconds... Please be patient ;-)\n"); await Task.Delay(TimeSpan.FromSeconds(30)); // Step 7 - Unwatch and unregister events level1Client.ReqUnwatch("AAPL"); level1Client.Fundamental -= Level1ClientOnFundamental; level1Client.Summary -= Level1ClientOnSummary; level1Client.Update -= Level1ClientOnSummary; level1Client.Timestamp -= Level1ClientOnTimestamp; }
public Level1ClientTests() { IQFeedLauncher.Start(); }
public SymbolFacadeTests() { IQFeedLauncher.Start(); }
public async Task RunAsync() { // ************************************* // Step 1 - !!! Configure your credentials for IQConnect in user environment variable or app.config !!! // Check the documentation for more information. // Step 2 - Run IQConnect launcher IQFeedLauncher.Start(); // Step 3 - Create an array that includes the fields desired for Update and Summary messages var fields = new[] { // The IQFeed servers *ALWAYS* include Symbol as first message data field, regardless of fields requested via SelectUpdateFieldName/SELECT UPDATE FIELDS // DynamicFieldset.Symbol *MUST* be the first dynamic field in the array at this time. Parsing errors will result otherwise. DynamicFieldset.Symbol, DynamicFieldset.SevenDayYield, DynamicFieldset.Ask, DynamicFieldset.AskChange, DynamicFieldset.AskMarketCenter, DynamicFieldset.AskSize, DynamicFieldset.AskTime, DynamicFieldset.AvailableRegions, DynamicFieldset.AverageMaturity, DynamicFieldset.Bid, DynamicFieldset.BidChange, DynamicFieldset.BidMarketCenter, DynamicFieldset.BidSize, DynamicFieldset.BidTime, DynamicFieldset.Change, DynamicFieldset.ChangeFromOpen, DynamicFieldset.Close, DynamicFieldset.CloseRange1, DynamicFieldset.CloseRange2, DynamicFieldset.DaysToExpiration, DynamicFieldset.DecimalPrecision, DynamicFieldset.Delay, DynamicFieldset.ExchangeID, DynamicFieldset.ExtendedTrade, DynamicFieldset.ExtendedTradeDate, DynamicFieldset.ExtendedTradeMarketCenter, DynamicFieldset.ExtendedTradeSize, DynamicFieldset.ExtendedTradeTime, DynamicFieldset.ExtendedTradingChange, DynamicFieldset.ExtendedTradingDifference, DynamicFieldset.FinancialStatusIndicator, DynamicFieldset.FractionDisplayCode, DynamicFieldset.High, DynamicFieldset.Last, DynamicFieldset.LastDate, DynamicFieldset.LastMarketCenter, DynamicFieldset.LastSize, DynamicFieldset.LastTime, DynamicFieldset.Low, DynamicFieldset.MarketCapitalization, DynamicFieldset.MarketOpen, DynamicFieldset.MessageContents, DynamicFieldset.MostRecentTrade, DynamicFieldset.MostRecentTradeConditions, DynamicFieldset.MostRecentTradeDate, DynamicFieldset.MostRecentTradeMarketCenter, DynamicFieldset.MostRecentTradeSize, DynamicFieldset.MostRecentTradeTime, DynamicFieldset.NetAssetValue, DynamicFieldset.NumberOfTradesToday, DynamicFieldset.Open, DynamicFieldset.OpenInterest, DynamicFieldset.OpenRange1, DynamicFieldset.OpenRange2, DynamicFieldset.PercentChange, DynamicFieldset.PercentOffAverageVolume, DynamicFieldset.PreviousDayVolume, DynamicFieldset.PriceEarningsRatio, DynamicFieldset.Range, DynamicFieldset.RestrictedCode, DynamicFieldset.Settle, DynamicFieldset.SettlementDate, DynamicFieldset.Spread, DynamicFieldset.Tick, DynamicFieldset.TickID, DynamicFieldset.TotalVolume, DynamicFieldset.Volatility, DynamicFieldset.VWAP, }; // Step 4 - Use the appropriate factory to create the client. Pass a new Level1MessageDynamicHandler to indicate dynamic fields in use var level1Client = Level1ClientFactory.CreateNew(new Level1MessageDynamicHandler()); // Step 5 - Connect it level1Client.Connect(); // Step 6 - Request the feed to begin returning selected fields in Summary and Update messages level1Client.SelectUpdateFieldName(fields); // Step 7 - Register to appropriate events level1Client.Fundamental += Level1ClientOnFundamental; level1Client.Summary += Level1ClientOnSummary; level1Client.Update += Level1ClientOnSummary; level1Client.Timestamp += Level1ClientOnTimestamp; // Step 8 - Make your streaming Level 1 requests level1Client.ReqWatch("AAPL"); Console.WriteLine("Watching APPL for the next 10 seconds... Please be patient ;-)\n"); await Task.Delay(TimeSpan.FromSeconds(10)); // Step 9 - Unwatch and unregister events level1Client.ReqUnwatch("AAPL"); level1Client.Fundamental -= Level1ClientOnFundamental; level1Client.Summary -= Level1ClientOnSummary; level1Client.Update -= Level1ClientOnSummary; level1Client.Timestamp -= Level1ClientOnTimestamp; }
public AdminClientTests() { IQFeedLauncher.Start(); }
public ChainsFacadeTests() { IQFeedLauncher.Start(); _years = $"{DateTime.Now.Date:yy}{DateTime.Now.Date.AddYears(1):yy}"; }
public Level2ClientOldProtocolTests() { IQFeedLauncher.Start(); }
public HistoricalFacadeMultiClientTests() { IQFeedLauncher.Start(); }
public HistoricalRawFacadeTests() { IQFeedLauncher.Start(); }
public ChainsFacadeTests() { IQFeedLauncher.Start(); _years = "12"; }
/// <summary> /// Primary entry point to the program. This program only supports EQUITY for now. /// </summary> public static void IQFeedDownloader(IList <string> tickers, string resolution, DateTime fromDate, DateTime toDate) { if (resolution.IsNullOrEmpty() || tickers.IsNullOrEmpty()) { Console.WriteLine("IQFeedDownloader ERROR: '--tickers=' or '--resolution=' parameter is missing"); Console.WriteLine("--tickers=SPY,AAPL"); Console.WriteLine("--resolution=Tick/Second/Minute/Hour/Daily/All"); Environment.Exit(1); } try { // Load settings from command line var allResolution = resolution.ToLowerInvariant() == "all"; var castResolution = allResolution ? Resolution.Tick : (Resolution)Enum.Parse(typeof(Resolution), resolution); var startDate = fromDate.ConvertToUtc(TimeZones.NewYork); var endDate = toDate.ConvertToUtc(TimeZones.NewYork); endDate = endDate.AddDays(1).AddMilliseconds(-1); // Load settings from config.json var dataDirectory = Config.Get("data-folder", "../../../Data"); var userName = Config.Get("iqfeed-username", "username"); var password = Config.Get("iqfeed-password", "password"); var productName = Config.Get("iqfeed-productName", "productname"); var productVersion = Config.Get("iqfeed-version", "productversion"); // Create an instance of the downloader const string market = Market.USA; // Connect to IQFeed IQFeedLauncher.Start(userName, password, productName, productVersion); var lookupClient = LookupClientFactory.CreateNew(NumberOfClients); lookupClient.Connect(); // Create IQFeed downloader instance var universeProvider = new IQFeedDataQueueUniverseProvider(); var historyProvider = new IQFeedFileHistoryProvider(lookupClient, universeProvider, MarketHoursDatabase.FromDataFolder()); var downloader = new IQFeedDataDownloader(historyProvider); var quoteDownloader = new IQFeedDataDownloader(historyProvider); var resolutions = allResolution ? new List <Resolution> { Resolution.Tick, Resolution.Second, Resolution.Minute, Resolution.Hour, Resolution.Daily } : new List <Resolution> { castResolution }; var requests = resolutions.SelectMany(r => tickers.Select(t => new { Ticker = t, Resolution = r })).ToList(); var sw = Stopwatch.StartNew(); Parallel.ForEach(requests, new ParallelOptions { MaxDegreeOfParallelism = NumberOfClients }, request => { // Download the data var symbol = Symbol.Create(request.Ticker, SecurityType.Equity, market); var data = downloader.Get(new DataDownloaderGetParameters(symbol, request.Resolution, startDate, endDate)); // Write the data var writer = new LeanDataWriter(request.Resolution, symbol, dataDirectory); writer.Write(data); if (request.Resolution == Resolution.Tick) { var quotes = quoteDownloader.Get(new DataDownloaderGetParameters(symbol, request.Resolution, startDate, endDate, TickType.Quote)); var quoteWriter = new LeanDataWriter(request.Resolution, symbol, dataDirectory, TickType.Quote); quoteWriter.Write(quotes); } }); sw.Stop(); Log.Trace($"IQFeedDownloader: Completed successfully in {sw.Elapsed}!"); } catch (Exception err) { Log.Error(err); } }
public Level1ClientDynamicFieldsetTests() { IQFeedLauncher.Start(); }
public ChainsFacadeTests() { IQFeedLauncher.Start(); }
public DerivativeClientTests() { IQFeedLauncher.Start(); }
public MarketSummaryFacadeTests() { IQFeedLauncher.Start(); }
public NewsFacadeTests() { IQFeedLauncher.Start(); }