Files
Alexandre Catarino 42b9d7666b
Rebase Organization Branches / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
API Tests / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Fix the USD/KRW minimum price variation (#9656)
The oanda USD/KRW entry declared a 0.00001 minimum price variation, the
generic five decimal forex default, for a pair that IB quotes around
1430: three orders of magnitude finer than its real tick, and out of
line with the other big number oanda pairs, which scale it (USD/JPY,
USD/HUF, USD/INR and USD/THB all use 0.001).

Interactive Brokers reports 0.01 as the minimum tick of its USD/KRW
IDEALPRO contract, so a limit order priced at 1395.123 is rounded down
to 1395.12 before it is sent. LEAN rounds order prices with the symbol
properties value, so the brokerage was the only thing keeping sub tick
prices from being used, and a backtest would rest limit orders at prices
the venue cannot represent.

The interactivebrokers entry, added by #9585 with the correct tick, is
removed: forex resolves through the brokerage model default market,
which is oanda for Interactive Brokers, so it is only reachable by
passing the market explicitly and it duplicates the oanda one.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 11:37:46 -03:00
..
2019-03-14 12:13:14 +01:00
2024-01-05 16:57:19 -03:00

alt tag

LEAN Data Formats

Introduction

From the beginning, LEAN has strived to use an open, human-readable data format - independent of any specific database or file format. From this core philosophy, we built LEAN to read its financial data from flat files on disk. Data compression is done in zip format, and all individual files are CSV or JSON.

When there is no activity for a security, the price is omitted from the file. Only new ticks and price changes are recorded.

File Data Format

Although we strive to make all data formats identical, it is often impossible. Below are links to dedicated documentation on the file format of the data in each asset type:

Equity | Forex | Options | Futures | Crypto

Folder Structure

Data files are separated and nested in a few predictable layers:

  • Tick, Second and Minute Financial Data: /data/securityType/marketName/resolution/ticker/date_tradeType.zip

  • Hour, Daily Financial Data: /data/securityType/marketName/resolution/ticker.zip

The marketName value is used to separate different tradable assets with the same ticker. E.g. EURUSD is traded on multiple brokerages all with slightly different prices.

Core Data Types

LEAN has a few core data types represented in all the asset classes we support. Below are links to their implementation in LEAN.

  • TradeBar - TradeBar represents trade ticks of assets consolidated for a period. TradeBar file format is slightly different for high resolution (second, minute) and low resolution (daily, hour).

  • QuoteBar - QuoteBar represents top of book quote data consolidated over a period of time (bid and ask bar).

  • Tick - Tick data represents an individual record of trades ("trade ticks") or quote updates ("quote tick") for an asset. Tick data is instantaneous - it does not have a period.

Data Readers

All data is parsed from disk via Reader() methods. The Reader takes a single line of the file and converts it the appropriate type. i.e. TradeBar.Reader() method is a factory which returns TradeBar objects. When implementing custom data, Readers are used

Other Data Formats

Theoretically LEAN can accept data in any format (database, API or flatfile). However, in practice, we currently have reader implementations written for a flat file system.