CCXT

lighter

lighter cryptocurrency exchange — CCXT unified API: methods, parameters and endpoints.

lighter

Kind: global class
Extends: Exchange

preLoadLighterLibrary

if the required credentials are available in options, it will pre-load the lighter Signer to avoid delaying sensitive calls like createOrder the first time they're executed

Kind: instance method of lighter
Returns: boolean - true if the signer was loaded, false otherwise

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.preLoadLighterLibrary (params?)

createOrder

create a trade order

Kind: instance method of lighter
Returns: object - an order structure

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to create an order in
typestringYes'market' or 'limit'
sidestringYes'buy' or 'sell'
amountfloatYeshow much of currency you want to trade in units of base currency
pricefloatNothe price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
paramsobjectNoextra parameters specific to the exchange API endpoint
params.timeInForcestringNo'GTT' or 'IOC', default is 'GTT'
params.clientOrderIdintNoclient order id, should be unique for each order, default is a random number
params.triggerPricestringNotrigger price for stop loss or take profit orders, in units of the quote currency
params.reduceOnlybooleanNowhether the order is reduce only, default false
params.nonceintNononce for the account
params.apiKeyIndexintNoapiKeyIndex
params.accountIndexintNoaccountIndex
params.orderExpiryintNoorderExpiry
lighter.createOrder (symbol, type, side, amount, price?, params?)

editOrder

cancels an order and places a new order

Kind: instance method of lighter
Returns: object - an order structure

ParamTypeRequiredDescription
idstringYesorder id
symbolstringYesunified symbol of the market to create an order in
typestringYes'market' or 'limit'
sidestringYes'buy' or 'sell'
amountfloatYeshow much of the currency you want to trade in units of the base currency
pricefloatNothe price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIndexstringNoaccount index
params.apiKeyIndexstringNoapi key index
lighter.editOrder (id, symbol, type, side, amount, price?, params?)

fetchStatus

the latest known information on the availability of the exchange API

Kind: instance method of lighter
Returns: object - a status structure

See: https://apidocs.lighter.xyz/reference/status

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.fetchStatus (params?)

fetchTime

fetches the current integer timestamp in milliseconds from the exchange server

Kind: instance method of lighter
Returns: int - the current integer timestamp in milliseconds from the exchange server

See: https://apidocs.lighter.xyz/reference/status

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.fetchTime (params?)

fetchMarkets

retrieves data on all markets for lighter

Kind: instance method of lighter
Returns: Array<object> - an array of objects representing market data

See: https://apidocs.lighter.xyz/reference/orderbookdetails

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.fetchMarkets (params?)

fetchCurrencies

fetches all available currencies on an exchange

Kind: instance method of lighter
Returns: object - an associative dictionary of currencies

See: https://apidocs.lighter.xyz/reference/assetdetails

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.fetchCurrencies (params?)

fetchOrderBook

fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data

Kind: instance method of lighter
Returns: object - A dictionary of order book structures indexed by market symbols

See: https://apidocs.lighter.xyz/reference/orderbookorders

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the order book for
limitintNothe maximum amount of order book entries to return
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.fetchOrderBook (symbol, limit?, params?)

fetchTicker

fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

Kind: instance method of lighter
Returns: object - a ticker structure

See: https://apidocs.lighter.xyz/reference/orderbookdetails

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.fetchTicker (symbol, params?)

fetchTickers

fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

Kind: instance method of lighter
Returns: object - a dictionary of ticker structures

See: https://apidocs.lighter.xyz/reference/orderbookdetails

ParamTypeRequiredDescription
symbolsArray<string>, undefinedYesunified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.fetchTickers (symbols, params?)

fetchOHLCV

fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

Kind: instance method of lighter
Returns: Array<Array<int>> - A list of candles ordered as timestamp, open, high, low, close, volume

See: https://apidocs.lighter.xyz/reference/candles

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch OHLCV data for
timeframestringYesthe length of time each candle represents
sinceintNotimestamp in ms of the earliest candle to fetch
limitintNothe maximum amount of candles to fetch
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNotimestamp in ms of the latest candle to fetch
lighter.fetchOHLCV (symbol, timeframe, since?, limit?, params?)

fetchFundingRates

fetch the current funding rate for multiple symbols

Kind: instance method of lighter
Returns: Array<object> - a list of funding rate structures

See: https://apidocs.lighter.xyz/reference/funding-rates

ParamTypeRequiredDescription
symbolsArray<string>Nolist of unified market symbols
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.fetchFundingRates (symbols?, params?)

fetchPosition

fetch data on an open position

Kind: instance method of lighter
Returns: object - a position structure

See: https://apidocs.lighter.xyz/reference/account-1

ParamTypeRequiredDescription
symbolstringYesunified market symbol of the market the position is held in
paramsobjectNoextra parameters specific to the exchange API endpoint
params.bystringNofetch balance by 'index' or 'l1_address', defaults to 'index'
params.valuestringNofetch balance value, account index or l1 address
lighter.fetchPosition (symbol, params?)

fetchPositions

fetch all open positions

Kind: instance method of lighter
Returns: Array<object> - a list of position structure

See: https://apidocs.lighter.xyz/reference/account-1

ParamTypeRequiredDescription
symbolsArray<string>Nolist of unified market symbols
paramsobjectNoextra parameters specific to the exchange API endpoint
params.bystringNofetch balance by 'index' or 'l1_address', defaults to 'index'
params.valuestringNofetch balance value, account index or l1 address
lighter.fetchPositions (symbols?, params?)

fetchAccounts

fetch all the accounts associated with a profile

Kind: instance method of lighter
Returns: object - a dictionary of account structures indexed by the account type

See: https://apidocs.lighter.xyz/reference/account-1

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
params.bystringNofetch balance by 'index' or 'l1_address', defaults to 'index'
params.valuestringNofetch balance value, account index or l1 address
lighter.fetchAccounts (params?)

fetchOpenOrders

fetch all unfilled currently open orders

Kind: instance method of lighter
Returns: Array<Order> - a list of order structures

See: https://apidocs.lighter.xyz/reference/accountactiveorders

ParamTypeRequiredDescription
symbolstringYesunified market symbol
sinceintNothe earliest time in ms to fetch open orders for
limitintNothe maximum number of open orders structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIndexstringNoaccount index
lighter.fetchOpenOrders (symbol, since?, limit?, params?)

fetchClosedOrders

fetch all unfilled currently closed orders

Kind: instance method of lighter
Returns: Array<Order> - a list of order structures

See: https://apidocs.lighter.xyz/reference/accountinactiveorders

ParamTypeRequiredDescription
symbolstringYesunified market symbol
sinceintNothe earliest time in ms to fetch open orders for
limitintNothe maximum number of open orders structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIndexstringNoaccount index
lighter.fetchClosedOrders (symbol, since?, limit?, params?)

transfer

transfer currency internally between wallets on the same account

Kind: instance method of lighter
Returns: object - a transfer structure

ParamTypeRequiredDescription
codestringYesunified currency code
amountfloatYesamount to transfer
fromAccountstringYesaccount to transfer from (spot, perp)
toAccountstringYesaccount to transfer to (spot, perp)
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIndexstringNoaccount index
params.toAccountIndexstringNoto account index, defaults to fromAccountIndex
params.apiKeyIndexstringNoapi key index
params.memostringNohex encoding memo
lighter.transfer (code, amount, fromAccount, toAccount, params?)

fetchTransfers

fetch a history of internal transfers made on an account

Kind: instance method of lighter
Returns: Array<object> - a list of transfer structures

See: https://apidocs.lighter.xyz/reference/transfer_history

ParamTypeRequiredDescription
codestringYesunified currency code of the currency transferred
sinceintNothe earliest time in ms to fetch transfers for
limitintNothe maximum number of transfers structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIndexstringNoaccount index
params.paginatebooleanNodefault false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the availble parameters
lighter.fetchTransfers (code, since?, limit?, params?)

fetchDeposits

fetch all deposits made to an account

Kind: instance method of lighter
Returns: Array<object> - a list of transaction structures

See: https://apidocs.lighter.xyz/reference/deposit_history

ParamTypeRequiredDescription
codestringNounified currency code
sinceintNothe earliest time in ms to fetch deposits for
limitintNothe maximum number of deposits structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIndexstringNoaccount index
params.addressstringNol1_address
params.paginatebooleanNodefault false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the availble parameters
lighter.fetchDeposits (code?, since?, limit?, params?)

fetchWithdrawals

fetch all withdrawals made from an account

Kind: instance method of lighter
Returns: Array<object> - a list of transaction structures

See: https://apidocs.lighter.xyz/reference/withdraw_history

ParamTypeRequiredDescription
codestringNounified currency code
sinceintNothe earliest time in ms to fetch withdrawals for
limitintNothe maximum number of withdrawals structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIndexstringNoaccount index
params.paginatebooleanNodefault false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the availble parameters
lighter.fetchWithdrawals (code?, since?, limit?, params?)

withdraw

make a withdrawal

Kind: instance method of lighter
Returns: object - a transaction structure

ParamTypeRequiredDescription
codestringYesunified currency code
amountfloatYesthe amount to withdraw
addressstringYesthe address to withdraw to
tagstringNo
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIndexstringNoaccount index
params.apiKeyIndexstringNoapi key index
params.routeTypeintNowallet type, 0: perp, 1: spot, default is 0
lighter.withdraw (code, amount, address, tag?, params?)

fetchMyTrades

fetch all trades made by the user

Kind: instance method of lighter
Returns: Array<object> - a list of trade structures

See: https://apidocs.lighter.xyz/reference/trades

ParamTypeRequiredDescription
symbolstringNounified market symbol
sinceintNothe earliest time in ms to fetch trades for
limitintNothe maximum number of trades structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIndexstringNoaccount index
params.paginatebooleanNodefault false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the availble parameters
params.untilintNotimestamp in ms of the latest trade to fetch
lighter.fetchMyTrades (symbol?, since?, limit?, params?)

setLeverage

set the level of leverage for a market

Kind: instance method of lighter
Returns: object - response from the exchange

ParamTypeRequiredDescription
leveragefloatYesthe rate of leverage
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIndexstringNoaccount index
params.apiKeyIndexstringNoapi key index
params.marginModestringNomargin mode, 'cross' or 'isolated'
lighter.setLeverage (leverage, symbol, params?)

setMarginMode

set margin mode to 'cross' or 'isolated'

Kind: instance method of lighter
Returns: object - response from the exchange

ParamTypeRequiredDescription
marginModestringYes'cross' or 'isolated'
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIndexstringNoaccount index
params.apiKeyIndexstringNoapi key index
params.leverageintNorequired leverage
lighter.setMarginMode (marginMode, symbol, params?)

cancelOrder

cancels an open order

Kind: instance method of lighter
Returns: object - an order structure

ParamTypeRequiredDescription
idstringYesorder id
symbolstringYesunified symbol of the market the order was made in
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIndexstringNoaccount index
params.apiKeyIndexstringNoapi key index
lighter.cancelOrder (id, symbol, params?)

cancelAllOrders

cancel all open orders

Kind: instance method of lighter
Returns: Array<object> - a list of order structures

ParamTypeRequiredDescription
symbolstringNounified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIndexstringNoaccount index
params.apiKeyIndexstringNoapi key index
lighter.cancelAllOrders (symbol?, params?)

cancelAllOrdersAfter

dead man's switch, cancel all orders after the given timeout

Kind: instance method of lighter
Returns: object - the api result

ParamTypeRequiredDescription
timeoutnumberYestime in milliseconds, 0 represents cancel the timer
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.cancelAllOrdersAfter (timeout, params?)

addMargin

add margin

Kind: instance method of lighter
Returns: object - a margin structure

ParamTypeRequiredDescription
symbolstringYesunified market symbol
amountfloatYesamount of margin to add
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.addMargin (symbol, amount, params?)

reduceMargin

remove margin from a position

Kind: instance method of lighter
Returns: object - a margin structure

ParamTypeRequiredDescription
symbolstringYesunified market symbol
amountfloatYesthe amount of margin to remove
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.reduceMargin (symbol, amount, params?)

setMargin

Either adds or reduces margin in an isolated position in order to set the margin to a specific value

Kind: instance method of lighter
Returns: object - A margin structure

ParamTypeRequiredDescription
symbolstringYesunified market symbol of the market to set margin in
amountfloatYesthe amount to set the margin to
paramsobjectNoparameters specific to the bingx api endpoint
params.accountIndexstringNoaccount index
params.apiKeyIndexstringNoapi key index
lighter.setMargin (symbol, amount, params?)

watchOrders

watches information on multiple orders made by the user

Kind: instance property of lighter
Returns: Array<object> - a list of order structures

See: https://apidocs.lighter.xyz/docs/websocket-reference#account-all-orders

ParamTypeRequiredDescription
symbolstringYesunified market symbol of the market orders were made in
sinceintNothe earliest time in ms to fetch orders for
limitintNothe maximum number of order structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.watchOrders (symbol, since?, limit?, params?)

watchOrderBook

watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data

Kind: instance method of lighter
Returns: object - A dictionary of order book structures indexed by market symbols

See: https://apidocs.lighter.xyz/docs/websocket-reference#order-book

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the order book for
limitintNothe maximum amount of order book entries to return
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.watchOrderBook (symbol, limit?, params?)

unWatchOrderBook

unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data

Kind: instance method of lighter
Returns: object - A dictionary of order book structures indexed by market symbols

See: https://apidocs.lighter.xyz/docs/websocket-reference#order-book

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.unWatchOrderBook (symbol, params?)

watchTicker

watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

Kind: instance method of lighter
Returns: object - a ticker structure

See: https://apidocs.lighter.xyz/docs/websocket-reference#market-stats

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.watchTicker (symbol, params?)

unWatchTicker

unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list

Kind: instance method of lighter
Returns: object - a ticker structure

See: https://apidocs.lighter.xyz/docs/websocket-reference#market-stats

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.unWatchTicker (symbol, params?)

watchTickers

watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list

Kind: instance method of lighter
Returns: object - a ticker structure

See: https://apidocs.lighter.xyz/docs/websocket-reference#market-stats

ParamTypeRequiredDescription
symbolsArray<string>Nounified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
params.channelstringNothe channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
lighter.watchTickers (symbols?, params?)

unWatchTickers

unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list

Kind: instance method of lighter
Returns: object - a ticker structure

See: https://apidocs.lighter.xyz/docs/websocket-reference#market-stats

ParamTypeRequiredDescription
symbolsArray<string>Nounified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.unWatchTickers (symbols?, params?)

watchMarkPrice

watches a mark price

Kind: instance method of lighter
Returns: object - a ticker structure

See: https://apidocs.lighter.xyz/docs/websocket-reference#market-stats

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.watchMarkPrice (symbol, params?)

watchMarkPrices

watches mark prices

Kind: instance method of lighter
Returns: object - a ticker structure

See: https://apidocs.lighter.xyz/docs/websocket-reference#market-stats

ParamTypeRequiredDescription
symbolsArray<string>Nounified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.watchMarkPrices (symbols?, params?)

unWatchMarkPrice

unWatches a mark price

Kind: instance method of lighter
Returns: object - a ticker structure

See: https://apidocs.lighter.xyz/docs/websocket-reference#market-stats

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.unWatchMarkPrice (symbol, params?)

unWatchMarkPrices

unWatches mark prices

Kind: instance method of lighter
Returns: object - a ticker structure

See: https://apidocs.lighter.xyz/docs/websocket-reference#market-stats

ParamTypeRequiredDescription
symbolsArray<string>Nounified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.unWatchMarkPrices (symbols?, params?)

watchTrades

get the list of most recent trades for a particular symbol

Kind: instance method of lighter
Returns: Array<object> - a list of trade structures

See: https://apidocs.lighter.xyz/docs/websocket-reference#trade

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch trades for
sinceintNotimestamp in ms of the earliest trade to fetch
limitintNothe maximum amount of trades to fetch
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.watchTrades (symbol, since?, limit?, params?)

unWatchTrades

unsubscribe from the trades channel

Kind: instance method of lighter
Returns: Array<object> - a list of trade structures

See: https://apidocs.lighter.xyz/docs/websocket-reference#trade

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch trades for
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.unWatchTrades (symbol, params?)

watchMyTrades

subscribe to recent trades of an account.

Kind: instance method of lighter
Returns: Array<object> - a list of trade structures

See: https://apidocs.lighter.xyz/docs/websocket-reference#account-all-trades

ParamTypeRequiredDescription
symbolstringNounified market symbol
sinceintNotimestamp in ms of the earliest trade to fetch
limitintNothe maximum amount of trades to fetch
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.watchMyTrades (symbol?, since?, limit?, params?)

unWatchMyTrades

unsubscribe from the account trades channel

Kind: instance method of lighter
Returns: Array<object> - a list of trade structures

See: https://apidocs.lighter.xyz/docs/websocket-reference#account-all-trades

ParamTypeRequiredDescription
symbolstringNounified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.unWatchMyTrades (symbol?, params?)

watchLiquidations

watch the public liquidations of a trading pair

Kind: instance method of lighter
Returns: Array<object> - a list of trade structures

See: https://apidocs.lighter.xyz/docs/websocket-reference#trade

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch trades for
sinceintNotimestamp in ms of the earliest trade to fetch
limitintNothe maximum amount of trades to fetch
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.watchLiquidations (symbol, since?, limit?, params?)

watchBalance

watch balance and get the amount of funds available for trading or funds locked in orders

Kind: instance method of lighter
Returns: object - a balance structure

See: https://apidocs.lighter.xyz/docs/websocket-reference#account-all-assets

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
params.typestringNo'spot' or 'swap', default is 'swap'
lighter.watchBalance (params?)

unWatchOrders

unWatches information on multiple orders made by the user

Kind: instance method of lighter
Returns: Array<object> - a list of order structures

See: https://apidocs.lighter.xyz/docs/websocket-reference#account-all-orders

ParamTypeRequiredDescription
symbolstringYesunified market symbol of the market orders were made in
paramsobjectNoextra parameters specific to the exchange API endpoint
lighter.unWatchOrders (symbol, params?)

On this page