1. Support Center
  2. Liberator Python User's Guide & Recipes

Usage of the as_of parameter FAQ-p7

Retrieving data as it was known at a particular point-in-time

 

The as_of parameter is a datetime parameter, as such you can set it to a date alone ie 

'2024-07-08' 


Which Liberator will interpret as midnight on that date ie..

'2024-07-08 00:00:00.000000'


Or you can set it to any time, down to the nanosecond, as displayed above.


NOTE: All Liberator times are NY Time (US ET).


REMINDER: When setting your query parameters, consider the amount of data you may be requesting and start small if you can until you get a good idea of how much data is returned for each symbol/date range combination.


DEFAULT VALUE: If you do not pass an as_of Liberator will assume you mean the current date and time.


Example with an as_of…

df = liberator.get_dataframe(liberator.query( name = 'daily_bars', as_of ='2024-07-10', back_to = '2024-07-10', symbols = ['GOOG','AAPL','MSFT']))

Which results in a pandas dataframe something like this…

faq-p7-i1

What happens if I pass an as_of but no back_to?

If I submit the same query with no back_to , or I if set it to None, I will get data right up to yesterday…

 

Today’s date is actually 2024-07-26 so the most recently completed daily_bar would be timestamped ‘2024-07-25 20:00:00.000000’. Let’s drop the back_to and see what we get back…

df = liberator.get_dataframe(liberator.query( name = 'daily_bars', as_of ='2024-07-18', symbols = ['GOOG','AAPL','MSFT']))

 

Which results in a much larger dataframe, with 36 rows, my Jupyter Notebook truncates this to look something like the dataframe below..

faq-p7-i2

If you are using Jupyter Notebooks/Labs and you do not want it to truncate the number of rows output, simply import pandas as pd (place it at the top with your other imports) and add the line below to set your max rows (or None to just display as many as you have!)...

 

import pandas as pd # in your imports section at the top…

pd.set_option('display.max_rows', 400) # set to a number or set to None to get them all every time!