Skip to content

Example mapping structure

Toby Thomas edited this page Nov 24, 2020 · 12 revisions

lusidtools is configured using data from the fields that are specified in the mapping. Default behaviour is to look in the column specified, however literal values can be specified to overwrite by using a constant prefix $. Alternatively, the default/column syntax can be used to attempt to get a value from a specified column, then to call back on a default value if no value exists for a row.

constant prefix

The constant prefix $ indices that the following string should be taken as a constant value, and to ignore any values provided in the data.

Default/Column syntax

Default values can be specified by using a dictionary containing "column" and "default" keys:

{
    "column" : "column_name",
    "default": "Name_not_found
    "
}

File_type

file_type in lusidtools refers to the type of file being upserted. It can take any of the following values:

  • instruments
  • portfolios
  • holdings
  • transactions
  • quotes
  • portfolio_group

Below is an example of what a fully populated mapping structure could look like:

mapping = {
    "instruments":{
        "identifier_mapping": {
            "ClientInternal": "Security Number",
            "Ticker": "Ticker Symbol",
            "Cusip": "CUSIP",
            "Sedol": "SEDOL",
            "Isin": "ISIN",
            "RIC": "Reuters RIC"
        },
        "required": {
            "name": "Security Description"
        },
        "properties":[
            "Security Category",
            "Security Category Sector",
            "Trading Currency",
            "Issue Currency",
            "Country of Taxation",
            "Country of Risk",
        ]
    },
    "transactions": {
        "identifier_mapping": {
            "ClientInternal": "Security Number",
            "Figi": "FIGI"
        },
        "required": {
            "code": "Account ID code",
            "transaction_id": "trans_id",
            "type": "Transaction Type",
            "transaction_price.price": "Price",
            "transaction_price.type": "$Price",                   # example of literal values
            "total_consideration.amount": "Amount",
            "units": "Shares/Par",
            "transaction_date": "Effective Date",
            "transaction_currency": "Trading Currency",
            "total_consideration.currency": "Settlement Currency",
            "settlement_date": "Settlement Date"
        },
        "optional": {
            "source": "$NT-InvestOne"                             # example of literal values 
        },
        "properties": [
            "Transaction Description",
            "Broker Name ",
            "Master ID"
        ]
    },
    "quotes": {
        "required": {
            "quote_id.quote_series_id.instrument_id_type": "$Figi",
            "quote_id.effective_at": "$2019-11-13T00:00:00Z",
           "quote_id.quote_series_id.provider": "$DataScope",
           "quote_id.quote_series_id.field": "$mid",
           "quote_id.quote_series_id.quote_type": "$Price",
           "quote_id.quote_series_id.instrument_id": "FIGI",
           "metric_value.unit": "Currency",
           "metric_value.value": "__adjusted_quote"
        },
        "quote_scalar":{
            "price": "Price",
            "type": "Price Code",
            "type_code": "Bond",
            "scale_factor": 0.01
        }
    },
    "portfolios": {
        "required": {
            "code": "Portfolio",
            "display_name":  "Account Name",
            "base_currency": {                            # Example of default/column syntax
                    "default": "GBP",                     # Default value to take
                    "column": "Account Base Currency"     # Column to attempt to take data from
            },
            "created": "$2018-01-01T00:00:00+00:00"
        }
    },
        "holdings": {
        "required": {
            "code": "Portfolio",
            "effective_at": "$2018-11-20T00:00:00+00:00",
            "tax_lots.units": "units"
        },
        "optional": {
            "tax_lots.cost.amount": "Amortized Cost (Local)",
            "tax_lots.cost.currency": "Trading Currency",
            "tax_lots.portfolio_cost": "Amortized Cost (Base)",
            "tax_lots.price": "Price (Local)"        
        },
        "identifier_mapping": {
            "ClientInternal": "Security Number"
        }
    },
    "cash_flag": {
        "cash_identifiers": {
            "FA Asset Group" : ["CC", "CU", "CA"]
        },
        "implicit": "Trading Currency"
    }
}