资源加载中... loading...

exchange.GetTrades

Get the {@struct/Trade Trade} structure array of the spot or contract corresponding to the currently set trading pair, contract code, i.e. the market transaction data.

The exchange.GetTrades() function returns an array of {@struct/Trade Trade} structures if the request for data succeeds, and it returns null values if the request for data fails. {@struct/Trade Trade}arrays, null values

exchange.GetTrades() exchange.GetTrades(symbol)

The parameter symbol is used to specify the specific trading pair and contract code corresponding to the requested {@struct/Trade Trade} array data. If this parameter is not passed, the latest transaction record data of the currently set trading pair and contract code will be requested by default. When calling the exchange.GetTrades(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 trading 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.GetTrades(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.GetTrades(symbol) function, exchange is the futures exchange object. If you need to request the order book data of 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 trades = exchange.GetTrades()
    /*
        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, trade is null. When accessing trade[0].Id, it will cause an error. Therefore, when testing this code, ensure that you can access the exchange interface.
    */
    Log("id:", trades[0].Id, "time:", trades[0].Time, "Price:", trades[0].Price, "Amount:", trades[0].Amount, "type:", trades[0].Type)
}
def main():
    trades = exchange.GetTrades()
    Log("id:", trades[0]["Id"], "time:", trades[0]["Time"], "Price:", trades[0]["Price"], "Amount:", trades[0]["Amount"], "type:", trades[0]["Type"])
void main() {
    auto trades = exchange.GetTrades();
    Log("id:", trades[0].Id, "time:", trades[0].Time, "Price:", trades[0].Price, "Amount:", trades[0].Amount, "type:", trades[0].Type);
}

Test the exchange.GetTrades() function:

function main() {
    // BTC's U-based perpetual contract
    var trades = exchange.GetTrades("BTC_USDT.swap")
    Log(trades)
}
def main():
    trades = exchange.GetTrades("BTC_USDT.swap")
    Log(trades)
void main() {
    auto trades = exchange.GetTrades("BTC_USDT.swap");
    Log(trades);
}

When the configured exchange object is a futures exchange object, use the symbol parameter to request market transaction record data for a specific symbol (futures symbol).

exchange.GetTrades() function to get the current trading pairs, the market’s transaction history (not their own) corresponding to contracts. Some exchanges do not support this function, and the specific data returned is how much of the range of transaction records depends on the exchange and needs to be handled according to the specific situation. The return data is an array, where each element of the chronological order and exchange.GetRecords () function returns the same order of data, that is, the last element of the array is the data closest to the current time. The exchange.GetTrades() function returns an empty array when using Simulate Tick backtesting in the backtesting system. The data returned by the exchange.GetTrades() function when using Real Tick backtesting in the backtesting system is the order flow snapshot data, i.e. the {@struct/Trade Trade} structure array. Exchanges that do not support the exchange.GetTrades() function:

Function Name Unsupported Spot Exchanges Unsupported Futures Exchanges
GetTrades Futures_BitMart / Futures_Bibox

{@fun/Market/exchange.GetTicker exchange.GetTicker}, {@fun/Market/exchange.GetDepth exchange.GetDepth}, {@fun/Market/exchange.GetRecords exchange.GetRecords}

exchange.GetDepth exchange.GetRecords