dxFeed Graal CXX API
Loading...
Searching...
No Matches
dxfcpp::CandleType Struct Reference

Type of the candle aggregation period constitutes CandlePeriod type together its actual value. More...

#include <CandleType.hpp>

Public Member Functions

std::int64_t getPeriodIntervalMillis () const noexcept
 Returns candle type period in milliseconds as closely as possible.
 
const std::string & getName () const &noexcept
 Returns a name of this candle type.
 
const std::string & toString () const &noexcept
 Returns string representation of this candle type.
 

Static Public Member Functions

static std::optional< std::reference_wrapper< const CandleType > > parse (const std::string &s) noexcept
 Parses string representation of candle type into object.
 

Static Public Attributes

static const CandleType TICK {"TICK", "t", 0LL}
 Certain number of ticks.
 
static const CandleType SECOND {"SECOND", "s", 1000LL}
 Certain number of seconds.
 
static const CandleType MINUTE {"MINUTE", "m", 60LL * 1000LL}
 Certain number of minutes.
 
static const CandleType HOUR {"HOUR", "h", 60LL * 60LL * 1000L}
 Certain number of hours.
 
static const CandleType DAY {"DAY", "d", 24LL * 60LL * 60LL * 1000L}
 Certain number of days.
 
static const CandleType WEEK {"WEEK", "w", 7LL * 24LL * 60LL * 60LL * 1000LL}
 Certain number of weeks.
 
static const CandleType MONTH
 Certain number of months.
 
static const CandleType OPTEXP
 Certain number of option expirations.
 
static const CandleType YEAR
 Certain number of years.
 
static const CandleType VOLUME
 Certain volume of trades.
 
static const CandleType PRICE
 Certain price change, calculated according to the following rules:
 
static const CandleType PRICE_MOMENTUM
 Certain price change, calculated according to the following rules:
 
static const CandleType PRICE_RENKO
 Certain price change, calculated according to the following rules:
 

Detailed Description

Type of the candle aggregation period constitutes CandlePeriod type together its actual value.

Member Function Documentation

◆ getName()

const std::string & dxfcpp::CandleType::getName ( ) const &
inlinenoexcept

Returns a name of this candle type.

Returns
A name of this candle type

◆ getPeriodIntervalMillis()

std::int64_t dxfcpp::CandleType::getPeriodIntervalMillis ( ) const
inlinenoexcept

Returns candle type period in milliseconds as closely as possible.

Certain types like CandleType::SECOND and CandleType::DAY span a specific number of milliseconds. CandleType::MONTH, CandleType::OPTEXP and CandleType::YEAR are approximate. Candle type period of CandleType::TICK, CandleType::VOLUME, CandleType::PRICE, CandleType::PRICE_MOMENTUM and CandleType::PRICE_RENKO is not defined and this method returns 0.

Returns
aggregation period in milliseconds.

◆ parse()

static std::optional< std::reference_wrapper< const CandleType > > dxfcpp::CandleType::parse ( const std::string & s)
inlinestaticnoexcept

Parses string representation of candle type into object.

Any string that that is a prefix of candle type CandleType::getName() can be parsed (including the one that was returned by CandleType::toString()) and case is ignored for parsing.

Parameters
sThe string representation of candle type.
Returns
A candle type or std::nullopt if the string representation is invalid.

◆ toString()

const std::string & dxfcpp::CandleType::toString ( ) const &
inlinenoexcept

Returns string representation of this candle type.

The string representation of candle type is the shortest unique prefix of the lower case string that corresponds to its name. For example, CandleType::TICK is represented as "t", while CandleType::MONTH is represented as "mo" to distinguish it from CandleType::MINUTE that is represented as "m".

Returns
string representation of this candle price type.

Member Data Documentation

◆ PRICE

const CandleType dxfcpp::CandleType::PRICE
static

Certain price change, calculated according to the following rules:

  1. high(n) - low(n) = price range
  2. close(n) = high(n) or close(n) = low(n)
  3. open(n+1) = close(n)

where n is the number of the bar.

◆ PRICE_MOMENTUM

const CandleType dxfcpp::CandleType::PRICE_MOMENTUM
static

Certain price change, calculated according to the following rules:

  1. high(n) - low(n) = price range
  2. close(n) = high(n) or close(n) = low(n)
  3. open(n+1) = close(n) + tick size, if close(n) = high(n)
  4. open(n+1) = close(n) - tick size, if close(n) = low(n)

where n is the number of the bar.

◆ PRICE_RENKO

const CandleType dxfcpp::CandleType::PRICE_RENKO
static

Certain price change, calculated according to the following rules:

  1. high(n+1) - high(n) = price range or low(n) - low(n+1) = price range
  2. close(n) = high(n) or close(n) = low(n)
  3. open(n+1) = high(n), if high(n+1) - high(n) = price range
  4. open(n+1) = low(n), if low(n) - low(n+1) = price range

where n is the number of the bar.