exchange.GetDepth
Gets the Depth structure, i.e. the order book data, of the spot or contract 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 reasons, the exchange interface may be inaccessible (even if the device where the docker program runs can open the exchange website, the API interface may still be unreachable) In this case depth is null, and accessing depth.Asks[1].Price will cause an error, so when testing this code make sure the exchange interface 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)rustfn main() { let depth = exchange.GetDepth(None).unwrap(); let 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 the order book data of a specified 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)rustfn main() { // BTC USDT-margined perpetual contract let depth = exchange.GetDepth("BTC_USDT.swap").unwrap(); 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 When calling the When calling the When calling the |
See Also
Remarks
In the backtesting system, when backtesting with Simulated-level Tick, all levels of the data returned by the exchange.GetDepth() function are simulated values.
In the backtesting system, when backtesting with Live-level Tick, the data returned by the exchange.GetDepth() function is a second-level depth snapshot.