1 Star 0 Fork 15

Eone / go_real_md

forked from 海风 / go_real_md 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 1.95 KB
一键复制 编辑 原始数据 按行查看 历史
海风 提交于 2021-02-06 21:54 . 增加:pgmin建表功能

go_real_md

介绍

golang 接收CTP实时行情

软件架构

  1. 采用goctp接口订阅行情
  2. 接收后合成分钟数据落入redis
  3. 以md.{instrumentid}发布分钟数据,应用端可订阅后接收分钟数据。
  4. 收盘后分钟数据保存至postgres数据库中

分钟处理

  • 只处理处于可交易状态的品种(会过滤掉开/收时的tick)
  • 处理actionDay
    • tradingday前一交易日为actionDay
    • actionDay下一自然日为actionDayNight
    • hour>=17 取 actionDay
    • hour<=3 取 actionDayNight
    • hour其他 取 tradingDay
  • 分钟Volume
    • preVol前一分钟最后tick的Volume
    • 当前分钟的Volume = tick.Volume-preVol

使用说明

环境变量

变量 默认值 说明
tradeFront tcp://180.168.146.187:10130 ctp交易前置
quoteFront tcp://180.168.146.187:10131 ctp行情前置
loginInfo 9999/008107/1/simnow_client_test/0000000000000000 登录配置格式 broker/investor/pwd/appid/authcode
redisAddr 127.0.0.1:6379 redis库配置host:port
pgMin 127.0.0.1:5432 分钟pg库配置

生成镜像

# 先编码再做镜像(要用centos基础镜像)
go build -o realmd
docker build -t haifengat/go_real_md:`date +%Y%m%d` .
# hub.docker.com
docker push haifengat/go_real_md:`date +%Y%m%d`

行情订阅后收不到ontick响应

原因:交易所状态处理问题 处理:已修复

接口断开重连,收不到login响应

原因:猜测为匿名函数被回收 解决:实际函数替代匿名函数

收盘时间的tick仍被处理

双tick仍无法避免,即15:00:00时收到2两个tick。例:y2105 20201214 解决:3tick

concurrent map read and map write

原因是mapMin变量用map[string]interface{}保存分钟数据,在lastInstMin读取时冲突 解决:改为Bar{}

pq: duplicate key value violates unique constraint "future_min_datetime_instrument

ticks改用bar.ticks处理 分钟是否更新用 > 判断,防止小于当前分钟的数据生成

Go
1
https://gitee.com/fhaoquan/go_real_md.git
git@gitee.com:fhaoquan/go_real_md.git
fhaoquan
go_real_md
go_real_md
master

搜索帮助