Trade Smarter with Automation

Interactions

Learn how to interact with your bot.

Prompt

Your bot can request additional input when needed by using a "prompt" to send a notification and request for your input. Prompt inputs are similar to bot inputs in that each input results in a form field to provide a value. However, instead of becoming global $ variables, input values are passed to the prompt's script as properties on the $event object.

Example

1. A "Buy calls" button click script sends the $buycalls prompt:

$buycalls.send();
$done();

2. The $buycalls prompt has 3 inputs for you to provide values:


3. The $buycalls prompt has a script that runs when you reply:

$bot.open({
    type: 'call',
    symbol: $under.symbol,
    expiration: $event.expiration, // date input
    strike: $event.strike,         // number input
    maxDraw: $event.draw           // number input
});

$done();

Prompt defaults

If provided, the properties of the data object passed to $prompt.send(data) are copied to the $event object available in your script. If any those property names match the name of a prompt input, the value is used as the default value for the input.

For example, the button script used in step 1 above can be modified to provide default values:

$buycalls.send({
    expiration: 'next friday',
    strike: $$.ceil($under.last, 1)  // next OTM, $1 price increment
});
$done();

Prompt API

Properties

  • String

    The id of the prompt.

  • String

    The text for the prompt's submit button. Defaults to 'Submit'.

  • String

    The title text for the prompt screen. Defaults to 'Input requested'.

Functions

display(data)

Display data in the prompt screen.

Arguments
  • Object

    The values to display.

Usage

Each property becomes a label and value displayed at the top of the prompt screen. For example, the Earnings starter bot displays useful earnings information when prompting for a prediction:

var details = {
    When: $nextDate.value,
    'Historical beat %': $$($stats.eps.beatRate * 100, 2) + '%',
    Estimize: $estimize.value,
    Wallstreet: $wallstreet.value
};

$autoAsk.display(details).send();

send(data)

Sends the prompt and triggers a notification.

If provided, the properties of the data object are copied to the $event object available in your script. If any those property names match the name of a prompt input, the value is used as the default value for the input.


setListItems(listId, items)

Change the options for "List" input specified bylistId.

Arguments
  • String

    The id given to the list input in the builder.

  • Array

    An array containing objects that have 2 properties: id and text. id is returned when the item is selected and text is the value displayed in the list.

Usage

Before sending prompt:

var types = [{
    id: 'bullput',          // the "id" is returned when the item is selected
    text: 'Bull put spread' // the "text" is displayed in the list
},{
    id: 'bearcall',
    text: 'Bear call spread'
}];

$prompt.setListItems('opptype', types).send();

When the prompt is submitted, the selected value is available in the prompt script as a property of the $event object:

var opp = {
    type: $event.opptype,     // the value selected for the list
    ...
}