Options
All
  • Public
  • Public/Protected
  • All
Menu

Module lib/profits

Index

Variables

documentation

documentation: { setFamilyStoploss: (data: STREAMING_TRADE_RECORD, trades: TRADE_RECORD[], tradeTransaction: Function) => Promise<void> } = ...

Public export to expose private methods for documentation

Type declaration

  • setFamilyStoploss: (data: STREAMING_TRADE_RECORD, trades: TRADE_RECORD[], tradeTransaction: Function) => Promise<void>
      • (data: STREAMING_TRADE_RECORD, trades: TRADE_RECORD[], tradeTransaction: Function): Promise<void>
      • Issue order stop-loss modification transactions for all orders in family

        Parameters

        • data: STREAMING_TRADE_RECORD
        • trades: TRADE_RECORD[]
        • tradeTransaction: Function

        Returns Promise<void>

testing

testing: { getLevel: (data: STREAMING_TRADE_RECORD) => number; getStopLoss: (data: STREAMING_TRADE_RECORD) => number; isBuyOrder: (cmd: number) => boolean } = ...

Public export to expose private methods for testing

Type declaration

  • getLevel: (data: STREAMING_TRADE_RECORD) => number
      • (data: STREAMING_TRADE_RECORD): number
      • Makes the initial take-profit a little less conservative

        The level in getStopLoss is the average of open & close unless we are closing TP1 in which case we make the break-even just slightly better than the entry price.

        note

        Technically, the stop loss should, except for TP1, be moved to the previous TP level, but since we don't have any meta-data about other orders when we close a TP, the current implementation just sets the SL to the average of the open & close prices.

        todo

        If somehow the bot misses the break-even from TP1. When we see the next take-profit, let's say TP2 it will set the SL to the entry price instead of where it should be (halfway between Open & TP2).

        Parameters

        • data: STREAMING_TRADE_RECORD

        Returns number

  • getStopLoss: (data: STREAMING_TRADE_RECORD) => number
      • (data: STREAMING_TRADE_RECORD): number
      • Parameters

        • data: STREAMING_TRADE_RECORD

        Returns number

  • isBuyOrder: (cmd: number) => boolean
      • (cmd: number): boolean
      • Determine if the given command is for buying (as opposed to selling)

        Parameters

        • cmd: number

        Returns boolean

Functions

checkProfits

  • checkProfits(data: STREAMING_TRADE_RECORD): Promise<void>
  • Set the family stop loss if our trade is closed due to take-profit

    Parameters

    • data: STREAMING_TRADE_RECORD

    Returns Promise<void>

Generated using TypeDoc