FMZ Quant has opened the platform’s extended API interface to support programmatic calls to various functions of the FMZ Quant Trading Platform.
The FMZ Quant Trading Platform supports the permission management of the
extended API interface, and the permission of API KEY
can be set. On the “API interface” option on the “Account settings”
(https://www.fmz.com/m/account) page of the platform, click the “Create
new ApiKey” button to create the extension API KEY
.
You can edit the “API Permission” input box when creating an API KEY
, and enter the *
symbol to enable all Extended API interface permissions. If you want to specify specific interface permissions, you need to enter the corresponding extended API function name. Use commas to separate, for example: GetRobotDetail,DeleteRobot
. This gives this API KEY
the permission to call the Get live trading detailed information interface and the Delete live trading interface.
The API KEY
management page also allows you to modify,
disable, delete the created API KEY
.
An example of the structure returned by the extended API interface is as follows:
"code":0,
"data":{
// ...
}
}
The code
field is: The call result status code returned when the extended API interface is called.
Description | Code |
---|---|
Successful execution | 0 |
Wrong API KEY | 1 |
Wrong signature | 2 |
Nonce error | 3 |
Incorrect method | 4 |
Incorrect parameter | 5 |
Internal unknown error | 6 |
The GetRobotList
interface, the GetRobotDetail
interface,
and the GetRobotLogs
interface return data in the status
field for: the live trading status code.
Status | Code |
---|---|
Idle | 0 |
In operation | 1 |
Stopping | 2 |
Signed out | 3 |
Stopped | 4 |
The strategy has errors | 5 |
Status | Code |
---|---|
The strategy has expired, and please contact the writer to buy it again | -1 |
No docker found | -2 |
Strategy compilation error | -3 |
The live trading is already running | -4 |
Insufficient balance | -5 |
The number of concurrent strategies exceeds the limit | -6 |
There are two verification methods when calling the extended API interface, supporting token
verification and direct verification.
Use md5
encryption method to verify, example of Python
, Golang
language call:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import time
import json
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
try:
import md5
import urllib2
from urllib import urlencode
except:
import hashlib as md5
import urllib.request as urllib2
from urllib.parse import urlencode
accessKey = '' # your API KEY
secretKey = ''
def api(method, *args):
d = {
'version': '1.0',
'access_key': accessKey,
'method': method,
'args': json.dumps(list(args)),
'nonce': int(time.time() * 1000),
}
d['sign'] = md5.md5(('%s|%s|%s|%d|%s' % (d['version'], d['method'], d['args'], d['nonce'], secretKey)).encode('utf-8')).hexdigest()
# Note: for the timeout problem of "urllib2.urlopen" function, you can set the timeout time; for example, urllib2.urlopen ('https://www.fmz.com/api/v1', urlencode(d).encode('utf-8'), timeout = 10), that is, set timeout for 10 seconds
return json.loads(urllib2.urlopen('https://www.fmz.com/api/v1', urlencode(d).encode('utf-8')).read().decode('utf-8'))
# Return the docker list
print(api('GetNodeList'))
# Return the exchange list
print(api('GetPlatformList'))
# GetRobotList(offset, length, robotStatus, label), passing "-1" means obtaining all
print(api('GetRobotList', 0, 5, -1, 'member2'))
# CommandRobot(robotId, cmd) sends command to live trading
print(api('CommandRobot', 123, 'ok'))
# StopRobot(robotId) returns the live trading status code
print(api('StopRobot', 123))
# RestartRobot(robotId) returns the live trading status code
print(api('RestartRobot', 123))
# GetRobotDetail(robotId) returns detailed live trading information
print(api('GetRobotDetail', 123))
package main
import (
"fmt"
"time"
"encoding/json"
"crypto/md5"
"encoding/hex"
"net/http"
"io/ioutil"
"strconv"
"net/url"
)
// Fill in your own FMZ platform api key
var apiKey string = ""
// Fill in your own FMZ platform secret key
var secretKey string = ""
var baseApi string = "https://www.fmz.com/api/v1"
func api(method string, args ... interface{}) (ret interface{}) {
// Process args
jsonStr, err := json.Marshal(args)
if err != nil {
panic(err)
}
params := map[string]string{
"version" : "1.0",
"access_key" : apiKey,
"method" : method,
"args" : string(jsonStr),
"nonce" : strconv.FormatInt(time.Now().UnixNano() / 1e6, 10),
}
data := fmt.Sprintf("%s|%s|%s|%v|%s", params["version"], params["method"], params["args"], params["nonce"], secretKey)
h := md5.New()
h.Write([]byte(data))
sign := h.Sum(nil)
params["sign"] = hex.EncodeToString(sign)
// http request
client := &http.Client{}
// request
urlValue := url.Values{}
for k, v := range params {
urlValue.Add(k, v)
}
urlStr := urlValue.Encode()
request, err := http.NewRequest("GET", baseApi + "?" + urlStr, nil)
if err != nil {
panic(err)
}
resp, err := client.Do(request)
if err != nil {
panic(err)
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
ret = string(b)
return
}
func main() {
settings := map[string]interface{}{
"name": "hedge test",
"strategy": 104150,
// K-line period parameter, "60" means 60 seconds
"period": 60,
"node" : 73938,
"appid": "member2",
"exchanges": []interface{}{
map[string]interface{}{
"eid": "Exchange",
"label" : "test_bjex",
"pair": "BTC_USDT",
"meta" : map[string]interface{}{
// Fill in the access key
"AccessKey": "",
// Fill in the secret key
"SecretKey": "",
"Front" : "http://127.0.0.1:6666/exchange",
},
},
},
}
method := "RestartRobot"
fmt.Println("Call interface:", method)
ret := api(method, 124577, settings)
fmt.Println("main ret:", ret)
}
It supports verification without token
(pass secret_key
directly), you can generate a URL that can be accessed directly. For
example, the URL that directly gives interactive instructions to
live trading, which can be used for TradingView
or the WebHook
callback in other cases. For CommandRobot(RobotId, Cmd)
function, the parameter
nonce
does not need verification, and the access frequency and
visit times of the interface are not limited.
For example, the AccessKey
of the created extension API KEY
is: xxx
and the SecretKey
is: yyy
. View the following link to send an interactive command message to
the live trading with the live trading Id 186515
, the message
content is a string: "ok12345"
.
https://www.fmz.com/api/v1?access_key=xxx&secret_key=yyy&method=CommandRobot&args=[186515,"ok12345"]
Under the circumstance that the direct verification is supported,
only CommandRobot
interface is supported to obtain the
Body
data in the request. For example, the settings in the
WebHook URL
of TradingView
:
https://www.fmz.com/api/v1?access_key=xxx&secret_key=yyy&method=CommandRobot&args=[186515,+""]
Pay attention to setting according to the following format:
args=[130350,+""]
, in which 130350
is the live trading
ID
of FMZ Quant Trading Platform.
Set in the message box of Trading View
(the requested “Body”
data to be sent):
JSON format:
{"close": {{close}}, "name": "aaa"}
The live trading with ID
of 186515
can receive the interactive command string: {"close": 39773.75, "name": "aaa"}
.
Text format:
BTCUSDTPERP Crossing 39700.00 close: {{close}}
The live trading with ID
of 186515
can receive the interactive command string: BTCUSDTPERP Crossing 39700.00 close: 39739.4
.
Examples of Python
& Golang
language calls:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import json
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
try:
import urllib2
except:
import urllib.request as urllib2
accessKey = 'your accessKey'
secretKey = 'your secretKey'
def api(method, *args):
return json.loads(urllib2.urlopen(('https://www.fmz.com/api/v1?access_key=%s&secret_key=%s&method=%s&args=%s' % (accessKey, secretKey, method, json.dumps(list(args)))).replace(' ', '')).read().decode('utf-8'))
# If APIKEY does not have the interface permission, the call to
print(api('RestartRobot', 186515)) will fail, and the returned data
is: {'code': 4, 'data': None}
# print(api('RestartRobot', 186515))
# Printed Id: the live trading details of 186515
print(api('GetRobotDetail', 186515))
package main
import (
"fmt"
"encoding/json"
"net/http"
"io/ioutil"
"net/url"
)
// Fill in your own FMZ platform api key
var apiKey string = "your access_key"
// Fill in your own FMZ platform secret key
var secretKey string = "your secret_key"
var baseApi string = "https://www.fmz.com/api/v1"
func api(method string, args ... interface{}) (ret interface{}) {
jsonStr, err := json.Marshal(args)
if err != nil {
panic(err)
}
params := map[string]string{
"access_key" : apiKey,
"secret_key" : secretKey,
"method" : method,
"args" : string(jsonStr),
}
// http request
client := &http.Client{}
// request
urlValue := url.Values{}
for k, v := range params {
urlValue.Add(k, v)
}
urlStr := urlValue.Encode()
request, err := http.NewRequest("GET", baseApi + "?" + urlStr, nil)
if err != nil {
panic(err)
}
resp, err := client.Do(request)
if err != nil {
panic(err)
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
ret = string(b)
return
}
func main() {
method := "GetRobotDetail"
fmt.Println("Call interface:", method)
ret := api(method, 186515)
fmt.Println("main ret:", ret)
}
Use the extended API on FMZ Quant to realize “TradingView” alert signal trading
The extended API Interface of FMZ Quant Trading Platform
Append the query parameters (separated by ?
) of the request directly after https://www.fmz.com/api/v1
. The following are the request parameters expressed using Python
:
{
"version" : "1.0",
"access_key": "xxx",
"method" : "GetNodeList",
"args" : [],
"nonce" : 1516292399361,
"sign" : "085b63456c93hfb243a757366600f9c2"
}
Fields | Directions |
---|---|
version | Version number. |
access_key | AccessKey, apply for it on the account management page. |
method | The specific calling method. |
args | The parameter list of the specific method called. |
nonce | Timestamp, in milliseconds, allows a 1-hour error from the standard time stamp. Nonce must be larger than the nonce value of the last access. |
sign | Signature. |
Each parameter name is separated by the character &
, and the parameter names and values are connected with the symbol =
. The complete request URL (taking method=GetNodeList
as an example):
https://www.fmz.com/api/v1?access_key=xxx&nonce=1516292399361&args=%5B%5D&sign=085b63456c93hfb243a757366600f9c2&version=1.0&method=GetNodeList
Note that there is no secret_key
parameter among request parameters.
Signature Method
The sign
parameter in the request parameter is encrypted as follows, according to the format:
version + "|" + method + "|" + args + "|" + nonce + "|" + secretKey
After concatenating strings, use MD5
encryption algorithm to encrypt the string and convert it to a hexadecimal data string value, referred as the value of parameter sign
. For the signature part, refer to the Python
code extension API interface Ways of Verification :
# Parameter
d = {
'version': '1.0',
'access_key': accessKey,
'method': method,
'args': json.dumps(list(args)),
'nonce': int(time.time() * 1000),
}
# Calculate "sign" signature
d['sign'] = md5.md5(('%s|%s|%s|%d|%s' % (d['version'], d['method'], d['args'], d['nonce'], secretKey)).encode('utf-8')).hexdigest()
Interface service error:
{
"code":0,
"data":{
"result":null,
"error":"Params length incorrect"
}
}
The GetNodeList
method is used to get the list of dockers
under the FMZ Quant Trading Platform account corresponding to the
API KEY
in the request.
{
"code": 0,
"data": {
"result": {
"all": 1,
"nodes": [{
"build": "3.7",
"city": "...",
"created": "2024-11-08 09:21:08",
"date": "2024-11-08 16:37:16",
"forward": "...",
"guid": "...",
"host": "node.fmz.com:9902",
"id": 123,
"ip": "...",
"is_owner": true,
"loaded": 0,
"name": "MacBook-Pro-2.local",
"online": true,
"os": "darwin/amd64",
"peer": "...",
"public": 0,
"region": "...",
"tunnel": false,
"version": "...",
"wd": 0
}]
},
"error": null
}
}
Description of the return value fields (the literal meaning is obvious and will not be repeated):
ecs_
and unit_
, which records the relevant information of the one-click deployment docker server (operator name, configuration, status, etc.), billing cycle, price and other information, which will not be repeated here.No parameter
GetRobotGroupList()
returns the live trading grouping list
of FMZ Quant Trading Platform account corresponding to the API KEY
in the request.
{
"code": 0,
"data": {
"result": {
"items": [{
"id": 3417,
"name": "Test"
}, {
"id": 3608,
"name": "Live trading demo"
}]
},
"error": null
}
}
items
field only records newly created groups. The “default” group is not in items
.No parameter
GetPlatformList()
returns the list of exchanges that have
been added by the FMZ Quant Trading Platform account corresponding
to the API KEY
in the request.
{
"code": 0,
"data": {
"result": {
"all": 2,
"platforms": [{
"category": "加密货币||Crypto",
"date": "2023-12-07 13:44:52",
"eid": "Binance",
"id": 123,
"label": "Binance",
"logo": "...",
"name": "币安现货|Binance",
"stocks": ["BTC_USDT", "LTC_USDT", "ETH_USDT", "ETC_USDT", "BTC_TUSD", "ETH_TUSD", "BNB_TUSD"],
"website": "..."
}, {
"category": "通用协议|Custom Protocol",
"date": "2020-11-09 11:23:48",
"eid": "Exchange",
"id": 123,
"label": "XX Exchange REST Protocol",
"logo": "...",
"name": "通用协议|Custom Protocol",
"stocks": ["BTC_USDT", "ETH_USDT"],
"website": ""
}]
},
"error": null
}
}
eid
will be used in some configurations and parameters.No parameter
The GetRobotList
method is used to get the list of live
tradings under the FMZ Quant Trading Platform account
corresponding to the API KEY
in the request.
{
"code": 0,
"data": {
"result": {
"all": 1,
"concurrent": 0,
"robots": [{
"charge_time": 1731654846,
"date": "2024-11-12 14:05:29",
"end_time": "2024-11-15 14:56:32",
"fixed_id": 4509153,
"id": 591026,
"is_sandbox": 0,
"name": "test",
"node_guid": "45891bcf3d57f99b08a43dff76ee1ea1",
"node_id": 4519153,
"node_public": 0,
"profit": 0,
"public": 0,
"refresh": 1731651257000,
"start_time": "2024-11-15 14:56:30",
"status": 3,
"strategy_id": 411670,
"strategy_isowner": true,
"strategy_language": 0,
"strategy_name": "test",
"strategy_public": 0,
"uid": "105ed6e511cc977921610fdbb7e2a1d6",
"wd": 0
}]
},
"error": null
}
}
group_id
field.The paging query offset setting.
offset
false
number
The paging query length setting.
length
false
number
Specify the status of the live trading to be queried, refer to the extended API interface Live Trading Code, pass -1
to get all live tradings.
robotStatus
false
number
Specify the custom label of the live trading you want to query, and you can filter all the live tradings of this label.
label
false
string
Search keywords.
keyWord
false
string
Take the Python
language’s extended API interface Ways of Verification as an example:
print(api('GetRobotList'))
: Get all live trading information.
print(api('GetRobotList', 'member2'))
: print the information of all live trading with the custom label member2.
print(api('GetRobotList', 0, 5, -1, 'member2'))
: pages from 0 to 5 and list up to 5 robots labeled with member2.
The CommandRobot
method is used to send an interaction
command to the live trading under the FMZ Quant Trading Platform
account corresponding to the API KEY
in the request. The Id
of the live trading receiving the interaction command is the live
trading Id specified by the robotId
parameter, and the
interaction command is returned by the GetCommand()
function
called in the strategy to capture it.
{
"code":0,
"data":{
"result":true,
"error":null
}
}
The parameter robotId
is used to specify the Id of the
live trading that receives the interactive command. You can use
the GetRobotList
method to get the information of the live
trading under the account, which contains the live trading Id.
robotId
true
number
The parameter cmd
is the interactive command sent to the bot; the command will be captured by the function GetCommand()
, which triggers the interactive logic in the strategy. For specific implementation of the interaction logic in the strategy code, please refer to the GetCommand()
function in the FMZ Quant Trading Platform API Manual.
cmd true string
Live trading strategy, assuming that this strategy is in operation, the live trading ID is 123:
function main() {
while (true) {
var cmd = GetCommand()
if (cmd) {
Log(cmd)
}
Sleep(2000)
}
}
If we use the Python test script in this chapter, access the extended API of the FMZ Quant Trading Platform: api("CommandRobot", 123, "test command")
. The live trading with ID 123 will receive the interactive command: test command
, and then print it out through the Log function output.
StopRobot(RobotId)
is used to request the API KEY
corresponding to the live trading of the FMZ Quant Trading
Platform account. The live trading Id to stop running is the live
trading Id specified by the robotId
parameter.
{
"code":0,
"data":{
"result":2,
"error":null
}
}
The parameter robotId
is used to specify the Id of the
live trading to be stopped. You can use the GetRobotList
method to get the information of the live trading under the
account, which contains the live trading Id.
robotId true number
The RestartRobot
method is used to restart the live trading under the API KEY
corresponding to the FMZ Quant Trading Platform account in the request. The Id of the restarted live trading is the live trading Id specified by the robotId
parameter.
{
"code":0,
"data":{
"result":1,
"error":null
}
}
The robotId
parameter is used to specify the Id of the
live trading to be restarted. You can use the GetRobotList
method to get the information of the live trading under the
account, which contains the live trading Id.
robotId
true
number
The live trading configuration parameters, the parameters settings
format is as follows:
{
"appid":"test",
"args":[],
"exchanges":[
{"pair":"SOL_USDT","pid":123},
{"pair":"ETH_USDT","pid":456}
],
"name":"test",
"node":123,
"period":60,
"strategy":123
}
Interval
, and you want to set Interval
to 500 when restarting the strategy, then args
contains: ["Interval", 500]
, that is: "args": [["Interval", 500]]
.pid
configuration: {"pair":"SOL_USDT","pid":123}
; pid
can be queried through the GetPlatformList
interface, and the id
field in the returned data is the exchange pid
.eid
configuration: {"eid":"Huobi","label":"test Huobi","meta":{"AccessKey":"123","SecretKey":"123"},"pair":"BCH_BTC"}
; sensitive information such as API KEY
is not stored by the FMZ Quant Trading Platform, and these data are directly forwarded to the docker program. If this type of configuration is used, the information must be configured each time a live trading is created or restarted.{"eid":"Exchange","label":"test exchange","pair":"BTC_USDT","meta":{"AccessKey":"123","SecretKey":"123","Front":"http://127.0.0.1:6666/test"}}
.
label
attribute is to set a label for the exchange object accessed by the current Custom Protocol, which can be obtained by the exchange.GetLabel()
function in the strategy.GetStrategyList
method.settings false JSON Object
If a live trading is created by the extended API, the extended API RestartRobot (RobotId, Settings)
must be used to restart, and the settings
parameter must be passed. The live trading created on the platform page can be restarted through the extended API or by clicking the button on the page. You can pass or don’t pass the settings
parameter. If you only pass the RobotId
parameter, start live trading according to the current live trading settings.
The GetRobotDetail
method is used to get the details of the live trading under the FMZ Quant Trading Platform account corresponding to the API KEY
in the request. The Id of the live trading to be retrieved is the live trading Id specified by the robotId
parameter.
{
"code": 0,
"data": {
"result": {
"robot": {
"charge_time": 1732246539,
"charged": 5850000,
"consumed": 5375000000,
"date": "2018-12-28 14:34:51",
"favorite": {
"added": false,
"type": "R"
},
"fixed_id": 123,
"hits": 1,
"id": 123,
"is_deleted": 0,
"is_manager": true,
"is_sandbox": 0,
"name": "test",
"node_id": 123,
"pexchanges": {
"123": "Futures_OKCoin"
},
"phash": {
"123": "ca1aca74b9cf7d8624f2af2dac01e36d"
},
"plabels": {
"123": "OKEX futures V5"
},
"priority": 0,
"profit": 0,
"public": 0,
"refresh": 1732244453000,
"robot_args": "[]",
"start_time": "2024-11-22 11:00:48",
"status": 1,
"strategy_args": "[]",
"strategy_exchange_pairs": "[60,[123],[\"ETH_USDT\"]]",
"strategy_id": 123,
"strategy_last_modified": "2024-11-21 16:49:25",
"strategy_name": "test",
"strategy_public": "0",
"uid": "105ed6e51bcc17792a610fdbb7e2a1d6",
"username": "abc",
"wd": 0
}
},
"error": null
}
}
The robotId
parameter is used to specify the Id of the live trading for which the details are to be obtained. You can use the GetRobotList
method to obtain information about the live trading under the account, which contains the live trading Id.
robotId true number
The attribute description of strategy_exchange_pairs
, take the following data as an example:
"[60,[44314,42960,15445,14703],[\"BTC_USDT\",\"BTC_USDT\",\"ETH_USDT\",\"ETH_USDT\"]]"
The first data 60
represents the default K-line period set
by live trading is 1 minute, namely 60 seconds.
[44314,42960,15445,14703]
is the exchange object pid
configured for live trading (according to the addition order).
[\"BTC_USDT\",\"BTC_USDT\",\"ETH_USDT\",\"ETH_USDT\"]
is the
trading pair set for the exchange object configured by live
trading (in the order of addition and in one-to-one correspondence
with pid
).
The GetAccount
method is used to acquire the account information corresponding to the API KEY
in the request of the FMZ Quant Trading Platform account.
{
"code":0,
"data":{
"result":{
"balance":22944702436,
"concurrent":0,
"consumed":211092719653,
"currency":"USD",
"email":"123@qq.com",
"openai":false,
"settings":null,
"sns":{"wechat":true},
"uid":"105ea6e51bcc177926a10fdbb7e2a1d6",
"username":"abc"
},
"error":null
}
}
The GetExchangeList
method is used to acquire the list of exchanges and the required configuration information supported by FMZ Quant Trading Platform.
When the isSummary
parameter is false
, the returned data is:
{
"code": 0,
"data": {
"result": {
"exchanges": [{
"category": "加密货币||Crypto",
"eid": "Futures_Binance",
"id": 74,
"logo": "/upload/asset/d8d84b23e573e9326b99.svg",
"meta": "[{\"desc\": \"Access Key\", \"qr\":\"apiKey\",\"required\": true, \"type\": \"string\", \"name\": \"AccessKey\", \"label\": \"Access Key\"}, {\"encrypt\": true, \"qr\":\"secretKey\",\"name\": \"SecretKey\", \"required\": true, \"label\": \"Secret Key\", \"type\": \"password\", \"desc\": \"Secret Key\"}]",
"name": "币安期货|Futures_Binance",
"priority": 200,
"stocks": "BTC_USDT,ETH_USDT,ETH_USD",
"website": "https://accounts.binance.com/zh-TC/register?ref=45110270"
}]
},
"error": null
}
}
When the isSummary
parameter is true
, the returned data is:
{
"code": 0,
"data": {
"result": {
"exchanges": [{
"category": "加密货币||Crypto",
"eid": "Futures_Binance",
"id": 74,
"logo": "/upload/asset/d8d84b23e573e9326b99.svg",
"name": "币安期货|Futures_Binance",
"priority": 200,
"website": "https://accounts.binance.com/zh-TC/register?ref=45110270"
}]
},
"error": null
}
}
The isSummary
parameter is used to specify whether the returned data is summary information.
isSummary true bool
The DeleteNode(Nid)
method is used to delete the docker node corresponding to the API KEY
in the request of the FMZ Quant Trading Platform account. The deleted docker node Id is the docker Id specified by the nid
parameter.
{
"code":0,
"data":{
"result":true,
"error":null
}
}
The nid
parameter is used to specify the Id of the docker to be deleted. You can use the GetNodeList
method to get information about the dockers of the account.
nid true number
The DeleteRobot(RobotId, DeleteLogs)
method is used to delete the live trading corresponding to the API KEY
in the request under the FMZ Quant Trading Platform account. The deleted live trading Id is the live trading Id specified by the robotId
parameter.
{
"code":0,
"data":{
"result":0,
"error":null
}
}
The parameter robotId
is used to specify the Id of the
live trading to be deleted. You can use the GetRobotList
method to get the information of the live trading under the
account, which contains the live trading Id.
robotId
true
number
The deleteLogs
parameter is used to set whether to delete the live trading log, if passed a true value (e.g.: true
), the live trading log is deleted.
deleteLogs true bool
The GetStrategyList
method is used to obtain platform strategy information.
{
"code": 0,
"data": {
"result": {
"all": 123,
"strategies": [{
"category": 9,
"date": "2024-11-10 20:40:04",
"description": "",
"forked": 0,
"hits": 0,
"id": 123,
"is_buy": false,
"is_owner": false,
"language": 2,
"last_modified": "2024-11-11 17:23:52",
"name": "HedgeGridStrategy",
"profile": {
"avatar": "...",
"nickname": "abc",
"uid": "4ed225440db1eda23fe05ed10184113e"
},
"public": 0,
"tags": "",
"uid": "4ed225440db1eda23fe05ed10184113e",
"username": "abc"
}]
},
"error": null
}
}
The offset
parameter is used to set the offset when querying.
offset
true
number
The length
parameter is used to set the length of the query.
length
true
number
The strategyType
parameter is used to set the strategy type to be queried.
strategyType
parameter setting 0
: all strategies.strategyType
parameter setting 1
: The strategy is public.strategyType
parameter setting 2
: strategy to be reviewed.strategyType
true
number
The category
parameter is used to set the strategy category to be queried.
category
parameter setting -1
: all strategies.category
parameter setting 0
: custom strategy.category
true
number
The needArgs
parameter is used to set whether the strategy to be queried has parameters.
needArgs
parameter setting 0
: all strategies.needArgs
true
number
The language
parameter is used to set the programming language of the strategy to be queried.
language
parameter settings 0
: JavaScript language.language
parameter settings 1
: Python language.language
parameter settings 2
: C++ language.language
parameter settings 3
: Visualization strategy.language
parameter settings 4
: My language.language
parameter settings 5
: PINE language.language
true
number
The kw
parameter is used to set the keyword of the strategy to be queried.
kw true string
The NewRobot
method is used to create a live trading under the API KEY
corresponding to the FMZ Quant Trading Platform account in the request.
{
"code":0,
"data":{
"result":591988,
"error":null
}
}
The live trading configuration parameters, settings
parameters format is as follows:
{
"appid":"test",
"args":[],
"exchanges":[
{"pair":"SOL_USDT","pid":123}
],
"group":123,
"name":"test",
"node":123,
"period":60,
"strategy":123
}
RestartRobot
interface.settings true JSON object
In the configuration of eid
in the settings
parameter, "meta":{"AccessKey": "123", "SecretKey": "123"}
these sensitive information is not stored by the FMZ Quant Trading Platform. These data are forwarded to the docker program directly, so this information must be configured every time a live trading is created or restarted.
If we create a live trading exchange object using the custom protocol, when configuring the settings
parameter, we can use the following settings for the exchanges
attribute:
{
"eid": "Exchange",
"label": "test",
"pair": "ETH_BTC",
"meta": {
"AccessKey": "123",
"SecretKey": "123",
"Front": "http://127.0.0.1:6666/test"
}
}
label
attribute is to set a label for the exchange object accessed by the current custom protocol, which can be obtained by the exchange.GetLabel()
function in the strategy.
The PluginRun
method is used to call the debug tool function of the FMZ Quant Trading Platform; Only JavaScript language is supported.
{
"code": 0,
"data": {
"result": "{\"logs\":[{\"PlatformId\":\"\",\"OrderId\":\"0\",\"LogType\":5,\"Price\":0,\"Amount\":0,\"Extra\":\"Hello FMZ\",\"Currency\":\"\",\"Instrument\":\"\",\"Direction\":\"\",\"Time\":1732267473108}],\"result\":\"\"}",
"error": null
}
}
The settings parameters in the debugging tool, settings
configuration, include the test code in the source
attribute. The settings
parameter format is as follows:
{
"exchanges":[{"pair":"SOL_USDT","pid":123}],
"node":123,
"period":60,
"source":"function main() {Log(\"Hello FMZ\")}"
}
RestartRobot
interface.settings true JSON object
{"eid": "OKEX", "pair": "ETH_BTC", "meta" :{"AccessKey": "123", "SecretKey": "123"}}
{"eid": "Huobi", "pair": "BCH_BTC", "meta" :{"AccessKey": "123", "SecretKey": "123"}}
For the exchanges
attribute in settings
, only one needs to be set when calling the PluginRun
method (only one exchange object is supported when used in the debug tool page). No error will be reported when you set 2 exchange objects in settings
, but an error will be reported when the second exchange object is accessed in the code.
The GetRobotLogs
method is used to get the log information of the live trading under the FMZ Quant Trading Platform account corresponding to the API KEY
in the request. The Id of the live trading platform to be obtained is the live trading platform Id specified by the robotId
parameter.
{
"code": 0,
"data": {
"result": {
"chart": "",
"chartTime": 0,
"logs": [{
"Total": 20,
"Max": 20,
"Min": 1,
"Arr": []
}, {
"Total": 0,
"Max": 0,
"Min": 0,
"Arr": []
}, {
"Total": 0,
"Max": 0,
"Min": 0,
"Arr": []
}],
"node_id": 123,
"online": true,
"refresh": 1732201544000,
"status": 4,
"summary": "...",
"updateTime": 1732201532636,
"wd": 0
},
"error": null
}
}
The robotId
parameter is used to specify the Id of the
live trading for which the log information is to be obtained.
You can use the GetRobotList
method to obtain information
about the live trading under the account, which contains the
live trading Id.
robotId
true
number
The logMinId
parameter is used to specify the minimum Id of the Log.
logMinId
true
number
The logMaxId
parameter is used to specify the maximum Id of the Log.
logMaxId
true
number
The logOffset
parameter is used to set the offset, after determining the range by logMinId
and logMaxId
, offset based on the logOffset
(how many records are skipped). Start as the starting position for fetching data.
logOffset
true
number
The parameter logLimit
is used to set the number of data records to be selected after the starting position is determined.
logLimit
true
number
The profitMinId
parameter is used to set the minimum Id of the profit log.
profitMinId
true
number
The parameter profitMaxId
is used to set the maximum Id of the profit log.
profitMaxId
true
number
The parameter profitOffset
is used to set the offset (how many records are skipped) as the starting position.
profitOffset
true
number
The parameter profitLimit
is used to set the number of data records to be selected after the starting position is determined.
profitLimit
true
number
The parameter chartMinId
is used to set the minimum Id of the chart data record.
chartMinId
true
number
The parameter chartMaxId
is used to set the maximum Id of the chart data record.
chartMaxId
true
number
The parameter chartOffset
is used to set the offset.
chartOffset
true
number
The parameter chartLimit
is used to set the number of
records to obtain.
chartLimit
true
number
The parameter chartUpdateBaseId
is used to set the base Id
after the query is updated.
chartUpdateBaseId
true
number
The parameter chartUpdateDate
is used to set the data
record update timestamp, and it will filter out records greater
than this timestamp.
chartUpdateDate
true
number
The parameter summaryLimit
is used to set the number of
bytes of status bar data to be queried. The parameter is of
integer type for querying the status bar data of the live
trading.
Setting to “0” means there is no need to query the status bar
information, and setting to non-zero number indicates the number
of bytes of the status bar information to be queried (the
interface does not limit the data quantity, so you can specify a
larger summaryLimit
parameter to get all status bar
information). The status bar data is stored in the returned data
summary
.
summaryLimit true number
The strategy log table in the database
The Arr
attribute value in the first element of the Logs
attribute value (array structure) in the return data (log data) is described as follows:
"Arr": [
[3977, 3, "Futures_OKCoin", "", 0, 0, "Sell(688.9, 2): 20016", 1526954372591, "", ""],
[3976, 5, "", "", 0, 0, "OKCoin:this_week too many positions, long: 2", 1526954372410, "", ""]
],
id | logType | eid | orderId | price | amount | extra | date | contractType | direction |
---|---|---|---|---|---|---|---|---|---|
3977 | 3 | “Futures_OKCoin” | "" | 0 | 0 | “Sell(688.9, 2): 20016” | 1526954372591 | "" | "" |
3976 | 5 | "" | "" | 0 | 0 | “OKCoin:this_week too many positions, long: 2” | 1526954372410 | "" | "" |
extra
is the attached message of the printed log.
The specific log types represented by the logType
values are described as follows:
logType: | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
---|---|---|---|---|---|---|---|
Meaning of logType: | BUY | SALE | RETRACT | ERROR | PROFIT | MESSAGE | RESTART |
Log table of the profit chart in the database The data in the chart’s log table is consistent with the profit log in the strategy log table.
"Arr": [
[202, 2515.44, 1575896700315],
[201, 1415.44, 1575896341568]
]
Take one of the log data as an example:
[202, 2515.44, 1575896700315]
202
is log ID
; 2515.44
is profit value; 1575896700315
is timestamp.
Chart log table in the database
"Arr": [
[23637, 0, "{\"close\":648,\"high\":650.5,\"low\":647,\"open\":650,\"x\":1575960300000}"],
[23636, 5, "{\"x\":1575960300000,\"y\":3.0735}"]
]
Take one of the log data as an example:
[23637, 0, "{\"close\":648,\"high\":650.5,\"low\":647,\"open\":650,\"x\":1575960300000}"],
23637
is the log ID
, 0
is the index of the chart data series, and the last data "{\"close\":648,\"high\":650.5,\"low\":647,\"open\":650,\"x\":1575960300000}"
is the log data; This data is the K-line data on the chart.