Mayson Monorepo Documentation
    Preparing search index...

    Class BinanceExchange

    Binance exchange implementation using the official binance npm package

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    name: "binance" = ...

    The name of the exchange

    testnet: false

    Whether the exchange is connected to testnet

    Methods

    • Format an asset to a trading symbol

      Parameters

      • asset: string

        The base asset (e.g., "ETH")

      • quoteAsset: string = "USDT"

        The quote asset (default: "USDT")

      Returns string

      Formatted symbol (e.g., "ETHUSDT")

    • Parse a symbol into base and quote assets

      Parameters

      • symbol: string

        The trading pair symbol

      Returns { base: string; quote: string }

      Object with base and quote assets

    • Verify that the API credentials are valid by fetching account info

      Returns Promise<boolean>

      True if credentials are valid

    • Get account balances

      Parameters

      • Optionalasset: string

        Optional specific asset to filter

      Returns Promise<ExchangeBalance[]>

      Array of balances

    • Get current price for a trading pair

      Parameters

      • symbol: string

        Trading pair symbol (e.g., "BTCUSDT")

      Returns Promise<ExchangePrice>

      Current price information

    • Get all available trading pairs

      Returns Promise<string[]>

      Array of trading pair symbols

    • Place a market buy order

      Parameters

      • symbol: string

        Trading pair symbol

      • quantity: number

        Amount to buy

      • quantityIsQuote: boolean = false

        If true, quantity is in quote currency

      Returns Promise<ExchangeOrder>

      The created order

    • Place a market sell order

      Parameters

      • symbol: string

        Trading pair symbol

      • quantity: number

        Amount to sell

      Returns Promise<ExchangeOrder>

      The created order

    • Place a limit buy order

      Parameters

      • symbol: string

        Trading pair symbol

      • quantity: number

        Amount to buy

      • price: number

        Limit price

      Returns Promise<ExchangeOrder>

      The created order

    • Place a limit sell order

      Parameters

      • symbol: string

        Trading pair symbol

      • quantity: number

        Amount to sell

      • price: number

        Limit price

      Returns Promise<ExchangeOrder>

      The created order

    • Place a stop loss order

      Parameters

      • symbol: string

        Trading pair symbol

      • quantity: number

        Amount to sell

      • stopPrice: number

        Stop trigger price

      • OptionallimitPrice: number

        Optional limit price

      Returns Promise<ExchangeOrder>

      The created order

    • Place a take profit order

      Parameters

      • symbol: string

        Trading pair symbol

      • quantity: number

        Amount to sell

      • price: number

        Take profit trigger price

      • OptionallimitPrice: number

        Optional limit price

      Returns Promise<ExchangeOrder>

      The created order

    • Cancel an existing order

      Parameters

      • orderId: string

        The order ID to cancel

      • symbol: string

        The trading pair symbol

      Returns Promise<boolean>

      True if cancellation was successful

    • Get order status

      Parameters

      • orderId: string

        The order ID to check

      • symbol: string

        The trading pair symbol

      Returns Promise<ExchangeOrder>

      The order details

    • Get open orders

      Parameters

      • Optionalsymbol: string

        Optional symbol to filter by

      Returns Promise<ExchangeOrder[]>

      Array of open orders