algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
krx.hpp
1#pragma once
2
3#include "../../core/instrument.hpp"
4
5namespace algotradelib {
6namespace krx {
7
13 PriceRule rule;
15 rule.source_ = "KRX cash equity tick table, 2023-01 revision (library-maintained)";
16 rule.bands_ = {
23 TickBand{Decimal64::parse("500000"), Decimal64::parse("1000")},
24 };
25 return rule;
26}
27
33 PriceRule rule;
35 rule.source_ = "KRX ETF and ETN tick table, 2023-12 revision (library-maintained)";
36 rule.bands_ = {
39 };
40 return rule;
41}
42
53 switch (type) {
54 case SecurityType::STOCK:
55 case SecurityType::FOREIGN_STOCK:
56 case SecurityType::DEPOSITARY_RECEIPT:
57 case SecurityType::INFRASTRUCTURE_FUND:
58 case SecurityType::REIT:
59 return equity_price_rule();
60 case SecurityType::ETF:
61 case SecurityType::ETN:
62 return fund_price_rule();
63 case SecurityType::FOREIGN_ETF:
64 return PriceRule::unknown("no price grid is confirmed for this foreign ETF class");
65 case SecurityType::STOCK_WARRANT:
66 case SecurityType::UNKNOWN:
67 break;
68 }
69 return PriceRule::unknown("no KRX price grid is known for this security type");
70}
71
72} // namespace krx
73} // namespace algotradelib
static Decimal64 parse(std::string_view input)
Parses a decimal string exactly (no binary floating point).
Definition types.hpp:468
The KRX tick tables that the Korean adapters attach to instruments, in <algotradelib/krx>.
Definition krx.hpp:6
PriceRule price_rule_for(SecurityType type)
Returns the KRX price grid for a kind of security listed on KRX.
Definition krx.hpp:52
PriceRule fund_price_rule()
Returns the KRX tick table for ETFs and ETNs (December 2023 revision).
Definition krx.hpp:32
PriceRule equity_price_rule()
Returns the KRX stock tick table (January 2023 revision).
Definition krx.hpp:12
The library: broker-neutral types (core), and the modules below.
SecurityType
What kind of security an instrument is.
The price grid (tick sizes) an instrument's order prices must sit on.
std::string source_
Where the table came from and its revision, or why there is none.
std::vector< TickBand > bands_
The bands, ascending by from_; empty unless kind_ is STATED.
@ STATED
bands_ describe the market's grid.
static PriceRule unknown(std::string reason)
Returns a rule that knows no grid and refuses to round.
Kind kind_
The kind of rule; UNKNOWN by default, so an unset rule refuses to round.
One band of a price grid: the tick size from a price upward, until the next band.