The Inventor Quantitative Trading Platform Extension API has recently been upgraded to support direct access mode, which makes it easy to send TradingView alerts to the Inventor Quantitative Trading Platform robot to automate trading.
Links to relevant parts of the Inventor API documentation
The main role of the API extension is to provide an interface to the various functions of the inventor's quantitative trading platform for programmatic operations, such as simultaneous batch start of the robot, timing of the robot's start, stop, reading of the robot's information details, etc. We use the Inventor's quantitative trading platform extension to implement the API TradingView alarm signals trading.CommandRobot(RobotId, Cmd)
The interface can send interactive instructions to the specified robot ID, which the robot receives and then performs the corresponding operation (e.g. placing an order to buy, sell, etc.).
To use the API extension, you first need to create your own inventor account.API KEY
:
API KEY
The secret key isaccess key
andsecret key
It's not just a question of time.API KEY
The inventor of the programmatic operation of the quantitative trading platform key, so it must be properly stored and never leaked.API KEY
You can specify permissions, like the one above, just for this.API KEY
Giving accessCommandRobot(RobotId, Cmd)
Permissions for the interface, for security reasons in this example, please only give the extension to FMZAPI KEY
GivingCommandRobot(RobotId, Cmd)
Access to the interface.
The direct access mode means thatAPI KEY
A query written directly into a URL, such as the URL for an Inventor Quantified Trading Platform Extension API, can be written as:
https://www.fmz.com/api/v1?access_key=xxx&secret_key=yyyy&method=CommandRobot&args=[186515,"ok12345"]
In this case,https://www.fmz.com/api/v1
It's the address of the interface.?
And then there wasQuery
, the parametersaccess_key
The secret key example is represented by xxx (the access_key of your FMZ account when using it), the parametersecret_key
The secret key is indicated by the symbol YYYYY (if used, specify your account secret_key), the parametermethod
This is the name of the extension API that you want to access.args
To be calledmethod
The parameters of the interface.
We use TradingView as a signal source to send trading orders to the inventor's quantified trading platform robot, which in fact only usesCommandRobot
This interface.
First you have to have an account at the TradingView Pro level, the Basic level is not able to use the WebHood function in the alarm.
Adding an indicator to a graph can also be another scripting algorithm. Here, for ease of demonstration, we use the most commonly usedMACD
Indicator, and then set the K-line cycle to 1 minute (to make the signal trigger faster, easy to demonstrate).
Right-click on the chart and select "Add alerts" from the pop-up menu.
Set in the "Alarm" pop-up windowWebHook
At this point, it is possible to set up without any haste, and we start with the inventor's robotic monitoring signal on the side of the trading platform.
The source code of the strategy:
// 全局变量
var BUY = "buy" // 注意:现货用的命令
var SELL = "sell" // 现货用的命令
var LONG = "long" // 期货用的命令
var SHORT = "short" // 期货用的命令
var COVER_LONG = "cover_long" // 期货用的命令
var COVER_SHORT = "cover_short" // 期货用的命令
function main() {
// 清空日志,如不需要,可以删除
LogReset(1)
// 设置精度
exchange.SetPrecision(QuotePrecision, BasePrecision)
// 识别期货还是现货
var eType = 0
var eName = exchange.GetName()
var patt = /Futures_/
if (patt.test(eName)) {
Log("添加的交易所为期货交易所:", eName, "#FF0000")
eType = 1
if (Ct == "") {
throw "Ct 合约设置为空"
} else {
Log(exchange.SetContractType(Ct), "设置合约:", Ct, "#FF0000")
}
} else {
Log("添加的交易所为现货交易所:", eName, "#32CD32")
}
var lastMsg = ""
var acc = _C(exchange.GetAccount)
while(true) {
var cmd = GetCommand()
if (cmd) {
// 检测交互命令
lastMsg = "命令:" + cmd + "时间:" + _D()
var arr = cmd.split(":")
if (arr.length != 2) {
Log("cmd信息有误:", cmd, "#FF0000")
continue
}
var action = arr[0]
var amount = parseFloat(arr[1])
if (eType == 0) {
if (action == BUY) {
var buyInfo = IsMarketOrder ? exchange.Buy(-1, amount) : $.Buy(amount)
Log("buyInfo:", buyInfo)
} else if (action == SELL) {
var sellInfo = IsMarketOrder ? exchange.Sell(-1, amount) : $.Sell(amount)
Log("sellInfo:", sellInfo)
} else {
Log("现货交易所不支持!", "#FF0000")
}
} else if (eType == 1) {
var tradeInfo = null
var ticker = _C(exchange.GetTicker)
if (action == LONG) {
exchange.SetDirection("buy")
tradeInfo = IsMarketOrder ? exchange.Buy(-1, amount) : exchange.Buy(ticker.Sell, amount)
} else if (action == SHORT) {
exchange.SetDirection("sell")
tradeInfo = IsMarketOrder ? exchange.Sell(-1, amount) : exchange.Sell(ticker.Buy, amount)
} else if (action == COVER_LONG) {
exchange.SetDirection("closebuy")
tradeInfo = IsMarketOrder ? exchange.Sell(-1, amount) : exchange.Sell(ticker.Buy, amount)
} else if (action == COVER_SHORT) {
exchange.SetDirection("closesell")
tradeInfo = IsMarketOrder ? exchange.Buy(-1, amount) : exchange.Buy(ticker.Sell, amount)
} else {
Log("期货交易所不支持!", "#FF0000")
}
if (tradeInfo) {
Log("tradeInfo:", tradeInfo)
}
} else {
throw "eType error, eType:" + eType
}
acc = _C(exchange.GetAccount)
}
var tbl = {
type : "table",
title : "状态信息",
cols : ["数据"],
rows : []
}
// tbl.rows.push([JSON.stringify(acc)]) // 测试时使用
LogStatus(_D(), eName, "上次接收到的命令:", lastMsg, "\n", "`" + JSON.stringify(tbl) + "`")
Sleep(1000)
}
}
The strategy code is very simple, detection.GetCommand
The return value of a function is the value that is returned when an interactive message is sent to a policy program.GetCommand
The function returns the message, and then the policy program makes the corresponding trading action based on the message content. The policy has an interaction button on it, which can test interaction features, such as running this policy and configuring the robot to the inventor of a simulated exchange for a quantized trading platform.WexApp
。
Click on the interaction button to test the functionality of the robot receiving the purchase order.
You can see that the command string received by the robot is:buy:0.01
。
When we simply trigger a TradingView alert, WebHook requests a URL to access the inventor's quantified trading platform extension API.CommandRobot
When the interface is used, the parameters carried are:buy:0.01
It's not that simple.
Back in TradingView, we fill in the URL of WebHook.access_key
、secret_key
Parameters fill in their ownAPI KEY
。method
The only thing we're going to do is visit.CommandRobot
This extended API interface is used to create a user-friendly interface.args
The parameter is[机器人ID,命令字符串]
In the form of a bot ID, we can access it directly from the bot page, as shown below:This time, when the signal is triggered, we buy 0.02 coins and the command string is:"buy:0.02"
◦ This is done with the WebHook URL. ◦ This only supports writing the signal in the URL.https://www.fmz.com/api#直接验证 。
https://www.fmz.com/api/v1?access_key=e3809e173e23004821a9bfb6a468e308&secret_key=45a811e0009d91ad21154e79d4074bc6&method=CommandRobot&args=[191755,"buy:0.02"]
In TradingView, set the following:
Wait for the signal to trigger... Wait for the signal to trigger... 等待信号触发. …
The robot received a signal:
This allows you to use the rich charting functionality in TradingView, indicator algorithms that work with the inventor's strategy robot to quantify the trading platform, and achieve the automated trading you want, which is less difficult than porting strategies from TradingView to JavaScript or Python.
The "Monitoring Signal Robot" strategy code is for learning and research purposes only, and for real-world use, it requires self-optimized adjustment, supports futures, and is recommended to be set to the market price order mode. See the policy code parameters for more details. If you have any questions, please leave a comment.
huangqingchi /upload/asset/2b12a9a1b89accb491a32.png
huangqingchiI want to implement stop loss, what parameters should I add in the alert, or directly modify the code, these order types fmz should all be wrapped up I directly debug the code right?
huangqingchiWhy not add a futures exchange?
pw1013If you could please connect me to the deepcoin exchange, thank you very much.
mingxi1005When will the inventors be able to pair the coins to win the futures contracts?
mingxi1005When will the inventors be able to pair the coins to win the futures contracts?
smilesgYou're right, my contract strategy is that sometimes I'm going to get a raise in the middle of a trade, so when I finally get to the bottom of the trade, I'm going to use cover_long to flatten out all the positions (because I don't know how many times the middle will add up), what's the 1 in "cover_long:1", and I'm going to kneel down and ask for code.
tyk950115My TV policy message is this: order {{strategy.order.action}}@{{strategy.order.contracts}} ticker; new policy position {{strategy.position_size}} If I want to do a contract, do I have to add four alerts? Can webhook reference the fields in the policy? Or do I have to write it off? How do the four ways in webhook long, cover_long\short, cover_short match the messages in the alert?
Quantitative measurements of small insectsI want to send the text of the news from tv, but unfortunately I can't carry it, only the URL can carry the parameters, not the information for tradingview.
NingQuestion: [1234567, "buy:50"] This is a $50 BTC buy, and it's a $50 USD buy. But when I sell it, [1234567, "sell:50"] it shows the error: Sell ((-1, 50): insufficient balance. So how do I set it up to sell all the BTC I bought the first time?
wqyThis is powerful!
lanbnHello teacher, I'm following your steps step by step, the server selected is the server that the inventor brought with him, but the TV has already sent a signal, but the robot on the inventor's side still does not execute the signal command, is it because of the server?
tnmmhmIt's great, take it slow.
Reverse the Q./upload/asset/19a5ed382b58652c4dd19.png /upload/asset/19b0ea9ffa5100a3594f3.png /upload/asset/19a806e32e9b589696fa0.png /upload/asset/19a5005173219393cf2d9.png Why is the contract code that I added in step by step still showing an error, is that the wrong step?
wuxianFor example, if there are multiple heads in the tv policy, will this be based on the tips in the tv policy?
PY008What does the futures contract code say?
melo23Where is the video tutorial for the futures?
sug210Is the Binance Futures not supported?
yuanlijieHow did the contract work? I am a programmer and I don't know English except for the spelling of the letters.
mikelslI'm going to go to the bathroom and I'm going to go to the bathroom and I'm going to go to the bathroom and I'm going to go to the bathroom.
skyfffireIt's a great step, but it's also a simple one.
homilyThat's great.
huangqingchiDo you handle all the work orders?
Inventors quantify - small dreamsI have too much to say here, if you have a problem, send a request, don't look for a reply.
huangqingchi /upload/asset/2b1eecac2c64d82a23bc6.png
huangqingchiI was wondering if I could do a delayed processing of the stop signal without affecting the next time the signal comes in, so that the code doesn't change too much.
huangqingchiThank you.
Inventors quantify - small dreamsThere is no wrapping under the condition list, because the exchange is not uniform, the wrapping is the market price list, the limit price list. The condition list requires the use of the exchange.IO function to call the exchange interface separately.
Inventors quantify - small dreamsTrading view webhook requests are sent to the FMZ platform, which has a message queue at the bottom of the platform, one that handles interactions.
huangqingchiHow do I get multiple alerts to come in at the same time, the same transaction pair, or different transaction pairs, but I see that I can only process one per second, and there's no way to sort.
huangqingchiI see, thank you! I'll try it on TV.
Inventors quantify - small dreamsThe price is listed in the documentation.
Inventors quantify - small dreamsI've already answered you above, you can check it out.
huangqingchiThis is an example of this in your article, because here -1 can identify the market list, and the middle one about {close} can also identify, but I looked at the platform's API documentation and couldn't find anything that corresponds to the market list.
huangqingchi /upload/asset/2b1a4e2566409a8499764.png
Inventors quantify - small dreamsThe test signal here refers to the final message sent to the FMZ, and when you set the webhook on the trading view, it says {{close}} It is the specific price when it is actually sent.
Inventors quantify - small dreamsWhen you fill in a specific price during the test signal, the FMZ will not recognize your {{close}}, this is the placeholder in the trading view, read the article and you understand.
huangqingchiThis code is the strategy interaction here, and I'm testing this 1000sats transaction pair, and I think I'm going to start with the closing price, which is too expensive, but I'm going to make mistakes, my code level is too poor, and gpt is not going to figure out the specific problem.
huangqingchi /upload/asset/2b190736753a1d4eb30bf.png
Inventors quantify - small dreamsI'm not going to go into detail.
Inventors quantify - small dreamsYou can create specific scenarios. You can debug specifically to find problems in the code. This policy is public and can be optimized for specific changes.
huangqingchi"Flag": "{{strategy.order.id}}", "Flag" and "Flag" are also included. "Exchange" is one. "Currency": 1000SATS_USDT, which is the currency of the country. "ContractType": "swap", "swap" and "swap". "Price": "{{close}}", "Price" is the name of the song. "Action": "long", and "long", and "long". "Amount": 33333 My signal says close, why does the log show no price?
Inventors quantify - small dreamsIt should be a transaction, the contract code is wrong, check it out.
huangqingchiI accidentally sent the wrong transaction pair in the test code, and then the code started to loop error messages, as if it had been requesting, only to restart the disk, and I wondered what was wrong.
huangqingchi /upload/asset/2b1206cf8d9c7e03d9a56.png
Inventors quantify - small dreamsThis strategy is a simple example of how one can only do a single variety, whereas multi-varieties can refer to another example: I've been trying to find out more about this for a while.
huangqingchi /upload/asset/2b14eddf87dbd2c8d8d13.png
huangqingchiHi, I've implemented adding exchanges, but how do I implement multiple transactions?
Inventors quantify - small dreamsHello, can you send a specific screenshot to add which exchange?
pw1013I asked the copyright owner about you.
hexiao49I have a problem in my community, can you help me see it?
Inventors quantify - small dreamsThe problem is that without an API, you can't do anything.
hexiao49Deep doesn't even have an API?
Inventors quantify - small dreamsThis depends on how many users want it.
Inventors quantify - small dreamsThis stop loss requires a specific change in strategy, not one or two sentences. FMZ directly supports the PINE language, which makes it easier to run PINE scripts directly.
mingxi1005Teacher: I want to add the function of shutdown after opening the tab on your robot, where should I add it?
Inventors quantify - small dreamsYes, I have also asked their customer service to root out the API interface bugs that are not under contract.
mingxi1005There's no way.
Inventors quantify - small dreamsThis is a live API, boss! #_#! FMZ has already supported this feature.
mingxi1005This website has an API, and you need a ladder to open /upload/asset/2986424014eb005f8cda2.png
mingxi1005https://www.coinw.fit/front/API This website has an API, you need a ladder to open it
Inventors quantify - small dreamsThis address cannot be opened. No API documentation is contracted.
mingxi1005API entry link: https://coinw.pw/API
Inventors quantify - small dreamsThis is the live API for coinw, which is already supported by FMZ, and they don't have a contract interface. You'd better check with Coinw. I asked their customer service and they said no contract API.
mingxi1005Can we bind ourselves using the common protocol? Just ask to fill in the IP address, which IP address to fill in? API entry link: https://coinw.pw/API
Inventors quantify - small dreamsI'm embarrassed, but are you sure that the coin-winning contract has an API?
mingxi1005Yes, little dream teacher, if you access, there will be a lot of quantitative access because the coin wins 80% commission.
Inventors quantify - small dreamsHello, do you need a contract to access this exchange? haven't evaluated this exchange yet.
Two or two old waves.I've been having the same problem.
lanbnBrother, did you succeed in the TV strategy of directly linking FMZ?
Inventors quantify - small dreamsThis can be specifically designed, for example, you design the request cover_long:1, change it to cover_long:all, so that in this listening policy of FMZ you change the time of receiving the interaction cover_long, judging if it is all, then all is flat. To achieve this you have to modify this policy.
What's up?
// global variable
var BUY = "buy" // note: command for spot
var SELL = "sell" // command to use on the spot
var LONG = "long" // The command to use the futures
var SHORT = "short" // command for the futures
var COVER_LONG = "cover_long" // the command to use the futures
var COVER_SHORT = "cover_short" // The command used for the futures
I'm not going to lie.
I'm not sure.
I mean...
I'm not sure.
} else if (eType == 1) {
var tradeInfo is null
This is a list of all the different ways Var ticker is credited in the database.
if (action == LONG) {
exchange.SetDirection (("buy")
TradeInfo = IsMarketOrder? exchange.Buy ((-1, amount)): exchange.Buy ((ticker.Sell, amount) is the name of the order.
} else if (action == SHORT) {
exchange.SetDirection (("sell")
TradeInfo = IsMarketOrder? exchange.Sell ((-1, amount)): exchange.Sell ((ticker.Buy, amount) is the name of the order.
} else if (action == COVER_LONG) { // COVER_LONG is the
yidaiHave you solved your question?
Inventors quantify - small dreamsThe stability of the TV alarms is not so clear, that depends on the TV.
beiyeargs=[191755, "buy:0.02"], adding a parameter here, doing more at the same time can also do nothing. Is one of the parameters better?
Inventors quantify - small dreamsReceive TV requests using FMZ's extended API and access Body content at: https://www.fmz.com/api# Direct verification Now the data in the body can be received in the url of the TV request.
1131717062Please ask me how to set up the alert on tv, how to set up the alert on strategy, webhook url
Inventors quantify - small dreamsYou can access Body content using FMZ's extended API to receive TV requests, see: https://www.fmz.com/api#%E7%9B%B4%E6%8E%A5%E9%AA%8C%E8%AF%81
Quantitative measurements of small insects https://www.fmz.com/strategy/221850,看到了,感谢大神!!
Inventors quantify - small dreamsThere is a direct link to the requested body information, which can be found in the Strategy Square search.
Inventors quantify - small dreamsThe policy was changed to 50 divided by the price then.
Inventors quantify - small dreamsIf a command is received, the Robot Status tab is turned on, and the Last Received Command tab is turned on. This will show the command received. Check to see if there is no configuration.
lanbnIt is configured as a real-time Binance, no hint on the robot log, the TV is just a trigger condition and set it on the webhook, right?
Inventors quantify - small dreamsTo answer the specific question, is the exchange configured on your robot spot, futures, what does the robot log show?
Inventors quantify - small dreams/upload/asset/16afbca03eec23516d37.png This is a list of all the different ways Afbca03eec23516d37 is credited in the database. You added the wrong exchange.
Inventors quantify - small dreamsBrother, the API KEY screenshot needs to be encoded, security first.
Reverse the Q./upload/asset/19aee891571def2a6c4f3.png I have both the API permissions on the binance and I have an open contract account, but I can't always add a futures exchange when the strategy is running, is the code a problem?
Inventors quantify - small dreamsThe log shows Binance explaining that the exchange object added is Binance Cash. But your policy set the futures contract code, so it is an error.
Inventors quantify - small dreamsYou need to set an alarm in Trading view, fill in the webhook address in the alarm setting.
Inventors quantify - small dreamshttps://www.fmz.com/api#exchange.setcontracttype... This function is described in the description and can be viewed here.
Inventors quantify - small dreamsThe link is at the beginning of this article.
melo23What's the name of the B station video?
Inventors quantify - small dreamsThe same applies to futures spot, just change the parameters inside the link. var BUY = "buy" Var SELL is "sell". var LONG is "long". var SHORT = "short" This is the last time I'm going to do this. This is the first time I've seen this. long is the open multihead position, short is the open blank position, cover_long is the flat multihead, cover_short is the flat blank position. What's up? This is a list of all the different ways Access_key=e3809e173e23004821a9bfb6a468e308&secret_key=45a811e0009d91ad21154e79d4074bc6&method=CommandRobot&args=[191755, "buy:0.02"] is credited in the database. What's up? The link to buy is replaced.
Inventors quantify - small dreamsTwo alarms are added to the TV. One is cheap and one is empty.
sug210If you want to have multiple slots, i.e. the signal setup is cover_long:10 and short:10, but the TV is set to execute only one signal, isn't that a loss?
Inventors quantify - small dreamsIn this case, the instruction to use the futures is not to buy, but to sell.
Inventors quantify - small dreamsThe futures settings contract is done, and the policy parameters, in addition to the webhook url configured on the TV, use the futures commands long, cover_long and so on.
key986That's the operating code for the set of futures, please ask the futures should be re-written.
Inventors quantify - small dreamsThere are video tutorials available here, from B Station.