# Configuration parameters

## WebAPI mode

Environment variable `OTP_WEBAPI` can be set *before* importing `onetick.py` module to force using WebAPI mode.

This is needed in case of using `onetick.py` on the machine with installed OneTick distribution.
In this case by default `onetick.py` will use locally installed OneTick, but setting `OTP_WEBAPI` variable
will change the mode to WebAPI.

If `onetick.py` is used on the machine without OneTick distribution, then setting this variable is not needed.

## Other configuration parameters

See [`otp.config`](../../api/config.md#onetick.py.configuration.Config) for details.

### OptionsTable

| Name                                                                                                                                            | Environment Variable                        | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
|-------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`otp.config.tz`](../../api/config.md#onetick.py.configuration.Config.tz)                                                                       | `OTP_DEFAULT_TZ`                            | Default timezone used for running queries and creating databases, e.g. with [`otp.run`](../../api/run.md#onetick.py.run). Default value is the local timezone of your machine.                                                                                                                                                                                                                                                                                                                                                                                                         |
| [`otp.config.context`](../../api/config.md#onetick.py.configuration.Config.context)                                                             | `OTP_CONTEXT`                               | Default context used for running queries, e.g. with [`otp.run`](../../api/run.md#onetick.py.run).Note: In WebAPI mode it will have None value.                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [`otp.config.default_start_time`](../../api/config.md#onetick.py.configuration.Config.default_start_time)                                       | `OTP_DEFAULT_START_TIME`                    | Default start time used for running queries, e.g. with [`otp.run`](../../api/run.md#onetick.py.run).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [`otp.config.default_end_time`](../../api/config.md#onetick.py.configuration.Config.default_end_time)                                           | `OTP_DEFAULT_END_TIME`                      | Default end time used for running queries, e.g. with [`otp.run`](../../api/run.md#onetick.py.run).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| [`otp.config.default_db`](../../api/config.md#onetick.py.configuration.Config.default_db)                                                       | `OTP_DEFAULT_DB`                            | Default database name used for running queries, e.g. with [`otp.run`](../../api/run.md#onetick.py.run).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| [`otp.config.default_symbol`](../../api/config.md#onetick.py.configuration.Config.default_symbol)                                               | `OTP_DEFAULT_SYMBOL`                        | Default symbol name used for running queries, e.g. with [`otp.run`](../../api/run.md#onetick.py.run).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [`otp.config.default_symbology`](../../api/config.md#onetick.py.configuration.Config.default_symbology)                                         | `OTP_DEFAULT_SYMBOLOGY`                     | Default database symbology.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| [`otp.config.default_concurrency`](../../api/config.md#onetick.py.configuration.Config.default_concurrency)                                     | `OTP_DEFAULT_CONCURRENCY`                   | Default concurrency level used for running queries, e.g. with [`otp.run`](../../api/run.md#onetick.py.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. Special value `local_number_of_cores` can be used to set concurrency to the number of cores of the machine where python code executes (this corresponds to the previous default logic still expected by some users). |
| [`otp.config.presort_force_default_concurrency`](../../api/config.md#onetick.py.configuration.Config.presort_force_default_concurrency)         | `OTP_PRESORT_FORCE_DEFAULT_CONCURRENCY`     | By default concurrency value for PRESORT EPs is empty and inherited from the concurrency level set in the query where this EP is used. However, is some cases it may be desirable to force setting default concurrency level for all PRESORT EPs (this corresponds to the previous default logic still expected by some users), for example when PRESORT is located in the first stage query and cannot inherit concurrency from the main query.                                                                                                                                       |
| [`otp.config.default_batch_size`](../../api/config.md#onetick.py.configuration.Config.default_batch_size)                                       | `OTP_DEFAULT_BATCH_SIZE`                    | Default batch size used for running queries, e.g. with [`otp.run`](../../api/run.md#onetick.py.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.                                                                                                                                                                                                                                                                                   |
| [`otp.config.default_license_dir`](../../api/config.md#onetick.py.configuration.Config.default_license_dir)                                     | `OTP_DEFAULT_LICENSE_DIR`                   | 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.                                                                                                                                                                                                                                                                                                                                                      |
| [`otp.config.default_license_file`](../../api/config.md#onetick.py.configuration.Config.default_license_file)                                   | `OTP_DEFAULT_LICENSE_FILE`                  | 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.                                                                                                                                                                                                                                                                                                                                                      |
| [`otp.config.default_fault_tolerance`](../../api/config.md#onetick.py.configuration.Config.default_fault_tolerance)                             | `OTP_DEFAULT_FAULT_TOLERANCE`               | Default value for USE_FT query property.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [`otp.config.default_username`](../../api/config.md#onetick.py.configuration.Config.default_username)                                           | `OTP_DEFAULT_USERNAME`                      | Default username to call queries. By default the name of the owner of the current process is used.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| [`otp.config.default_auth_username`](../../api/config.md#onetick.py.configuration.Config.default_auth_username)                                 | `OTP_DEFAULT_AUTH_USERNAME`                 | Default username used for authentication.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [`otp.config.default_password`](../../api/config.md#onetick.py.configuration.Config.default_password)                                           | `OTP_DEFAULT_PASSWORD`                      | Default password used for authentication.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [`otp.config.http_address`](../../api/config.md#onetick.py.configuration.Config.http_address)                                                   | `OTP_HTTP_ADDRESS`                          | Default HTTP server used as WebAPI endpoint.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [`otp.config.http_username`](../../api/config.md#onetick.py.configuration.Config.http_username)                                                 | `OTP_HTTP_USERNAME`                         | Username used for WebAPI authentication.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [`otp.config.http_password`](../../api/config.md#onetick.py.configuration.Config.http_password)                                                 | `OTP_HTTP_PASSWORD`                         | Password used for WebAPI authentication.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [`otp.config.http_proxy`](../../api/config.md#onetick.py.configuration.Config.http_proxy)                                                       | `HTTP_PROXY`                                | HTTP proxy used for WebAPI requests.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [`otp.config.https_proxy`](../../api/config.md#onetick.py.configuration.Config.https_proxy)                                                     | `HTTPS_PROXY`                               | HTTPS proxy used for WebAPI requests.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [`otp.config.access_token`](../../api/config.md#onetick.py.configuration.Config.access_token)                                                   | `OTP_ACCESS_TOKEN`                          | SSO access token for WebAPI endpoint.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [`otp.config.client_id`](../../api/config.md#onetick.py.configuration.Config.client_id)                                                         | `OTP_CLIENT_ID`                             | Client ID for obtaining SSO access token.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [`otp.config.client_secret`](../../api/config.md#onetick.py.configuration.Config.client_secret)                                                 | `OTP_CLIENT_SECRET`                         | Client Secret for obtaining SSO access token.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| [`otp.config.access_token_url`](../../api/config.md#onetick.py.configuration.Config.access_token_url)                                           | `OTP_ACCESS_TOKEN_URL`                      | URL for obtaining SSO access token.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [`otp.config.access_token_scope`](../../api/config.md#onetick.py.configuration.Config.access_token_scope)                                       | `OTP_ACCESS_TOKEN_SCOPE`                    | Scope for obtaining SSO access token.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [`otp.config.trusted_certificates_file`](../../api/config.md#onetick.py.configuration.Config.trusted_certificates_file)                         | `OTP_SSL_CERT_FILE`                         | Either a boolean, in which case it controls whether we verify the server TLS certificate or a string with the path to the file with list of trusted Certificate Authority certificates for WebAPI requests. Default behaviour implies verification is enabled.                                                                                                                                                                                                                                                                                                                         |
| [`otp.config.max_expected_ticks_per_symbol`](../../api/config.md#onetick.py.configuration.Config.max_expected_ticks_per_symbol)                 | `OTP_MAX_EXPECTED_TICKS_PER_SYMBOL`         | Expected maximum number of ticks per symbol (used for performance optimizations). Default is 2000.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| [`otp.config.show_stack_info`](../../api/config.md#onetick.py.configuration.Config.show_stack_info)                                             | `OTP_SHOW_STACK_INFO`                       | Show stack info (filename and line or stack trace) in OneTick exceptions.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [`otp.config.log_symbol`](../../api/config.md#onetick.py.configuration.Config.log_symbol)                                                       | `OTP_LOG_SYMBOL`                            | Log currently executed symbol. Note, this only works with unbound symbols. Note, in this case [`otp.run`](../../api/run.md#onetick.py.run) does not produce the output so it should be used only for debugging purposes.                                                                                                                                                                                                                                                                                                                                                               |
| [`otp.config.ignore_ticks_in_unentitled_time_range`](../../api/config.md#onetick.py.configuration.Config.ignore_ticks_in_unentitled_time_range) | `OTP_IGNORE_TICKS_IN_UNENTITLED_TIME_RANGE` | Default value for IGNORE_TICKS_IN_UNENTITLED_TIME_RANGE query property. By default it is set to None, which means that the property is not set in queries and the OneTick server may decide what to do, if configured.                                                                                                                                                                                                                                                                                                                                                                 |
| [`otp.config.main_query_generated_filename`](../../api/config.md#onetick.py.configuration.Config.main_query_generated_filename)                 | `OTP_MAIN_QUERY_GENERATED_FILENAME`         | The name of the .otq file with generated main query executed by otp.run.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [`otp.config.logging`](../../api/config.md#onetick.py.configuration.Config.logging)                                                             | `OTP_LOGGING`                               | 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.                                                                                                                                                                                                                                                                                                                                            |
| [`otp.config.otq_debug_mode`](../../api/config.md#onetick.py.configuration.Config.otq_debug_mode)                                               | `OTP_OTQ_DEBUG_MODE`                        | Enable .otq files debug mode. If set to True, onetick.py will keep all generated otq files and log their paths to the console.                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [`otp.config.allow_lowercase_in_saved_fields`](../../api/config.md#onetick.py.configuration.Config.allow_lowercase_in_saved_fields)             | `None`                                      | 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.                                                                                                                                                                                                                                                                                                                                                                                       |
| [`otp.config.clean_up_tmp_files`](../../api/config.md#onetick.py.configuration.Config.clean_up_tmp_files)                                       | `OTP_CLEAN_UP_TMP_FILES`                    | Control deleting temporary files created by onetick-py. Temporary files are OneTick configuration files and generated .otq queries.                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [`otp.config.default_schema_policy`](../../api/config.md#onetick.py.configuration.Config.default_schema_policy)                                 | `OTP_DEFAULT_SCHEMA_POLICY`                 | Default schema policy when querying onetick database. See parameter `schema_policy` in [`otp.DataSource`](../../api/sources/data_source.md#onetick.py.DataSource) for the list of supported values.                                                                                                                                                                                                                                                                                                                                                                                    |
| [`otp.config.disable_compatibility_checks`](../../api/config.md#onetick.py.configuration.Config.disable_compatibility_checks)                   | `OTP_DISABLE_COMPATIBILITY_CHECKS`          | Disable compatibility checks when querying OneTick database. Using this parameter outside test environment could lead to unexpected errors.                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| [`otp.config.print_symbol_errors`](../../api/config.md#onetick.py.configuration.Config.print_symbol_errors)                                     | `OTP_PRINT_SYMBOL_ERRORS`                   | When calling otp.run that returns dataframe as result print symbol errors from OneTick as python warnings.                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [`otp.config.default_db_symbol`](../../api/config.md#onetick.py.configuration.Config.default_db_symbol)                                         |                                             | Default symbol with database. Defined with `default_db` and `default_symbol` as string **default_db::default_symbol**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [`otp.config.default_date`](../../api/config.md#onetick.py.configuration.Config.default_date)                                                   |                                             | Default date. Defined as a date part of `default_start_time`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
