---
title: "CFD"
description: "A CFD is a contract where the buyer must pay the seller the difference between the current value of an asset and its value at contract time."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/cfd
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/cfd.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/03%20Securities/99%20Asset%20Classes/10%20CFD
modified: 2026-10-30
index: https://www.quantconnect.com/llms.txt
---

# CFD

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Securities > [Asset Classes](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes.md) > CFD

> Code examples are shown in Python. Append `?lang=csharp` to this URL for the C# version of this page.

A contract for difference (CFD) is a contract between a buyer and a seller that stipulates that the buyer must pay the seller the difference between the current value of an asset and its value at contract time.

- [Requesting Data](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/cfd/requesting-data.md)
- [Handling Data](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/cfd/handling-data.md)
- [Market Hours](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/cfd/market-hours.md)

### See Also

- [BasicTemplateCfdAlgorithm.py](https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/BasicTemplateCfdAlgorithm.py)
- [BasicTemplateCfdAlgorithm.cs](https://github.com/QuantConnect/Lean/blob/master/Algorithm.CSharp/BasicTemplateCfdAlgorithm.cs)

## Pages in This Section

- [Requesting Data](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/cfd/requesting-data.md): Request Contract for Difference (CFD) data in your algorithm to receive a feed of contract prices in the OnData method.
- [Handling Data](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/cfd/handling-data.md): LEAN passes the data you request to the OnData method so you can make trading decisions. The Slice object groups the data together with a timestamp.
- [Market Hours](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/cfd/market-hours.md): This page shows the trading hours, holidays, and time zone of the CFD market.
