Skip to content

finbourne/horizon-sdk-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LUSID_by_Finbourne

Python SDK for the FINBOURNE Horizon API

Contents

Summary

This is the python SDK for the FINBOURNE Horizon API, part of the LUSID by FINBOURNE platform. To use it you'll need a LUSID account - sign up for free at lusid.com.

For more details on other applications in the LUSID platform, see Understanding all the applications in the LUSID platform.

This sdk supports Production, Early Access, Beta and Experimental API endpoints. For more details on API endpoint categories, see What is the LUSID feature release lifecycle. To find out which category an API endpoint falls into, see the swagger page.

This code is automatically generated by the OpenAPI Generator project.

Versions

  • API version: 0.1.1048
  • SDK version: 2.1.319

Requirements

  • Python 3.7+

Installation

If using poetry

poetry add finbourne-horizon-sdk

If using pip

pip install finbourne-horizon-sdk

Then import the package in your python file

import finbourne_horizon

Getting Started

You'll need to provide some configuration to connect to the FINBOURNE Horizon API - see the articles about short-lived access tokens and a long-lived Personal Access Token. This configuration can be provided using a secrets file or environment variables.

For some configuration it is also possible to override the global configuration at the ApiClientFactory level, or at the request level. For the set of configuration which can be overridden, please see ConfigurationOptions. For a code illustration of this configuration being overridden, please see the example.

Environment variables

Required for a short-lived access token

FBN_TOKEN_URL
FBN_HORIZON_URL
FBN_USERNAME
FBN_PASSWORD
FBN_CLIENT_ID
FBN_CLIENT_SECRET

Required for a long-lived access token

FBN_HORIZON_URL
FBN_ACCESS_TOKEN

You can send your requests to the FINBOURNE Horizon API via a proxy, by setting FBN_PROXY_ADDRESS. If your proxy has basic auth enabled, you must also set FBN_PROXY_USERNAME and FBN_PROXY_PASSWORD.

Other optional configuration

# sdk client timeouts in milliseconds - a value of 0 means no timeout, otherwise timeout values must be a positive integer
# please note - the chances of seeing a network issue increase with the duration of the request
# for this reason, rather than increasing the timeout, it will be more reliable to use an alternate polling style endpoint where these exist
FBN_TOTAL_TIMEOUT_MS # the default is 1800000 (30 minutes)
FBN_CONNECT_TIMEOUT_MS # the default is 0 (no timeout)
FBN_READ_TIMEOUT_MS # the default is 0 (no timeout)
FBN_RATE_LIMIT_RETRIES # the default is 2

Secrets file

The secrets file must be in the current working directory. By default the SDK looks for a secrets file called secrets.json

Required for a short-lived access token

{
    "api":
    {
        "tokenUrl":"<your-token-url>",
        "horizonUrl":"https://<your-domain>.lusid.com/horizon",
        "username":"<your-username>",
        "password":"<your-password>",
        "clientId":"<your-client-id>",
        "clientSecret":"<your-client-secret>",
    }
}

Required for a long-lived access token

{
    "api":
    {
        "horizonUrl":"https://<your-domain>.lusid.com/horizon",
        "accessToken":"<your-access-token>"
    }
}

You can send your requests to the FINBOURNE Horizon API via a proxy, by adding a proxy section. If your proxy has basic auth enabled, you must also supply a username and password in this section.

{
    "api":
    {
        "horizonUrl":"https://<your-domain>.lusid.com/horizon",
        "accessToken":"<your-access-token>"
    },
    "proxy":
    {
        "address":"<your-proxy-address>",
        "username":"<your-proxy-username>",
        "password":"<your-proxy-password>"
    }
}

Other optional configuration

{
    "api": 
    {
        // sdk client timeouts in milliseconds - a value of 0 means no timeout, otherwise timeout values must be a positive integer
        // please note - the chances of seeing a network issue increase with the duration of the request
        // for this reason, rather than increasing the timeout, it will be more reliable to use an alternate polling style endpoint where these exist
        "totalTimeoutMs":<timeout-in-ms>, // the default is 1800000 (30 minutes)
        "connectTimeoutMs":<timeout-in-ms>, // the default is 0 (no timeout)
        "readTimeoutMs":<timeout-in-ms>, // the default is 0 (no timeout)
        "rateLimitRetries":<retries-when-being-rate-limited> // the default is 2
    }
}

Example

import asyncio
from finbourne_horizon.exceptions import ApiException
from finbourne_horizon.extensions.configuration_options import ConfigurationOptions
from finbourne_horizon.models import *
from pprint import pprint
from finbourne_horizon import (
    ApiClientFactory,
    InstrumentApi
)

async def main():

    with open("secrets.json", "w") as file:
        file.write('''
{
    "api":
    {
        "tokenUrl":"<your-token-url>",
        "horizonUrl":"https://<your-domain>.lusid.com/horizon",
        "username":"<your-username>",
        "password":"<your-password>",
        "clientId":"<your-client-id>",
        "clientSecret":"<your-client-secret>"
    }
}''')

    # Use the finbourne_horizon ApiClientFactory to build Api instances with a configured api client
    # By default this will read config from environment variables
    # Then from a secrets.json file found in the current working directory

    # uncomment the below to use configuration overrides
    # opts = ConfigurationOptions();
    # opts.total_timeout_ms = 30_000

    # uncomment the below to use an api client factory with overrides
    # api_client_factory = ApiClientFactory(opts=opts)

    api_client_factory = ApiClientFactory()

    # Enter a context with an instance of the ApiClientFactory to ensure the connection pool is closed after use
    async with api_client_factory:
        # Create an instance of the API class
        api_instance = api_client_factory.build(InstrumentApi)

        # Objects can be created either via the class constructor, or using the 'from_dict' or 'from_json' methods
        # Change the lines below to switch approach
        # onboard_instrument_request = OnboardInstrumentRequest.from_json("")
        # onboard_instrument_request = OnboardInstrumentRequest.from_dict({})
        onboard_instrument_request = OnboardInstrumentRequest()

        try:
            # uncomment the below to set overrides at the request level
            # api_response = await api_instance.create_instrument(onboard_instrument_request, opts=opts)

            # [EARLY ACCESS] CreateInstrument: Creates and masters instruments with third party vendors.
            api_response = await api_instance.create_instrument(onboard_instrument_request)
            pprint(api_response)
        except ApiException as e:
            print("Exception when calling InstrumentApi->create_instrument: %s\n" % e)

asyncio.run(main())

Endpoints and models

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages