This is the Python SDK for LUSID by FINBOURNE, a bi-temporal investment management data platform with portfolio accounting capabilities. To use it you'll need a LUSID account. Sign up for free at


The PyPi package for the LUSID SDK can installed using the following:

pip install lusid-sdk

We publish two versions of the Python SDK:

  • lusid-sdk-python (this one) - supports Production and Early Access API endpoints
  • lusid-sdk-python-preview - 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 LUSID API Documentation.

If you install both lusid-sdk-python and lusid-sdk-python-preview, import lusid will refer to lusid-sdk-python.


Create API Client

First, import the following LUSID modules:

import lusid
import lusid.models as models
from lusid.utilities import ApiConfigurationLoader

And construct the API factory:

secrets_file_path = "/path/to/secrets.json"
config = ApiConfigurationLoader.load(secrets_file_path)
api_factory = lusid.utilities.ApiClientFactory(

You will need to create a secrets file containing your LUSID credentials. For instructions on how to construct this file, see Getting started with the LUSID API and SDKs

Now that the API client is ready, you are ready to use the various API endpoints. You can list all the API endpoints by running the following:

[api for api in dir(lusid.api) if "API" in api]

An API endpoint can be constructed by calling<className>) for any of the returned classes.

Code Samples

Before running the examples, import the following modules:

import uuid
import datetime
import pytz

The examples below should be run in order, as they assume that the preceding code has been executed.

For a Python script containing all the sample code, see sdk/examples/

Create portfolio

tx_portfolios_api =

scope = "GettingStartedScope"
guid = uuid.uuid4()

portfolio_request = models.CreateTransactionPortfolioRequest(
    created=datetime.datetime(2021, 3, 20, tzinfo=pytz.utc)

portfolio = tx_portfolios_api.create_portfolio(scope, create_transaction_portfolio_request=portfolio_request)
portfolio_code =
print("Porfolio Code:", portfolio_code)

Upsert instruments

instruments_api =

# FIGI is from
figis_to_create = {
    "BBG000C6K6G9": models.InstrumentDefinition(name="VODAFONE GROUP PLC",
        identifiers={"Figi": models.InstrumentIdValue(value="BBG000C6K6G9")}


Get instruments

instruments_response = instruments_api.get_instruments(
    identifier_type="Figi", request_body=list(figis_to_create.keys()))
name_to_luid = { value.lusid_instrument_id
    for _, value in instruments_response.values.items()
luid_to_name = {v: k for k, v in name_to_luid.items()}

Upsert transactions

tx_portfolios_api =

tx1 = models.TransactionRequest(
    instrument_identifiers={"Instrument/default/LusidInstrumentId": name_to_luid["VODAFONE GROUP PLC"]},
    transaction_date=datetime.datetime(2021, 3, 27, tzinfo=pytz.utc),
    settlement_date=datetime.datetime(2021, 3, 28, tzinfo=pytz.utc),
    total_consideration=models.CurrencyAndAmount(amount=103 * 100, currency="GBP"),

tx_portfolios_api.upsert_transactions(scope=scope, code=portfolio_code, transaction_request=[tx1])

Get holdings

tx_portfolios_api =

holdings_response = tx_portfolios_api.get_holdings(
    scope=scope, code=portfolio_code, property_keys=["Instrument/default/Name"]).values

for holding in holdings_response:
    print(luid_to_name[holding.instrument_uid], holding.units, holding.cost.amount)

For more fully fledged examples showing how to use the SDK, see sdk/tests/tutorials