Function getTotalCostClosed

  • Returns the cost basis in dollars of the position currently held (not closed). Correctly accounts for DCA entries between partial closes.

    Automatically detects backtest/live mode from execution context.

    Parameters

    • symbol: string

      Trading pair symbol

    Returns Promise<number>

    Promise - held cost basis in dollars

    import { getTotalCostClosed } from "backtest-kit";

    const heldCost = await getTotalCostClosed("BTCUSDT");
    console.log(`Holding $${heldCost} of position`);