algotradelib
0.0.0.9000
C++ header-only library for algorithmic trading
Toggle main menu visibility
Loading...
Searching...
No Matches
krx.hpp
1
#pragma once
2
3
#include "../../core/instrument.hpp"
4
5
namespace
algotradelib
{
6
namespace
krx
{
7
12
inline
PriceRule
equity_price_rule
() {
13
PriceRule
rule;
14
rule.
kind_
=
PriceRule::Kind::STATED
;
15
rule.
source_
=
"KRX cash equity tick table, 2023-01 revision (library-maintained)"
;
16
rule.
bands_
= {
17
TickBand
{
Decimal64::parse
(
"0"
),
Decimal64::parse
(
"1"
)},
18
TickBand
{
Decimal64::parse
(
"2000"
),
Decimal64::parse
(
"5"
)},
19
TickBand
{
Decimal64::parse
(
"5000"
),
Decimal64::parse
(
"10"
)},
20
TickBand
{
Decimal64::parse
(
"20000"
),
Decimal64::parse
(
"50"
)},
21
TickBand
{
Decimal64::parse
(
"50000"
),
Decimal64::parse
(
"100"
)},
22
TickBand
{
Decimal64::parse
(
"200000"
),
Decimal64::parse
(
"500"
)},
23
TickBand
{
Decimal64::parse
(
"500000"
),
Decimal64::parse
(
"1000"
)},
24
};
25
return
rule;
26
}
27
32
inline
PriceRule
fund_price_rule
() {
33
PriceRule
rule;
34
rule.
kind_
=
PriceRule::Kind::STATED
;
35
rule.
source_
=
"KRX ETF and ETN tick table, 2023-12 revision (library-maintained)"
;
36
rule.
bands_
= {
37
TickBand
{
Decimal64::parse
(
"0"
),
Decimal64::parse
(
"1"
)},
38
TickBand
{
Decimal64::parse
(
"2000"
),
Decimal64::parse
(
"5"
)},
39
};
40
return
rule;
41
}
42
52
inline
PriceRule
price_rule_for
(
SecurityType
type) {
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
algotradelib::Decimal64::parse
static Decimal64 parse(std::string_view input)
Parses a decimal string exactly (no binary floating point).
Definition
types.hpp:468
algotradelib::krx
The KRX tick tables that the Korean adapters attach to instruments, in <algotradelib/krx>.
Definition
krx.hpp:6
algotradelib::krx::price_rule_for
PriceRule price_rule_for(SecurityType type)
Returns the KRX price grid for a kind of security listed on KRX.
Definition
krx.hpp:52
algotradelib::krx::fund_price_rule
PriceRule fund_price_rule()
Returns the KRX tick table for ETFs and ETNs (December 2023 revision).
Definition
krx.hpp:32
algotradelib::krx::equity_price_rule
PriceRule equity_price_rule()
Returns the KRX stock tick table (January 2023 revision).
Definition
krx.hpp:12
algotradelib
The library: broker-neutral types (core), and the modules below.
Definition
conversion.hpp:13
algotradelib::SecurityType
SecurityType
What kind of security an instrument is.
Definition
instrument.hpp:111
algotradelib::PriceRule
The price grid (tick sizes) an instrument's order prices must sit on.
Definition
instrument.hpp:150
algotradelib::PriceRule::source_
std::string source_
Where the table came from and its revision, or why there is none.
Definition
instrument.hpp:168
algotradelib::PriceRule::bands_
std::vector< TickBand > bands_
The bands, ascending by from_; empty unless kind_ is STATED.
Definition
instrument.hpp:166
algotradelib::PriceRule::Kind::STATED
@ STATED
bands_ describe the market's grid.
Definition
instrument.hpp:154
algotradelib::PriceRule::unknown
static PriceRule unknown(std::string reason)
Returns a rule that knows no grid and refuses to round.
Definition
instrument.hpp:276
algotradelib::PriceRule::kind_
Kind kind_
The kind of rule; UNKNOWN by default, so an unset rule refuses to round.
Definition
instrument.hpp:164
algotradelib::TickBand
One band of a price grid: the tick size from a price upward, until the next band.
Definition
instrument.hpp:135
algotradelib
src
brokers
common
krx.hpp
Generated by
1.18.0