TradePatio uses cookies to provide necessary site functionality and improve your experience. By using our website, you agree to our privacy policy.

Start Form

Start Form

Customizable form that the user fills out before running the script. Data from the form get into an object that can be obtained using the 'input' module.

An example form:

[
{
"label": "Pairs",
"prop": "orders",
"type": "array",
"items": [
{
"label": "Exchange",
"prop": "ex",
"type": "select",
"itemsFrom": "exchanges",
"required": true
},
{
"label": "Pair",
"prop": "pair",
"type": "select",
"itemsFrom": "unitPairsByExchange",
"lookup": ".ex",
"required": true
},
{
"label": "Quantity in first currency",
"prop": "quantity",
"type": "number",
"required": true
},
{
"label": "First step is buy?",
"prop": "isBuy",
"type": "checkbox",
"defValue": true
},
{
"label": "+- Price shift",
"prop": "shift",
"type": "number"
}
]
}
]

Every JSON object of FormSchemaModel in this array will become a variable in the "input" object.

 

FormSchemaModel :

"label" - label in the interface.

"prop" - variable name in the "input" object.

"type" - inout field type. Look at FieldType.

constants FieldType {

  • text - text. Returns string
  • textarea - multi-line text. Returns string
  • date - date and time picker. Returns string
  • number - number.  Returns number
  • color - color picker. Returns hex
  • checkbox - checkbox button. Returns boolean
  • select - selection from the suggested values. Returns string, if multiSelect - returns array of strings
  • object - Nested object with its own variables. Use "items" to specify the object fields. Returns Lua table
  • array - array of objects. The same type when specifying "items", or the different type when specifying "arrayItems".

}

"defValue" - default value.

"required" - whether this field is mandatory.

"items" - contains fields of similar objects lying in an array for the array type

"arrayItems" - contains different types of objects lying in an array for the array type. Represents an array of arrays FormSchemaModel[ ][ ]

"multiSelect" - boolean will allow you to select several values in the select type.

"customItems" - is used for the select type. Contains selection options. Example:

"customItems": [
{"label": "Ask less or equal then", "value": 0},
{"label": "Ask greater or equal then", "value": 1},
{"label": "Bid less or equal then", "value": 2},
{"label": "Bid greater or equal then", "value": 3}
]

"itemsFrom" - gets values for the select type from the API. See the ItemFrom constant.

"lookup" - for some "itemsFrom". A link to another field containing "itemsFrom" by its "prop" value.

An example of getting the name of an exchange and a pair on the selected exchange:

{
"label": "Exchange",
"prop": "
ex",
"type": "select",
"itemsFrom": "exchanges",
"required": true
},
{
"label": "Pair",
"prop": "pair",
"type": "select",
"itemsFrom": "unitPairsByExchange",
"lookup": "
ex",
"required": true
}

 

 

 

constants  ItemFrom {

  •   exchanges - contains a list of the names of all the exchanges.
  •   pairs - has a list of pairs on all the exchanges.
  •   UnitPairsByExchange - contains a list of the full names of pairss on a particular exchange. Requires lookup to the field containing the name of the exchange.
  • sourcePairsByExchangeSource - contains a list of short names of pairs on a particular exchange. You need to lookup to the field containing the name of the exchange.
  • pairsByExchanges - contains a list of the full names of pairs that match on the selected exchanges. Requires lookup to the field with the parameter "multiSelect": true containing the names of exchangers.

}