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 the 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 the subsequent documentation.

exchange.GetAccount()

Examples

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

javascript
function main(){ // Switch the trading pair exchange.IO("currency", "BTC_USDT") // Taking OKX Futures as an example, set the contract to the current-week contract. The current trading pair is BTC_USDT, so the current contract is the USDT-margined current-week contract of BTC exchange.SetContractType("this_week") // Get the current account asset data var account = exchange.GetAccount() // Available balance with USDT as margin Log(account.Balance) // Frozen amount with USDT as margin Log(account.FrozenBalance) // Current asset equity Log(account.Equity) // Unrealized profit and loss of all positions with the current assets as margin 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"])
rust
fn main() { // Switch the trading pair exchange.IO(("currency", "BTC_USDT")).unwrap(); // Taking OKX Futures as an example, set the contract to the current-week contract. The current trading pair is BTC_USDT, so the current contract is the USDT-margined current-week contract of BTC exchange.SetContractType("this_week").unwrap(); // Get the current account asset data let account = exchange.GetAccount().unwrap(); // Available balance with USDT as margin Log!(account.Balance); // Frozen amount with USDT as margin Log!(account.FrozenBalance); // Current asset equity Log!(account.Equity); // Unrealized profit and loss of all positions with the current assets as margin 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 value

Queries the account asset information. Returns the Account structure when the query succeeds, and returns a null value when the query fails.

See Also

Remarks

If the exchange object is set to a cryptocurrency futures contract exchange and switched to a contract that uses USDT as margin (for the switching method, please refer to the exchange.SetCurrency and exchange.SetContractType functions), the assets are then denominated in USDT as margin 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 a coin-margined contract, the assets are then denominated in the coin as margin and recorded in the Stocks and FrozenStocks properties of the Account structure.

When using a Binance Futures unified account, calling the exchange.GetAccount() function to request account information returns encapsulated data where all assets are converted into their value in **USD**, displayed in the Balance field of the Account structure. If you need to calculate the converted value of other assets, you can divide the USD-converted amount by the index price (of the asset to be converted), and then divide by the collateral ratio (of the asset to be converted).

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

exchange.GetAssets()

Examples

Get the asset information of the exchange account. The exchange.GetAssets() function returns an array with Asset structures as elements.

javascript
function main() { // exchange.SetCurrency("BTC_USDT") // You can set the trading pair // exchange.SetContractType("swap") // You can set the contract var assets = exchange.GetAssets() Log(assets) }
python
def main(): # exchange.SetCurrency("BTC_USDT") # You can set the trading pair # exchange.SetContractType("swap") # You can set the contract assets = exchange.GetAssets() Log(assets)
rust
fn main() { // exchange.SetCurrency("BTC_USDT"); // You can set the trading pair // exchange.SetContractType("swap").unwrap(); // You can set the contract let assets = exchange.GetAssets().unwrap(); Log!(assets); }
c++
void main() { // exchange.SetCurrency("BTC_USDT"); // You can set the trading pair // exchange.SetContractType("swap"); // You can set the contract auto assets = exchange.GetAssets(); Log(assets); }

Returns

TypeDescription

Asset array / null value

The exchange.GetAssets() function returns a Asset structure array when the data request succeeds, and returns a null value when the data request fails.

See Also

Remarks

The GetAssets() function of a futures exchange object returns the margin assets under the current trading pair (coin-margined, USDT-margined, USDC-margined, etc.).

The exchange.GetName() function is used to get the name of the exchange 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")
rust
fn 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 typically used to identify the exchange or exchanges[1], exchanges[2], and other exchange objects in the strategy code. The name of a cryptocurrency futures contract exchange carries the fixed prefix Futures_.

The exchange.GetLabel() function is used to obtain 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())
rust
fn 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

By means of the label that was set, you can identify the exchange or exchanges[1], exchanges[2] and other exchange objects in the strategy code.

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())
rust
fn 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 on the current exchange exchange object.

See Also

Remarks

The trading pair format uniformly uses uppercase, with an underscore separating 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 the 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())
rust
fn main() { let ticker = exchange.GetTicker(None).unwrap(); Log!(ticker); Log!(exchange.GetAccount()); // Switch the trading pair, note the changes in market data and account information after switching exchange.SetCurrency("LTC_USDT"); Log!("Switched to LTC_USDT"); let ticker = exchange.GetTicker(None).unwrap(); 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 specify the trading pair to switch to. The trading pair format is uniformly uppercase, using an underscore to separate baseCurrency and quoteCurrency, for example: BTC_USDT.

See Also

Remarks

  1. Compatible with the exchange.IO("currency", "BTC_USDT") switching method, see excahnge.IO for details.

  2. Switching trading pairs is supported in the backtesting system, but when switching trading pairs in the backtesting system, the name of the quote currency 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 other than the one initially set on the backtesting page, the amount of the base currency is 0. For example: during backtesting, the trading pair initially set on the backtesting page is BTC_USDT, with 3 BTC and 10000 USDT. If you immediately switch to LTC_USDT at this point, the amount of the base currency after switching is 0, i.e., the amount of LTC in the account is 0; the amount of USDT is shared after switching, i.e., the amount remains 10000.

The exchange.GetQuoteCurrency() function is used to get the name of the quote currency 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())
rust
fn 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 name of the quote currency of the current trading pair.

See Also

Remarks

For example: when 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, then the exchange.GetQuoteCurrency() function returns BTC.