Utilities for calculating take profit and stop loss price levels. Automatically inverts direction based on position type (long/short).

Constructors

Properties

Constructors

Properties

bracket: (
    dto: {
        currentPrice: number;
        percentStopLoss: number;
        percentTakeProfit: number;
        position: "long" | "short";
    },
) => {
    position: "long"
    | "short";
    priceStopLoss: number;
    priceTakeProfit: number;
}

Calculates levels for a bracket order with custom TP and SL.

Type declaration

    • (
          dto: {
              currentPrice: number;
              percentStopLoss: number;
              percentTakeProfit: number;
              position: "long" | "short";
          },
      ): {
          position: "long"
          | "short";
          priceStopLoss: number;
          priceTakeProfit: number;
      }
    • Parameters

      • dto: {
            currentPrice: number;
            percentStopLoss: number;
            percentTakeProfit: number;
            position: "long" | "short";
        }
        • currentPrice: number

          current asset price

        • percentStopLoss: number

          stop loss percentage from 0 to 100

        • percentTakeProfit: number

          take profit percentage from 0 to 100

        • position: "long" | "short"

          position type: "long" or "short"

      Returns { position: "long" | "short"; priceStopLoss: number; priceTakeProfit: number }

      priceTakeProfit and priceStopLoss in fiat

moonbag: (
    dto: {
        currentPrice: number;
        percentStopLoss: number;
        position: "long" | "short";
    },
) => {
    position: "long"
    | "short";
    priceStopLoss: number;
    priceTakeProfit: number;
}

Calculates levels for the "moonbag" strategy — fixed TP at 50% from the current price.

Type declaration

    • (
          dto: {
              currentPrice: number;
              percentStopLoss: number;
              position: "long" | "short";
          },
      ): {
          position: "long"
          | "short";
          priceStopLoss: number;
          priceTakeProfit: number;
      }
    • Parameters

      • dto: { currentPrice: number; percentStopLoss: number; position: "long" | "short" }
        • currentPrice: number

          current asset price

        • percentStopLoss: number

          stop loss percentage from 0 to 100

        • position: "long" | "short"

          position type: "long" or "short"

      Returns { position: "long" | "short"; priceStopLoss: number; priceTakeProfit: number }

      priceTakeProfit and priceStopLoss in fiat