otp.query (onetick.query reference)#
- class query(path, *config, **params)[source]#
Bases:
object
Constructs a query object with a certain path. Keyword arguments specify query parameters.
You also can pass an instance of
otp.query.config
class as the second positional argument to specify a query.- Parameters
path (str) – path to an .otq file. If path is relative, then it’s assumed that file is located in one of the directories specified in OneTick
OTQ_FILE_PATH
configuration variable. If there are more than one query in the file, then its name should be specified in the format<path>::<query-name>
. Also prefixremote://<database-name>::
can be used to specify if query is located on the remote server.config – optional
otp.query.config
object.params – parameters for the query.
Examples
>>> otp.query('/otqs/some.otq::some_query', PARAM1='val1', PARAM2=3.14) >>> otp.query('remote://DATABASE::/otqs/some.otq::some_query', PARAM1='val1', PARAM2=3.14)
- Raises
- class config(output_columns=None)[source]#
Bases:
object
- Parameters
output_columns (str, list, dict, optional) –
The parameter defines what the outputs columns are. Default value is
None
that means no output fields after applying query for every output pin.The
input
value means that output columns are the same as inputs for every output pinA list of tuples allows to define output columns with their types; for example [(‘x’, int), (‘y’, float), …]. Applicable for every output pin.
A dict allows to specify output columns for every output pin.
- Raises
- special_values = {'input'}#
- property str_params#