合约静态信息
More...
#include <instrument.hpp>
合约静态信息
期货合约的基本属性,包含交易规则相关的参数。 系统通过此结构进行保证金计算和价格有效性检查。
- 保证金计算
- 保证金 = 价格 × 数量 × 合约乘数 × 保证金率
- 使用示例
合约静态信息
Definition instrument.hpp:48
bool isPriceValid(double price) const
检查价格是否在涨跌停范围内
Definition instrument.hpp:141
double calculateMargin(double price, int64_t volume) const
计算开仓保证金
Definition instrument.hpp:127
double priceTick
最小变动价位(如 0.2)
Definition instrument.hpp:59
double marginRate
保证金率(如 0.12 表示 12)
Definition instrument.hpp:61
int volumeMultiple
合约乘数(如 300)
Definition instrument.hpp:60
std::string instrumentId
合约代码(如 "IF2601")
Definition instrument.hpp:52
std::string exchangeId
交易所代码(如 "CFFEX")
Definition instrument.hpp:53
◆ Instrument() [1/2]
| fix40::Instrument::Instrument |
( |
| ) |
|
|
inline |
◆ Instrument() [2/2]
| fix40::Instrument::Instrument |
( |
const std::string & |
instId, |
|
|
const std::string & |
exchId, |
|
|
const std::string & |
prodId, |
|
|
double |
tick, |
|
|
int |
multiple, |
|
|
double |
margin |
|
) |
| |
|
inline |
带基本参数的构造函数
- Parameters
-
| instId | 合约代码 |
| exchId | 交易所代码 |
| prodId | 品种代码 |
| tick | 最小变动价位 |
| multiple | 合约乘数 |
| margin | 保证金率 |
◆ calculateMargin()
| double fix40::Instrument::calculateMargin |
( |
double |
price, |
|
|
int64_t |
volume |
|
) |
| const |
|
inline |
计算开仓保证金
根据价格和数量计算所需的保证金。
- Parameters
-
- Returns
- 所需保证金金额
- 计算公式
- 保证金 = 价格 × 数量 × 合约乘数 × 保证金率
◆ isPriceTickValid()
| bool fix40::Instrument::isPriceTickValid |
( |
double |
price | ) |
const |
|
inline |
检查价格是否符合最小变动价位
验证给定价格是否是最小变动价位的整数倍。
- Parameters
-
- Returns
- 如果价格符合最小变动价位返回 true
- Note
- 使用容差比较以处理浮点数精度问题
◆ isPriceValid()
| bool fix40::Instrument::isPriceValid |
( |
double |
price | ) |
const |
|
inline |
检查价格是否在涨跌停范围内
验证给定价格是否在当日涨跌停价格范围内。
- Parameters
-
- Returns
- 如果价格在有效范围内返回 true
- Note
- 如果涨跌停价格未设置(为0),则认为价格有效
◆ operator!=()
| bool fix40::Instrument::operator!= |
( |
const Instrument & |
other | ) |
const |
|
inline |
不等比较操作符
- Parameters
-
- Returns
- 如果任意字段不相等则返回 true
◆ operator==()
| bool fix40::Instrument::operator== |
( |
const Instrument & |
other | ) |
const |
|
inline |
相等比较操作符
比较两个合约的所有字段是否相等。
- Parameters
-
- Returns
- 如果所有字段相等则返回 true
- Note
- 此操作符使用精确比较,适用于序列化/反序列化的 round-trip 测试。 如需比较计算结果,请使用带容差的比较方法。
◆ updateLimitPrices()
| void fix40::Instrument::updateLimitPrices |
( |
double |
upper, |
|
|
double |
lower |
|
) |
| |
|
inline |
更新涨跌停价格
从行情数据更新涨跌停价格。
- Parameters
-
◆ exchangeId
| std::string fix40::Instrument::exchangeId |
◆ instrumentId
| std::string fix40::Instrument::instrumentId |
◆ lowerLimitPrice
| double fix40::Instrument::lowerLimitPrice |
◆ marginRate
| double fix40::Instrument::marginRate |
◆ preSettlementPrice
| double fix40::Instrument::preSettlementPrice |
◆ priceTick
| double fix40::Instrument::priceTick |
◆ productId
| std::string fix40::Instrument::productId |
◆ upperLimitPrice
| double fix40::Instrument::upperLimitPrice |
◆ volumeMultiple
| int fix40::Instrument::volumeMultiple |
The documentation for this struct was generated from the following file: