Get the {@struct/Depth Depth} structure of the spot or contract corresponding to the currently set trading pair, contract code, i.e. order book data.
The exchange.GetDepth()
function returns the {@struct/Depth Depth} structure if the request for data succeeds, and it returns null if the request for data fails.
{@struct/Depth Depth}, null value
exchange.GetDepth() exchange.GetDepth(symbol)
The parameter symbol
is used to specify the specific trading pair and contract code corresponding to the requested {@struct/Depth Depth} data. If this parameter is not passed, the order book data of the currently set trading pair and contract code will be requested by default. When calling the exchange.GetDepth(symbol)
function, exchange
is the spot exchange object. If you need to request to obtain the order book data with the denominated currency as USDT and the transaction currency as BTC, the parameter symbol
is: "BTC_USDT"
, and the format is the trading pair format defined by the FMZ platform. When calling the exchange.GetDepth(symbol)
function, exchange
is the futures exchange object. If you need to request the order book data of BTC’s U-standard perpetual contract, the parameter symbol
is: "BTC_USDT.swap"
, and the format is a combination of the trading pair and contract code defined by the FMZ platform, separated by the character “.”. When calling the exchange.GetDepth(symbol)
function, exchange
is the futures exchange object. If you need to request the order book data of the BTC’s U-standard option contract, the parameter symbol
is: "BTC_USDT.BTC-240108-40000-C"
(taking Binance Option BTC-240108-40000-C as an example), the format is the combination of the trading pair defined by the FMZ platform and the specific option contract code defined by the exchange, separated by the character “.”.
symbol
false
string
function main(){
var depth = exchange.GetDepth()
/*
The exchange interface may not be accessible due to network reasons (even if the docker program's device can open the exchange website, the API interface may not be accessible).
At this point, the depth is null, which will cause an error when accessing depth.Asks[1].Price, so make sure you can access the exchange interface when testing the code.
*/
var price = depth.Asks[1].Price
Log("Sell 2 price is:", price)
}
def main():
depth = exchange.GetDepth()
price = depth["Asks"][1]["Price"]
Log("Sell 2 price is:", price)
void main() {
auto depth = exchange.GetDepth();
auto price = depth.Asks[1].Price;
Log("Sell 2 price is:", price);
}
Test exchange.GetDepth()
function:
function main() {
// BTC U-based perpetual contract
var depth = exchange.GetDepth("BTC_USDT.swap")
Log(depth)
}
def main():
depth = exchange.GetDepth("BTC_USDT.swap")
Log(depth)
void main() {
auto depth = exchange.GetDepth("BTC_USDT.swap");
Log(depth);
}
When the configured exchange
object is a futures exchange object, use the symbol
parameter to request the order book data of a specific symbol (futures symbol).
In the backtesting system, the data for each grade returned by the exchange.GetDepth()
function when using the Simulate Tick backtesting are all simulated values. In the backtesting system, the data returned by the exchange.GetDepth()
function when using the Real Tick backtesting is a second level deep snapshot.
{@fun/Market/exchange.GetTicker exchange.GetTicker}, {@fun/Market/exchange.GetTrades exchange.GetTrades}, {@fun/Market/exchange.GetRecords exchange.GetRecords}
exchange.GetTicker exchange.GetTrades