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

The exchange.GetAccount() function is used to request exchange account information. The GetAccount() function is a member function of the exchange object exchange. The member functions (methods) of the exchange object are only related to exchange, which will not be repeated in subsequent documentation.

exchange.GetAccount()

Examples

Set trading pair and contract code, get current account information.

javascript
function main(){ // 切换交易对 exchange.IO("currency", "BTC_USDT") // 以OKX期货为例,设置合约为当周合约,当前交易对为BTC_USDT,所以当前合约为BTC的U本位当周合约 exchange.SetContractType("this_week") // 获取当前账户资产数据 var account = exchange.GetAccount() // USDT作为保证金的可用余额 Log(account.Balance) // USDT作为保证金的冻结金额 Log(account.FrozenBalance) // 当前资产权益 Log(account.Equity) // 当前资产作为保证金的所有持仓的未实现盈亏 Log(account.UPnL) }
python
def main(): exchange.IO("currency", "BTC_USDT") exchange.SetContractType("this_week") account = exchange.GetAccount() Log(account["Balance"]) Log(account["FrozenBalance"]) Log(account["Equity"]) Log(account["UPnL"])
c++
void main() { exchange.IO("currency", "BTC_USDT"); exchange.SetContractType("this_week"); auto account = exchange.GetAccount(); Log(account.Balance); Log(account.FrozenBalance); Log(account.Equity); Log(account.UPnL); }

Returns

TypeDescription

Account / null

Query account asset information. Returns Account structure on successful query, returns null on failed query.

See Also

Remarks

If the exchange object is set to a cryptocurrency futures contract exchange and switched to contracts using USDT as margin (for switching methods, please refer to exchange.SetCurrency, exchange.SetContractType functions), assets are margined in USDT and recorded in the Balance and FrozenBalance properties of the Account structure.

If the exchange object is set to a cryptocurrency futures contract exchange and switched to coin-margined contracts, assets are margined in coins and recorded in the Stocks and FrozenStocks properties of the Account structure.

When using Binance Futures unified account, when calling the exchange.GetAccount() function to request account information, the encapsulated data is the amount of all assets converted to **USD**, displayed in the Balance field of the Account structure. To calculate the converted amount of other assets, divide the USD converted amount by the index price (of the asset to be converted) and then divide by the collateral rate (of the asset to be converted).

The exchange.GetAssets function is used to request asset information from the exchange account.

exchange.GetAssets()

Examples

Get exchange account asset information, exchange.GetAssets() returns an array with Asset structure elements.

javascript
function main() { // exchange.SetCurrency("BTC_USDT") // 可以设置交易对 // exchange.SetContractType("swap") // 可以设置合约 var assets = exchange.GetAssets() Log(assets) }
python
def main(): # exchange.SetCurrency("BTC_USDT") # 可以设置交易对 # exchange.SetContractType("swap") # 可以设置合约 assets = exchange.GetAssets() Log(assets)
c++
void main() { // exchange.SetCurrency("BTC_USDT"); // 可以设置交易对 // exchange.SetContractType("swap"); // 可以设置合约 auto assets = exchange.GetAssets(); Log(assets); }

Returns

TypeDescription

Asset array / null

The exchange.GetAssets() function returns an array of Asset structures when the data request is successful, and returns null when the data request fails.

See Also

Remarks

The GetAssets() function of futures exchange objects returns margin asset information under the current trading pair (coin-margined, USDT-margined, USDC-margined, etc.).

The exchange.GetName() function is used to get the exchange name bound to the current exchange object.

exchange.GetName()

Examples

javascript
function main() { Log("Check if exchange object is Binance spot, result:", exchange.GetName() == "Binance") }
python
def main(): Log("Check if exchange object is Binance spot, result:", exchange.GetName() == "Binance")
c++
void main() { Log("Check if exchange object is Binance spot, result:", exchange.GetName() == "Binance"); }

Returns

TypeDescription

string

The exchange.GetName() function returns the exchange name defined by the FMZ Quant Trading Platform.

See Also

Remarks

The exchange.GetName() function is commonly used to identify exchange objects such as exchange or exchanges[1], exchanges[2] etc. in strategy code. Cryptocurrency futures contract exchange names have a fixed prefix Futures_.

The exchange.GetLabel() function is used to get the custom label set when configuring the exchange object.

exchange.GetLabel()

Examples

javascript
function main() { Log("exchange label:", exchange.GetLabel()) }
python
def main(): Log("exchange label:", exchange.GetLabel())
c++
void main() { Log("exchange label:", exchange.GetLabel()); }

Returns

TypeDescription

string

The exchange.GetLabel() function returns the custom label set when configuring the exchange object.

See Also

Remarks

Identify exchange objects such as exchange or exchanges[1], exchanges[2] etc. in the strategy code through the set labels.

The exchange.GetCurrency() function is used to get the currently set trading pair.

exchange.GetCurrency()

Examples

javascript
function main() { Log("Current trading pair:", exchange.GetCurrency()) }
python
def main(): Log("Current trading pair:", exchange.GetCurrency())
c++
void main() { Log("Current trading pair:", exchange.GetCurrency()); }

Returns

TypeDescription

string

The exchange.GetCurrency() function returns the trading pair set for the current exchange exchange object.

See Also

Remarks

The trading pair format is uniformly in uppercase, using underscore to separate baseCurrency and quoteCurrency, for example: BTC_USDT.

The exchange.SetCurrency() function is used to switch the current trading pair of the exchange object exchange.

exchange.SetCurrency(currency)

Examples

javascript
function main() { var ticker = exchange.GetTicker() Log(ticker) Log(exchange.GetAccount()) // Switch trading pair, note the changes in market data and account information after switching exchange.SetCurrency("LTC_USDT") Log("Switched to LTC_USDT") ticker = exchange.GetTicker() Log(ticker) Log(exchange.GetAccount()) }
python
def main(): ticker = exchange.GetTicker() Log(ticker) Log(exchange.GetAccount()) exchange.SetCurrency("LTC_USDT") Log("Switched to LTC_USDT") ticker = exchange.GetTicker() Log(ticker) Log(exchange.GetAccount())
c++
void main() { auto ticker = exchange.GetTicker(); Log(ticker); Log(exchange.GetAccount()); exchange.SetCurrency("LTC_USDT"); Log("Switched to LTC_USDT"); ticker = exchange.GetTicker(); Log(ticker); Log(exchange.GetAccount()); }

Arguments

NameTypeRequiredDescription

currency

string

Yes

The currency parameter is used to set the trading pair to switch to. The trading pair format is uniformly uppercase, using underscore to separate baseCurrency and quoteCurrency, for example: BTC_USDT.

See Also

Remarks

  1. Compatible with exchange.IO("currency", "BTC_USDT") switching method, refer to excahnge.IO.

  2. Supports switching trading pairs in the backtesting system. When switching trading pairs in the backtesting system, the quote currency name cannot be changed. For example: BTC_USDT can be switched to LTC_USDT, but cannot be switched to LTC_BTC.

  3. After switching to a trading pair that is not initially set on the backtesting page, the amount of the base currency is 0. For example: during backtesting, the initially set trading pair on the backtesting page is BTC_USDT, with 3 BTC and 10000 USDT. When immediately switching to LTC_USDT, after switching, the base currency amount is 0, meaning the LTC amount in the account is 0, and the switched trading pair shares the USDT amount, which remains 10000.

The exchange.GetQuoteCurrency() function is used to get the quote currency name of the current trading pair, i.e., quoteCurrency.

exchange.GetQuoteCurrency()

Examples

javascript
function main() { exchange.SetCurrency("BTC_USDT") Log("Quote currency for BTC_USDT:", exchange.GetQuoteCurrency()) // exchange.SetCurrency("ETH_BTC") // Log("Quote currency for ETH_BTC:", exchange.GetQuoteCurrency()) }
python
def main(): exchange.SetCurrency("BTC_USDT") Log("Quote currency for BTC_USDT:", exchange.GetQuoteCurrency()) # exchange.SetCurrency("ETH_BTC") # Log("Quote currency for ETH_BTC:", exchange.GetQuoteCurrency())
c++
void main() { exchange.SetCurrency("BTC_USDT"); Log("Quote currency for BTC_USDT:", exchange.GetQuoteCurrency()); // exchange.SetCurrency("ETH_BTC") // Log("Quote currency for ETH_BTC:", exchange.GetQuoteCurrency()) }

Returns

TypeDescription

string

The exchange.GetQuoteCurrency() function returns the quote currency name of the current trading pair.

See Also

Remarks

For example: if the current trading pair of the exchange exchange object is BTC_USDT, the exchange.GetQuoteCurrency() function returns USDT. If the current trading pair is ETH_BTC, the exchange.GetQuoteCurrency() function returns BTC.