Type/to search
Built-in Functions
Global
Version
Sleep
IsVirtual
Mail
Mail_Go
SetErrorFilter
GetPid
GetLastError
GetCommand
GetMeta
Dial
HttpQuery
HttpQuery_Go
Encode
UnixNano
Unix
GetOS
MD5
DBExec
UUID
EventLoop
__Serve
_G
_D
_N
_C
_Cross
JSON.parse
JSON.stringify
SetChannelData
GetChannelData
Log
Market
Trade
Account
Futures
NetSettings
Threads
threading
Thread
getThread
mainThread
currentThread
Lock
Condition
Event
Dict
pending
Thread
ThreadLock
ThreadEvent
ThreadCondition
ThreadDict
Web3
TA
Talib
talib.CDL2CROWS
talib.CDL3BLACKCROWS
talib.CDL3INSIDE
talib.CDL3LINESTRIKE
talib.CDL3OUTSIDE
talib.CDL3STARSINSOUTH
talib.CDL3WHITESOLDIERS
talib.CDLABANDONEDBABY
talib.CDLADVANCEBLOCK
talib.CDLBELTHOLD
talib.CDLBREAKAWAY
talib.CDLCLOSINGMARUBOZU
talib.CDLCONCEALBABYSWALL
talib.CDLCOUNTERATTACK
talib.CDLDARKCLOUDCOVER
talib.CDLDOJI
talib.CDLDOJISTAR
talib.CDLDRAGONFLYDOJI
talib.CDLENGULFING
talib.CDLEVENINGDOJISTAR
talib.CDLEVENINGSTAR
talib.CDLGAPSIDESIDEWHITE
talib.CDLGRAVESTONEDOJI
talib.CDLHAMMER
talib.CDLHANGINGMAN
talib.CDLHARAMI
talib.CDLHARAMICROSS
talib.CDLHIGHWAVE
talib.CDLHIKKAKE
talib.CDLHIKKAKEMOD
talib.CDLHOMINGPIGEON
talib.CDLIDENTICAL3CROWS
talib.CDLINNECK
talib.CDLINVERTEDHAMMER
talib.CDLKICKING
talib.CDLKICKINGBYLENGTH
talib.CDLLADDERBOTTOM
talib.CDLLONGLEGGEDDOJI
talib.CDLLONGLINE
talib.CDLMARUBOZU
talib.CDLMATCHINGLOW
talib.CDLMATHOLD
talib.CDLMORNINGDOJISTAR
talib.CDLMORNINGSTAR
talib.CDLONNECK
talib.CDLPIERCING
talib.CDLRICKSHAWMAN
talib.CDLRISEFALL3METHODS
talib.CDLSEPARATINGLINES
talib.CDLSHOOTINGSTAR
talib.CDLSHORTLINE
talib.CDLSPINNINGTOP
talib.CDLSTALLEDPATTERN
talib.CDLSTICKSANDWICH
talib.CDLTAKURI
talib.CDLTASUKIGAP
talib.CDLTHRUSTING
talib.CDLTRISTAR
talib.CDLUNIQUE3RIVER
talib.CDLUPSIDEGAP2CROWS
talib.CDLXSIDEGAP3METHODS
talib.AD
talib.ADOSC
talib.OBV
talib.ACOS
talib.ASIN
talib.ATAN
talib.CEIL
talib.COS
talib.COSH
talib.EXP
talib.FLOOR
talib.LN
talib.LOG10
talib.SIN
talib.SINH
talib.SQRT
talib.TAN
talib.TANH
talib.MAX
talib.MAXINDEX
talib.MIN
talib.MININDEX
talib.MINMAX
talib.MINMAXINDEX
talib.SUM
talib.HT_DCPERIOD
talib.HT_DCPHASE
talib.HT_PHASOR
talib.HT_SINE
talib.HT_TRENDMODE
talib.ATR
talib.NATR
talib.TRANGE
talib.BBANDS
talib.DEMA
talib.EMA
talib.HT_TRENDLINE
talib.KAMA
talib.MA
talib.MAMA
talib.MIDPOINT
talib.MIDPRICE
talib.SAR
talib.SAREXT
talib.SMA
talib.T3
talib.TEMA
talib.TRIMA
talib.WMA
talib.LINEARREG
talib.LINEARREG_ANGLE
talib.LINEARREG_INTERCEPT
talib.LINEARREG_SLOPE
talib.STDDEV
talib.TSF
talib.VAR
talib.ADX
talib.ADXR
talib.APO
talib.AROON
talib.AROONOSC
talib.BOP
talib.CCI
talib.CMO
talib.DX
talib.MACD
talib.MACDEXT
talib.MACDFIX
talib.MFI
talib.MINUS_DI
talib.MINUS_DM
talib.MOM
talib.PLUS_DI
talib.PLUS_DM
talib.PPO
talib.ROC
talib.ROCP
talib.ROCR
talib.ROCR100
talib.RSI
talib.STOCH
talib.STOCHF
talib.STOCHRSI
talib.TRIX
talib.ULTOSC
talib.WILLR
talib.AVGPRICE
talib.MEDPRICE
talib.TYPPRICE
talib.WCLPRICE
OS
Structures
Built-in Variables

Get the Trade structure array for the currently set trading pair or contract code, i.e., the market transaction data for spot or futures.

exchange.GetTrades()
exchange.GetTrades(symbol)

Examples

  • Test the exchange.GetTrades() function:

    javascript
    function main(){ var trades = exchange.GetTrades() /* Due to network issues, the exchange API may be inaccessible (even if the host device can open the exchange website, the API interface may still be unreachable) In this case, trades will be null, and accessing trades[0].Id will cause an error. Therefore, when testing this code, please ensure the exchange API is accessible */ Log("id:", trades[0].Id, "time:", trades[0].Time, "Price:", trades[0].Price, "Amount:", trades[0].Amount, "type:", trades[0].Type) }
    python
    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"])
    c++
    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); }
  • When the configured exchange object is a futures exchange object, use the symbol parameter to request market trade data for a specific instrument (futures contract).

    javascript
    function main() { // BTC USDT-margined perpetual contract var trades = exchange.GetTrades("BTC_USDT.swap") Log(trades) }
    python
    def main(): trades = exchange.GetTrades("BTC_USDT.swap") Log(trades)
    c++
    void main() { auto trades = exchange.GetTrades("BTC_USDT.swap"); Log(trades); }

Returns

TypeDescription

Trade array / null

The exchange.GetTrades() function returns a Trade structure array when the data request is successful, and returns null when the data request fails.

Arguments

NameTypeRequiredDescription

symbol

string

No

The parameter symbol is used to specify the specific trading pair or contract code corresponding to the requested Trade array data. When this parameter is not passed, it defaults to requesting the recent transaction record data for the currently set trading pair or contract code.

When calling the exchange.GetTrades(symbol) function, if exchange is a spot exchange object and you need to request transaction data with USDT as the quote currency and BTC as the base currency, the parameter symbol would be: "BTC_USDT", formatted according to the FMZ platform's defined trading pair format.

When calling the exchange.GetTrades(symbol) function, if exchange is a futures exchange object and you need to request transaction data for BTC's USDT-margined perpetual contract, the parameter symbol would be: "BTC_USDT.swap", formatted as a combination of the FMZ platform's defined trading pair and contract code, separated by the character ".".

When calling the exchange.GetTrades(symbol) function, if exchange is a futures exchange object and you need to request transaction data for BTC's USDT-margined option contract, the parameter symbol would be: "BTC_USDT.BTC-240108-40000-C" (using Binance option BTC-240108-40000-C as an example), formatted as a combination of the FMZ platform's defined trading pair and the exchange's specific option contract code, separated by the character ".".

See Also

Remarks

The exchange.GetTrades() function retrieves the market trading history (not your own trades) for the current trading pair or contract. Some exchanges do not support this function, and the specific range of returned data varies by exchange and needs to be handled according to actual circumstances. The returned data is an array, where the time order of each element is consistent with the order of data returned by the exchange.GetRecords() function, meaning the last element of the array is the data closest to the current time.

In the backtesting system, when using simulated-level Tick backtesting, the exchange.GetTrades() function returns an empty array.

In the backtesting system, when using **real-level Tick** backtesting, the data returned by the exchange.GetTrades() function is order flow snapshot data, i.e., a Trade structure array.

Exchanges that do not support the exchange.GetTrades() function:

Function NameUnsupported Spot ExchangesUnsupported Futures Exchanges
GetTradesHyperliquidFutures_BitMart / Futures_Bibox / Futures_Hyperliquid / Futures_edgeX