otp.config#
- class Config[source]#
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.
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:
Value that is set by modifying object
otp.config
Value that is set via environment variable
Value that is set in file
OTP_DEFAULT_CONFIG_PATH
Default value specified in the source code
To reset configuration value that has been set by modifying object
otp.config
, special valueotp.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 byonetick-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
.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: int = 16#
Default concurrency level used for running queries, e.g. with
otp.run
. Default value is the number of cores/threads on your machine.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
.
- 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
.
The following properties are derived and thus read-only:
- default_db_symbol: str = DEMO_L1::AAPL#
Default symbol with database. Defined with
default_db
anddefault_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
.