// true
}
[http://underscorejs.org/](http://underscorejs.org/)
```js
function main() {
var sum = _.reduce([1, 2, 3], function(memo, num){return memo + num}, 0)
Log(sum)
}
C++
library
https://nlohmann.github.io/json/
void main() {
json table = R"({"type": "table", "title": "Position Information", "cols": ["Column1", "Column2"], "rows": [["abc", "def"], ["ABC", "support color #ff0000"]]})"_json;
LogStatus("`" + table.dump() + "`");
LogStatus("Fist line message\n`" + table.dump() + "`\nThird line message");
json arr = R"([])"_json;
arr.push_back(table);
arr.push_back(table);
LogStatus("`" + arr.dump() + "`");
table = R"({
"type" : "table",
"title" : "Position Operation",
"cols" : ["Column1", "Column2", "Action"],
"rows" : [
["abc", "def", {"type": "button", "cmd": "coverAll", "name": "close position"}]
]
})"_json;
LogStatus("`" + table.dump() + "`", "\n`" + R"({"type": "button", "cmd": "coverAll", "name": "close position"})"_json.dump() + "`");
}
Among the parameters of the following functions, Records[Close]
represents the close price in the incoming k-line data, Array()
represents an array, and Array(outInteger)
represents returning an array of integer data.
Example code for calling CCI
indicator:
function main() {
var records = exchange.GetRecords()
var cci = talib.CCI(records, 14)
Log(cci)
}
import talib
def main():
records = exchange.GetRecords()
# the parameter "14" can be default
cci = talib.CCI(records.High, records.Low, records.Close, 14)
Log(cci)
void main() {
auto records = exchange.GetRecords();
auto cci = talib.CCI(records, 14);
Log(cci);
}
Pattern Recognition
:
Indicator | Description |
---|---|
CDL2CROWS | Two Crows |
CDL2CROWS(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDL3BLACKCROWS | Three Black Crows |
CDL3BLACKCROWS(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDL3INSIDE | Three Inside Up/Down |
CDL3INSIDE(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDL3LINESTRIKE | Three-Line Strike |
CDL3LINESTRIKE(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDL3OUTSIDE | Three Outside Up/Down |
CDL3OUTSIDE(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDL3STARSINSOUTH | Three Stars In The South |
CDL3STARSINSOUTH(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDL3WHITESOLDIERS | Three Advancing White Soldiers |
CDL3WHITESOLDIERS(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLABANDONEDBABY | Abandoned Baby |
CDLABANDONEDBABY(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) | |
CDLADVANCEBLOCK | Advance Block |
CDLADVANCEBLOCK(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLBELTHOLD | Belt-hold |
CDLBELTHOLD(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLBREAKAWAY | Breakaway |
CDLBREAKAWAY(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLCLOSINGMARUBOZU | Closing Marubozu |
CDLCLOSINGMARUBOZU(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLCONCEALBABYSWALL | Concealing Baby Swallow |
CDLCONCEALBABYSWALL(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLCOUNTERATTACK | Counterattack |
CDLCOUNTERATTACK(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLDARKCLOUDCOVER | Dark Cloud Cover |
CDLDARKCLOUDCOVER(Records[Open,High,Low,Close],Penetration = 0.5) = Array(outInteger) | |
CDLDOJI | Doji |
CDLDOJI(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLDOJISTAR | Doji Star |
CDLDOJISTAR(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLDRAGONFLYDOJI | Dragonfly Doji |
CDLDRAGONFLYDOJI(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLENGULFING | Engulfing Pattern |
CDLENGULFING(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLEVENINGDOJISTAR | Evening Doji Star |
CDLEVENINGDOJISTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) | |
CDLEVENINGSTAR | Evening Star |
CDLEVENINGSTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) | |
CDLGAPSIDESIDEWHITE | Up/Down-gap side-by-side white lines |
CDLGAPSIDESIDEWHITE(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLGRAVESTONEDOJI | Gravestone Doji |
CDLGRAVESTONEDOJI(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLHAMMER | Hammer |
CDLHAMMER(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLHANGINGMAN | Hanging Man |
CDLHANGINGMAN(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLHARAMI | Harami Pattern |
CDLHARAMI(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLHARAMICROSS | Harami Cross Pattern |
CDLHARAMICROSS(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLHIGHWAVE | High-Wave Candle |
CDLHIGHWAVE(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLHIKKAKE | Hikkake Pattern |
CDLHIKKAKE(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLHIKKAKEMOD | Modified Hikkake Pattern |
CDLHIKKAKEMOD(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLHOMINGPIGEON | Homing Pigeon |
CDLHOMINGPIGEON(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLIDENTICAL3CROWS | Identical Three Crows |
CDLIDENTICAL3CROWS(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLINNECK | In-Neck Pattern |
CDLINNECK(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLINVERTEDHAMMER | Inverted Hammer |
CDLINVERTEDHAMMER(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLKICKING | Kicking |
CDLKICKING(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLKICKINGBYLENGTH | Kicking - bull/bear determined by the longer marubozu |
CDLKICKINGBYLENGTH(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLLADDERBOTTOM | Ladder Bottom |
CDLLADDERBOTTOM(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLLONGLEGGEDDOJI | Long Legged Dojz |
CDLLONGLEGGEDDOJI(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLLONGLINE | Long Line Candle |
CDLLONGLINE(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLMARUBOZU | Marubozu |
CDLMARUBOZU(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLMATCHINGLOW | Matching Low |
CDLMATCHINGLOW(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLMATHOLD | Mat Hold |
CDLMATHOLD(Records[Open,High,Low,Close],Penetration = 0.5) = Array(outInteger) | |
CDLMORNINGDOJISTAR | Morning Doji Star |
CDLMORNINGDOJISTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) | |
CDLMORNINGSTAR | Morning Star |
CDLMORNINGSTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) | |
CDLONNECK | On-Neck Pattern |
CDLONNECK(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLPIERCING | Piercing Pattern |
CDLPIERCING(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLRICKSHAWMAN | Rickshaw Man |
CDLRICKSHAWMAN(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLRISEFALL3METHODS | Rising/Falling Three Methods |
CDLRISEFALL3METHODS(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLSEPARATINGLINES | Separating Lines |
CDLSEPARATINGLINES(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLSHOOTINGSTAR | Shooting Star |
CDLSHOOTINGSTAR(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLSHORTLINE | Short Line Candle |
CDLSHORTLINE(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLSPINNINGTOP | Spinning Top |
CDLSPINNINGTOP(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLSTALLEDPATTERN | Stalled Pattern |
CDLSTALLEDPATTERN(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLSTICKSANDWICH | Stick Sandwich |
CDLSTICKSANDWICH(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLTAKURI | Takuri (Dragonfly Doji with very long lower shadow) |
CDLTAKURI(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLTASUKIGAP | Tasuki Gap |
CDLTASUKIGAP(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLTHRUSTING | Thrusting Pattern |
CDLTHRUSTING(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLTRISTAR | Tristar Pattern |
CDLTRISTAR(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLUNIQUE3RIVER | Unique 3 River |
CDLUNIQUE3RIVER(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLUPSIDEGAP2CROWS | Upside Gap Two Crows |
CDLUPSIDEGAP2CROWS(Records[Open,High,Low,Close]) = Array(outInteger) | |
CDLXSIDEGAP3METHODS | Upside/Downside Gap Three Methods |
CDLXSIDEGAP3METHODS(Records[Open,High,Low,Close]) = Array(outInteger) |
Volume Indicators
:
Indicator | Description |
---|---|
AD | Chaikin A/D Line |
AD(Records[High,Low,Close,Volume]) = Array(outReal) | |
ADOSC | Chaikin A/D Oscillator |
ADOSC(Records[High,Low,Close,Volume],Fast Period = 3,Slow Period = 10) = Array(outReal) | |
OBV | On Balance Volume |
OBV(Records[Close],Records[Volume]) = Array(outReal) |
Math Transform
:
Indicator | Description |
---|---|
ACOS | Vector Trigonometric ACos |
ACOS(Records[Close]) = Array(outReal) | |
ASIN | Vector Trigonometric ASin |
ASIN(Records[Close]) = Array(outReal) | |
ATAN | Vector Trigonometric ATan |
ATAN(Records[Close]) = Array(outReal) | |
CEIL | Vector Ceil |
CEIL(Records[Close]) = Array(outReal) | |
COS | Vector Trigonometric Cos |
COS(Records[Close]) = Array(outReal) | |
COSH | Vector Trigonometric Cosh |
COSH(Records[Close]) = Array(outReal) | |
EXP | Vector Arithmetic Exp |
EXP(Records[Close]) = Array(outReal) | |
FLOOR | Vector Floor |
FLOOR(Records[Close]) = Array(outReal) | |
LN | Vector Log Natural |
LN(Records[Close]) = Array(outReal) | |
LOG10 | Vector Log10 |
LOG10(Records[Close]) = Array(outReal) | |
SIN | Vector Trigonometric Sin |
SIN(Records[Close]) = Array(outReal) | |
SINH | Vector Trigonometric Sinh |
SINH(Records[Close]) = Array(outReal) | |
SQRT | Vector Square Root |
SQRT(Records[Close]) = Array(outReal) | |
TAN | Vector Trigonometric Tan |
TAN(Records[Close]) = Array(outReal) | |
TANH | Vector Trigonometric Tanh |
TANH(Records[Close]) = Array(outReal) |
Math Operators
:
Indicator | Description |
---|---|
MAX | Highest value over a specified period |
MAX(Records[Close],Time Period = 30) = Array(outReal) | |
MAXINDEX | Index of highest value over a specified period |
MAXINDEX(Records[Close],Time Period = 30) = Array(outInteger) | |
MIN | Lowest value over a specified period |
MIN(Records[Close],Time Period = 30) = Array(outReal) | |
MININDEX | Index of lowest value over a specified period |
MININDEX(Records[Close],Time Period = 30) = Array(outInteger) | |
MINMAX | Lowest and highest values over a specified period |
MINMAX(Records[Close],Time Period = 30) = [Array(outMin),Array(outMax)] | |
MINMAXINDEX | Indexes of lowest and highest values over a specified period |
MINMAXINDEX(Records[Close],Time Period = 30) = [Array(outMinIdx),Array(outMaxIdx)] | |
SUM | Summation |
SUM(Records[Close],Time Period = 30) = Array(outReal) |
Cycle Indicators
:
Indicator | Description |
---|---|
HT_DCPERIOD | Hilbert Transform - Dominant Cycle Period |
HT_DCPERIOD(Records[Close]) = Array(outReal) | |
HT_DCPHASE | Hilbert Transform - Dominant Cycle Phase |
HT_DCPHASE(Records[Close]) = Array(outReal) | |
HT_PHASOR | Hilbert Transform - Phasor Components |
HT_PHASOR(Records[Close]) = [Array(outInPhase),Array(outQuadrature)] | |
HT_SINE | Hilbert Transform - SineWave |
HT_SINE(Records[Close]) = [Array(outSine),Array(outLeadSine)] | |
HT_TRENDMODE | Hilbert Transform - Trend vs Cycle Mode |
HT_TRENDMODE(Records[Close]) = Array(outInteger) |
Volatility Indicators
:
Indicator | Description |
---|---|
ATR | Average True Range |
ATR(Records[High,Low,Close],Time Period = 14) = Array(outReal) | |
NATR | Normalized Average True Range |
NATR(Records[High,Low,Close],Time Period = 14) = Array(outReal) | |
TRANGE | True Range |
TRANGE(Records[High,Low,Close]) = Array(outReal) |
Overlap Studies
:
Indicator | Description |
---|---|
BBANDS | Bollinger Bands |
BBANDS(Records[Close],Time Period = 5,Deviations up = 2,Deviations down = 2,MA Type = 0) = [Array(outRealUpperBand),Array(outRealMiddleBand),Array(outRealLowerBand)] | |
DEMA | Double Exponential Moving Average |
DEMA(Records[Close],Time Period = 30) = Array(outReal) | |
EMA | Exponential Moving Average |
EMA(Records[Close],Time Period = 30) = Array(outReal) | |
HT_TRENDLINE | Hilbert Transform - Instantaneous Trendline |
HT_TRENDLINE(Records[Close]) = Array(outReal) | |
KAMA | Kaufman Adaptive Moving Average |
KAMA(Records[Close],Time Period = 30) = Array(outReal) | |
MA | Moving Average |
MA(Records[Close],Time Period = 30,MA Type = 0) = Array(outReal) | |
MAMA | MESA Adaptive Moving Average |
MAMA(Records[Close],Fast Limit = 0.5,Slow Limit = 0.05) = [Array(outMAMA),Array(outFAMA)] | |
MIDPOINT | Midpoint over period |
MIDPOINT(Records[Close],Time Period = 14) = Array(outReal) | |
MIDPRICE | Midpoint Price over period |
MIDPRICE(Records[High,Low],Time Period = 14) = Array(outReal) | |
SAR | Parabolic SAR |
SAR(Records[High,Low],Acceleration Factor = 0.02,AF Maximum = 0.2) = Array(outReal) | |
SAREXT | Parabolic SAR - Extended |
SAREXT(Records[High,Low],Start Value = 0,Offset on Reverse = 0,AF Init Long = 0.02,AF Long = 0.02,AF Max Long = 0.2,AF Init Short = 0.02,AF Short = 0.02,AF Max Short = 0.2) = Array(outReal) | |
SMA | Simple Moving Average |
SMA(Records[Close],Time Period = 30) = Array(outReal) | |
T3 | Triple Exponential Moving Average (T3) |
T3(Records[Close],Time Period = 5,Volume Factor = 0.7) = Array(outReal) | |
TEMA | Triple Exponential Moving Average |
TEMA(Records[Close],Time Period = 30) = Array(outReal) | |
TRIMA | Triangular Moving Average |
TRIMA(Records[Close],Time Period = 30) = Array(outReal) | |
WMA | Weighted Moving Average |
WMA(Records[Close],Time Period = 30) = Array(outReal) |
Statistic Functions
:
Indicator | Description |
---|---|
LINEARREG | Linear Regression |
LINEARREG(Records[Close],Time Period = 14) = Array(outReal) | |
LINEARREG_ANGLE | Linear Regression Angle |
LINEARREG_ANGLE(Records[Close],Time Period = 14) = Array(outReal) | |
LINEARREG_INTERCEPT | Linear Regression Intercept |
LINEARREG_INTERCEPT(Records[Close],Time Period = 14) = Array(outReal) | |
LINEARREG_SLOPE | Linear Regression Slope |
LINEARREG_SLOPE(Records[Close],Time Period = 14) = Array(outReal) | |
STDDEV | Standard Deviation |
STDDEV(Records[Close],Time Period = 5,Deviations = 1) = Array(outReal) | |
TSF | Time Series Forecast |
TSF(Records[Close],Time Period = 14) = Array(outReal) | |
VAR | Variance |
VAR(Records[Close],Time Period = 5,Deviations = 1) = Array(outReal) |
Momentum Indicators
:
Indicator | Description |
---|---|
ADX | Average Directional Movement Index |
ADX(Records[High,Low,Close],Time Period = 14) = Array(outReal) | |
ADXR | Average Directional Movement Index Rating |
ADXR(Records[High,Low,Close],Time Period = 14) = Array(outReal) | |
APO | Absolute Price Oscillator |
APO(Records[Close],Fast Period = 12,Slow Period = 26,MA Type = 0) = Array(outReal) | |
AROON | Aroon |
AROON(Records[High,Low],Time Period = 14) = [Array(outAroonDown),Array(outAroonUp)] | |
AROONOSC | Aroon Oscillator |
AROONOSC(Records[High,Low],Time Period = 14) = Array(outReal) | |
BOP | Balance Of Power |
BOP(Records[Open,High,Low,Close]) = Array(outReal) | |
CCI | Commodity Channel Index |
CCI(Records[High,Low,Close],Time Period = 14) = Array(outReal) | |
CMO | Chande Momentum Oscillator |
CMO(Records[Close],Time Period = 14) = Array(outReal) | |
DX | Directional Movement Index |
DX(Records[High,Low,Close],Time Period = 14) = Array(outReal) | |
MACD | Moving Average Convergence/Divergence |
MACD(Records[Close],Fast Period = 12,Slow Period = 26,Signal Period = 9) = [Array(outMACD),Array(outMACDSignal),Array(outMACDHist)] | |
MACDEXT | MACD with controllable MA type |
MACDEXT(Records[Close],Fast Period = 12,Fast MA = 0,Slow Period = 26,Slow MA = 0,Signal Period = 9,Signal MA = 0) = [Array(outMACD),Array(outMACDSignal),Array(outMACDHist)] | |
MACDFIX | Moving Average Convergence/Divergence Fix 12/26 |
MACDFIX(Records[Close],Signal Period = 9) = [Array(outMACD),Array(outMACDSignal),Array(outMACDHist)] | |
MFI | Money Flow Index |
MFI(Records[High,Low,Close,Volume],Time Period = 14) = Array(outReal) | |
MINUS_DI | Minus Directional Indicator |
MINUS_DI(Records[High,Low,Close],Time Period = 14) = Array(outReal) | |
MINUS_DM | Minus Directional Movement |
MINUS_DM(Records[High,Low],Time Period = 14) = Array(outReal) | |
MOM | Momentum |
MOM(Records[Close],Time Period = 10) = Array(outReal) | |
PLUS_DI | Plus Directional Indicator |
PLUS_DI(Records[High,Low,Close],Time Period = 14) = Array(outReal) | |
PLUS_DM | Plus Directional Movement |
PLUS_DM(Records[High,Low],Time Period = 14) = Array(outReal) | |
PPO | Percentage Price Oscillator |
PPO(Records[Close],Fast Period = 12,Slow Period = 26,MA Type = 0) = Array(outReal) | |
ROC | Rate of change : ((price/prevPrice)-1)*100 |
ROC(Records[Close],Time Period = 10) = Array(outReal) | |
ROCP | Rate of change Percentage: (price-prevPrice)/prevPrice |
ROCP(Records[Close],Time Period = 10) = Array(outReal) | |
ROCR | Rate of change ratio: (price/prevPrice) |
ROCR(Records[Close],Time Period = 10) = Array(outReal) | |
ROCR100 | Rate of change ratio 100 scale: (price/prevPrice)*100 |
ROCR100(Records[Close],Time Period = 10) = Array(outReal) | |
RSI | Relative Strength Index |
RSI(Records[Close],Time Period = 14) = Array(outReal) | |
STOCH | Stochastic |
STOCH(Records[High,Low,Close],Fast-K Period = 5,Slow-K Period = 3,Slow-K MA = 0,Slow-D Period = 3,Slow-D MA = 0) = [Array(outSlowK),Array(outSlowD)] | |
STOCHF | Stochastic Fast |
STOCHF(Records[High,Low,Close],Fast-K Period = 5,Fast-D Period = 3,Fast-D MA = 0) = [Array(outFastK),Array(outFastD)] | |
STOCHRSI | Stochastic Relative Strength Index |
STOCHRSI(Records[Close],Time Period = 14,Fast-K Period = 5,Fast-D Period = 3,Fast-D MA = 0) = [Array(outFastK),Array(outFastD)] | |
TRIX | 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA |
TRIX(Records[Close],Time Period = 30) = Array(outReal) | |
ULTOSC | Ultimate Oscillator |
ULTOSC(Records[High,Low,Close],First Period = 7,Second Period = 14,Third Period = 28) = Array(outReal) | |
WILLR | Williams’ %R |
WILLR(Records[High,Low,Close],Time Period = 14) = Array(outReal) |
Price Transform
:
Indicator | Description |
---|---|
AVGPRICE | Average Price |
AVGPRICE(Records[Open,High,Low,Close]) = Array(outReal) | |
MEDPRICE | Median Price |
MEDPRICE(Records[High,Low]) = Array(outReal) | |
TYPPRICE | Typical Price |
TYPPRICE(Records[High,Low,Close]) = Array(outReal) | |
WCLPRICE | Weighted Close Price |
WCLPRICE(Records[High,Low,Close]) = Array(outReal) |
FMZ Quant Trading platform supports backtesting and querying various fundamental data in the bot. Fundamental data are provided in real time by FMZ Quant Trading platform data center, and the data center will continue to collect and summarize various fundamental data.
Use exchange.GetData(Source)
function to obtain the fundamental data.
The fundamental data of cryptocurrency have not been collected temporarily.
The fundamental data of cryptocurrency have not been collected temporarily.
FMZ Quant Trading platform supports the programmatic invocation of various functions of the Platform, and it has opened up the extended API.
It supports the API authority management extension, as shown in the figure:
It allows the newly added API KEY
to have all permissions. You can enter *
in the API permission input box to open all interface permissions. Specify specific interface permissions, and enter the corresponding extended API function names, separated by commas, such as GetRobotDetail, DeleteRobot
, that is, give this API KEY
the permission to obtain the interface of bot detailed information and delete bot interface.
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 |
(Normal start)
Status | Code |
---|---|
Idle | 0 |
In operation | 1 |
Stopping | 2 |
Signed out | 3 |
Stopped | 4 |
The strategy has errors | 5 |
(abnormal)
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 bot is already running | -4 |
Insufficient balance | -5 |
The number of concurrent strategies exceeds the limit | -6 |
Use md5
encryption method to verify.
Python, Golang language call examples:
#!/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 = 'f27bfcXXXXXXXX013c62e98XXXXX817a'
secretKey = 'ffeXXXXXXXX085ff7269XXXXXXXX6f82'
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 commands to the bot
print(api('CommandRobot', 123, 'ok'))
# StopRobot(robotId) returns the bot status code
print(api('StopRobot', 123))
# RestartRobot(robotId) returns the bot status code
print(api('RestartRobot', 123))
# GetRobotDetail(robotId) returns detailed bot 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 the bot, 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.
https://www.fmz.com/api/v1?access_key=xxx&secret_key=yyyy&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=fd3be82e9e6e6ed4439f2793a5e9ca&secret_key=520b9f10f3768e6ad1af59ff25184&method=CommandRobot&args=[130350,+""]
Pay attention to setting according to the following format: args=[130350,+""]
, in which 130350
is the bot ID
of FMZ Quant Trading platform.
Settings in the message box (the requested “Body” data to be sent):
JSON format:
{"close": {{close}}, "name": "aaa"}
The bot with ID
of 186515
can receive the interactive instruction: {"close": 39773.75, "name": "aaa"}
.
Text format:
BTCUSDTPERP Crossing 39700.00 close: {{close}}
The bot with ID
of 186515
can receive the interactive instruction: 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', 130350)) will fail, and the returned data is: {'code': 4, 'data': None}
# print(api('RestartRobot', 130350))
# Print bot details with ID 130350
print(api('GetRobotDetail', 130350))
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, 130350)
fmt.Println("main ret:", ret)
}
Use the extended API on FMZ Quant to realize “TradingView” alert signal trading
The extended API of FMZ Quant Trading platform
https://www.fmz.com/api/v1?
The above symbol ?
is followed by the request parameters.
The request parameters described in Python
language:
{
'version' : '1.0',
# Access key, applied on the account management page
'access_key': '8a1f6c3785fd78a1848320e0b19js99f',
# The specific method called
'method' : 'GetNodeList',
# The parameter list of specific method algorithm
'args' : [],
# Timestamp, in the unit of millisecond, is allowed to have 1 hour of time error both before and after the standard timestamp;the nonce must be greater than the nonce value of the last access
'nonce' : 1516292399361,
# Signature
'sign' : '085b63456c93hfb243a757366600f9c2'
}
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=8a1f6c3785fd78a1848320e0b19js99f&
nonce=1516292399361&
args=%5B%5D&
sign=085b63456c93hfb243a757366600f9c2&
version=1.0&
method=GetNodeList
Pay attention that there is no secret_key
among request parameters.
Signature Method
In the request parameters, the parameter sign
is an encrypted string, and the encryption method is 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
.
The reference Python
code of the signature part:
# parameter
d = {
'version': '1.0',
'access_key': accessKey,
'method': method,
'args': json.dumps(list(args)),
'nonce': int(time.time() * 1000),
}
# Calculate "sign" signature (encrypted)
d['sign'] = md5.md5(('%s|%s|%s|%d|%s' % (d['version'], d['method'], d['args'], d['nonce'], secretKey)).encode('utf-8')).hexdigest()
GetNodeList()
returns the docker list of the FMZ Quant Trading platform account corresponding to the API KEY
in the request.
Parameter None
Return value
{
"code": 0,
"data": {
"result": {
"nodes": [{
// Version number
"build": "3.3",
"date": "2018-01-19 10:35:24",
"id": 34500,
"ip": "126.28.21.120",
// Number of the bots running on this docker
"loaded": 1,
"name": "iZ9116xhkgtZ",
// Whether online
"online": true,
// Operation system
"os": "linux",
// Whether to enable offline alert
"wd": 0
},
...
]
},
"error": null
}
}
GetRobotGroupList()
returns the bot grouping list of FMZ Quant Trading platform account corresponding to the API KEY
in the request.
Parameter None
Return value
{
"code":0,
"data":{
"result":{
// All bot grouping information: group ID, group name
"items":[{"id":1122,"name":"test"}]
},
"error":null
}
}
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.
Parameter None
Return value
{
"code": 0,
"data": {
"result": {
"platforms": [{
"eid": "Huobi",
"id": 12483,
// The label when adding a platform
"label": "huobi - test ETH/ETC",
"logo": "huobi.png",
"name": "huobi",
"stocks": ["LTC_BTC", "ETH_BTC", "ETC_BTC", "BCH_BTC"],
"website": "https://www.huobi.pro/"
}, {
"eid": "AEX",
"id": 16345,
"label": "AEX",
"logo": "",
"name": "AEX",
"stocks": ["LTC_BTC", "ETH_BTC", "ETC_BTC", "BCC_BTC"],
"website": "https://www.aex.com/"
},
...
]
},
"error": null
}
}
GetRobotList(offset, length, robotStatus, label)
returns the robot list of the FMZ Quant Trading platform account corresponding to the API KEY
in the request.
Parameter
offset
, length
and robotStatus
are of integer type, and label
is of string type.
offset
length
robotStatus
(passing “-1” means getting all)label
(custom label; all bots with the label can be flirted out)For Python
code example, refer to the above verification method - Token Verification, and the following is the Python
invocation example:
print api('GetRobotList', 'member2')
print the information of all robots 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
.
Return value
{
"code": 0,
"data": {
"result": {
"all": 53,
"bots": [{
"date": "2017-12-25 09:29:27",
"end_time": "2017-12-28 17:44:21",
"id": 66054,
// If the value is 1, the bot is a virtual platform bot
"is_sandbox": 1,
"name": "C++ test strategy",
"node_guid": "705d9aaaaaaaa93b49baaaaa787581cb087",
"profit": 0,
"public": 0,
"refresh": 151345645647000,
"start_time": "2017-12-28 17:44:15",
"status": 3,
"strategy_id": 65365,
"strategy_isowner": true,
"strategy_name": "C++ Version Docker API Test Strategy(cryptocurrency futures and spot markets)",
"wd": 0
}, ...
]
},
"error": null
}
}
CommandRobot(RobotId, Cmd)
the interface sends the interactive command to the corresponding robot (robot ID
: RobotId
) of the API KEY
in the request of the FMZ Quant account (the interactive command is captured by the GetCommand()
API called in the strategy and returns).
Parameter
RobotId
is of integer type, namely the bot ID
; Cmd
is of string type, which sends interactive commands to bots.
RobotId
, the bot ID
, can be obtained by the GetRobotList(...)
interface.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 (to realize the interactive logic in the strategy, please refer to the GetCommand()
function in the file).Return value
{
// The API request was successfully executed
"code": 0,
"data": {
// However, sending a command to a bot that is not running returns failure
"result": false,
"error": null
}
}
StopRobot(RobotId)
stops running the bot with the specified ID (robot ID
: RobotId
), corresponding to the API KEY
in the request of the FMZ Quant account.
Parameter
RobotId
is of integer type, namely the bot ID
, which can be obtained by GetRobotList(...)
interface; StopRobot(RobotId)
interface returns the status code of the stopped robot.
Return value
{
"code": 0,
"data": {
// 2 means stopping
"result": 2,
"error": null
}
}
RestartRobot(RobotId, Settings)
restarts the robot with the specified ID (robot ID
: RobotId
), corresponding to the API KEY
in the request of the FMZ Quant account.
If the robot 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 robot 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, or just pass the the RobotId
parameter. If you only pass the RobotId
parameter, start the bot according to the current bot settings.
Parameter
Without configuring the bot, the strategy parameter Settings
:
RobotId
is of integer type; the robot ID
can be obtained by GetRobotList(...)
.
With configuring the bot, the strategy parameter Settings
:
RobotId
is of integer type; the bot ID
can be obtained by GetRobotList(...)
.
Settings
is of JSON
object type.
Settings
parameter format as follows:
Settings = {
"name": "hedge test",
// Strategy parameter
"args": [["Interval", 500]],
// Strategy ID, which can be obtained with "GetStrategyList" method
"strategy": 25189,
// K-line period parameter "60" means 60 seconds
"period": 60,
// Specify on which docker to run; if the attribute is not written, it will be automatically assigned to run
"node" : 51924,
// Custom field
"appid": "member2",
"exchanges": [
// ZB; "pid" can be obtained by "GetPlatformList" method
{"pid": 15445, "pair": "ETH_BTC"},
// OKEX; 2 exchange objects are configured
{"pid": 13802, "pair": "BCH_BTC"},
// In addition to the platforms ("pid" identification) configured by the FMZ dashboard, you can also set exchange configuration information that has not been configured to operate the bot
{"eid": "OKEX", "pair": "ETH_BTC", "meta" :{"AccessKey": "xxx", "SecretKey": "yyy"}},
{"eid": "Huobi", "pair": "BCH_BTC", "meta" :{"AccessKey": "xxx", "SecretKey": "yyy"}}
]
}
Note:
When you use the sensitive information, such as platform API KEY
, including "meta":{"AccessKey":"xxx","SecretKey":"yyy"}
in the configuration of eid
, you should know that FMZ does not store the data. The data will be sent directly to the docker program, so this information must be configured every time the bot is created or restarted.
To restart the bot that uses the plugin to support the exchange, when configuring the Settings
parameter, you should make the following settings for the exchanges
attribute:
{"eid": "Exchange", "label" : "testXXX", "pair": "ETH_BTC", "meta" :{"AccessKey": "123", "SecretKey": "1234", "Front" : "http://127.0.0.1:6666/XXX"}}
label
attribute is to set a label for the exchange object accessed by the current general protocol, which can be obtained by the exchange.GetLabel()
function in the strategy.
Return value
{
"code": 0,
"data": {
// 1 means running
"result": 1,
"error": null
}
}
GetRobotDetail(RobotId)
obtains the detailed information about the robot with the specified ID (robot ID
: RobotId
), corresponding to the API KEY
in the request of the FMZ Quant Trading platform account.
Parameter
RobotId
is of integer type; the robot ID
can be obtained by GetRobotList(...)
.
Return value
{
"code": 0,
"data": {
"result": {
"robot": {
// Next payment time, namely the effective cut-off time after the current payment
"charge_time": 1561992608,
// Elapsed Time
"charged": 3600,
// Amount consumed (0.125 CNY = 12500000 / 1e8)
"consumed": 12500000,
"date": "2019-07-01 21:50:08",
"debug": "{\"Nano\":1561989722431145193,\"Stderr\":\"\",\"Stdout\":\"\"}",
// Stop time
"end_time": "2019-07-01 22:02:02",
// The docker ID assigned when the robot is running; if it is automatic, the value is -1
"fixed_id": 85960,
"id": 150288,
"is_deleted": 0,
// Whether it has the permission to manage the bot
"is_manager": true,
// Whether it is virtual exchange
"is_sandbox": 0,
// Robot name
"name": "Spread monitoring2",
// Docker ID
"node_id": 85960,
// The exchange objects configured by the robot
"pexchanges": {
// 14703 is eid, and "GateIO" is exchange name
"14703": "GateIO",
"15445": "ZB",
"42960": "OKEX",
"44314": "Huobi"
},
// label information of the exchange object configured by the robot
"plabels": {
"14703": "Gate.IO (old name: BTER)",
"15445": "ZB",
"42960": "OKEX spot V3 test",
"44314": "Huobi - newest test"
},
"profit": 0,
// Whether to show public
"public": 0,
// Recent active time
"refresh": 1561989724000,
"robot_args": "[[\"TickInterval\",500],[\"StrOnePair\",\"spot:Huobi:spot;spot:OKEX:spot;false;60;5;0;0\"],[\"StrTwoPair\",\"spot:ZB:spot;spot:GateIO:spot;false;60;5;0;0\"],[\"StrThreePair\",\"null\"],[\"StrFourPair\",\"null\"],[\"StrSixPair\",\"null\"],[\"StrFivePair\",\"null\"],[\"ResetChart\",false]]",
"start_time": "2019-07-01 22:00:54",
// Robot status
"status": 4,
"strategy_args": "[[\"TickInterval\",\"Detection frequency (ms)\",\"This is millisecond. Don't set it too small.\",500],[\"StrOnePair\",\"Combination1\",\"Spread Combination\",\"spot:Huobi:spot;spot:OKCoin:spot;false;60;5;0;0\"],[\"StrTwoPair\",\"Combination2\",\"Spread Combination\",\"future:Futures_OKCoin:this_week;spot:OKCoin:spot;false;60;5;0;0\"],[\"StrThreePair\",\"Combination3\",\"Spread Combination\",\"future:Futures_OKCoin:this_week;future:Futures_OKCoin:quarter;true;60;5;0;0\"],[\"StrFourPair\",\"Combination4\",\"Spread Combination\",\"null\"],[\"StrSixPair\",\"Combination6\",\"Combination\",\"null\"],[\"StrFivePair\",\"Combination5\",\"Combination\",\"null\"],[\"ResetChart\",\"whether to clear the previous chart\",\"clear the previous chart\",false]]",
// Configured exchange objects, set trading pair information
"strategy_exchange_pairs": "[60,[44314,42960,15445,14703],[\"BTC_USDT\",\"BTC_USDT\",\"ETH_USDT\",\"ETH_USDT\"]]",
// Strategy ID
"strategy_id": 21337,
// Strategy's last modification time
"strategy_last_modified": "2018-11-29 12:07:58",
// Strategy name
"strategy_name": "Digital currency spread monitoring and analysis",
"summary": "Polling time consuming: 500ms\n`[{\"type\":\"table\",\"title\":\"pair basic data\",\"cols\":[\"ID\",\"NameA - NameB\",\"SymbolA - SymbolB\",\"UpdCycle\",\"isUSD\",\"Collect\"],\"rows\":[[\"0 \",\"Huobi/OKEX\",\"spot/spot\",60,false,\"612ms\"],[\"1 \",\"ZB/GateIO\",\"spot/spot\",60,false,\"501ms\"]]},{\"type\":\"table\",\"title\":\"pair market data\",\"cols\":[\"ID\",\"NameA - NameB\",\"SymbolA - SymbolB\",\"A_Bids1\",\"B_Asks1\",\"Plus\",\"A_Asks1\",\"B_Bids1\",\"Minus\"],\"rows\":[[\"0 \",\"Huobi/OKEX\",\"spot/spot\",10518.02,10525.1,-7.08,10520,10523,-3],[\"1 \",\"ZB/GateIO\",\"spot/spot\",285.68,286,-0.32,285.8,285.85,-0.05]]},{\"type\":\"table\",\"title\":\"pair statistical data\",\"cols\":[\"ID\",\"NameA - NameB\",\"SymbolA - SymbolB\",\"Maximum spread\",\"Minimum spread\",\"Mean positive premium\",\"Mean negative premium\"],\"rows\":[[\"0 \",\"Huobi/OKEX\",\"spot/spot\",0,-3,0,-1.47],[\"1 \",\"ZB/GateIO\",\"spot/spot\",0.03,-0.05,0.03,-0.05]]}]`\n",
// Whether to enable offline alert
"wd": 0
}
},
"error": null
}
}
The summary
attribute in the returned data (information on the bot status bar; cached for 10 second; not the latest data) currently has a data amount limit (cached data); the data amount limit is 200KB, and the excess data will be truncated. If you need more status bar information data, you can use the GetRobotLogs
interface to get (when GetRobotLogs
obtains the information of status bar, the field summary
is the latest data).
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 the bot is 1 minute, namely 60 seconds.
[44314,42960,15445,14703]
is the exchange object eid
configured for the bot (according to the addition order).
[\"BTC_USDT\",\"BTC_USDT\",\"ETH_USDT\",\"ETH_USDT\"]
is the trading pair set for the exchange object configured by the bot (in the order of addition and in one-to-one correspondence with eid
).
GetAccount()
returns the account information corresponding to the API KEY
in the request of the FMZ Quant Trading platform account.
Parameter None
Return value
{
"code": 0,
"data": {
"result": {
"username": "littlelittledream",
"level": 0,
"consumed": 3235500000,
"invitation_code": "1545967",
"points": 25,
// The value here, due to precision control, is expressed in integer. To convert it to actual value, you need to divide it by 1e8 (i.e. 10 to the 8th power), and the actual result here is: 65.421
"balance": 6542100000
},
"error": None
}
}