Getting started with LumiCode

Prev Next

In about fifteen minutes, you'll find a provider, write and run a query, explore and chart the results, and save them, all without leaving the keyboard. Along the way you'll pick up the handful of keys that make LumiCode quick to use every day. The examples query Luminesce's own catalog, so they work in any LUSID domain.

Prerequisites

  • LumiCode installed, and signed in to your LUSID domain. See How do I install LumiCode?

  • Permission to query the Sys.Field provider, which lists the fields of every provider in your catalog.

A few terminal basics

LumiCode runs in a terminal, the text window your computer uses for typing commands. If you already use one every day, skip ahead to Step 1.

  • Opening a terminal. On macOS, open iTerm2, or Terminal from Applications > Utilities. On Windows, open Windows Terminal from the Start menu.

  • Key names. This article names keys as you press them: Enter, Tab, Esc, Shift, Ctrl. LumiCode's own help uses the symbols you see on Mac keyboards: ⏎ Enter, ⇥ Tab, ⇧ Shift, ^ Ctrl, ⌥ Option (Alt on Windows). So ^J means Ctrl+J.

  • Getting back out. Esc steps back or closes whatever is open. /help lists every command at any time.

Step 1: Start LumiCode

In your terminal, type lumi and press Enter.

LumiCode opens with a welcome screen and a prompt, ❯, where you type both SQL and LumiCode's own commands. Every command starts with /.

LumiCode's welcome screen and the ❯ prompt

Type / and press Tab. LumiCode lists every command, with the help for the highlighted one beside the list. Use the arrow keys to look through them, then press Esc to close the list.

Step 2: Look up a provider

Before you write a query, it helps to know what you can query. Type the following and press Enter:

/catalog Sys.Field

LumiCode lists the providers that match. Select Sys.Field and press Enter to see its fields. TableName is the name of a provider, and FieldType says whether a field is a column or a parameter.

The fields of Sys.Field in /catalog

Press Esc to go back one screen. You can see “breadcrumbs” in the banner at the top. In this case pressing Esc twice will get you to the prompt.

Step 3: Write and run a query

This query counts the columns of each Lusid.Instrument provider in your catalog:

select TableName, count(*) as Columns
from Sys.Field
where TableName like 'Lusid.Instrument%' and FieldType = 'Column'
group by TableName
order by Columns desc

Type it at the prompt. As you type:

  • Enter runs the query, so it can't start a new line. To start a new line, press Shift+Enter. On macOS, most terminals send Shift+Enter as Enter, so press Ctrl+J instead, or run /set enter newline to swap Enter and Ctrl+J over. You can also type the whole query on one line.

  • Tab completes what you are typing. Try typing from Sys.F and pressing Tab: LumiCode offers the matching providers, with each one's documentation beside the list. It does the same for fields, functions and keywords.

Code completion while writing the query (1 of 2)

Code completion while writing the query (2 of 2)

When the query is complete, press Enter. LumiCode shows the query's progress while it runs, then writes a summary of the results into the transcript, the record of your session that scrolls above the prompt.

Summary of the query's results in the transcript

While a query runs

Press Esc to stop waiting. The query carries on, and /history finds its results when it finishes. Press Ctrl+C to cancel it instead.

Step 4: Explore the results

The transcript shows a summary. To see every row, type /rows and press Enter.

  • Use the arrow keys to move between rows and columns.

  • Press Enter to open a row in full, and Esc to close it.

  • Press s to sort by the column under the cursor.

  • Press / to filter with SQL. For example, type Columns > 20 to keep only the larger providers.

Press Esc to leave /rows.

For a quick summary of every numeric column, type /stats. It shows the minimum, median, maximum and average, with a sparkline for each.

Exploring the results with /rows and /stats

Step 5: Chart the results

Type the following and press Enter:

/chart bar TableName Columns

LumiCode draws a bar chart into the transcript, beside the query: one bar per provider, sized by its number of columns.

Bar chart of the number of columns per provider

If you type /chart on its own, LumiCode asks for the kind of chart and the columns to use. It offers the likeliest answer first, so you can press Enter to accept each one. To see an example of every kind of chart, type /chart gallery.

Step 6: Change the query and run it again

Press the Up arrow at an empty prompt. LumiCode puts your last query back in the editor.

Change 'Lusid.Instrument%' to 'Lusid.Portfolio%' and press Enter to run it again. Press Ctrl+P at any time to lay out the query neatly.

The Up arrow goes further back each time you press it. To browse, rerun or save any recent query, type /recent.

Step 7: Save the results

Type /save and press Enter. Choose whether to save the results to a file on your computer or to Drive, then browse to the folder you want.

/save can also store the query itself as a Saved Query in LUSID Workspaces, so that you or your colleagues can run it again later with /run.

Step 8: Ask Candela about the query

Candela is FINBOURNE's AI agent. Type the following and press Enter:

/ai last What does this query tell me?

Candela explains the query you just ran, and if it had failed, why. You can carry on the conversation at the prompt. When Candela suggests a query, you can run it or edit it straight away.

Candela explaining the last query

To go back to running SQL, type /sql, or press Esc at an empty prompt. /ai resume reopens the conversation later.

Candela availability

Candela is currently available to some customers only. If it isn't available in your domain, LumiCode tells you when you use /ai, and everything else in LumiCode works as usual.

Step 9: Keep a record and leave

Type /transcript html and press Enter. LumiCode writes everything you did in this session, including the chart, to a web page, and tells you where it saved it. Use /transcript on its own for a Markdown file instead.

To leave LumiCode, type /exit, or press Ctrl+C twice at an empty prompt.

What's next

  • A tour of LumiCode shows what else LumiCode can do, from grouping results to diagnosing failed queries.

  • LumiCode Commands describes every command in full.

  • In LumiCode, /help keys lists every editing key, and /help <command> shows the help for any command.

If something doesn't work as described, such as links not opening or Shift+Enter running the query, see the Troubleshooting section of How do I install LumiCode?