MultiMarkets API Docs
HomeGitHubReferenceLanguage
  • 概览
  • 快速开始
    • 服务状态
  • CLIENT API
    • 概述
    • 接入说明
      • 签名
      • 请求
      • 限速
      • 错误码
      • API地址
      • API代码
    • 授权访问
      • 人机校验
    • 客户管理
      • 客户注册
      • 更换令牌
      • API管理
        • 申请API
        • 设置权限
        • 删除API
    • 报价接口
      • 接入说明
      • 限制说明
      • 错误码说明
      • 订阅接口
        • 实时报价订阅
        • 盘口成交订阅
        • 取消报价订阅
      • 查询接口
        • 心跳
        • K线获取
    • Open API
      • 说明
        • 签名
        • 请求
        • 错误码
        • API地址
      • 下单流程
      • 基础数据
        • 产品简要数据
      • 客户资料
        • 客户基础信息
      • 交易接口
        • 合约下单
      • 消息接口
        • 获取消息Token
        • 消息订阅说明
      • 更多接口
    • Auth2 API
      • 说明
      • 获取授权码
      • 获取访问令牌
      • 获取用户信息
      • 刷新访问令牌
    • 更多...
  • Manager API
    • 概述
    • 接入说明
      • 签名
      • 请求
      • 限速
      • 错误码
      • API地址
      • API代码
    • 授权访问
    • 基础数据
      • 获取通用字典列表
      • 获取公司币种权限
    • 产品列表
      • 产品信息列表
    • 客户管理
      • 客户列表
      • 客户注册
      • 客户详情
      • 客户组列表
      • 账户信息
    • 资金管理
      • 额度调整
      • 余额查询
    • 数据推送
    • 更多...
  • BRIDGE API
    • 概述
    • 接入说明
      • 说明
      • 签名
      • 请求
      • 限速
      • 错误码
      • 产品清单
    • 基础数据
      • 获取通用字典列表
      • 获取公司币种权限
    • 产品数据
      • 产品信息列表
      • 产品规则列表
    • 客户管理
      • 客户注册
      • 客户列表
      • 客户详情
      • 客户销户
    • 账户管理
      • 添加账户
      • 更新账户
      • 查询账户
      • 删除账户
    • 交易接口
      • 查询余额
      • 查询入金记录
      • 查询出金记录
      • 查询划转记录
      • 下单
      • 查询订单
      • 订单列表
      • 成交记录
      • 当前挂单
      • 撤单
    • 消息订阅
      • 通知消息说明
      • Webhook订阅
      • 信息回调通知
  • Webhook API
    • 概述
    • 查询用户账户余额
    • 执行外部系统调额
    • 取消外部系统调额
  • Message API
    • 概述
    • 自定义消息API
  • WEB IFRAME
    • 介绍
    • 流程说明
  • FAQ
    • 接口如何申请apikey?
    • 公钥的用途是什么?
    • 接口请求超时时间是多少?
    • 支持的开发语言?
    • API调用限制有哪一些?
    • 如何更安全使用API?
  • API Reference
    • Manager API
    • Client API
  • CHANGELOGS
    • API
Powered by GitBook
On this page
  • 订阅消息流程:
  • 1.获取token
  • 2.订阅成交消息:
  • 交易下单流程:
  • 1.请求产品信息:
  • 2.请求客户信息:
  • 3.交易下单请求:
  • 4.处理下结果:
  1. CLIENT API
  2. Open API

下单流程

PreviousAPI地址Next基础数据

Last updated 11 months ago

订阅消息流程:

1.获取token

调用接口:

取出返回结果中的data字段备用,这个就是token

2.订阅成交消息:

接口文档说明:

2.1 先建立连接

PRE环境地址:wss://pre-api-test.cmfbl.com/openapi-c/openMsg/{appId}

2.2 登录发送消息:

{"device":1,"head":{"lang":"en-US","msgType":"login","sendTime":1698299047686,"token":"dbe3d3e6-0b10-4bdc-9778-dfc76c6d9341app"},"seqId":3,"trace":"x-1698299047686-4"}  

2.3 订阅发送消息:

{"data":{"tradeTypes":"2"},"device":1,"head":{"lang":"en-US","msgType":"subscribe_asset","sendTime":1698299047686,"token":"dbe3d3e6-0b10-4bdc-9778-dfc76c6d9341app"},"seqId":5,"trace":"x-1698299047686-6"}  

2.4 另外每15秒发送一下心跳消息,保持心跳:

{"device":1,"head":{"lang":"en-US","msgType":"ping","sendTime":1698299057667,"token":"dbe3d3e6-0b10-4bdc-9778-dfc76c6d9341app"},"seqId":7,"trace":"x-1698299057667-8"}

交易下单流程:

1.请求产品信息:

取出symbolId,symbolDigits备用。

2.请求客户信息:

取出accountList中的trade_type=2的那条数据中的accountId,digits,currency备用。

3.交易下单请求:

参数示例: http header:

Version: 0.01  
Group: tradeApi  
Trace: [Custom unique string] 
Content-Type: application/json  
Accept: application/json  
Apikey: [Already provided.]  
Timestamp: [Millisecond timestamp]
CompanyId: [Already provided (Test field: 439)] 
Signature: Signature, the generation rules are here <https://mtf.readme.io/reference/sgin, with example reference.>

http body:

{
     "accountCurrency":"CNY", //Parameters obtained in step 2
     "accountDigits":2, //Parameters obtained in step 2
     "accountId":1034124, //Parameters obtained in step 2
     "bizType":1, //Currently only supports these four types: business types, 1-market price opening; 2-market price flat; 13-limit price opening order; 14-limit price closing order
     "crossLevelNum":1, //fixed with 1
     "direction":1, //Order buying and selling direction, 1-buy; 2-sell;
     "entryType":1, //Order type 1 by quantity, 2 by amount
     "expireType":1, //limit order expiration type, 1-valid on the day; 2-valid on the week;
     "requestNum":"0.100000", //Order lot size or order amount, used with entryType
     "requestPrice":"167655", //The decimal place obtained in step 1 is used to convert the quotation into an integer. For example, if the decimal place is 3 and the quotation is 1.23, it will be converted to: 1230
     "requestTime":1698299972000,
     "symbolId":8390, //Parameters obtained in step 1
     "tradeType":2 //Fixed to 2
}

4.处理下结果:

收到第3步的回应后取出code看是否为"0", 当结果是"0"时,代表下单委托成功,此时取出data中的orderId字段,也成交消息中的orderId字段对应起来,就形成完整的交易流程。 成交消息中的字段说明:

{
     "trace":"x-1698310473323-102_b_bb76b676-8d8e-4278-82be-6ae7e063c9d3",
     "msgCode":"trade", //Only need to pay attention to msgCode=trade
     "content":{
         "accountId":1034124,
         "companyId":439,
         "bizType":"POSITION_OPEN", //POSITION_OPEN: Market price opening was successful, POSITION_CLOSE: Market price closing was successful, ME_POSITION_LIMIT_OPEN: Limit price opening was successful, ME_POSITION_LIMIT_CLOSE: Limit price closing was successful POSITION_OPEN_FAIL: Market price opening failed, ME_POSITION_LIMIT_FAIL: Limit price opening was Warehouse failed
         "customerId":2482,
         "paramMap":{
             "date":"1698310474529",
             "orderType":"1",
             "symbolId":"8390",
             "dealExecuteTime":"1698310474529",
             "orderBizType":"1",
             "orderId":"21257491", //Order ID
             "pendingId":"0",
             "dealId":"21262382",
             "accountCurrency":"CNY",
             "orderStatus":"2", //Order status: 1-order received; 2-order completed; 3-order partially completed; 4-order canceled; 5-order partially canceled; 6-order rejected; 7-order expired ;
             "dealExecuteNum":"8000.0",
             "source":"H5",
             "dealPrice":"1.67094", //Transaction price
             "requestAmount":"0.08",
             "takeProfitMsg":"--",
             "currency":"CNY",
             "symbolName":"EURAUD",
             "contractSize":"100000", //Contract size
             "sourceExecuteVolSum":"0.100000",
             "commission":"0",
             "sourceExecuteVol":"0.100000",
             "direction":"2",
             "dealAmount":"0.08", //Number of lots traded
             "accountId":"1034124",
             "companyId":"439",
             "positionId":"2023102650229", //Position ID
             "dealExecutePrice":"1.67094",
             "playType":"2",
             "orderDirection":"2",
             "symbolDigits":"5",
             "stopLossMsg":"--",
             "Margin":"59371.20"
         },
         "tradeType":2
     },
     "timestamp":1698310474563
}

调用接口:

调用接口:

调用接口:

获取token
消息订阅对接
产品简要数据
查询客户信息
下单