PluginRun
Runs a piece of JavaScript code on a docker and returns the result, without creating a robot or charging fees; one run lasts at most 5 minutes, and the code can place real orders.
Examples
Run code on docker 123 and get its logs and return value.
python
# api() is the function in the Python example on the signature authentication page
import json
settings = {
"source": "function main() {Log(\"Hello FMZ\")}",
"node": 123,
"period": 60,
"exchanges": [{"pid": 123, "pair": "SOL_USDT"}]
}
r = api('PluginRun', settings)
out = json.loads(r['data']['result'])
print(out['logs'], out['result'])Returns
| Type | Description |
string |
|
Arguments
| Name | Type | Required | Description |
settings | object | Yes | Run configuration; fields are in the attributes table below. |
Attributes
| Name | Type | Description |
settings.source | string | The code to run; its entry is |
settings.strategy | number | Without |
settings.node | number | ID of the docker that runs the code; omitted or |
settings.exchanges | array | Exchange object configuration, written as in "Robot configuration (settings)" in |
Remarks
It uses the same execution mechanism as the "Debugging Tool" of the development tools and trading terminal plugins; see Plugin Principle and Development.
exchanges can also pass an exchange configuration directly instead of referencing an exchange account on the platform, e.g. {"eid": "Binance", "pair": "ETH_BTC", "meta": {"AccessKey": "...", "SecretKey": "..."}}; the field names of meta are given by the meta returned by GetExchangeList. Usually only one exchange object is set in exchanges (the debugging tool page supports only one); setting two raises no error, but accessing the second exchange object in the code does.
Example response
json
{
"code": 0,
"data": {
"result": "{\"logs\": [...], \"result\": \"\"}",
"error": null
}
}
Parsed, result is:
json
{
"logs": [{
"PlatformId": "", "OrderId": "0", "LogType": 5, "Price": 0, "Amount": 0,
"Extra": "Hello FMZ", "Currency": "", "Instrument": "", "Direction": "",
"Time": 1732267473108
}],
"result": ""
}