You can model a Contract For Difference (CFD) as an instrument of type ContractForDifference
in LUSID. See all supported instruments.
Note there is an accompanying Jupyter Notebook that demonstrates many of the operations and concepts in this article.
Mastering an underlying instrument
Before you can create a ContractForDifference
, you must separately master the underlying instrument if this has not been done already.
To see how to do this, choose the appropriate instructions for the underlying asset class from this this table.
Mastering a ContractForDifference
instrument
There are numerous tools you can use to master an ContractForDifference
in the LUSID Security Master.
Some fields are common to all types of instrument, such as an intuitive name
, the requirement to specify a set of identifiers
, and the facility to store extra information as properties
.
Fields in the economic definition
object are specific to ContractForDifference
. For more information on these fields, select ContractForDifference from the definition dropdown in the UpsertInstruments API reference:
In this tutorial we’ll master a ContractForDifference
for 50 Apple shares, where Apple has been separately mastered as an Equity
with a LUID of LUID_6OHFNCI7
:
Note the following:
The
referenceRate
should be set to the price of the underlying. The gain or loss will then reference changes in the underlying against that price.If you are using the mark to market P&L model, set
referenceRate
to 0 instead (as per this example) and the transaction's total consideration is then the reference for gain or loss.The
contractSize
determines the leverage applied to the underlying asset.The
payCcy
and theunderlyingCcy
can be different.CFDs typically don't expire but you can set a
maturityDate
if you wish.If you want to explicitly set or maintain a funding leg against your equity position, please see the alternative
EquitySwap
instrument.
Providing the request is successful, the response:
Confirms the globally-unique LUID for the instrument, in this case,
LUID_00003D5A
. This is of course different to that of the underlying.Generates extra fields that are stored as part of the instrument definition and can be filtered on.
Supplies default values for fields not explicitly specified in the request:
Booking a transaction to establish a position
Once the instrument is mastered, you can call the UpsertTransactions API to purchase a quantity of the CFD in a particular portfolio.
As mentioned above, the CFD instrument determines contract size. In the transaction, you specify a number of contracts (units) to buy or sell. In our example, the transactionPrice.price
is the underlying price of 1 Apple share, and the totalConsideration.amount
is the units multiplied by price and the instrument's contract size. Note that the margin paid to the broker is typically booked as a separate fee or commission. For example:
Note this transaction uses the built-in StockIn
transaction type rather than the built-in Buy
, since there is no cash movement. However, you could define your own custom transaction type to represent CFD purchases if you wish, as demonstrated in section 3 of the accompanying Jupyter Notebook.
You can confirm your position at any time by calling the GetHoldings API with the appropriate LUID:
Valuing your position
To value your position, work through our valuation checklist.
In your recipe, you can choose between two valuation models. Specify:
ConstantTimeValueOfMoney
to set the PV to the unrealised gain (whether you choose to realise it daily or not).Discounting
to achieve the same effect, but taking into account a particular discount curve.
For a demonstration of the former, see section 5 of the accompanying Jupyter Notebook.
Assessing risk
LUSID supports both analytic and bump and valuation mechanisms for assessing risk; contact Technical Support if you need more information.
Managing P&L on a regular basis
You can choose between two models for managing P&L on a regular basis, for example at or near month end.
Mark to market model
This 'close out' mark to market model realises P&L for a period by booking it as a cash amount and resetting the CFD's cost price to today’s close (so the P&L is now 0). To choose this model, you must:
Set the
referenceRate
to0
when you create the CFD instrument.Manually book a transaction in a cash instrument. As demonstrated in section 5.3 of the accompanying Jupyter Notebook, from one month in there is a second line item for the Apple CFD representing cumulative cash adjustments. You can record this as a total for the portfolio, for the CFD position itself, or for a particular strategy combination of CFDs.
Cumulative P&L model
This 'non-close out' model maintains P&L as unrealised. To choose this model, set referenceRate
to the price of the underlying when you create the CFD instrument. You do not need to take any other action.
As demonstrated in section 5.3 of the Jupyter Notebook, the Amazon CFD is shown as a single line entry. The Present Value column in the valuation tables for Amazon shows the (lifetime) unrealised contract gain.
Closing your position and booking cash settlements
Typically, CFDs don't expire, so there may be no occasion to monitor the final cashflows on a contract.
You would normally close the position at a time when P&L is favourable to you. You would then book the final cash transaction to realise either the lifetime contract gain, or the gain since the last time you realised P&L, depending on the model chosen above.