合约行情快照
More...
#include <market_data_snapshot.hpp>
合约行情快照
存储合约的实时行情数据,用于撮合引擎判断订单成交条件。 数据来源于 CTP 行情推送,经过转换后存储在此结构中。
- 撮合规则
- 买单成交条件:买价 >= 卖一价(askPrice1)
- 卖单成交条件:卖价 <= 买一价(bidPrice1)
- 使用示例
}
合约行情快照
Definition market_data_snapshot.hpp:47
int32_t askVolume1
卖一量
Definition market_data_snapshot.hpp:60
double askPrice1
卖一价(最低卖价)
Definition market_data_snapshot.hpp:59
int32_t bidVolume1
买一量
Definition market_data_snapshot.hpp:58
bool isValid() const
检查行情是否有效
Definition market_data_snapshot.hpp:124
std::string instrumentId
合约代码(如 "IF2601")
Definition market_data_snapshot.hpp:51
double bidPrice1
买一价(最高买价)
Definition market_data_snapshot.hpp:57
double lastPrice
最新价
Definition market_data_snapshot.hpp:56
◆ MarketDataSnapshot() [1/2]
| fix40::MarketDataSnapshot::MarketDataSnapshot |
( |
| ) |
|
|
inline |
默认构造函数
初始化所有数值字段为 0,时间戳为当前时间。
◆ MarketDataSnapshot() [2/2]
| fix40::MarketDataSnapshot::MarketDataSnapshot |
( |
const std::string & |
instId | ) |
|
|
inlineexplicit |
◆ getMidPrice()
| double fix40::MarketDataSnapshot::getMidPrice |
( |
| ) |
const |
|
inline |
获取中间价
- Returns
- (买一价 + 卖一价) / 2,如果任一价格无效则返回最新价
◆ getSpread()
| double fix40::MarketDataSnapshot::getSpread |
( |
| ) |
const |
|
inline |
获取买卖价差
- Returns
- 卖一价 - 买一价,如果任一价格无效则返回 0
- Note
- 正常情况下价差应为正数(卖一价 > 买一价)。 如果返回负值,表示出现"crossed quotes"异常行情, 调用方应检查数据有效性。
◆ hasAsk()
| bool fix40::MarketDataSnapshot::hasAsk |
( |
| ) |
const |
|
inline |
检查是否有卖盘
- Returns
- 如果卖一价和卖一量都大于 0 返回 true
◆ hasBid()
| bool fix40::MarketDataSnapshot::hasBid |
( |
| ) |
const |
|
inline |
检查是否有买盘
- Returns
- 如果买一价和买一量都大于 0 返回 true
◆ isValid()
| bool fix40::MarketDataSnapshot::isValid |
( |
| ) |
const |
|
inline |
检查行情是否有效
行情有效的条件是买一价或卖一价大于 0。 无效行情不能用于撮合判断。
- Returns
- 如果行情有效返回 true
- Note
- 价格为 0 或负数视为无效行情(未初始化或数据异常)
◆ operator!=()
不等比较操作符
- Parameters
-
- Returns
- 如果任意字段不相等则返回 true
◆ operator==()
相等比较操作符
比较两个行情快照的所有字段是否相等(不包括时间戳)。
- Parameters
-
- Returns
- 如果所有字段相等则返回 true
- Note
- 此操作符使用精确比较,适用于序列化/反序列化的 round-trip 测试。 如需比较计算结果,请使用带容差的比较方法。
◆ askPrice1
| double fix40::MarketDataSnapshot::askPrice1 |
◆ askVolume1
| int32_t fix40::MarketDataSnapshot::askVolume1 |
◆ bidPrice1
| double fix40::MarketDataSnapshot::bidPrice1 |
◆ bidVolume1
| int32_t fix40::MarketDataSnapshot::bidVolume1 |
◆ instrumentId
| std::string fix40::MarketDataSnapshot::instrumentId |
◆ lastPrice
| double fix40::MarketDataSnapshot::lastPrice |
◆ lowerLimitPrice
| double fix40::MarketDataSnapshot::lowerLimitPrice |
◆ updateTime
| std::chrono::system_clock::time_point fix40::MarketDataSnapshot::updateTime |
◆ upperLimitPrice
| double fix40::MarketDataSnapshot::upperLimitPrice |
The documentation for this struct was generated from the following file: