Newbie : clientData.ListHistoricalBarsAsync issue (Possibly data subscription based)

So, I am just really getting started. I’m using code below to get some minute bars. This works fine if ‘into’ is set to DateTime.Today, but not DateTime.Now! I cannot really see a reason why and no exception is caused. I am trying this on the paper account. Is this a data subscription issue perhaps? Or am I missing something obvious. I have seen other code with .Minute and DataTime.Now, so I expected it to work. Basically, I am looking to get data up to the current bar. Thanks.

            // get data
            var into = DateTime.Now;
            var from = into.AddDays(-5);

            // Get daily price data for AAPL over the last 5 trading days.
            Console.Write("Getting data from:"+from.ToString()+" to "+into.ToString());
                var bars = await clientData.ListHistoricalBarsAsync(
                    new HistoricalBarsRequest(s, from, into, BarTimeFrame.Minute));
                Console.Write("Got "+bars.Items.Count()+" bars...");

OK, my bad. It WAS returning an error. I was just missing it! (Printer to debug instead of console, doh!).

“Erroryour subscription does not permit querying data from the past 15 min

So, that answers that. Hope it helps someone else. I did a lot of Googling and did not find the answer!

The default Free data subscription tier has this limitation. It’s not practical to add this check into SDK because you will use at least a Basic subscription in most real use cases. This subscription level doesn’t have such limitations.

1 Like