资源加载中... loading...

Direct Verification

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 130350is 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:

    https://www.fmz.comimg

    {"close": {{close}}, "name": "aaa"}
    

    The live trading with ID of 186515 can receive the interactive command string: {"close": 39773.75, "name": "aaa"}.

  • Text format:

    https://www.fmz.comimg

    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

token Verification Explanation of Extended API Interface