Webhooks Updated
This commit is contained in:
1 parent
ac43839d5d
commit
bbbdb43cdd
4 files changed
+213
-38
No files matched your search
@@ -257,6 +257,9 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
webhookMessages = []
|
||||
}
|
||||
|
||||
console.log('[INFO] httpInterface -> Webhook -> Fetch-Messages -> Exchange-Market = ' + exchange + '-' + market)
|
||||
console.log('[INFO] httpInterface -> Webhook -> Fetch-Messages -> Messeges Fetched by Webhooks Sensor Bot = ' + webhookMessages.length)
|
||||
|
||||
respondWithContent(JSON.stringify(webhookMessages), httpResponse)
|
||||
webhookMessages = []
|
||||
|
||||
@@ -299,6 +302,9 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
webhookMessages.push([timestamp, source, messageReceived])
|
||||
webhook.set(key, webhookMessages)
|
||||
|
||||
console.log('[INFO] httpInterface -> Webhook -> New-Message -> Exchange-Market = ' + exchange + '-' + market)
|
||||
console.log('[INFO] httpInterface -> Webhook -> New-Message -> messageReceived = ' + messageReceived)
|
||||
console.log('[INFO] httpInterface -> Webhook -> New-Message -> Messeges waiting to be Fetched by Webhooks Sensor Bot = ' + webhookMessages.length)
|
||||
respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse)
|
||||
}
|
||||
break
|
||||
|
||||
@@ -15122,7 +15122,7 @@
|
||||
"config": true
|
||||
},
|
||||
"initialValues": {
|
||||
"config": "{ \n\"webhookURL\": \"Webhook/New-Message/Trading-View/Binance/BTC-USDT\",\n\"testMessage\": \"\" \n}"
|
||||
"config": "{ \n\"webhookURL\": \"Webhook/New-Message/Trading-View/binance/BTC-USDT\",\n\"testMessage\": \"\" \n}"
|
||||
},
|
||||
"propertyNameAtParent": "signalsProviders",
|
||||
"childrenNodesProperties": [],
|
||||
|
||||
+204
-37
@@ -3,8 +3,8 @@
|
||||
"pageNumber": "2",
|
||||
"type": "Webhook Notifications",
|
||||
"definition": {
|
||||
"text": "Receive webhook notifications from other systems and use them as signals in your strategies.",
|
||||
"updated": 1611486052936
|
||||
"text": "Receive webhook notifications from other systems like Trading View, and use them as signals in your strategies.",
|
||||
"updated": 1615365927821
|
||||
},
|
||||
"paragraphs": [
|
||||
{
|
||||
@@ -17,8 +17,29 @@
|
||||
"text": "Superalgos allows you to receive webhook notifications from TradingView or any other system supporting webhooks. You may use this feature to turn notifications into signals upon which you may act from within your strategies."
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "The system’s Web Server receives notifications and serves them to a sensor bot running as a data mining task. The sensor creates a data product with several properties which are made available to be used from within strategies."
|
||||
"style": "Title",
|
||||
"text": "How does it Work?",
|
||||
"updated": 1615366465462
|
||||
},
|
||||
{
|
||||
"style": "List",
|
||||
"text": "Receving Data: the Client receives via it's http interface notifications from external sources (like Trading View) and keep the data received in-memory. This happens independently of the Webhooks Sensor Bot, meaning that it does not matter if the Webhook Sensor Bot is running or not.",
|
||||
"updated": 1615366502234
|
||||
},
|
||||
{
|
||||
"style": "List",
|
||||
"text": "Retrieving Data: The Webhooks Sensor Bot, when it is running, queries the Client and ask it for the in-memory data it holds.",
|
||||
"updated": 1615366526381
|
||||
},
|
||||
{
|
||||
"style": "List",
|
||||
"text": "Saving Data: The Webhooks Sensor Bot saves this data to disk.",
|
||||
"updated": 1615366538404
|
||||
},
|
||||
{
|
||||
"style": "List",
|
||||
"text": "Consuming Data: A Trading Bot running a Strategy, might consume the data saved by the Webhooks Sensor Bot.",
|
||||
"updated": 1615366547425
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
@@ -26,19 +47,11 @@
|
||||
},
|
||||
{
|
||||
"style": "Title",
|
||||
"text": "Set-up the Webhooks Sensor Bot Tasks"
|
||||
"text": "Set-up the Client for Webhooks"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "The Masters data mine features the definition of the Webhooks sensor bot used to monitor incoming notifications. You need to run an instance of this bot in the data mining section of the exchange and market of your choice."
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "The default workspace does not feature these tasks. To create a task for the Webhooks sensor bot, you need to uninstall and re-install the corresponding market."
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "Once the Webhooks sensor task is set up and running, you are all set at the application level. It’s that simple."
|
||||
"text": "There is nothing to configure in order for the Client to receive webhooks calls from external systems. The only thing you might need to do is to change the http interface port number at the Environment.js file if and only if your signals provider has any constraints regarding the port number it can send the notifications to."
|
||||
},
|
||||
{
|
||||
"style": "Title",
|
||||
@@ -54,21 +67,143 @@
|
||||
},
|
||||
{
|
||||
"style": "Json",
|
||||
"text": "{\n\"webhookURL\": \"Webhook/New-Message/Trading-View/Binance/BTC-USDT\",\n\"testMessage\": \"\"\n}",
|
||||
"updated": 1611486196742
|
||||
"text": "{\n\"webhookURL\": \"Webhook/New-Message/Trading-View/binance/BTC-USDT\",\n\"testMessage\": \"\"\n}",
|
||||
"updated": 1615370606690
|
||||
},
|
||||
{
|
||||
"style": "List",
|
||||
"text": "webhookURL: This is the URL you need to use for testing purposes. Make sure you refer to the correct exchange and market."
|
||||
"text": "webhookURL: This is the URL you need to use for testing purposes. Make sure you refer to the correct exchange and market. Something very similar to this, you will configure later at Trading View or other Signal Provider. ",
|
||||
"updated": 1615368679683
|
||||
},
|
||||
{
|
||||
"style": "List",
|
||||
"text": "testMessage: Enter any message, for testing purposes."
|
||||
"text": "testMessage: Enter any message, for testing purposes. This message will be what you will use at your Trading System conditions to know which type of signal you received. ",
|
||||
"updated": 1615368846219
|
||||
},
|
||||
{
|
||||
"style": "Subtitle",
|
||||
"text": "testMessage Examples"
|
||||
},
|
||||
{
|
||||
"style": "Javascript",
|
||||
"text": "BUY"
|
||||
},
|
||||
{
|
||||
"style": "Javascript",
|
||||
"text": "SELL"
|
||||
},
|
||||
{
|
||||
"style": "Javascript",
|
||||
"text": "TRIGGER ON"
|
||||
},
|
||||
{
|
||||
"style": "Javascript",
|
||||
"text": "TRIGGER OFF"
|
||||
},
|
||||
{
|
||||
"style": "Javascript",
|
||||
"text": "TAKE POSITION"
|
||||
},
|
||||
{
|
||||
"style": "Subtitle",
|
||||
"text": "Send the Test Message to the Client",
|
||||
"updated": 1615368890166
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "Once the test message is configured, select Send Test Message on the menu."
|
||||
},
|
||||
{
|
||||
"style": "Success",
|
||||
"text": "By doing this, you are simulating being Trading View's server and sending the message in the exact same way they would do it, to the Superalgos Client you are running. "
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "The Client does not know you are sending a Test Message, and it does not know it is you and not the real Trading View. For the Client's point of view someone sent a Webhook message to it and it will do with it what it will do with any other message of this type. Store it in-memory waiting for the Webhook Sensor Bot to fetch the pending messages, in which case the Client will delete them upon delivery to the Sensor Bot.",
|
||||
"updated": 1615369237281
|
||||
},
|
||||
{
|
||||
"style": "Note",
|
||||
"text": "At the Signals Provider node you will see a message of failure or success depending if the message was succesfuly delivered to the Client or not."
|
||||
},
|
||||
{
|
||||
"style": "Note",
|
||||
"text": "At the Client 's console, you will see 3 lines of logs, aknolidging that the message was received or if something was wrong, an error message with the cause."
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "The success logs looks like this:"
|
||||
},
|
||||
{
|
||||
"style": "Javascript",
|
||||
"text": "[INFO] httpInterface -> Webhook -> New-Message -> Exchange-Market = binance-BTC-USDT\n[INFO] httpInterface -> Webhook -> New-Message -> messageReceived = Sell\n[INFO] httpInterface -> Webhook -> New-Message -> Messeges waiting to be Ferched by Webhooks Sensor Bot = 1",
|
||||
"updated": 1615370618823
|
||||
},
|
||||
{
|
||||
"style": "Title",
|
||||
"text": "Set-up the Webhooks Sensor Bot Tasks",
|
||||
"updated": 1615370044893
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "The Masters Data Mine features the definition of the Webhooks sensor bot used to monitor incoming notifications. You need to run an instance of this bot in the data mining section of the exchange and market of your choice.",
|
||||
"updated": 1615370092995
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "The default workspace does not feature these tasks. To create a task for the Webhooks sensor bot, you need to uninstall and re-install the corresponding market."
|
||||
},
|
||||
{
|
||||
"style": "Success",
|
||||
"text": "Once the Webhooks sensor task is set up, you are all set at the application level. It’s that simple.",
|
||||
"updated": 1615370160742
|
||||
},
|
||||
{
|
||||
"style": "Title",
|
||||
"text": "Running the Webhooks Sensor Bot"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "Now that you have verified that the Client is receiving the signal messages and storing them for you, the next thing to do is to run the Webhooks Sensor Bot so that it fetches the signals from the Client and saves them on disk in the format that later can be consumed from strategies.",
|
||||
"updated": 1615369878800
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "By default, this bot will run every 30 seconds. Each time it runs you will see logs entries at the Client 's console similar to this:"
|
||||
},
|
||||
{
|
||||
"style": "Javascript",
|
||||
"text": "2021-03-10T09:57:40.111Z Binance BTC/USDT Masters Webhooks Check-Webhook Main Loop # 3\n[INFO] httpInterface -> Webhook -> Fetch-Messages -> Exchange-Market = binance-BTC-USDT\n[INFO] httpInterface -> Webhook -> Fetch-Messages -> Messeges Fetched by Webhooks Sensor Bot = 0",
|
||||
"updated": 1615370294905
|
||||
},
|
||||
{
|
||||
"style": "Title",
|
||||
"text": "Send Test Messages while Sensor Bot is Running",
|
||||
"updated": 1615371461320
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "Now that you know how to send test messages, try doing that while the Sensor Bot is running. By looking at the Client 's console you will be able to see what is going on:",
|
||||
"updated": 1615370466427
|
||||
},
|
||||
{
|
||||
"style": "List",
|
||||
"text": "The Client accumulates the signas received.",
|
||||
"updated": 1615370477786
|
||||
},
|
||||
{
|
||||
"style": "List",
|
||||
"text": "The Sensor Bot fetches all the accumulated signals every time it runs."
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "In the example below I sent 3 signal messages from the UI to the Client, and then the Sensor Bot fetch them all."
|
||||
},
|
||||
{
|
||||
"style": "Javascript",
|
||||
"text": "[INFO] httpInterface -> Webhook -> New-Message -> Exchange-Market = binance-BTC-USDT\n[INFO] httpInterface -> Webhook -> New-Message -> messageReceived = Sell\n[INFO] httpInterface -> Webhook -> New-Message -> Messeges waiting to be Fetched by Webhooks Sensor Bot = 1\n[INFO] httpInterface -> Webhook -> New-Message -> Exchange-Market = binance-BTC-USDT\n[INFO] httpInterface -> Webhook -> New-Message -> messageReceived = Sell\n[INFO] httpInterface -> Webhook -> New-Message -> Messeges waiting to be Fetched by Webhooks Sensor Bot = 2\n[INFO] httpInterface -> Webhook -> New-Message -> Exchange-Market = binance-BTC-USDT\n[INFO] httpInterface -> Webhook -> New-Message -> messageReceived = Sell\n[INFO] httpInterface -> Webhook -> New-Message -> Messeges waiting to be Fetched by Webhooks Sensor Bot = 3\n2021-03-10T10:04:40.472Z Binance BTC/USDT Masters Webhooks Check-Webhook Main Loop # 17\n[INFO] httpInterface -> Webhook -> Fetch-Messages -> Exchange-Market = binance-BTC-USDT\n[INFO] httpInterface -> Webhook -> Fetch-Messages -> Messeges Fetched by Webhooks Sensor Bot = 3",
|
||||
"updated": 1615370778562
|
||||
},
|
||||
{
|
||||
"style": "Title",
|
||||
"text": "Webhooks Sensor Bot Output"
|
||||
@@ -80,8 +215,18 @@
|
||||
},
|
||||
{
|
||||
"style": "Json",
|
||||
"text": "\\Data-Storage\\Exchange\\Market\\Masters\\Webhooks\\Output\\External-Signals\\Single-File\\",
|
||||
"updated": 1611486278677
|
||||
"text": " Data-Storage\\Project\\Superalgos\\Data-Mine\\Masters\\Webhooks\\Exchange-Id\\Market\\Output\\External-Signals\\Single-File\n",
|
||||
"updated": 1615371100856
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "Based on our tests, the location you would find the file would be:",
|
||||
"updated": 1615371008258
|
||||
},
|
||||
{
|
||||
"style": "Json",
|
||||
"text": "Data-Storage\\Project\\Superalgos\\Data-Mine\\Masters\\Webhooks\\binance\\BTC-USDT\\Output\\External-Signals\\Single-File",
|
||||
"updated": 1615371017985
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
@@ -94,11 +239,13 @@
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "This is what the file may look like, assuming you sent four different test messages:"
|
||||
"text": "This is what the file may look like after the 3 test messages we sent:",
|
||||
"updated": 1615370943470
|
||||
},
|
||||
{
|
||||
"style": "Json",
|
||||
"text": "[[1587998459260,\"Trading-View\",\"Sell\"],[1587998475409,\"Trading-View\",\"Buy\"],[1587998530190,\"Trading-View\",\"A custom signal I just configured\"],[1588000300940,\"Trading-View\",\"This is my new message\"]]"
|
||||
"text": "[[1615370665064,\"Trading-View\",\"Sell\"],[1615370665655,\"Trading-View\",\"Sell\"],[1615370666472,\"Trading-View\",\"Sell\"]]\n",
|
||||
"updated": 1615370924302
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
@@ -106,15 +253,18 @@
|
||||
},
|
||||
{
|
||||
"style": "List",
|
||||
"text": "timestamp: the Unix datetime of the message."
|
||||
"text": "timestamp: the Unix datetime of the message. This is the moment in time the Client received the signal from the external Signals provider.",
|
||||
"updated": 1615371169447
|
||||
},
|
||||
{
|
||||
"style": "List",
|
||||
"text": "source: the name of the signal provider."
|
||||
"text": "source: the name of the Signal Provider. This comes as part of the message sent by the provider, because is part of the URL you will specify later at the Signal Provider's system. In our example we used Trading View, but in fact it could be any other provider. You will have this property available at your Trading System, meaning that you will be able to write conditions that distingish the signal by Signal Provider.",
|
||||
"updated": 1615371322994
|
||||
},
|
||||
{
|
||||
"style": "List",
|
||||
"text": "message: the message set up at the provider’s system."
|
||||
"text": "message: the message set up at the provider’s system (BUY, SELL, etc.).",
|
||||
"updated": 1615371373274
|
||||
},
|
||||
{
|
||||
"style": "Title",
|
||||
@@ -142,7 +292,8 @@
|
||||
},
|
||||
{
|
||||
"style": "Javascript",
|
||||
"text": "chart.atAnyTimeFrame.externalSignal.source === \"Trading-View\" && chart.atAnyTimeFrame.externalSignal.message === \"Buy\""
|
||||
"text": "chart.atAnyTimeFrame.externalSignal.source === \"Trading-View\" && \nchart.atAnyTimeFrame.externalSignal.message === \"BUY\"",
|
||||
"updated": 1615371544991
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
@@ -150,7 +301,8 @@
|
||||
},
|
||||
{
|
||||
"style": "Javascript",
|
||||
"text": "chart.atAnyTimeFrame.externalSignal.previous.message === \"Buy\""
|
||||
"text": "chart.atAnyTimeFrame.externalSignal.previous.message === \"BUY\"",
|
||||
"updated": 1615371536367
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
@@ -164,9 +316,31 @@
|
||||
"style": "Text",
|
||||
"text": "In the above example, the first parameter chart.atAnyTimeFrame.externalSignal is the signal object you wish to check, and the second parameter chart.at01hs.candle is any other object that is delimited in time. In this case, the condition validates true if the last message falls within the last 1-hour candle."
|
||||
},
|
||||
{
|
||||
"style": "Warning",
|
||||
"text": "The reason to make this validation is to avoid situations where the Webhook sensor bot was not running and it retrieved from the Client signals that are already old. If you do not check the age of the signal you might get into the situation where you are triggering a buy or sell based on old data."
|
||||
},
|
||||
{
|
||||
"style": "Title",
|
||||
"text": "Set-up Alerts/Messages at the Provider"
|
||||
"text": "Set-up your Firewall / Rounter to accept Incoming Connections"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "As you might have imagined, you will need to open a port at your rounter / firewall to accept incomming connections from the signal provider's servers (like Trading View for instance). This is what allows that server to connect to the server where the Client is running, enabling the Client to receive those signals."
|
||||
},
|
||||
{
|
||||
"style": "Important",
|
||||
"text": "How you configure your Rounter / Firewall is up to you, and it depends on your network setup. You will need to do your research for details on how to do it, because it depends on which rounter / firewall you are using. We suggest you to include on the rules of your Firewall / Rounter the domain name or IP address of the Signal provider, so that nobody else can connect to the Client's http interface, which has, beyond Webhooks other features you don't want to expose openly to the world without restrictions.",
|
||||
"updated": 1615368540044
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "What we can tell you regarding this, is that the Superalgos Client is running a very simple http server at the port configured at the Environment.js file."
|
||||
},
|
||||
{
|
||||
"style": "Title",
|
||||
"text": "Set-up Alerts / Messages at the Signals Provider",
|
||||
"updated": 1615368585310
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
@@ -182,15 +356,8 @@
|
||||
},
|
||||
{
|
||||
"style": "Json",
|
||||
"text": "http://182.45.73.1:34247/Webhook/New-Message/Trading-View/Binance/BTC-USDT"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "Set-up Your Network to Accept Incoming Connections"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "Needless to say, you need to configure your network / router / firewall to allow incoming webhook messages on the corresponding port."
|
||||
"text": "http://182.45.73.1:34247/Webhook/New-Message/Trading-View/binance/BTC-USDT",
|
||||
"updated": 1615371762205
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
|
||||
@@ -13,8 +13,10 @@ function newSuperalgosFunctionLibraryWebhookFunctions() {
|
||||
|
||||
function onResponse(err) {
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
node.payload.uiObject.setInfoMessage('Test Message sent to the Client.')
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
} else {
|
||||
node.payload.uiObject.resetErrorMessage('Could not send Test Message to the Client.')
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user