Rates#
This section contains 1 example for Rates using the onetick-py.
Each example is a self-contained script that can be run against the OneTick Cloud sample databases.
# onetick-py WebAPI configuration for OneTick Cloud
import os
os.environ['OTP_WEBAPI'] = '1'
os.environ['OTP_HTTP_ADDRESS'] = 'https://rest.cloud.onetick.com'
os.environ['OTP_ACCESS_TOKEN_URL'] = 'https://cloud-auth.parent.onetick.com/realms/OMD/protocol/openid-connect/token'
os.environ['OTP_CLIENT_ID'] = '__FILL_IN__'
os.environ['OTP_CLIENT_SECRET'] = '__FILL_IN__'
Data Retrieval for 1-year SONIA Interest Rate#
Query SONIA (Sterling Overnight Index Average) interest rate data.
Returns closing rates from January 1, 2024 to today.
import onetick.py as otp
data = otp.DataSource(db='RATES', tick_type='DAY') # RATES database, daily data
# Optionally, limit the number of rows
data = data.limit(1000)
# Run the query for the SONIA_RATE symbol, selecting only the CLOSE column
result = otp.run(
data[['CLOSE']], # Select only closing price
symbols='SONIA_RATE', # SONIA interest rate symbol
start=otp.dt(2024, 1, 1), # Query start time: January 1, 2024
end=otp.now(), # Query end time, this will use the current date and time at runtime
)
result # Display results
Time |
CLOSE |
|
|---|---|---|
0 |
2024-01-01 19:00:00 |
5.1863 |
1 |
2024-01-02 19:00:00 |
5.1863 |
2 |
2024-01-03 19:00:00 |
5.1870 |
3 |
2024-01-04 19:00:00 |
5.1869 |
4 |
2024-01-07 19:00:00 |
5.1869 |
.. |
… |
… |
625 |
2026-07-21 20:00:00 |
3.7303 |
626 |
2026-07-23 20:00:00 |
3.7307 |
627 |
2026-07-26 20:00:00 |
3.7312 |
628 |
2026-07-27 20:00:00 |
3.7316 |
629 |
2026-07-28 20:00:00 |
3.7313 |
630 rows x 2 columns