|
dxFeed Graal CXX API v9.0.0
|
A Candle event is requested with a candle symbol: a market symbol with attributes that say how to build the candles.
The symbol is a CandleSymbol object or its string, AAPL{=5m,price=bid}: the base symbol, an optional & with an exchange code letter and an optional list of key=value pairs in curly braces. CandleSymbol::valueOf() and the _c literal parse such a string, the overloads of CandleSymbol::valueOf() with attributes build a symbol from objects: CandleSymbol::valueOf("AAPL", CandlePeriod::valueOf(5, CandleType::MINUTE)).
The period has an empty key, {=5m}: an optional value (1 by default, a fraction and the exponential form are allowed: {=0.5h}, {=1.5E1m}) and a type. A symbol without a period gives tick candles (CandlePeriod::TICK).
| Type | String | Example |
|---|---|---|
| CandleType::TICK | t | AAPL{=100t} |
| CandleType::SECOND | s | AAPL{=30s} |
| CandleType::MINUTE | m | AAPL{=5m} |
| CandleType::HOUR | h | AAPL{=h} |
| CandleType::DAY | d | AAPL{=d} |
| CandleType::WEEK | w | AAPL{=w} |
| CandleType::MONTH | mo | AAPL{=mo} |
| CandleType::OPTEXP | o | AAPL{=o} |
| CandleType::YEAR | y | AAPL{=y} |
| CandleType::VOLUME | v | AAPL{=1000v} |
| CandleType::PRICE | p | AAPL{=0.5p} |
| CandleType::PRICE_MOMENTUM | pm | AAPL{=0.5pm} |
| CandleType::PRICE_RENKO | pr | AAPL{=0.5pr} |
The type strings of the table are the canonical form, CandleSymbol::toString() writes them: a price is p. Like Java, the parser also takes the name of a type or the start of the name in any case ({=5min}, {=day}). An exact type string is taken first, and the start of a name is matched against the types in the order of the table, so a short string in a wrong case gives another type: M is a minute (a month is mo), PR and Pr are a price (a Renko price is pr). Both are typical mistakes, see below.
| Attribute | Key | Values |
|---|---|---|
| price | price | last (default), bid, ask, mark, s (settlement) |
| session | tho | false (all sessions, default), true (regular hours) |
| alignment | a | m (at midnight, default), s (at the session start) |
| price level | pl | a number, NaN by default |
| data type | dt | any string, for example source, tho, all, rth, eth |
| exchange | &X | after the base symbol, AAPL&Q{=5m}; composite by default |
Examples:
A wrong candle symbol is valid for the parser and for the feed, so it gives no error, only no candles or other candles than expected.
How far back the history of the candles goes depends on the period and on the data source: the shorter the period, the shorter the history.
CandleSymbol::valueOf() of a string and the _c literal report a warning for the first three mistakes through ErrorManager (see Error handling), and the symbol is created as before:
[dxfcpp] WARN #1 CandleSymbol (CandleSymbol.cpp:NNN): Candle symbol 'AAPL' has no period and gives tick candles; for other candles add a period, for example 'AAPL{=1m}' or 'AAPL{=d}', for tick candles write 'AAPL{=t}'
A warning is reported once per string, for the first 1000 strings in the process. The symbols of the received candles, the overloads of CandleSymbol::valueOf() with attributes and a string given to a subscription directly are not checked.