WebAPI Configuration#

The main way to set up onetick-py to use remote OneTick server through WebAPI. Main advantage of this approach is that it does not require OneTick binaries to be installed on the client side.

The configuration is done through environment variables:

  • OTP_WEBAPI=1 - this variable should be set to enable WebAPI mode.

NOTE: this environment variables should be set before importing the onetick.py module.

When using WebAPI, it is not required to use otp.Session() object, as it makes no sense in this context.

Example:

# Set up WebAPI configuration through environment variables
import os
os.environ['OTP_WEBAPI'] = '1'
# Import the onetick.py module
import onetick.py as otp

# Set up the WebAPI server address
otp.config.http_server = 'http://your-webapi-instance-host:port'

# Set up authentication if required
otp.config.http_username = 'your-username'
otp.config.http_password = 'your-password'

# Use the onetick module as usual
data = otp.DataSource(db='NYSE_TAQ',
                      tick_type='TRD',
                      start=otp.dt(2022, 4, 1),
                      end=otp.dt(2022, 4, 2))

data['VOLUME'] = data['PRICE'] * data['SIZE']
df = otp.run(data)

Difference of WebAPI mode#

All functions, that rely on using binaries on the client side, are not supported in WebAPI mode:

  • RefDB.put()

  • otp.perf

The following features are not supported when using WebAPI mode:

  • otp.Session() object (not required)

  • Ignored otp.run() parameters:
    • start_time_expression

    • end_time_expression

    • alternative_username

    • batch_size

    • treat_byte_arrays_as_strings

    • output_mode

    • output_matrix_per_field

    • return_utc_times

    • connection

    • svg_path

    • use_connection_pool

    • time_as_nsec

    • max_expected_ticks_per_symbol

    • manual_dataframe_callback

OQD usage requires to have corresponding extension installed on the server side.

Callbacks in otp.run() are partially supported, meaning it receives only the final result of the query, not tick-by-tick data arriving from the server. Callback class in WebAPI mode could have process_ticks() callback for processing the data after the query is finished, or backward-compatible process_tick() which actually will be called in loop for each tick.

ODBC is not supported.

WebAPI differs otp.string[N] field type on empty results: <U4 turns to <U64

otp.RemoteTS is not applicable, as all configuration is done on server side.

Source.dump() is not supported.

otp.logf() is not supported.

Session._log_file is not supported.

Some error messages could differs.