Skip to content
Jack Yaffe edited this page Jun 1, 2022 · 10 revisions

lusidtools Command Line Interface

lusidtools (lusid-python-tools) is a toolbox of basic commands for interacting with LUSID.

Installing lusidtools CLI

The lusidtools CLI is installed during the setup of the lusidtools python package. This can be installed with the following command.

pip install lusidtools

After the installation is complete and one of the three authentication methods below has been setup, run the following command to display tools available from the lusidtools CLI.

lusidtools --help

If the command is not available, check that there is a lusidtools binary executable in the python installation's Scripts folder (Python_Path/Scripts). If it isn't there for some reason, pip uninstall lusidtools and then reinstall. The Scripts folder needs to be added to the path environment variable

lusidtools CLI Authentication

Lusidtools commands can be authenticated using 3 methods:

  1. a secrets.json file containing credentials
  2. Credentials set as environment variables
  3. Authenticated token

for more details on how to create a secrets.json file, setting environment variables or aquiring an authenticated token, see our support page on Authentication.

Authentication using a secrets file

Firstly, the lusditools CLI will look for a secrets.json file containing credentials in the current folder from which the lusidtools call was made. Alternatively the path to a secrets.json file can be explicitly stated using the --secrets-file argument on any lusidtools call.

Credentials set as environment variables

If no secrets.json file can be found, then the lusditools CLI checks for credentials set as environment variables. See the Using Environment Variables section of Getting started with the LUSID API and SDKs for details on setting these.

Authenticated token

If no credentials are found either in a secrets.json or set as environment variables, then the user will be prompted to provide the client name and an authenticated token. See the Authenticating & Generating an Access Token section of Getting started with the LUSID API and SDKs for details on how to get an Authenticated token. Note that these tokens are reset after a limited amount of time.

Flushing transactions with lusidtools

The flush_transactions command in the lusidtools package can flush (cancel) all transactions in a portfolio, a portfolio group or for all portfolios in a scope. This can be over a defined time period or over the portfolio's entire lifetime.

If flushing for a single portfolio:

flush_transactions [scope] - p [portfolio_code] -s YYYY-MM-DDT00:00:00.0000000+00:00 -e YYYY-MM-DDT23:59:59.0000000+00:00 --secrets path/to/secrets.json

where [scope] and [portfolio_code] are used to identify the portfolio in question and -s [date] and -e [date] correspond to the starting and ending dates, between which, the transactions will get flushed.

If no value is passed in for the starting date, -s, there will be no lower bound from when the transactions are flushed.

If no value is passed in for the ending date, -e, there will be no upper bound to when the transactions are flushed.

This means that if no dates are given when calling the command, all transactions in the specified portfolio will be flushed.

If flushing an entire portfolio group:

Adding the --group flag will make the command handle portfolio groups.

The command can be run in the following format:

flush_transactions [scope] -p [portfolio_group_code] -s YYYY-MM-DDT00:00:00.0000000+00:00 -e YYYY-MM-DDT23:59:59.0000000+00:00 --secrets path/to/secrets.json --group

where [scope] and [portfolio_group_code] are used to identify the portfolio group.

If flushing an entire scope:

You will need to remove the portfolio flag and add a flag to confirm that you want to flush the whole scope:

flush_transactions [scope] -s YYYY-MM-DDT00:00:00.0000000+00:00 -e YYYY-MM-DDT23:59:59.0000000+00:00 --secrets path/to/secrets.json --flush_scope

Additional Notes:

If a date supplied does not include a time, e.g. YYYY-MM-DD as opposed to YYYY-MM-DDTHH:MM:SS.0000000+00:00, this app will interpret this with the time as 00:00 (i.e. date goes to: YYYY-MM-DDT00:00:00.0000000+00:00)

Managing transaction type configuration using lusidtools

The lusidtools CLI has a txn_cfg feature which you can use view and edit transaction type configurations.

In the example below we set and get from a YAML file.

Get a file of current configuration

lusidtools txn_cfg get --secrets-file C:\dev\test\test-secrets.json --filename test-config.yml

Set a file of new configuration from a path

lusidtools txn_cfg set --secrets-file C:\dev\test\test-secrets.json --filename test-config.yml

WARNING Please be careful with Transaction Type configuration. Changes to this configuration will have system wide impacts.