Last Known Value
A query that does not provide any date parameters will return the last known value.
import liberator
liberator.url='https://api.cloudquant.ai'
res = liberator.query(name='daily_bars')
df = liberator.get_dataframe(res)
df[['symbol','timestamp','open','high','low','close','volume']]
💡: Note Rather than printing the whole dataframe, we choose the columns we want to print. Alternatively, you can pass a fields parameter to the query containing a list of the columns you require (note there will always be some key fields returned by default).
Time Series Queries – Providing Date Parameters
There are two date parameters that you can pass.
as _of |
This value can be any past date so that you can see the data as it was known on the “as of” date. |
String Format YYYY-MM-DD HH:MM:SS (HH:MM:SS is optional) |
“as_of”:“2020-11-22 19:51:31” |
back_to |
The date where the return dataset should begin. |
String Format YYYY-MM-DD HH:MM:SS (HH:MM:SS is optional) |
“back_to”:“2020-01-01” |
💡: Note if as_of and back_to are the same date time, then you will not receive a time series result.
💡: Note how you can roll the query and the dataframe conversion into one line.
import liberator
liberator.url='https://api.cloudquant.ai'
df = liberator.get_dataframe(liberator.query( name = 'daily_bars', as_of = '2020-11-15', symbols = ['FB', 'AAPL', 'NFLX', 'GOOG', 'MSFT', 'IBM']))
df
Query All Symbols in a Dataset
To query all the symbols in a dataset, simply drop the symbols= parameter from the above queries.
import liberator
liberator.url='https://api.cloudquant.ai'
df = liberator.get_dataframe(liberator.query( name = 'daily_bars', as_of = '2020-11-15'))
df
Query a Live Dataset
To query a live dataset, set the as_of= parameter to 'live'.
import liberator
liberator.url='https://api.cloudquant.ai'
res=liberator.query(name=‘ice_live_nasdaq_composite_564_b', as_of='live')
for batch in res:
df=batch.to_pandas()
print(df)