Skip to main content

Send Notifications to the Gunbot GUI

In Gunbot, custom strategies can send notifications directly to the graphical user interface (GUI). This feature enhances the monitoring of trading activities by providing real-time communication from your strategies to the GUI.

Info

GUI notifications are messages that appear directly within the Gunbot interface, offering immediate visual feedback or alerts from your custom trading logic.

How to Create Notifications​

To create notifications, you need to assign an array of notification objects to gb.data.pairLedger.notifications in your custom strategy code. Each object in the array represents a unique notification message.

Here's an example:

gb.data.pairLedger.notifications = [
{
text: 'Custom success notification',
variant: 'success', // Corresponds to a green notification
persist: true // Notification stays visible until manually dismissed by the user
},
{
text: 'Custom error notification',
variant: 'error', // Corresponds to a red notification
},
{
text: 'Custom info notification',
variant: 'info', // Corresponds to a blue notification
persist: false // Notification will auto-dismiss after a short period
},
{
text: `Multi-line notification:

This allows for more detailed information
to be spread over multiple lines of text.`,
variant: 'error',
persist: true,
}
];

Attributes of Notification Objects​

Each notification object can include the following attributes:

  • text (string, required): The message content to be displayed in the notification.
  • variant (string, optional): Determines the color and icon of the notification. Common values include:
    • 'success' (green)
    • 'error' (red)
    • 'warning' (yellow)
    • 'info' (blue)
    • If omitted, a default style is used.
  • persist (boolean, optional):
    • If true, the notification will remain visible in the GUI until the user manually dismisses it.
    • If false or omitted, the notification will automatically disappear after a short period.

Implementing Notifications in Custom Strategies​

Incorporate these notification objects into your custom strategy JavaScript code to facilitate real-time updates and alerts within the Gunbot GUI. For example, you might send a notification when a trade is executed, an error occurs, or a specific market condition is met.

Viewing Notifications in the GUI​

Notifications added to gb.data.pairLedger.notifications are automatically picked up and displayed by the Gunbot GUI. The GUI manages their lifecycle, including displaying them according to their variant and persist properties, and removing them once they are acknowledged by the user (if persist is true) or after they time out (if persist is false or not set).

Example of a GUI Notification

Example of a GUI notification appearing on the chart interface.