exchange.GetDepth
Get the Depth structure, i.e., order book data, for the spot or futures corresponding to the currently set trading pair and contract code.
exchange.GetDepth()
exchange.GetDepth(symbol)Examples
-
Test the
exchange.GetDepth()function:javascriptfunction main(){ var depth = exchange.GetDepth() /* Due to network issues, the exchange API may be inaccessible (even if the device hosting the bot can open the exchange website, the API interface may still be unreachable) In this case, depth will be null, and accessing depth.Asks[1].Price will cause an error, so when testing this code, ensure that the exchange API is accessible */ var price = depth.Asks[1].Price Log("Second ask price:", price) }pythondef main(): depth = exchange.GetDepth() price = depth["Asks"][1]["Price"] Log("Second ask price:", price)c++void main() { auto depth = exchange.GetDepth(); auto price = depth.Asks[1].Price; Log("Second ask price:", price); } -
When the configured
exchangeobject is a futures exchange object, use thesymbolparameter to request order book data for a specific instrument (futures instrument).javascriptfunction main() { // BTC USDT-margined perpetual contract var depth = exchange.GetDepth("BTC_USDT.swap") Log(depth) }pythondef main(): depth = exchange.GetDepth("BTC_USDT.swap") Log(depth)c++void main() { auto depth = exchange.GetDepth("BTC_USDT.swap"); Log(depth); }
Returns
| Type | Description |
| The |
Arguments
| Name | Type | Required | Description |
symbol | string | No | The parameter When calling the When calling the When calling the |
See Also
Remarks
In the backtesting system, when using Simulated Tick backtesting, the data returned by the exchange.GetDepth() function has simulated values for each level.
In the backtesting system, when using Real Tick backtesting, the data returned by the exchange.GetDepth() function is a second-level depth snapshot.