FIX 4.0 Demo 1.0
Loading...
Searching...
No Matches
fix40::MarketDataSnapshot Struct Reference

合约行情快照 More...

#include <market_data_snapshot.hpp>

Collaboration diagram for fix40::MarketDataSnapshot:
Collaboration graph

Public Member Functions

 MarketDataSnapshot ()
 默认构造函数
 
 MarketDataSnapshot (const std::string &instId)
 带合约代码的构造函数
 
bool isValid () const
 检查行情是否有效
 
bool hasBid () const
 检查是否有买盘
 
bool hasAsk () const
 检查是否有卖盘
 
double getSpread () const
 获取买卖价差
 
double getMidPrice () const
 获取中间价
 
bool operator== (const MarketDataSnapshot &other) const
 相等比较操作符
 
bool operator!= (const MarketDataSnapshot &other) const
 不等比较操作符
 

Public Attributes

std::string instrumentId
 合约代码(如 "IF2601")
 
double lastPrice
 最新价
 
double bidPrice1
 买一价(最高买价)
 
int32_t bidVolume1
 买一量
 
double askPrice1
 卖一价(最低卖价)
 
int32_t askVolume1
 卖一量
 
double upperLimitPrice
 涨停价
 
double lowerLimitPrice
 跌停价
 
std::chrono::system_clock::time_point updateTime
 行情更新时间
 

Detailed Description

合约行情快照

存储合约的实时行情数据,用于撮合引擎判断订单成交条件。 数据来源于 CTP 行情推送,经过转换后存储在此结构中。

撮合规则
  • 买单成交条件:买价 >= 卖一价(askPrice1)
  • 卖单成交条件:卖价 <= 买一价(bidPrice1)
使用示例
snapshot.instrumentId = "IF2601";
snapshot.lastPrice = 4000.0;
snapshot.bidPrice1 = 3999.8;
snapshot.bidVolume1 = 100;
snapshot.askPrice1 = 4000.2;
snapshot.askVolume1 = 50;
if (snapshot.isValid()) {
// 可以用于撮合判断
}
合约行情快照
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

Constructor & Destructor Documentation

◆ MarketDataSnapshot() [1/2]

fix40::MarketDataSnapshot::MarketDataSnapshot ( )
inline

默认构造函数

初始化所有数值字段为 0,时间戳为当前时间。

◆ MarketDataSnapshot() [2/2]

fix40::MarketDataSnapshot::MarketDataSnapshot ( const std::string &  instId)
inlineexplicit

带合约代码的构造函数

Parameters
instId合约代码

Member Function Documentation

◆ 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
Here is the caller graph for this function:

◆ hasBid()

bool fix40::MarketDataSnapshot::hasBid ( ) const
inline

检查是否有买盘

Returns
如果买一价和买一量都大于 0 返回 true
Here is the caller graph for this function:

◆ isValid()

bool fix40::MarketDataSnapshot::isValid ( ) const
inline

检查行情是否有效

行情有效的条件是买一价或卖一价大于 0。 无效行情不能用于撮合判断。

Returns
如果行情有效返回 true
Note
价格为 0 或负数视为无效行情(未初始化或数据异常)

◆ operator!=()

bool fix40::MarketDataSnapshot::operator!= ( const MarketDataSnapshot other) const
inline

不等比较操作符

Parameters
other另一个行情快照
Returns
如果任意字段不相等则返回 true

◆ operator==()

bool fix40::MarketDataSnapshot::operator== ( const MarketDataSnapshot other) const
inline

相等比较操作符

比较两个行情快照的所有字段是否相等(不包括时间戳)。

Parameters
other另一个行情快照
Returns
如果所有字段相等则返回 true
Note
此操作符使用精确比较,适用于序列化/反序列化的 round-trip 测试。 如需比较计算结果,请使用带容差的比较方法。

Member Data Documentation

◆ 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

合约代码(如 "IF2601")

◆ 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: