Comments (1)
spdlog本身耗时就很大,会有一两百微秒的时延,所以用spdlog测量的时间误差比较大
先保证时间能够准确测量,在tick中加入当前毫秒时间字段
struct TickData : public pubsub::Serializable {
uint64_t current_time_us; // 加入该字段
MarketDataSource source;
datetime::Datetime datetime;
uint32_t ticker_id;
double last_price = 0;
double open_price = 0;
double highest_price = 0;
double lowest_price = 0;
double pre_close_price = 0;
double upper_limit_price = 0;
double lower_limit_price = 0;
uint64_t volume = 0;
uint64_t turnover = 0;
uint64_t open_interest = 0;
double ask[kMaxMarketLevel]{0};
double bid[kMaxMarketLevel]{0};
int ask_volume[kMaxMarketLevel]{0};
int bid_volume[kMaxMarketLevel]{0};
struct {
double iopv;
} etf;
SERIALIZABLE_FIELDS(current_time_us, source, datetime, ticker_id, last_price, open_price, highest_price,
lowest_price, pre_close_price, upper_limit_price, lower_limit_price, volume,
turnover, open_interest, ask, bid, ask_volume, bid_volume, etf.iopv);
};
在收到行情时,先在tick中记录当前时间
uint64_t GetCurrentTimeUs() {
timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_nsec / 1000 + ts.tv_sec * 1000000;
}
tick.current_time_us = GetCurrentTimeUs();
在策略端收到行情时
uint64_t current_us = GetCurrentTimeUs();
uint64_t delay_us = current_us - tick.current_time_us;
tick延迟大应该是由于ZeroMQ延迟大。
解决办法:开发基于共享内存的行情分发模块,可以让通信时延降低至1us以内。
from ft.
Related Issues (20)
- TradingEngine的下单时延需要优化 HOT 2
- 正在研究量化交易 HOT 3
- readme和master有明显差别,建议分支
- zmq连接建立的时刻发消息可能会丢失 HOT 1
- zmq pub/sub模式下,多个pub绑定同一个地址,只有一个pub能绑定成功 HOT 4
- TODO:行情回报分发以及交易指令分发全部基于无锁共享内存队列实现
- 拆分各个模块,用共享内存做IPC HOT 3
- Any plan on measuring tick to trade latency? HOT 4
- python的策略demo是否还能使用 HOT 2
- 行情服务和交易服务拆分为不同的进程
- 单账户多策略 HOT 1
- 本项目已不再维护,有意合作可直接联系作者 HOT 1
- 如果本地字符集中没有GB2312可能导致运行时抛出异常 HOT 1
- 今天提交了比较多无用commit...
- TODO:提出一个方便地获取并操作历史数据的解决方案 HOT 1
- 更好的算法交易平台当然需要大家提出更多的需求和想法~
- 是否需要跨平台?移植到Windows? HOT 1
- 重新设计风险管理模块,使其更易于扩展及更易于其他模块交互
- 之前专注于开发交易平台模块,现在开始对各个量化交易组件的研究及开发(即策略侧组件的开发) HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ft.