FIX 4.0 Demo 1.0
Loading...
Searching...
No Matches
fix40::client::ClientApp Class Reference

客户端 FIX Application More...

#include <client_app.hpp>

Inheritance diagram for fix40::client::ClientApp:
Inheritance graph
Collaboration diagram for fix40::client::ClientApp:
Collaboration graph

Public Member Functions

 ClientApp (std::shared_ptr< ClientState > state, const std::string &userId)
 构造函数
 
 ~ClientApp () override=default
 
void onLogon (const SessionID &sessionID) override
 会话登录成功回调
 
void onLogout (const SessionID &sessionID) override
 会话登出回调
 
void fromApp (const FixMessage &msg, const SessionID &sessionID) override
 收到业务消息回调
 
void toApp (FixMessage &msg, const SessionID &sessionID) override
 发送业务消息前回调
 
void setSession (std::shared_ptr< Session > session)
 设置 Session
 
std::string sendNewOrder (const std::string &symbol, const std::string &side, int64_t qty, double price, const std::string &ordType="2")
 发送新订单
 
void sendCancelOrder (const std::string &origClOrdID, const std::string &symbol, const std::string &side)
 发送撤单请求
 
void queryBalance ()
 查询资金
 
void queryPositions ()
 查询持仓
 
void queryOrderHistory ()
 查询订单历史(服务端持久化)
 
void searchInstruments (const std::string &pattern, int maxResults=10)
 搜索合约
 
const std::string & getUserId () const
 获取用户ID
 
- Public Member Functions inherited from fix40::Application
virtual ~Application ()=default
 虚析构函数
 
virtual void fromAdmin (const FixMessage &msg, const SessionID &sessionID)
 收到管理消息回调
 
virtual void toAdmin (FixMessage &msg, const SessionID &sessionID)
 发送管理消息前回调
 
virtual IStoregetStore () const
 获取持久化存储接口(可选)
 

Detailed Description

客户端 FIX Application

实现 Application 接口,处理:

  • 登录/登出
  • 执行报告 (8)
  • 资金查询响应 (U2)
  • 持仓查询响应 (U4)
  • 账户推送 (U5)
  • 持仓推送 (U6)
  • 合约搜索响应 (U8)
  • 订单历史查询响应 (U10)

Constructor & Destructor Documentation

◆ ClientApp()

fix40::client::ClientApp::ClientApp ( std::shared_ptr< ClientState state,
const std::string &  userId 
)

构造函数

Parameters
state客户端状态管理器
userId用户ID(作为 SenderCompID)

◆ ~ClientApp()

fix40::client::ClientApp::~ClientApp ( )
overridedefault

Member Function Documentation

◆ fromApp()

void fix40::client::ClientApp::fromApp ( const FixMessage msg,
const SessionID sessionID 
)
overridevirtual

收到业务消息回调

Parameters
msg收到的 FIX 业务消息
sessionID消息来源的会话标识符

当收到非会话层消息(MsgType 不是 A/0/1/5)时调用。 典型的业务消息包括:

  • D: NewOrderSingle(新订单)
  • F: OrderCancelRequest(撤单请求)
  • 8: ExecutionReport(执行报告)
Warning
可能被多个工作线程并发调用! 推荐实现:只做轻量操作,将消息 push 到无锁队列

Implements fix40::Application.

Here is the call graph for this function:

◆ getUserId()

const std::string & fix40::client::ClientApp::getUserId ( ) const
inline

获取用户ID

◆ onLogon()

void fix40::client::ClientApp::onLogon ( const SessionID sessionID)
overridevirtual

会话登录成功回调

Parameters
sessionID已建立的会话标识符

当 FIX 会话成功建立(收到 Logon 确认)后调用。 可用于初始化交易状态、订阅行情等。

Note
可能被多个工作线程并发调用

Implements fix40::Application.

Here is the call graph for this function:

◆ onLogout()

void fix40::client::ClientApp::onLogout ( const SessionID sessionID)
overridevirtual

会话登出回调

Parameters
sessionID即将断开的会话标识符

当 FIX 会话即将断开(收到 Logout 或连接关闭)时调用。 可用于清理交易状态、取消未完成订单等。

Note
可能被多个工作线程并发调用

Implements fix40::Application.

Here is the call graph for this function:

◆ queryBalance()

void fix40::client::ClientApp::queryBalance ( )

查询资金

Here is the call graph for this function:
Here is the caller graph for this function:

◆ queryOrderHistory()

void fix40::client::ClientApp::queryOrderHistory ( )

查询订单历史(服务端持久化)

发送 U9 请求,服务端返回 U10 响应(Text 字段为序列化订单列表)。

Here is the call graph for this function:
Here is the caller graph for this function:

◆ queryPositions()

void fix40::client::ClientApp::queryPositions ( )

查询持仓

Here is the call graph for this function:
Here is the caller graph for this function:

◆ searchInstruments()

void fix40::client::ClientApp::searchInstruments ( const std::string &  pattern,
int  maxResults = 10 
)

搜索合约

Parameters
pattern搜索前缀
maxResults最大返回数量
Here is the call graph for this function:

◆ sendCancelOrder()

void fix40::client::ClientApp::sendCancelOrder ( const std::string &  origClOrdID,
const std::string &  symbol,
const std::string &  side 
)

发送撤单请求

Parameters
origClOrdID原订单ID
symbol合约代码
side买卖方向
Here is the call graph for this function:

◆ sendNewOrder()

std::string fix40::client::ClientApp::sendNewOrder ( const std::string &  symbol,
const std::string &  side,
int64_t  qty,
double  price,
const std::string &  ordType = "2" 
)

发送新订单

Parameters
symbol合约代码
side"1"=买, "2"=卖
qty数量
price价格(限价单)
ordType"1"=市价, "2"=限价
Returns
客户端订单ID
Here is the call graph for this function:

◆ setSession()

void fix40::client::ClientApp::setSession ( std::shared_ptr< Session session)

设置 Session

◆ toApp()

void fix40::client::ClientApp::toApp ( FixMessage msg,
const SessionID sessionID 
)
overridevirtual

发送业务消息前回调

Parameters
msg即将发送的 FIX 业务消息(可修改)
sessionID发送消息的会话标识符

在业务消息发送前调用,可用于:

  • 记录审计日志
  • 添加/修改字段
  • 消息验证

默认实现为空,子类可选择性重写。

Note
可能被多个工作线程并发调用

Reimplemented from fix40::Application.

Here is the call graph for this function:

The documentation for this class was generated from the following files: