Mayson Monorepo Documentation
    Preparing search index...

    Class ExchangeAbstract

    Abstract base class for exchange implementations. All exchange connectors must extend this class.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    The name of the exchange

    testnet: boolean

    Whether the exchange is connected to testnet

    Methods

    • Initialize the exchange with credentials

      Parameters

      Returns void

    • Verify that the API credentials are valid

      Returns Promise<boolean>

      True if credentials are valid

    • Get account balances

      Parameters

      • Optionalasset: string

        Optional specific asset to get balance for

      Returns Promise<ExchangeBalance[]>

      Array of balances, or single balance if asset specified

    • Get current price for a trading pair

      Parameters

      • symbol: string

        The 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 (e.g., "ETHUSDT")

      • quantity: number

        Amount to buy (in base asset or quote asset depending on quantityIsQuote)

      • OptionalquantityIsQuote: boolean

        If true, quantity is in quote currency (e.g., USDT)

      Returns Promise<ExchangeOrder>

      The created order

    • Place a market sell order

      Parameters

      • symbol: string

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

      • quantity: number

        Amount to sell (in base asset)

      Returns Promise<ExchangeOrder>

      The created order

    • Place a limit buy order

      Parameters

      • symbol: string

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

      • quantity: number

        Amount to buy (in base asset)

      • price: number

        Limit price

      Returns Promise<ExchangeOrder>

      The created order

    • Place a limit sell order

      Parameters

      • symbol: string

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

      • quantity: number

        Amount to sell (in base asset)

      • price: number

        Limit price

      Returns Promise<ExchangeOrder>

      The created order

    • Place a stop loss order

      Parameters

      • symbol: string

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

      • quantity: number

        Amount to sell (in base asset)

      • stopPrice: number

        Price at which to trigger the stop loss

      • OptionallimitPrice: number

        Optional limit price (if not provided, uses stopPrice)

      Returns Promise<ExchangeOrder>

      The created order

    • Place a take profit order

      Parameters

      • symbol: string

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

      • quantity: number

        Amount to sell (in base asset)

      • price: number

        Price at which to take profit

      • OptionallimitPrice: number

        Optional limit price (if not provided, uses 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

    • 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