diff --git a/Projects/Superalgos/Schemas/Docs-Topics/trading-logic-002-syntax-overview.json b/Projects/Superalgos/Schemas/Docs-Topics/trading-logic-002-syntax-overview.json index 939d894c3..ba36f7f41 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/trading-logic-002-syntax-overview.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/trading-logic-002-syntax-overview.json @@ -33,6 +33,19 @@ "style": "Text", "text": "The above syntax returns the value of the property of the declared product at the latest closed candle. This is common throughout all available datasets." }, + { + "style": "Success", + "text": "Each Indicator Bot outputs one or more data products, each with a set of properties. Find the details of the products and properties available in the documentation of each indicator.", + "updated": 1610216390888 + }, + { + "style": "Text", + "text": "" + }, + { + "style": "Text", + "text": "" + }, { "style": "Title", "text": "Specifying the Time Frame" @@ -232,18 +245,22 @@ }, { "style": "Title", - "text": "Trading Engine Node Path", - "updated": 1610215613207 + "text": "JaveScript Code" }, { "style": "Text", - "text": "The trading engine is the data structure that keeps track of all the information processed by the trading bot. The information is made available to both human users through the Design Space and the Charting Space interfaces. But—most importantly—it is made available to trading systems through a similar syntax as the one described earlier.", - "updated": 1610215642822 + "text": "You may use any valid piece of JavaScript code for your conditions and formulas. The system imposses no contraints whatsoever. The code on conditions and formulas is run through the eval() function, as follows:", + "updated": 1610215780497 }, { - "style": "Note", - "text": "Learn more about the Trading Engine and Accessing Runtime Data.", - "updated": 1610215673351 + "style": "Javascript", + "text": "try {\n let code = node.code\n value = eval(code);\n addCodeToSnapshot(code)\n}", + "updated": 1610215800115 + }, + { + "style": "Success", + "text": "Remember that all conditions must evaluate to true or false and that formulas must evaluate to a number. If you are having issues with your code, learn how to debug a task.", + "updated": 1610215814504 } ] } \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/trading-logic-003-accessing-runtime-data.json b/Projects/Superalgos/Schemas/Docs-Topics/trading-logic-003-accessing-runtime-data.json new file mode 100644 index 000000000..3f0c52965 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/trading-logic-003-accessing-runtime-data.json @@ -0,0 +1,74 @@ +{ + "topic": "Trading Logic", + "pageNumber": "3", + "type": "Accessing Runtime Data", + "definition": { + "text": "The Trading Bot makes every piece of information processed available to Trading Systems in the data structure of the Trading Engine hierarchy.", + "updated": 1610216690404 + }, + "paragraphs": [ + { + "style": "Text", + "text": "To access the value of any of the nodes in the Trading Engine from within conditions and formulas, the syntax follows the ramifications of the data structure, exactly as seen in the visual representation of the hierarchy on the Design Space.", + "updated": 1610216724389 + }, + { + "style": "Text", + "text": "For example, let’s say you wish to access the value of the Begin node under Strategy Open Stage. The path to that node, as denoted by the structure of the hierachy below, is:", + "updated": 1610216746961 + }, + { + "style": "Javascript", + "text": "tradingEngine.current.strategyOpenStage.begin.value" + }, + { + "style": "Text", + "text": "If you wish to go one step lower and access the value of the Target Size under the Stage Quoted Asset, then the path is:", + "updated": 1610216775084 + }, + { + "style": "Javascript", + "text": "tradingEngine.current.strategyOpenStage.stageQuotedAsset.targetSize.value" + }, + { + "style": "Note", + "text": "As usual, make sure you follow the JavaScript camel case notation by which the first word is in lower case and the rest in uppercase.", + "updated": 1610216790819 + }, + { + "style": "Title", + "text": "Copy Node Path" + }, + { + "style": "Text", + "text": "For ease of use, you may copy the path of any node that holds a valid value directly from within the node’s menu. Simply use the Copy Node Path button." + }, + { + "style": "Title", + "text": "Formula Example" + }, + { + "style": "Text", + "text": "Let’s say you wish to set a take profit 3% above the initial target rate you defined in the open stage of your strategy." + }, + { + "style": "Text", + "text": "That value is stored in the Entry Target Rate node under the Current Position.", + "updated": 1610216903247 + }, + { + "style": "Text", + "text": "So, the formula for the take profit phase is:" + }, + { + "style": "Javascript", + "text": "tradingEngine.current.position.entryTargetRate.value * 1.03", + "updated": 1610216926922 + }, + { + "style": "Success", + "text": "All of this will become clear when you study the Trading Engine hierarchy!", + "updated": 1610216962576 + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/trading-logic-004-accessing-trading-system-definitions-and-session-parameters.json b/Projects/Superalgos/Schemas/Docs-Topics/trading-logic-004-accessing-trading-system-definitions-and-session-parameters.json new file mode 100644 index 000000000..d6557f4d9 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/trading-logic-004-accessing-trading-system-definitions-and-session-parameters.json @@ -0,0 +1,70 @@ +{ + "topic": "Trading Logic", + "pageNumber": "4", + "type": "Accessing Trading System Definitions and Session Parameters", + "definition": { + "text": "The Trading System may access it's own definitions as well as Session Parameters from any Formula or Condition.", + "updated": 1610217064031 + }, + "paragraphs": [ + { + "style": "Text", + "text": "Trading System definitions and Trading Session Parameters are accessible from within conditions and formulas, pretty much like conditions and formulas may access the values of indicators, or the Trading Engine hierarchy.", + "updated": 1610217113377 + }, + { + "style": "Note", + "text": "This is a technical feature mostly oriented to developers. Practical use cases are few for less technically oriented individuals.", + "updated": 1610217120684 + }, + { + "style": "Title", + "text": "Syntax" + }, + { + "style": "Text", + "text": "To access a trading system definition, follow the path given by the trading system structure. For example, to access a condition in the take position event, use:", + "updated": 1610217151294 + }, + { + "style": "Javascript", + "text": "tradingSystem.tradingStrategies[i].triggerStage.takePositionEvent.situations[n].conditions[m].code" + }, + { + "style": "Text", + "text": "To access a trading session parameter, use the syntax starting with sessionParameters followed by the name of the parameter, and the name of the specific parameter in the configuration. For example, to access the taker parameter in the fee structure, use:", + "updated": 1610217182677 + }, + { + "style": "Javascript", + "text": "sessionParameters.feeStructure.config.taker", + "updated": 1610217195909 + }, + { + "style": "Title", + "text": "Example" + }, + { + "style": "Text", + "text": "Such a feature may be useful, for instance, to include such definitions or parameters on Telegram accouncement messages, as in:" + }, + { + "style": "Javascript", + "text": "\"The condition with the following code: \" + \ntradingSystem.tradingStrategies[tradingEngine.current.strategy.index.value].triggerStage.takePositionEvent.situations[0].conditions[0].code +\n\" triggered the take position event.\"", + "updated": 1610217276846 + }, + { + "style": "Text", + "text": "Notice that...", + "updated": 1610217314692 + }, + { + "style": "Javascript", + "text": "[tradingEngine.current.strategy.index.value]" + }, + { + "style": "Text", + "text": "... corresponds to the syntax deriving from the trading engine hierarchy." + } + ] +} \ No newline at end of file