# 委托追单 **Repository Path**: haifengat/after_single ## Basic Information - **Project Name**: 委托追单 - **Description**: 提供 http 服务,用于委托&追单. - **Primary Language**: Go - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 4 - **Created**: 2022-08-14 - **Last Updated**: 2025-01-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [![海风/委托追单](https://gitee.com/haifengat/after_single/widgets/widget_card.svg?colors=4183c4,ffffff,ffffff,e3e9ed,666666,9b9b9b)](https://gitee.com/haifengat/after_single)
Fork me on Gitee
star
# 委托追单 ## 介绍 委托追单服务,通过 http 传递委托参数,接收数据后,根据配置进行委托撤单追单等操作。 ## 安装教程 ### Makefile 部署 如果提示 curdate 不正确,请指定变量 ```sh make deploy CURDATE=yyyyMMdd ``` ### docker-compose 部署 ```yaml version: "3.7" services: # 启动: docker-compose --compatibility up -d after_single: image: haifengat/after_single container_name: after_single restart: on-failure:3 ports: - 8765:80 environment: - TZ=Asia/Shanghai - tradeFront=tcp://180.168.146.187:10101 - quoteFront=tcp://180.168.146.187:10111 - loginInfo=9999/008107/1/simnow_client_test/0000000000000000 - firstOffset=0 - cancelSeconds=3 - reorderTimes=3 - reorderOffset=2 ``` #### 参数说明 - tradeFront 交易前置 - quoteFront 行情前置 - loginInfo 登录配置 broker/investor/password/appid/authcode - firstOffset 首次发单偏移 实际委托价格以委托参数中的 price 加上此参数 × 最小变动作为偏移量。如示例中价格 4090,rb 最小变动(priceTick)为 10,实际委托价=price+firstOffset*priceTick,63460+2*10=63480 - cancelSeconds 撤单秒数 委托后 n 秒内未成交,对委托进行撤单处理。 - reorderTimes 重发次数 撤单成功后重新发送委托进行追单,追单次数由此参数控制,达到次数后以板价委托。buy 涨板价,sell 跌板价。 - reorderOffset 重发偏移 在重发追单时,以当前行情的对价加上此参数 × 最小变动的偏移量。 ## 使用说明 ### 委托 ```sh curl -i http://localhost:8765/order --header 'Content-Type: application/json' -d '{ "instrument": "rb2210", "direction": "sell", "offset": "close", "price": 4090, "volume": 1, "remark": "正确用例" }' curl -i http://localhost:8765/order --header 'Content-Type: application/json' -d '{ "instrument": "n1903", "direction": "buy", "offset": "close", "price": 3184.92, "volume": 19, "remark": "错误用例" }' ``` #### 参数说明 - instrument 合约 - direction 买卖 取值 buy sell - offset 开平 取值 open close - price 价格 - volume 手数 - remark 备注 ### 更新配置 ```sh curl -i http://localhost:8765/config --header 'Content-Type: application/json' -d '{ "firstOffset": -2, "cancelSeconds": 3, "reorderTimes": 3, "reorderOffset": -2 }' ``` firstOffset 和 reorderOffset 均为负值,以测试追单效果