Installation#

This section describes how to install the onetick-py package to use remotely with OneTick Cloud Server. In this case, the package does not require OneTick binaries to be installed on the client side. If you have OneTick binaries installed on your machine, please refer to the On-Premises Installation section.

Prerequisites#

  • You installed python 3.8 or older.

  • You installed pip.

  • Optional, but it is highly recommended to use virtual environment for Python packages.

    Create and activate it with following commands:

    • Linux / MacOS: python3 -m venv venv && source venv/bin/activate

    • Windows: python -m venv venv and venv\Scripts\activate

Installation with pip#

Ask your OneMarketData rep for a USERNAME and PASSWORD and run the command below

pip install -U --index-url https://USERNAME:PASSWORD@pip.distribution.sol.onetick.com/simple/ onetick-py[webapi]

If you need to use proxy to reach external server, you need to specify it separately (replace https://user_name:password@proxyname:port in the command with your proxy credentials):

pip install --index-url https://USERNAME:PASSWORD@pip.distribution.sol.onetick.com/simple/ --proxy https://user_name:password@proxyname:port onetick-py[webapi]

For MacOS, additionally run: pip install "pyarrow<16"

Note: if you have a local OneTick installation and PYTHONPATH pointing to it (e.g., to “C:\omd\one_market_data\one_tick\bin;C:\omd\one_market_data\one_tick\bin\python;C:\omd\one_market_data\one_tick\bin\numpy\python39;”), you need to unset PYTHONPATH in order to avoid conflicts:

  • on Windows in PowerShell (echo $env:PYTHONPATH - too see it; $env:PYTHONPATH='' - to unset it)

  • on Linux/MacOS: unset PYTHONPATH

If you need to install strictly defined versions of the packages numpy and pandas, which is the most tested combination, then you can use the following command to install onetick-py:

pip install -U --index-url https://USERNAME:PASSWORD@pip.distribution.sol.onetick.com/simple/ onetick-py[strict,webapi]

Installation without internet connection#

If your machine is not connected to the internet, you can download the wheel files from our pip repository, and distribute them to your machines:

pip download -d /path/to/wheel/files onetick-py[webapi] --index-url https://USERNAME:PASSWORD@pip.distribution.sol.onetick.com/simple/

Then you can install onetick-py with the following command:

pip install -U --no-index --find-links=/path/to/wheel/files onetick-py[webapi]

Examples#

Ask your OneMarketData rep for a http_username and http_password (it is different from the one used for the pip install) to run the example code below. Replace the placeholders <FILL IN> with the provided credentials.

Runnable code for US equities#

# Initialize WebAPI mode for onetick-py
import os
os.environ['OTP_WEBAPI'] = '1'

# Import and configure onetick-py
import onetick.py as otp
otp.config.tz = 'EST5EDT'
otp.config.default_db = 'NYSE_TAQ'
otp.config.default_symbol = 'DUMMY'

# Set authentication for Cloud Server (replace USERNAME and PASSWORD with provided)
otp.config.http_address = 'https://data.onetick.com:443'
otp.config.http_username = '<FILL IN>'
otp.config.http_password = '<FILL IN>'

sym = 'AAPL'
start = otp.dt(2024, 7, 26, 10,)
еnd = start + otp.Minute(1)

# Get trades
trades = otp.DataSource('NYSE_TAQ', tick_type='TRD')
print(otp.run(trades, start=start, end=еnd, symbols=sym))

# Join trades with quotes
quotes = otp.DataSource(db='TAQ_NBBO', tick_type='NBBO')

joined = otp.join_by_time([trades, quotes])

res = otp.run(joined,
            symbols=[sym],
            start=start,
            end=еnd)

print(res)

Runnable code for futures#

# Initialize WebAPI mode for onetick-py
import os
os.environ['OTP_WEBAPI'] = '1'

# Import and configure onetick-py
import onetick.py as otp

otp.config.tz = 'America/Chicago'
otp.config.default_db = 'CME'
otp.config.default_symbol = 'DUMMY'

# Set authentication for Cloud Server (replace USERNAME and PASSWORD with provided)
otp.config.http_address = 'https://data.onetick.com:443'
otp.config.http_username = '<FILL IN>'
otp.config.http_password = '<FILL IN>'

sym = r'NG\N22'
start = otp.dt(2022, 6, 6, 10,)
еnd = start + otp.Minute(100)

# Get trades
trades = otp.DataSource('CME', tick_type='TRD')
print(otp.run(trades, start=start, end=еnd, symbols=sym))

# Join trades with quotes
quotes = otp.DataSource(db='CME', tick_type='QTE')

joined = otp.join_by_time([trades, quotes])

res = otp.run(joined,
            symbols=[sym],
            start=start,
            end=еnd)

print(res)