MT4客户端API

 

  测试地址供大家学习交流  可能会不定时不可用(:

  基于逆向客户端通讯实现

  可以用任意MT4服务器帐号测试(前提必须是正版MT4 最新版本)

 

登录

请求地址

http://{host}/srv/dologin

参数

名称

类型

必须

说明

server

string

yes

MT4服务器地址

login

int

yes

Mt4帐号

password

string

yes

密码

 

示例

http://47.75.183.195:89/srv/dologin?login=91813325&password=rl3gvpl&server=78.140.180.200:443

返回成功

{
  "result": 0,
  "msg": "no error",
  "data": {
    "guid": "3E1E618C969F4EA7910B4C81564F12A8",
    "user": {
      "login": 91813325,
      "group": "demo",
      "name": "Chunchao Li",
      "balance": 9962.24
    }
  }
}

 

 

 

持仓单据

请求地址

http://{host}/srv/trades

 

参数

名称

类型

必须

说明

guid

string

yes

登录返回的guid

示例

http://47.75.183.195:89/srv/trades?guid=15A325A71A94499DA45AE788E0CABB1C

返回成功

{
  "result": 0,
  "msg": "no error",
  "data": [
    {
      "order": 738559050,
      "login": 91813325,
      "symbol": "EURUSD",
      "digits": 5,
      "cmd": 1,
      "volume": 10,
      "open_time": 1618805832,
      "open_reserv": 0,
      "open_price": 1.19483,
      "sl": 0,
      "tp": 0,
      "close_time": 0,
      "value_date": 0,
      "commission": 0,
      "storage": 0,
      "close_price": 1.19532,
      "profit": -4.89999999999964,
      "taxes": 0,
      "magic": 0,
      "comment": "",
      "internal_id": 0,
      "activation": 0
    },
    {
      "order": 738558969,
      "login": 91813325,
      "symbol": "USDJPY",
      "digits": 3,
      "cmd": 0,
      "volume": 20,
      "open_time": 1618805816,
      "open_reserv": 0,
      "open_price": 108.568,
      "sl": 0,
      "tp": 0,
      "close_time": 0,
      "value_date": 0,
      "commission": 0,
      "storage": 0,
      "close_price": 108.618,
      "profit": 9.20999999999913,
      "taxes": 0,
      "magic": 0,
      "comment": "",
      "internal_id": 0,
      "activation": 0
    }
  ]
}

 

 

 

商品信息

请求地址

http://{host}/srv/symbols

 

参数

名称

类型

必须

说明

guid

string

yes

 

 

示例

http://47.75.183.195:89/srv/symbols?guid=15A325A71A94499DA45AE788E0CABB1C

 

行情推送

请求地址

ws://{host}/ws

 

参数

名称

类型

必须

说明

guid

string

yes

登录接口返回的guid

datatype

int

yes

0

 

 

示例

<html>
<head>
    <meta charset="UTF-8">	
<script>
var ws = new WebSocket("ws://47.75.183.195:89/ws"); 
ws.onopen = function() {
   var guid = '15A325A71A94499DA45AE788E0CABB1C'; 
   var msg = "{\"guid\":\""+guid+"\",\"datatype\":0}";
   alert(msg);	
   ws.send(msg);
};
ws.onmessage = function (evt) {
   console.log(evt.data);
};	
</script>
</head>		
<body>	
</body>

推送信息

 

报价

{"datatype": "5", "result": 0, "data": [{"symbol": "CADCHF", "digits": 5, "bid": 0.73616, "ask": 0.73624}]}

成交

{"datatype": "9", "result": 0, "data": [{"order": 738585298, "login": 91813325, "symbol": "USDCAD", "digits": 5, "cmd": 0, "volume": 20, "open_time": 1618810833, "open_reserv": 0, "open_price": 1.25121, "sl": 0, "tp": 0, "close_time": 0, "value_date": 0, "commission": 0, "storage": 0, "close_price": 1.25094, "profit": -4.32, "taxes": 0, "magic": 0, "comment": "", "internal_id": 0, "activation": 0}]}

 

 

登出

请求地址

http://{host}/srv/doLogout

 

参数

名称

类型

必须

说明

guid

string

yes

 

 

 

单据历史

请求地址

http://{host}/srv/tradesHistory

 

 

参数

名称

类型

必须

说明

server

string

yes

MT4服务器

login

int

yes

MT4帐号

password

string

yes

密码

timeFrom

int

yes

起始时间(时间戳)

timeTo

int

yes

截止时间(时间戳)(范围不超过30天)

 

示例

 

http://47.75.183.195:89/srv/tradesHistory?login=91813325&password=rl3gvpl&server=78.140.180.200:443&timeFrom=1617206400&timeTo=1618812000

返回成功

{
  "result": 0,
  "msg": "6",
  "data": [
    {
      "order": 738456674,
      "login": 91813325,
      "symbol": "",
      "digits": 0,
      "cmd": 6,
      "volume": 1,
      "open_time": 1618752105,
      "open_reserv": 0,
      "open_price": 0,
      "sl": 0,
      "tp": 0,
      "close_time": 1618752105,
      "value_date": 0,
      "commission": 0,
      "storage": 0,
      "close_price": 0,
      "profit": 10000,
      "taxes": 0,
      "magic": 0,
      "comment": "Deposit",
      "internal_id": 0,
      "activation": 0
    },
    {
      "order": 738549203,
      "login": 91813325,
      "symbol": "EURUSD",
      "digits": 5,
      "cmd": 0,
      "volume": 10,
      "open_time": 1618804158,
      "open_reserv": 3,
      "open_price": 1.19455,
      "sl": 0,
      "tp": 0,
      "close_time": 1618805685,
      "value_date": 0,
      "commission": 0,
      "storage": 0,
      "close_price": 1.19497,
      "profit": 4.2,
      "taxes": 0,
      "magic": 0,
      "comment": "",
      "internal_id": 0,
      "activation": 0
    },
    {
      "order": 738549893,
      "login": 91813325,
      "symbol": "GBPUSD",
      "digits": 5,
      "cmd": 0,
      "volume": 100,
      "open_time": 1618804266,
      "open_reserv": 3,
      "open_price": 1.38215,
      "sl": 0,
      "tp": 0,
      "close_time": 1618804941,
      "value_date": 0,
      "commission": 0,
      "storage": 0,
      "close_price": 1.38163,
      "profit": -52,
      "taxes": 0,
      "magic": 0,
      "comment": "",
      "internal_id": 0,
      "activation": 0
    },
    {
      "order": 738550075,
      "login": 91813325,
      "symbol": "USDCHF",
      "digits": 5,
      "cmd": 0,
      "volume": 100,
      "open_time": 1618804296,
      "open_reserv": 3,
      "open_price": 0.92129,
      "sl": 0,
      "tp": 0,
      "close_time": 1618804995,
      "value_date": 0,
      "commission": 0,
      "storage": 0,
      "close_price": 0.92131,
      "profit": 2.17,
      "taxes": 0,
      "magic": 0,
      "comment": "",
      "internal_id": 0,
      "activation": 0
    },
    {
      "order": 738553864,
      "login": 91813325,
      "symbol": "USDJPY",
      "digits": 3,
      "cmd": 1,
      "volume": 10,
      "open_time": 1618804957,
      "open_reserv": 3,
      "open_price": 108.641,
      "sl": 0,
      "tp": 0,
      "close_time": 1618805686,
      "value_date": 0,
      "commission": 0,
      "storage": 0,
      "close_price": 108.586,
      "profit": 5.07,
      "taxes": 0,
      "magic": 0,
      "comment": "",
      "internal_id": 0,
      "activation": 0
    },
    {
      "order": 738554245,
      "login": 91813325,
      "symbol": "EURUSD",
      "digits": 5,
      "cmd": 0,
      "volume": 20,
      "open_time": 1618805022,
      "open_reserv": 3,
      "open_price": 1.19483,
      "sl": 0,
      "tp": 0,
      "close_time": 1618805687,
      "value_date": 0,
      "commission": 0,
      "storage": 0,
      "close_price": 1.19497,
      "profit": 2.8,
      "taxes": 0,
      "magic": 0,
      "comment": "",
      "internal_id": 0,
      "activation": 0
    }
  ]
}

 

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值