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

Module 'subject'

Module 'subject'

Contains functions for event subscriptions. The script that waits for the event exists in RAM and the callback functions have access to it. Each subscription is executed once. For a permanent subscription, use recursion. You can specify a subscription group when you subscribe. If the subscription group is 0, a new subscription group will be assigned to the subscription. Each subscription returns a subscription group. If one of the subscriptions in the group is running, the remaining subscriptions in the group are deleted.

Functions:

alarm_clock(time_in_seconds: number, callback: () => void) return: group_id: number(may throw an error)

Calls the function after the specified time.

  • time_in_seconds - time in seconds.
  • callback - callback function.
  • group_id - the id of the subscription group.

 

telegram(callback: ( msg: string, user_name: string, chat_id: number) => void) return: group_id: number

Calls the function when it receives a message in telegram.

  • callback callback  function  ( msg: string, user_name: string, chat_id: number )
    • msg  - the text of the message.
    • user_name  - the name of the sender of the message.
    • chat_id  - id of the chat in which the message was received.
  • group_id - the id of the subscription group.

 

market(type: PAIR_SUBSCRIBE_TYPE, ex: EX_ID, long_pair: string, price: number, callback: ( ex: EX_ID, long_pair: string, ab: AskBid) => void) return: group_id: number(may throw an error)

 Calls the function when the price reaches the specified value.

  • type  - subscription type. Look at the PAIR_SUBSCRIBE_TYPE
  • ex - exchange ID. Use EX_ID
  • long_pair  - full name of the pair.
  • price  - the price that a subscription awaits.
  • callback callback  function  ( ex: EX_ID, long_pair: string, ab: AskBid )
    • ex - exchange ID. Look at the EX_ID
    • long_pair  - full pair name.
    • ab - data on the DOM on the stock exchange. Look at the AskBid.
  • group_id - the id of the subscription group.

 

my_order(callback: ( order: Order ) => void) return: group_id: number

It will call the function when the order status changes on one of the exchanges.

  • callback callback  function  ( order: Order )
    • order - the data on the changed order. Look at the Order model.
  • group_id - the id of the subscription group.

 

balance(callback: ( ex: EX_ID ) => void) return: group_id: number

Calls the function when the balance changes on one of the exchanges.

  • callback callback  function  ( order: Order )
    • ex - ID of the exchange on which the balance changed. Look at the EX_ID
  • group_id - the id of the subscription group.

 

trade(callback: ( trade_order: TradeOrder, event_type: ORDER_TYPE_EVENT) => void) return: group_id: number

It will call the function when the order state changes on the trade bot.

  • callback -  callback function  ( trade_ order: TradeOrder , event_type: ORDER_TYPE_EVENT)
    • trade_order - the data on the changed order. See the TradeOrder model.
    • event_type  - the type of event that called the function. Look at the ORDER_TYPE_EVENT
  • group_id - the id of the subscription group.

 

trailing(callback: ( trailing_order: TrailingOrder, event_type: ORDER_TYPE_EVENT) => void) return: group_id: number

It will call the function when the order state changes on the trailing bot.

  • callback - callback function  ( trailing_ order:  TrailingOrder event_type:  ORDER_TYPE_EVENT)
    • trailing_order - the data on the changed order. See the TrailingOrder model.
    • event_type  - the type of event that called the function. See the ORDER_TYPE_EVENT
  • group_id - the id of the subscription group.