otp.config#

class Config#

Bases: object

This object is used to access onetick.py configuration variables.

Configuration variables may be accessed via otp.config['...'] syntax, e.g. otp.config['tz'].

Configuration variables may be changed by:

  • during python runtime by modifying properties of object otp.config,

  • by setting environment variables before importing onetick.py module.

During python runtime you can modify properties of otp.config object either directly or via context manager: with otp.config('property', 'value'):

Also special environment variable OTP_DEFAULT_CONFIG_PATH can be used to specify a file, from which configuration variables will be taken. This file will be read only once on module loading or when getting one of the configuration variables when the environment variable is discovered. The names of the variables in this file are the same as the names of environment variables.

In case several methods of setting configuration variables are used, the following order of priority is in place:

  1. Value that is set by modifying object otp.config

  2. Value that is set via environment variable

  3. Value that is set in file OTP_DEFAULT_CONFIG_PATH

  4. Default value specified in the source code

To reset configuration value that has been set by modifying object otp.config, special value otp.config.default should be assigned to it.

Most of the config vars are optional and have default values, but some of them need to be set manually.

There are also some environment variables that do not have corresponding property in otp.config object:

  • OTP_BASE_FOLDER_FOR_GENERATED_RESOURCE: a folder where all intermediate queries, files and databases generated by onetick-py are located. The default value is system-dependent, e.g. some generated directory with a unique name under a standard directory /tmp for Linux.

The following properties must be set manually in most cases:

default_start_time: datetime, datetime = nothing#

Default start time used for running queries, e.g. with otp.run.

Can be set using environment variable OTP_DEFAULT_START_TIME.

Format of the env variable: %Y/%m/%d %H:%M:%S.%f, %Y/%m/%d %H:%M:%S.

default_end_time: datetime, datetime = nothing#

Default end time used for running queries, e.g. with otp.run.

Can be set using environment variable OTP_DEFAULT_END_TIME.

Format of the env variable: %Y/%m/%d %H:%M:%S.%f, %Y/%m/%d %H:%M:%S.

default_db: str = nothing#

Default database name used for running queries, e.g. with otp.run.

Can be set using environment variable OTP_DEFAULT_DB.

default_symbol: str = nothing#

Default symbol name used for running queries, e.g. with otp.run.

Can be set using environment variable OTP_DEFAULT_SYMBOL.

The following properties can be changed:

tz: NoneType, str = None#

Default timezone used for running queries and creating databases, e.g. with otp.run. Default value is the local timezone of your machine.

Can be set using environment variable OTP_DEFAULT_TZ.

context: str = 'DEFAULT'#

Default context used for running queries, e.g. with otp.run.Note: In WebAPI mode it will have None value.

Can be set using environment variable OTP_CONTEXT.

default_symbology: str = 'BZX'#

Default database symbology.

Can be set using environment variable OTP_DEFAULT_SYMBOLOGY.

default_concurrency: NoneType, int = None#

Default concurrency level used for running queries, e.g. with otp.run. Default value is None which means that the value is adaptive and is set to 0 (meaning concurrency will be auto-assigned by OneTick server) on the latest OneTick versions where it is supported or to 1 (meaning no concurrency) on older versions.

Can be set using environment variable OTP_DEFAULT_CONCURRENCY.

default_batch_size: int = 0#

Default batch size used for running queries, e.g. with otp.run. Batch size is the maximum number of symbols that are processed at once. The value of 0 means unlimited – works faster for simple queries, but may consume too much memory for complex queries.

Can be set using environment variable OTP_DEFAULT_BATCH_SIZE.

default_license_dir: str = '/license'#

Default path for license directory. Needed for user to be allowed to use OneTick API. Default value is system-dependent: /license for Linux systems and C:/OMD/client_data/config/license_repository for Windows systems.

Can be set using environment variable OTP_DEFAULT_LICENSE_DIR.

default_license_file: str = '/license/license.dat'#

Default path for license file. Needed for user to be allowed to use OneTick API. Default value is system-dependent: /license/license.dat for Linux systems and C:/OMD/client_data/config/license.dat for Windows systems.

Can be set using environment variable OTP_DEFAULT_LICENSE_FILE.

default_fault_tolerance: str = 'FALSE'#

Default value for USE_FT query property.

Can be set using environment variable OTP_DEFAULT_FAULT_TOLERANCE.

default_auth_username: NoneType, str = None#

Default username used for authentication.

Can be set using environment variable OTP_DEFAULT_AUTH_USERNAME.

default_password: NoneType, str = None#

Default password used for authentication.

Can be set using environment variable OTP_DEFAULT_PASSWORD.

http_address: NoneType, str = None#

Default HTTP server used as WebAPI endpoint.

Can be set using environment variable OTP_HTTP_ADDRESS.

http_username: NoneType, str = None#

Username used for WebAPI authentication.

Can be set using environment variable OTP_HTTP_USERNAME.

http_password: NoneType, str = None#

Password used for WebAPI authentication.

Can be set using environment variable OTP_HTTP_PASSWORD.

http_proxy: NoneType, str = None#

HTTP proxy used for WebAPI requests.

Can be set using environment variable HTTP_PROXY.

https_proxy: NoneType, str = None#

HTTPS proxy used for WebAPI requests.

Can be set using environment variable HTTPS_PROXY.

access_token: NoneType, str = None#

SSO access token for WebAPI endpoint.

Can be set using environment variable OTP_ACCESS_TOKEN.

trusted_certificates_file: NoneType, str = None#

Path to the file with list of trusted Certificate Authority certificates for WebAPI requests.

Can be set using environment variable OTP_SSL_CERT_FILE.

max_expected_ticks_per_symbol: int = 2000#

Expected maximum number of ticks per symbol (used for performance optimizations).

Can be set using environment variable OTP_MAX_EXPECTED_TICKS_PER_SYMBOL.

show_stack_info: str, bool, int = False#

Show stack info (filename and line or stack trace) in OneTick exceptions.

log_symbol: str, bool, int = False#

Log currently executed symbol. Note, this only works with unbound symbols. Note, in this case otp.run does not produce the output so it should be used only for debugging purposes.

Can be set using environment variable OTP_LOG_SYMBOL.

ignore_ticks_in_unentitled_time_range: str, bool, int = False#

Default value for IGNORE_TICKS_IN_UNENTITLED_TIME_RANGE query property.

Can be set using environment variable OTP_IGNORE_TICKS_IN_UNENTITLED_TIME_RANGE.

main_query_generated_filename: str = ''#

The name of the .otq file with generated main query executed by otp.run.

Can be set using environment variable OTP_MAIN_QUERY_GENERATED_FILENAME.

logging: str = 'WARNING'#

The logging level string or path to the file with configuration. Check the documentation of python logging module for the configuration formats. JSON format (in the file with .json suffix) and python configparser formats are supported.

Can be set using environment variable OTP_LOGGING.

otq_debug_mode: str, bool, int = False#

Enable .otq files debug mode. If set to True, onetick.py will keep all generated otq files and log their paths to the console.

Can be set using environment variable OTP_OTQ_DEBUG_MODE.

allow_lowercase_in_saved_fields: bool = True#

Allow using lower case characters in field names that are being stored in Onetick databases. If set to False, onetick.py would not allow saving fields with lower case characters to a database.

clean_up_tmp_files: str, bool, int = True#

Control deleting temporary files created by onetick-py. Temporary files are OneTick configuration files and generated .otq queries.

Can be set using environment variable OTP_CLEAN_UP_TMP_FILES.

default_schema_policy: NoneType, str = None#

Default schema policy when querying onetick database. See parameter schema_policy in otp.DataSource for the list of supported values.

Can be set using environment variable OTP_DEFAULT_SCHEMA_POLICY.

The following properties are derived and thus read-only:

default_db_symbol: str = DEMO_L1::AAPL#

Default symbol with database. Defined with default_db and default_symbol as string default_db::default_symbol.

default_date: datetime = 2003-12-01 00:00:00#

Default date. Defined as a date part of default_start_time.