Strategy Structure
Strategies in JavaScript (including TypeScript), Python and Rust consist of a few functions with agreed names, which the docker calls at fixed points. MyLanguage, PINE, Blockly and Workflow strategies do not need to define them.
Lifecycle functions
| Function | Required | When it is called |
|---|---|---|
main() | Yes | The entry function and body of the strategy. When main() returns, the strategy has finished. |
init() | No | Called once before main(), for initialization. |
onexit() | No | Called when the strategy exits, for cleanup (cancel orders, close positions, save state, etc.). |
onerror(msg) | No | JavaScript only: called when main() ends with an uncaught exception; msg is the error message. When onerror() is called, onexit() is not. |
destroy() | No | JavaScript template libraries only: called when the strategy exits, after onexit() or onerror(); see Writing Strategies → Template Library. |
Which function runs on exit:
| Exit reason | JavaScript | Python | Rust |
|---|---|---|---|
main() returns normally | onexit() | onexit() | onexit() |
| Live trading stopped | onexit() | onexit() | onexit() |
Uncaught exception or panic | onerror(msg) | neither | onexit() |
Notes:
onexit()andonerror()may run for at most 5 minutes (the limit is sent by the server with each task; the default is 5 minutes) and are terminated when they exceed it.- In backtesting a strategy is usually an endless polling loop, so
main()does not return normally when the backtest ends; see Strategy Structure → onexit() for how to handle this. - When
main()of aJavaScriptstrategy returns, threads created withthreadingare terminated;setTimeoutcallbacks that have not fired yet run first, thenonexit()is called. JavaScriptandPythontemplate libraries can define their owninit(), which runs when the template is loaded, before the strategy'sinit().
Main loop and event-driven strategies
Most strategies run a loop in main(): each round fetches data, computes, places orders, then calls Sleep() to wait for the next round (see Strategy Structure → Main Loop). A strategy can also wait for market data, order updates and other events and handle them as they arrive (see Strategy Structure → Event-Driven). For a categorized list of all API functions see Strategy Structure → API Quick Reference.
init()
init() is the initialization function implemented by the user. When a strategy starts running, the init() function is automatically executed first to complete the initialization tasks designed within the strategy.
Examples
javascript
function main(){
Log("First line of code executed!", "#FF0000")
Log("Exiting!")
}
// Initialization function
function init(){
Log("Initializing!")
}
python
def main():
Log("First line of code executed!", "#FF0000")
Log("Exiting!")
def init():
Log("Initializing!")
rust
fn main() {
Log!("First line of code executed!", "#FF0000");
Log!("Exiting!");
}
// Initialization function
fn init() {
Log!("Initializing!");
}onexit()
onexit() is implemented by the user to clean up when the strategy exits; it is optional. It may run for at most 5 minutes and is terminated when it exceeds that. For when each language calls onexit(), see Writing Strategies → Strategy Structure.
Examples
-
Testing the
onexit()function:javascriptfunction main(){ Log("Starting, will stop after 5 seconds and execute cleanup function!") Sleep(1000 * 5) } // cleanup function function onexit(){ var beginTime = new Date().getTime() while(true){ var nowTime = new Date().getTime() Log("Program stop countdown..cleanup started, elapsed time:", (nowTime - beginTime) / 1000, "seconds!") Sleep(1000) } }pythonimport time def main(): Log("Starting, will stop after 5 seconds and execute cleanup function!") Sleep(1000 * 5) def onexit(): beginTime = time.time() * 1000 while True: ts = time.time() * 1000 Log("Program stop countdown..cleanup started, elapsed time:", (ts - beginTime) / 1000, "seconds!") Sleep(1000)rustfn main() { Log!("Starting, will stop after 5 seconds and execute cleanup function!"); Sleep(1000 * 5); } // cleanup function fn onexit() { let beginTime = Unix() * 1000; loop { let nowTime = Unix() * 1000; Log!("Program stop countdown..cleanup started, elapsed time:", (nowTime - beginTime) / 1000, "seconds!"); Sleep(1000); } } -
In the backtesting system a strategy is usually an endless polling loop, so
main()has not returned normally when the backtest data ends, andJavaScriptandPythonstrategies therefore do not runonexit(). In a backtest (IsVirtual()is true) you can catch the exception (EOF) thrown when the backtest ends so thatmain()returns andonexit()runs. InRustthe API calls returnErrwhen the backtest ends, so just leave the loop.javascriptfunction main() { if (exchange.GetName().startsWith("Futures_")) { Log("Exchange is futures") exchange.SetContractType("swap") } else { Log("Exchange is spot") } if (IsVirtual()) { try { onTick() } catch (e) { Log("error:", e) } } else { onTick() } } function onTick() { while (true) { var ticker = exchange.GetTicker() LogStatus(_D(), ticker ? ticker.Last : "--") Sleep(500) } } function onexit() { Log("Executing cleanup function") }pythondef main(): if exchange.GetName().startswith("Futures_"): Log("Exchange is futures") else: Log("Exchange is spot") if IsVirtual(): try: onTick() except Exception as e: Log(e) else: onTick() def onTick(): while True: ticker = exchange.GetTicker() LogStatus(_D(), ticker["Last"] if ticker else "--") Sleep(500) def onexit(): Log("Executing cleanup function")rustfn onTick() { loop { match exchange.GetTicker(None) { Ok(ticker) => LogStatus!(_D(None), ticker.Last), Err(e) => { // API calls return Err when the backtest ends; leaving the loop lets main return, which triggers onexit() Log!("error:", e); break; } } Sleep(500); } } fn main() { if exchange.GetName().starts_with("Futures_") { Log!("Exchange is futures"); let _ = exchange.SetContractType("swap"); } else { Log!("Exchange is spot"); } onTick(); } fn onexit() { Log!("Executing cleanup function"); }
onerror()
onerror(msg) is supported only by JavaScript (including TypeScript) strategies. It is called when main() ends with an uncaught exception; the argument msg is the error message. When onerror() is called, onexit() is not. It may run for at most 5 minutes and is terminated when it exceeds that. The backtesting system does not support this function.
Python and Rust strategies do not support onerror().
Examples
javascript
function main() {
var arr = []
Log(arr[6].Close) // deliberately raise an exception here
}
function onerror(msg) {
Log("Error:", msg)
}
python
# Not supported in Python
rust
// Not supported in RustMain Loop
A strategy usually runs a loop in main(): each round fetches market data, computes signals, places orders, then calls Sleep to wait for the next round. In backtesting Sleep() advances backtest time and controls the replay speed; in live trading it controls the polling interval and therefore how often the exchange API is called. A loop without Sleep() calls the exchange API as fast as it can and easily hits the exchange's rate limits. To limit the API call rate on the docker, see Advanced Topics → API Rate Limit Control.
Examples
-
Basic framework:
javascriptfunction onTick(){ // strategy logic goes here and is called repeatedly, e.g. print market data Log(exchange.GetTicker()) } function main(){ while(true){ onTick() // Sleep controls the polling frequency so the exchange API is not called too often Sleep(60000) } }pythondef onTick(): Log(exchange.GetTicker()) def main(): while True: onTick() Sleep(60000)rustfn onTick() { // strategy logic goes here and is called repeatedly, e.g. print market data Log!(exchange.GetTicker(None)); } fn main() { loop { onTick(); // Sleep controls the polling frequency so the exchange API is not called too often Sleep(60000); } } -
The simplest example: place a buy order at price 100 for amount 1 every second:
javascriptfunction onTick(){ // only an example: it quickly spends all funds on orders, do not run it live exchange.Buy(100, 1) } function main(){ while(true){ onTick() // the pause is in milliseconds; 1 second = 1000 milliseconds Sleep(1000) } }pythondef onTick(): exchange.Buy(100, 1) def main(): while True: onTick() Sleep(1000)rustfn onTick() { // only an example: it quickly spends all funds on orders, do not run it live let _ = exchange.Buy(100, 1); } fn main() { loop { onTick(); // the pause is in milliseconds; 1 second = 1000 milliseconds Sleep(1000); } } -
A strategy that acts on K-line updates (On Bar):
onTick()runs only when the time of the latest K-line changes:javascriptfunction onTick() { Log("K-line updated, new BAR generated") } function main() { var exName = exchange.GetName() if (exName.includes("Futures_")) { exchange.SetContractType("swap") } var lastTs = 0 while (true) { var r = _C(exchange.GetRecords) if (r.length > 0 && r[r.length - 1].Time != lastTs) { onTick() lastTs = r[r.length - 1].Time } Sleep(1000) } }pythondef onTick(): Log("K-line updated, new BAR generated") def main(): exName = exchange.GetName() if "Futures_" in exName: exchange.SetContractType("swap") lastTs = 0 while True: r = _C(exchange.GetRecords) if len(r) > 0 and r[-1]["Time"] != lastTs: onTick() lastTs = r[-1]["Time"] Sleep(1000)rustfn onTick() { Log!("K-line updated, new BAR generated"); } fn main() { let exName = exchange.GetName(); if exName.contains("Futures_") { let _ = exchange.SetContractType("swap"); } let mut lastTs = 0; loop { let r = _C!(exchange.GetRecords(None, None, None)); if r.len() > 0 && r[r.len() - 1].Time != lastTs { onTick(); lastTs = r[r.len() - 1].Time; } Sleep(1000); } }
Event-Driven
Besides polling at a fixed interval, a strategy can wait for events and handle them as they arrive, which avoids useless requests and reacts faster to market changes.
EventLoop
EventLoop waits for events such as the completion of concurrent tasks started with exchange.Go() or HttpQuery_Go(), readable data on a WebSocket connection, or thread messages; when one occurs it returns the event information and the strategy then reads the corresponding data. Events are recorded only from the first call of EventLoop(), so call EventLoop(-1) once before starting concurrent tasks:
javascript
function main() {
EventLoop(-1) // start recording events so none are missed
var r1 = exchange.Go("GetTicker")
var r2 = exchange.Go("GetDepth")
var ev = EventLoop(1000) // wait up to 1 second for either task to finish
Log("event:", ev)
Log("ticker:", r1.wait(), "depth:", r2.wait())
}
ctx.subscribe / ctx.poll
JavaScript and Rust strategies can also use the docker's event subscription interface: ctx.subscribe() subscribes to market data or order updates for an account and symbol and returns a stream ID; ctx.poll() takes the next event (optionally with a timeout), and the strategy handles it according to its kind. Python strategies do not support it.
javascript
function main() {
ctx.subscribe(0, "BTC_USDT", {channel: "ticker"}) // the first argument is the account's index in exchanges
ctx.subscribe(0, "", {channel: "orders"}) // order updates
while (true) {
const ev = ctx.poll([], 1000) // [] means all subscriptions; wait up to 1 second
if (!ev) {
continue
}
if (ev.kind === 1) {
Log("ticker:", ev.symbol, ev.bid, ev.ask, ev.last)
} else if (ev.kind === 16) {
Log("order:", ev.id, ev.state, ev.filledQty)
}
}
}
channelcan be"ticker","bbo","depth","trade","kline"(intervalis the period in seconds) or"orders".- Event
kind: 1 ticker, 3 depth (the event only signals that the order book changed; read the levels withctx.book(ev.ex, ev.symbol, n)), 4 trade, 5 K-line, 16 order update. - If market data subscriptions are not consumed in time, only the latest data is kept or the oldest is dropped; order updates are never dropped, so the strategy must keep calling
ctx.poll().
In Rust the calls are ctx::subscribe() and ctx::poll(); events are raw structures whose prices and quantities are fixed-point integers:
rust
fn main() {
let s = ctx::subscribe(0, "BTC_USDT", ctx::SubOpts::ticker()).unwrap();
loop {
match ctx::poll(&[s], Some(1000)) {
ctx::Polled::Event(ev) => Log!("event kind:", ev.kind),
ctx::Polled::Stopped => break,
_ => {}
}
}
}
API Quick Reference
Every function, structure and constant of the API reference, grouped by its category, with a one-line description; click a name for the full page. This page is generated from the reference by doc_tools/gen_api_index.py.
Built-in Functions
Global
| Name | Description |
|---|---|
Version | Returns the current system version number. |
IsVirtual | Used to determine whether the strategy's runtime environment is the backtesting system. |
GetOS | Retrieves the operating system information of the device hosting the bot. |
GetPid | Get the ID of the live trading process. |
GetMeta | Get the Meta value written when generating the strategy registration code. |
Sleep | The sleep function pauses program execution for a specified period of time. |
Unix | Get the second-level timestamp of the current moment. |
UnixNano | Get the nanosecond-level timestamp of the current moment. |
_D | Convert a millisecond-level timestamp or a Date object into a time string. |
GetCommand | Get the strategy's interactive command. |
GetLastError | Retrieves the most recent error message. |
SetErrorFilter | Filters error logs. |
_N | Format a floating-point number. |
_C | A retry function used for fault-tolerant handling of interface calls. |
_Cross | Returns the number of crossover periods between array arr1 and array arr2. |
JSON.parse | The JSON.parse function is a method of the ECMAScript standard built-in object JSON, used to decode (parse) a JSON string. |
JSON.stringify | The JSON.stringify function is a method of the ECMAScript standard built-in object JSON, used to convert JavaScript values to JSON strings. |
Encode | This function encodes data according to the parameters passed in. |
MD5 | Calculate the MD5 hash of the parameter data. |
UUID | Create a UUID. |
Log
| Name | Description |
|---|---|
Log | The Log() function is used to output logs. |
LogStatus | Outputs information to the status bar on the backtesting system or the live trading page. |
LogProfit | Records and prints the profit/loss value, and plots the equity curve based on the profit/loss value. |
LogProfitReset | Clear all profit logs and the profit chart. |
LogReset | Clear the logs. |
LogVacuum | Used to reclaim the storage space occupied by deleted data in SQLite after clearing logs with the LogReset() function. |
EnableLog | Enable or disable logging of order information. |
Chart | Custom chart plotting function. |
KLineChart | This function is used to perform custom drawing while a strategy is running, using a drawing approach similar to the Pine language. |
console.log | Used to output debug information in the "Debug Info" section of the live trading page. |
console.error | Used to output error messages in the "Debug Information" section of the live trading page. |
exchange.Log | The exchange.Log() function is used to output order placement and cancellation logs in the log column area. |
Market
| Name | Description |
|---|---|
exchange.GetTicker | Retrieves the Ticker structure (i.e., the market data) corresponding to the spot or contract of the currently configured trading pair and contract code. |
exchange.GetTickers | The exchange.GetTickers() function is used to retrieve aggregated market data from the exchange (an array of Ticker structures). |
exchange.GetDepth | Gets the Depth structure, i.e. |
exchange.GetTrades | Gets the Trade structure array of the spot or futures corresponding to the currently set trading pair and contract code, i.e. |
exchange.GetRecords | Get the Record structure array (i.e. |
exchange.GetMarkets | The exchange.GetMarkets() function is used to retrieve market information from the exchange. |
exchange.GetRawJSON | Get the raw content returned by the most recent rest request from the current exchange object (exchange, exchanges). |
exchange.SetData | The exchange.SetData() function is used to set the data loaded when the strategy is running. |
exchange.GetData | The exchange.GetData() function is used to retrieve data loaded by the exchange.SetData() function, or data provided by an external link. |
Trade
| Name | Description |
|---|---|
exchange.Buy | The exchange.Buy() function is used to place a buy order. |
exchange.Sell | The exchange.Sell() function is used to place a sell order. |
exchange.CreateOrder | exchange.CreateOrder() function is used to place orders. |
exchange.ModifyOrder | The exchange.ModifyOrder() function is used to modify an existing regular order, allowing you to modify the order's price and quantity. |
exchange.CancelOrder | The exchange.CancelOrder() function is used to cancel an order. |
exchange.GetOrder | The exchange.GetOrder() function is used to obtain order information. |
exchange.GetOrders | The exchange.GetOrders() function is used to obtain the current unfilled orders. |
exchange.GetHistoryOrders | exchange.GetHistoryOrders() function is used to retrieve the historical orders of the current trading pair or contract, and supports specifying a parti... |
exchange.CreateConditionOrder | The exchange.CreateConditionOrder() function is used to create a conditional order. |
exchange.ModifyConditionOrder | The exchange.ModifyConditionOrder() function is used to modify an existing conditional order, allowing modification of the order amount, trigger condit... |
exchange.CancelConditionOrder | exchange.CancelConditionOrder() function is used to cancel a conditional order. |
exchange.GetConditionOrder | The exchange.GetConditionOrder() function is used to retrieve information about a specified conditional order. |
exchange.GetConditionOrders | exchange.GetConditionOrders() function is used to obtain unfinished conditional orders (conditional orders that have not yet been triggered or canceled). |
exchange.GetHistoryConditionOrders | The exchange.GetHistoryConditionOrders() function is used to retrieve the historical conditional orders (including triggered, canceled, and expired con... |
Account
| Name | Description |
|---|---|
exchange.GetAccount | The exchange.GetAccount() function is used to request the exchange account information. |
exchange.GetAssets | The exchange.GetAssets function is used to request the asset information of the exchange account. |
Futures
| Name | Description |
|---|---|
exchange.SetContractType | The exchange.SetContractType() function is used to set the current contract code of the exchange exchange object. |
exchange.GetContractType | The exchange.GetContractType() function is used to get the contract code currently set for the exchange exchange object. |
exchange.SetDirection | The exchange.SetDirection() function is used to set the order direction when calling the exchange.Buy function or exchange.Sell function to place futur... |
exchange.SetMarginLevel | The exchange.SetMarginLevel() function is used to set the leverage value for the trading pair or contract specified by the symbol parameter. |
exchange.GetPositions | exchange.GetPositions() function is used to get position information; the GetPositions() function is a member function of the exchange object exc... |
exchange.GetFundings | The exchange.GetFundings() function is used to obtain the funding rate data for the current period. |
Exchange
| Name | Description |
|---|---|
exchange.GetName | The exchange.GetName() function is used to get the name of the exchange bound to the current exchange object. |
exchange.GetLabel | The exchange.GetLabel() function is used to obtain the custom label set when configuring the exchange object. |
exchange.GetCurrency | The exchange.GetCurrency() function is used to get the currently set trading pair. |
exchange.SetCurrency | The exchange.SetCurrency() function is used to switch the current trading pair of the exchange object exchange. |
exchange.GetQuoteCurrency | The exchange.GetQuoteCurrency() function is used to get the name of the quote currency of the current trading pair, i.e. |
exchange.GetPeriod | Retrieves the K-line period configured on the FMZ Quant Trading platform website page when running a strategy in backtesting or live trading, i.e., the defau... |
exchange.SetMaxBarLen | Set the maximum length of the K-line (candlestick chart). |
exchange.SetPrecision | The exchange.SetPrecision() function is used to set the precision of the price and order amount for the exchange exchange object. |
exchange.GetRate | Get the exchange rate currently set for the exchange object. |
exchange.SetRate | Sets the current exchange rate for the exchange object. |
exchange.SetBase | The exchange.SetBase() function is used to set the base URL of the exchange API interface used by the exchange exchange object. |
exchange.GetBase | The exchange.GetBase() function is used to get the base address of the current exchange API interface. |
exchange.SetProxy | The exchange.SetProxy() function is used to configure the proxy settings of the exchange exchange object. |
exchange.SetTimeout | The exchange.SetTimeout() function is used to set the timeout for rest requests of the exchange exchange object. |
exchange.Encode | The exchange.Encode() function is used to perform signature and encryption computations. |
IO
| Name | Description |
|---|---|
exchange.IO | exchange.IO() function is used to call other interfaces related to the exchange object. |
exchange.IO("api", ...) | exchange.IO("api", ...) calls a raw REST endpoint of the exchange that has no wrapper function; the platform signs the request. |
exchange.IO("currency", ...) | exchange.IO("currency", ...) switches the current trading pair of the exchange object at runtime. |
exchange.IO("base", ...) | exchange.IO("base", ...) switches the base address of the trading API, and exchange.IO("mbase", ...) that of the market data API. |
exchange.IO(mode, value) | exchange.IO(mode, value) switches trading modes of the exchange: simulated or live, cross or isolated margin, hedge or one-way positions, unified accou... |
exchange.IO("rate", ...) | exchange.IO("rate", ...) and exchange.IO("quota", ...) limit how often API functions are called. |
Network
| Name | Description |
|---|---|
HttpQuery | Sends an HTTP request. |
HttpQuery_Go | Sends an Http request. |
Dial | Used for raw Socket access, supporting the tcp, udp, tls, and unix protocols. |
Mail | Send an email. |
Mail_Go | Asynchronous version of the Mail function. |
Storage
| Name | Description |
|---|---|
_G | Persistently store data. |
DBExec | Database interface function. |
SetChannelData | Publishes the latest status data to a channel. |
GetChannelData | Subscribes to the channel data of a specified live trading bot. |
Threads
| Name | Description |
|---|---|
exchange.Go | Multi-threaded asynchronous support function that can convert the operations of all supported functions into asynchronous concurrent execution. |
EventLoop | Listens for events and returns when any WebSocket has readable data, or when concurrent tasks such as exchange.Go() or HttpQuery_Go() compl... |
Threads/threading
| Name | Description |
|---|---|
Thread | The Thread() function is used to create concurrent threads. |
getThread | The getThread() function is used to get a thread object based on the specified thread ID. |
mainThread | The mainThread() function is used to get the thread object of the main thread, which is the thread where the main() function in the strategy is l... |
currentThread | The currentThread() function is used to get the thread object of the current thread. |
Lock | The Lock() function is used to create a thread lock object. |
Condition | The Condition() function is used to create a condition variable object, which is used to implement synchronization and communication between threads in... |
Event | The Event() function is used to create a thread event object, which is used for synchronization between threads, allowing one thread to wait for noti... |
Dict | The Dict() function is used to create a dictionary object for passing and sharing data between concurrent threads. |
Serve | The Serve() function starts an HTTP, TCP or WebSocket (over HTTP) service inside the strategy process and returns a Server object. |
pending | The pending function is used to get the number of concurrent threads currently running in the strategy program. |
Threads/Thread
| Name | Description |
|---|---|
peekMessage | The peekMessage() function is used to receive messages from a thread. |
postMessage | The postMessage() function is used to send messages to a thread. |
join | The join() function is used to wait for a thread to exit and reclaim system resources. |
terminate | The terminate() function is used to forcibly terminate a thread and release the hardware resources occupied when the thread was created. |
getData | The getData() function is used to access variables recorded in the thread environment. |
setData | The setData() function is used to store variables in the thread environment. |
id | The id() function is used to return the threadId of the current multi-threaded object instance. |
name | The name() function is used to return the name of the current multi-threaded object instance. |
eventLoop | The eventLoop() function is used to listen for events received by the current thread. |
Threads/ThreadLock
| Name | Description |
|---|---|
acquire | The acquire() function is used to request a thread lock (acquire lock). |
release | The release() function is used to release a thread lock (unlock). |
Threads/ThreadEvent
| Name | Description |
|---|---|
set | The set() function is used to set an event signal. |
clear | The clear() function is used to clear the signal. |
wait | The wait() function is used to set event (signal) waiting, which will block until the event (signal) is set; supports setting timeout parameters. |
isSet | The isSet() function is used to determine whether an event (signal) has been set. |
Threads/ThreadCondition
| Name | Description |
|---|---|
notify | The notify() function is used to wake up one waiting thread (if any exists). |
notifyAll | The notifyAll() function is used to wake up all waiting threads. |
wait | The wait() function is used to put a thread into a waiting state under specific conditions. |
acquire | The acquire() function is used to request a thread lock (acquire lock). |
release | The release() function is used to release the thread lock (unlock). |
Threads/ThreadDict
| Name | Description |
|---|---|
get | The get() function is used to retrieve the value of a key recorded in a dictionary object. |
set | The set() function is used to set key-value pairs. |
Threads/Server
| Name | Description |
|---|---|
addr | The addr() function returns the address and port the service actually listens on. |
close | The close() function stops accepting new connections; handlers already running finish normally (graceful shutdown). |
stop | The stop() function closes the service (as close()) and then terminates every handler thread that is still running. |
join | The join() function waits until the service is closed and no handler is running. |
pending | The pending() function returns the number of handlers currently running, i.e. |
Web3
| Name | Description |
|---|---|
exchange.IO("abi", ...) | On the FMZ Quant Trading Platform, various blockchain-related functions and calls are mainly implemented through the exchange.IO() function. |
exchange.IO("api", blockChain, ...) | The exchange.IO("api", "eth", ...) calling method is used to call Ethereum RPC methods (select eth when configuring the Web3 exchange object). |
exchange.IO("encode", ...) | The exchange.IO("encode", ...) function is called in this way for data encoding. |
exchange.IO("encodePacked", ...) | The exchange.IO("encodePacked", ...) function is used to perform encodePacked encoding operations. |
exchange.IO("decode", ...) | The exchange.IO("decode", ...) calling method is used to decode data. |
exchange.IO("hash", ...) | The exchange.IO("hash", ...) call computes hash digests and HMACs, signs with the private key configured on the exchange object, and so on. |
exchange.IO("key", ...) | The exchange.IO("key", ...) function is used to switch the private key calling method. |
exchange.IO("sign", ...) | The exchange.IO("sign", ...) calling method is used to sign a 32-byte hash with a secp256k1 private key and returns signature data such as r, s, and v. |
exchange.IO("signTypedData", ...) | The exchange.IO("signTypedData", ...) calling method is used to sign structured data according to the EIP-712 standard. |
exchange.IO("signMessage", ...) | The exchange.IO("signMessage", ...) calling method is used to sign messages according to the EIP-191 standard (personal_sign). |
exchange.IO("api", ...) | The exchange.IO("api", ...) calling method is used to call methods of smart contracts. |
exchange.IO("call", ...) | The exchange.IO("call", ...) calling method simulates the execution of any smart contract method (including write methods that modify on-chain state) v... |
exchange.IO("multicall", ...) | The exchange.IO("multicall", ...) calling method is used to batch-read the results of multiple contract calls in a single request through the Multicall... |
exchange.IO("logs", ...) | The exchange.IO("logs", ...) calling method is used to query the event logs of a contract (eth_getLogs) and decode them according to the ABI. |
exchange.IO("waitReceipt", ...) | The exchange.IO("waitReceipt", ...) calling method is used to wait for a transaction to be included on-chain and reach the specified number of confirma... |
exchange.IO("nonce", ...) | The exchange.IO("nonce", ...) function call is used to query, synchronize, or set the nonce counter used when sending transactions. |
exchange.IO("speedUp", ...) | The exchange.IO("speedUp", ...) call is used to resend a stuck transaction (one that has not been mined for a long time) with a higher fee: the recipie... |
exchange.IO("cancelTx", ...) | The exchange.IO("cancelTx", ...) calling method is used to cancel a transaction that has not yet been included on-chain: it sends a zero-amount transac... |
exchange.IO("toUnits", ...) | The exchange.IO("toUnits", ...) function call is used to convert a human-readable amount into an on-chain integer. |
exchange.IO("fromUnits", ...) | The exchange.IO("fromUnits", ...) calling method is used to convert an on-chain integer value into a human-readable amount. |
exchange.IO("uniswapV3", ...) | The exchange.IO("uniswapV3", ...) calling method is used for concentrated liquidity (Uniswap V3) related calculations, including conversions between ti... |
exchange.IO("contracts", ...) | The exchange.IO("contracts", ...) call is used to obtain commonly used contract addresses on the current chain (or a specified chain), including mainst... |
exchange.IO("address") | The exchange.IO("address") call returns the address of the wallet configured on the exchange object. |
exchange.IO("base", ...) | The exchange.IO("base", ...) calling method is used to set the RPC node address, and supports setting multiple nodes as backups for each other. |
exchange.IO("sendBase", ...) | The exchange.IO("sendBase", ...) call is used to set a node dedicated solely to broadcasting transactions. |
Uniswap
| Name | Description |
|---|---|
exchange.IO("transfer", ...) | The exchange.IO("transfer", ...) call transfers the chain's native coin (such as ETH or BNB) or an ERC20 token out of the wallet configured on the Unis... |
exchange.IO("receipt", ...) | When called as exchange.IO("receipt", ...), this function queries the receipt of a transaction sent by the Uniswap exchange object (such as an order or... |
exchange.IO("route", ...) | The exchange.IO("route", ...) call requests quotes on a Uniswap exchange object. |
exchange.IO("simulate", ...) | The exchange.IO("simulate", ...) call builds a swap transaction using the same order logic as the Uniswap exchange object (route selection, quoting and... |
exchange.IO("token", ...) | The exchange.IO("token", ...) call is used to register a token on a Uniswap exchange object, or to list the token table. |
exchange.IO("wrap", ...) | The exchange.IO("wrap", ...) call wraps the native coin (ETH, BNB) into the wrapped coin (WETH, WBNB) on a Uniswap exchange object: 1:1, no slippage, o... |
exchange.IO("unwrap", ...) | The exchange.IO("unwrap", ...) call unwraps the wrapped coin (WETH, WBNB) into the native coin (ETH, BNB) on a Uniswap exchange object: 1:1, no slippag... |
exchange.IO("approve", ...) | When called as exchange.IO("approve", ...), this function sets the token approval mode on a Uniswap exchange object. |
exchange.IO("slippage", ...) | When called this way, exchange.IO("slippage", ...) sets slippage protection for market orders on a Uniswap exchange object. |
exchange.IO("deadline", ...) | The exchange.IO("deadline", ...) call sets the transaction deadline on a Uniswap exchange object. |
exchange.IO("gasMultiplier", ...) | exchange.IO("gasMultiplier", ...) is used to set the gas limit multiplier on a Uniswap exchange object. |
TA
| Name | Description |
|---|---|
TA.MACD | The TA.MACD() function is used to calculate the Moving Average Convergence Divergence (MACD) indicator. |
TA.KDJ | The TA.KDJ() function is used to calculate the Stochastic Oscillator (KDJ). |
TA.RSI | The TA.RSI() function is used to calculate the Relative Strength Index (RSI). |
TA.ATR | The TA.ATR() function is used to calculate the Average True Range indicator (ATR). |
TA.OBV | TA.OBV() function is used to calculate the On-Balance Volume (OBV). |
TA.MA | The TA.MA() function is used to calculate the Moving Average indicator (Moving Average). |
TA.EMA | The TA.EMA() function is used to calculate the Exponential Moving Average (EMA) indicator. |
TA.BOLL | The TA.BOLL() function is used to calculate the Bollinger Bands indicator. |
TA.Alligator | TA.Alligator() function is used to calculate the Alligator indicator. |
TA.CMF | The TA.CMF() function is used to calculate the Chaikin Money Flow (CMF) indicator. |
TA.Highest | The TA.Highest() function is used to calculate the highest price within a period. |
TA.Lowest | The TA.Lowest() function is used to calculate the lowest price over a period. |
TA.SMA | The TA.SMA() function is used to calculate the Simple Moving Average (SMA) indicator. |
Talib/OverlapStudies
| Name | Description |
|---|---|
talib.BBANDS | The talib.BBANDS() function is used to calculate Bollinger Bands. |
talib.DEMA | The talib.DEMA() function is used to calculate Double Exponential Moving Average. |
talib.EMA | The talib.EMA() function is used to calculate Exponential Moving Average. |
talib.HT_TRENDLINE | The talib.HT_TRENDLINE() function is used to calculate Hilbert Transform - Instantaneous Trendline. |
talib.KAMA | The talib.KAMA() function is used to calculate Kaufman Adaptive Moving Average. |
talib.MA | The talib.MA() function is used to calculate Moving average. |
talib.MAMA | The talib.MAMA() function is used to calculate the MESA Adaptive Moving Average. |
talib.MIDPOINT | The talib.MIDPOINT() function is used to calculate MidPoint over period. |
talib.MIDPRICE | The talib.MIDPRICE() function is used to calculate Midpoint Price over period. |
talib.SAR | The talib.SAR() function is used to calculate the Parabolic SAR (Stop and Reverse) indicator. |
talib.SAREXT | The talib.SAREXT() function is used to calculate Parabolic SAR - Extended. |
talib.SMA | The talib.SMA() function is used to calculate Simple Moving Average. |
talib.T3 | The talib.T3() function is used to calculate Triple Exponential Moving Average (T3). |
talib.TEMA | The talib.TEMA() function is used to calculate Triple Exponential Moving Average. |
talib.TRIMA | The talib.TRIMA() function is used to calculate Triangular Moving Average. |
talib.WMA | The talib.WMA() function is used to calculate Weighted Moving Average. |
Talib/MomentumIndicators
| Name | Description |
|---|---|
talib.ADX | The talib.ADX() function is used to calculate the Average Directional Movement Index. |
talib.ADXR | The talib.ADXR() function is used to calculate the Average Directional Movement Index Rating. |
talib.APO | The talib.APO() function is used to calculate Absolute Price Oscillator. |
talib.AROON | The talib.AROON() function is used to calculate Aroon (Aroon Indicator). |
talib.AROONOSC | The talib.AROONOSC() function is used to calculate the Aroon Oscillator. |
talib.BOP | The talib.BOP() function is used to calculate Balance Of Power. |
talib.CCI | The talib.CCI() function is used to calculate the Commodity Channel Index. |
talib.CMO | The talib.CMO() function is used to calculate the Chande Momentum Oscillator. |
talib.DX | The talib.DX() function is used to calculate the Directional Movement Index. |
talib.MACD | The talib.MACD() function is used to calculate Moving Average Convergence/Divergence. |
talib.MACDEXT | The talib.MACDEXT() function is used to calculate MACD with controllable MA type. |
talib.MACDFIX | The talib.MACDFIX() function is used to calculate Moving Average Convergence/Divergence Fix 12/26. |
talib.MFI | The talib.MFI() function is used to calculate Money Flow Index. |
talib.MINUS_DI | The talib.MINUS_DI() function is used to calculate the Minus Directional Indicator. |
talib.MINUS_DM | The talib.MINUS_DM() function is used to calculate Minus Directional Movement. |
talib.MOM | The talib.MOM() function is used to calculate Momentum (Momentum Indicator). |
talib.PLUS_DI | The talib.PLUS_DI() function is used to calculate the Plus Directional Indicator. |
talib.PLUS_DM | The talib.PLUS_DM() function is used to calculate Plus Directional Movement. |
talib.PPO | The talib.PPO() function is used to calculate Percentage Price Oscillator. |
talib.ROC | The talib.ROC() function is used to calculate the *Rate of Change indicator: ((price/prevPrice)-1)100. |
talib.ROCP | The talib.ROCP() function is used to calculate Rate of change Percentage: (price-prevPrice)/prevPrice. |
talib.ROCR | The talib.ROCR() function is used to calculate Rate of change ratio: (price/prevPrice). |
talib.ROCR100 | The talib.ROCR100() function is used to calculate *Rate of change ratio 100 scale: (price/prevPrice)100. |
talib.RSI | The talib.RSI() function is used to calculate the Relative Strength Index. |
talib.STOCH | The talib.STOCH() function is used to calculate the Stochastic Oscillator (STOCH indicator). |
talib.STOCHF | The talib.STOCHF() function is used to calculate Stochastic Fast. |
talib.STOCHRSI | The talib.STOCHRSI() function is used to calculate the Stochastic Relative Strength Index. |
talib.TRIX | The talib.TRIX() function is used to calculate 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA. |
talib.ULTOSC | The talib.ULTOSC() function is used to calculate the Ultimate Oscillator. |
talib.WILLR | The talib.WILLR() function is used to calculate Williams' %R (Williams Percent Range). |
Talib/VolumeIndicators
| Name | Description |
|---|---|
talib.AD | The talib.AD() function is used to calculate the Chaikin A/D Line (Accumulation/Distribution Line indicator). |
talib.ADOSC | The talib.ADOSC() function is used to calculate Chaikin A/D Oscillator. |
talib.OBV | The talib.OBV() function is used to calculate On Balance Volume. |
Talib/VolatilityIndicators
| Name | Description |
|---|---|
talib.ATR | The talib.ATR() function is used to calculate the Average True Range indicator. |
talib.NATR | The talib.NATR() function is used to calculate Normalized Average True Range. |
talib.TRANGE | The talib.TRANGE() function is used to calculate the True Range indicator. |
Talib/CycleIndicators
| Name | Description |
|---|---|
talib.HT_DCPERIOD | The talib.HT_DCPERIOD() function is used to calculate Hilbert Transform - Dominant Cycle Period. |
talib.HT_DCPHASE | The talib.HT_DCPHASE() function is used to calculate the Hilbert Transform - Dominant Cycle Phase. |
talib.HT_PHASOR | The talib.HT_PHASOR() function is used to calculate Hilbert Transform - Phasor Components. |
talib.HT_SINE | The talib.HT_SINE() function is used to calculate Hilbert Transform - SineWave. |
talib.HT_TRENDMODE | The talib.HT_TRENDMODE() function is used to calculate Hilbert Transform - Trend vs Cycle Mode. |
Talib/PriceTransform
| Name | Description |
|---|---|
talib.AVGPRICE | The talib.AVGPRICE() function is used to calculate Average Price. |
talib.MEDPRICE | The talib.MEDPRICE() function is used to calculate Median Price. |
talib.TYPPRICE | The talib.TYPPRICE() function is used to calculate Typical Price. |
talib.WCLPRICE | The talib.WCLPRICE() function is used to calculate Weighted Close Price. |
Talib/StatisticFunctions
| Name | Description |
|---|---|
talib.LINEARREG | The talib.LINEARREG() function is used to calculate the Linear Regression indicator. |
talib.LINEARREG_ANGLE | The talib.LINEARREG_ANGLE() function is used to calculate Linear Regression Angle. |
talib.LINEARREG_INTERCEPT | The talib.LINEARREG_INTERCEPT() function is used to calculate the Linear Regression Intercept. |
talib.LINEARREG_SLOPE | The talib.LINEARREG_SLOPE() function is used to calculate Linear Regression Slope. |
talib.STDDEV | The talib.STDDEV() function is used to calculate Standard Deviation. |
talib.TSF | The talib.TSF() function is used to calculate Time Series Forecast. |
talib.VAR | The talib.VAR() function is used to calculate Variance. |
Talib/MathTransform
| Name | Description |
|---|---|
talib.ACOS | The talib.ACOS() function is used to calculate Vector Trigonometric ACos. |
talib.ASIN | The talib.ASIN() function is used to calculate Vector Trigonometric ASin. |
talib.ATAN | The talib.ATAN() function is used to calculate Vector Trigonometric ATan. |
talib.CEIL | The talib.CEIL() function is used to calculate Vector Ceil. |
talib.COS | The talib.COS() function is used to calculate Vector Trigonometric Cos. |
talib.COSH | The talib.COSH() function is used to calculate Vector Trigonometric Cosh. |
talib.EXP | The talib.EXP() function is used to calculate Vector Arithmetic Exp. |
talib.FLOOR | The talib.FLOOR() function is used to calculate Vector Floor. |
talib.LN | The talib.LN() function is used to calculate Vector Log Natural. |
talib.LOG10 | The talib.LOG10() function is used to calculate Vector Log10 (logarithm function). |
talib.SIN | The talib.SIN() function is used to calculate Vector Trigonometric Sin. |
talib.SINH | The talib.SINH() function is used to calculate Vector Trigonometric Sinh. |
talib.SQRT | The talib.SQRT() function is used to calculate Vector Square Root. |
talib.TAN | The talib.TAN() function is used to calculate Vector Trigonometric Tan. |
talib.TANH | The talib.TANH() function is used to calculate Vector Trigonometric Tanh. |
Talib/MathOperators
| Name | Description |
|---|---|
talib.MAX | The talib.MAX() function is used to calculate the Highest value over a specified period. |
talib.MAXINDEX | The talib.MAXINDEX() function is used to calculate the Index of highest value over a specified period. |
talib.MIN | The talib.MIN() function is used to calculate the Lowest value over a specified period. |
talib.MININDEX | The talib.MININDEX() function is used to calculate the Index of lowest value over a specified period. |
talib.MINMAX | The talib.MINMAX() function is used to calculate the Lowest and highest values over a specified period. |
talib.MINMAXINDEX | The talib.MINMAXINDEX() function is used to calculate Indexes of lowest and highest values over a specified period. |
talib.SUM | The talib.SUM() function is used to calculate Summation. |
Talib/PatternRecognition
| Name | Description |
|---|---|
talib.CDL2CROWS | The talib.CDL2CROWS() function is used to calculate Two Crows (K-line pattern - Two Crows). |
talib.CDL3BLACKCROWS | The talib.CDL3BLACKCROWS() function is used to calculate Three Black Crows (K-line pattern - Three Black Crows). |
talib.CDL3INSIDE | The talib.CDL3INSIDE() function is used to calculate Three Inside Up/Down (Candlestick Pattern: Three Inside Up/Down). |
talib.CDL3LINESTRIKE | The talib.CDL3LINESTRIKE() function is used to calculate Three-Line Strike (Candlestick Pattern: Three-Line Strike). |
talib.CDL3OUTSIDE | The talib.CDL3OUTSIDE() function is used to calculate Three Outside Up/Down (Candlestick Pattern: Three Outside). |
talib.CDL3STARSINSOUTH | The talib.CDL3STARSINSOUTH() function is used to calculate Three Stars In The South (Candlestick Pattern: Three Stars In The South). |
talib.CDL3WHITESOLDIERS | The talib.CDL3WHITESOLDIERS() function is used to calculate Three Advancing White Soldiers (K-line pattern: Three White Soldiers). |
talib.CDLABANDONEDBABY | The talib.CDLABANDONEDBABY() function is used to calculate Abandoned Baby (Candlestick Pattern: Abandoned Baby). |
talib.CDLADVANCEBLOCK | The talib.CDLADVANCEBLOCK() function is used to calculate Advance Block (Candlestick Pattern: Advance Block). |
talib.CDLBELTHOLD | The talib.CDLBELTHOLD() function is used to calculate Belt-hold (Candlestick Pattern: Belt-hold). |
talib.CDLBREAKAWAY | The talib.CDLBREAKAWAY() function is used to calculate Breakaway (Candlestick Pattern: Breakaway Pattern). |
talib.CDLCLOSINGMARUBOZU | The talib.CDLCLOSINGMARUBOZU() function is used to calculate the Closing Marubozu candlestick pattern. |
talib.CDLCONCEALBABYSWALL | The talib.CDLCONCEALBABYSWALL() function is used to calculate Concealing Baby Swallow (Candlestick Pattern: Concealing Baby Swallow). |
talib.CDLCOUNTERATTACK | The talib.CDLCOUNTERATTACK() function is used to calculate Counterattack Lines (K-Line Pattern: Counterattack). |
talib.CDLDARKCLOUDCOVER | The talib.CDLDARKCLOUDCOVER() function is used to calculate Dark Cloud Cover candlestick pattern. |
talib.CDLDOJI | The talib.CDLDOJI() function is used to calculate Doji (K-line pattern: Doji Star). |
talib.CDLDOJISTAR | The talib.CDLDOJISTAR() function is used to calculate Doji Star (Candlestick Pattern: Doji Star). |
talib.CDLDRAGONFLYDOJI | The talib.CDLDRAGONFLYDOJI() function is used to calculate Dragonfly Doji (Candlestick Pattern: Dragonfly Doji). |
talib.CDLENGULFING | The talib.CDLENGULFING() function is used to calculate Engulfing Pattern. |
talib.CDLEVENINGDOJISTAR | The talib.CDLEVENINGDOJISTAR() function is used to calculate Evening Doji Star (K-line pattern: Evening Doji Star). |
talib.CDLEVENINGSTAR | The talib.CDLEVENINGSTAR() function is used to calculate the Evening Star candlestick pattern. |
talib.CDLGAPSIDESIDEWHITE | The talib.CDLGAPSIDESIDEWHITE() function is used to calculate **Up/Down-gap side-by-side white lines (K-line pattern: Up/Down-gap side-by-side white li... |
talib.CDLGRAVESTONEDOJI | The talib.CDLGRAVESTONEDOJI() function is used to calculate the Gravestone Doji candlestick pattern. |
talib.CDLHAMMER | The talib.CDLHAMMER() function is used to calculate Hammer (Candlestick Pattern: Hammer). |
talib.CDLHANGINGMAN | The talib.CDLHANGINGMAN() function is used to calculate Hanging Man (Candlestick Pattern: Hanging Man). |
talib.CDLHARAMI | The talib.CDLHARAMI() function is used to calculate Harami Pattern (K-line chart: bullish/bearish pattern). |
talib.CDLHARAMICROSS | The talib.CDLHARAMICROSS() function is used to calculate Harami Cross Pattern (Candlestick Pattern: Harami Cross). |
talib.CDLHIGHWAVE | The talib.CDLHIGHWAVE() function is used to calculate High-Wave Candle (Candlestick Pattern: High Wave Candle). |
talib.CDLHIKKAKE | The talib.CDLHIKKAKE() function is used to calculate Hikkake Pattern (Candlestick: Trap Pattern). |
talib.CDLHIKKAKEMOD | The talib.CDLHIKKAKEMOD() function is used to calculate Modified Hikkake Pattern (Candlestick: Modified Hikkake Pattern). |
talib.CDLHOMINGPIGEON | The talib.CDLHOMINGPIGEON() function is used to calculate Homing Pigeon (Candlestick Pattern: Homing Pigeon). |
talib.CDLIDENTICAL3CROWS | The talib.CDLIDENTICAL3CROWS() function is used to calculate Identical Three Crows (Candlestick Pattern: Identical Three Crows). |
talib.CDLINNECK | The talib.CDLINNECK() function is used to calculate In-Neck Pattern (Candlestick Chart: In-Neck Pattern). |
talib.CDLINVERTEDHAMMER | The talib.CDLINVERTEDHAMMER() function is used to calculate Inverted Hammer (K-Line Pattern: Inverted Hammer). |
talib.CDLKICKING | The talib.CDLKICKING() function is used to calculate Kicking (Candlestick Pattern: Kicking Pattern). |
talib.CDLKICKINGBYLENGTH | The talib.CDLKICKINGBYLENGTH() function is used to calculate **Kicking - bull/bear determined by the longer marubozu (K-line pattern: Kicking Bull/Bear... |
talib.CDLLADDERBOTTOM | The talib.CDLLADDERBOTTOM() function is used to calculate Ladder Bottom (Candlestick Pattern: Ladder Bottom). |
talib.CDLLONGLEGGEDDOJI | The talib.CDLLONGLEGGEDDOJI() function is used to calculate Long Legged Doji (Candlestick Pattern: Long Legged Doji). |
talib.CDLLONGLINE | The talib.CDLLONGLINE() function is used to calculate Long Line Candle Pattern (Candlestick Chart: Long Line). |
talib.CDLMARUBOZU | The talib.CDLMARUBOZU() function is used to calculate the Marubozu (Candlestick Pattern: Shaven Head and Bottom) pattern. |
talib.CDLMATCHINGLOW | The talib.CDLMATCHINGLOW() function is used to calculate Matching Low (Candlestick Pattern: Matching Low). |
talib.CDLMATHOLD | The talib.CDLMATHOLD() function is used to calculate Mat Hold (Candlestick Pattern: Mat Hold). |
talib.CDLMORNINGDOJISTAR | The talib.CDLMORNINGDOJISTAR() function is used to calculate Morning Doji Star (Candlestick Pattern: Morning Doji Star). |
talib.CDLMORNINGSTAR | The talib.CDLMORNINGSTAR() function is used to calculate Morning Star (Candlestick Pattern: Morning Star). |
talib.CDLONNECK | The talib.CDLONNECK() function is used to calculate On-Neck Pattern (Candlestick Chart: On-Neck Pattern). |
talib.CDLPIERCING | The talib.CDLPIERCING() function is used to calculate Piercing Pattern (Candlestick Pattern: Piercing Pattern). |
talib.CDLRICKSHAWMAN | The talib.CDLRICKSHAWMAN() function is used to calculate Rickshaw Man (Candlestick Pattern: Rickshaw Man). |
talib.CDLRISEFALL3METHODS | The talib.CDLRISEFALL3METHODS() function is used to calculate Rising/Falling Three Methods (Candlestick Pattern: Rising/Falling Three Methods). |
talib.CDLSEPARATINGLINES | The talib.CDLSEPARATINGLINES() function is used to calculate Separating Lines Pattern (Candlestick Chart: Separating Lines). |
talib.CDLSHOOTINGSTAR | The talib.CDLSHOOTINGSTAR() function is used to calculate Shooting Star (Candlestick Pattern: Shooting Star). |
talib.CDLSHORTLINE | The talib.CDLSHORTLINE() function is used to calculate Short Line Candle Pattern (K-Line: Short Line). |
talib.CDLSPINNINGTOP | The talib.CDLSPINNINGTOP() function is used to calculate Spinning Top (Candlestick Pattern: Spinning Top). |
talib.CDLSTALLEDPATTERN | The talib.CDLSTALLEDPATTERN() function is used to calculate Stalled Pattern (Candlestick Pattern: Stalled Pattern). |
talib.CDLSTICKSANDWICH | The talib.CDLSTICKSANDWICH() function is used to calculate Stick Sandwich (Candlestick Pattern: Stick Sandwich). |
talib.CDLTAKURI | The talib.CDLTAKURI() function is used to calculate Takuri (Dragonfly Doji with very long lower shadow) candlestick pattern. |
talib.CDLTASUKIGAP | The talib.CDLTASUKIGAP() function is used to calculate Tasuki Gap (Candlestick Pattern: Tasuki Gap). |
talib.CDLTHRUSTING | The talib.CDLTHRUSTING() function is used to calculate Thrusting Pattern (Candlestick Pattern: Thrusting Pattern). |
talib.CDLTRISTAR | The talib.CDLTRISTAR() function is used to calculate Tristar Pattern (Candlestick Chart: Tristar Pattern). |
talib.CDLUNIQUE3RIVER | The talib.CDLUNIQUE3RIVER() function is used to calculate Unique 3 River (Candlestick Pattern: Unique Three River). |
talib.CDLUPSIDEGAP2CROWS | The talib.CDLUPSIDEGAP2CROWS() function is used to calculate Upside Gap Two Crows (Candlestick Pattern: Two Crows). |
talib.CDLXSIDEGAP3METHODS | The talib.CDLXSIDEGAP3METHODS() function is used to calculate Upside/Downside Gap Three Methods (Candlestick Pattern Recognition). |
OS
| Name | Description |
|---|---|
ListFilesResult | File list object used to record directory listing information. |
FileStat | File statistics information object. |
OS/os
| Name | Description |
|---|---|
open | Open a file in the specified mode. |
fgets | Read the entire file content at once. |
fputs | Write content to a file. |
mmap | Memory-mapped file, returns the binary data of the file. |
getRootDir | Get the root directory path for file operations. |
listFiles | List files and subdirectories in the specified directory. |
exists | Check if the specified file or directory exists. |
remove | Delete the specified file. |
mkdir | Create a directory. |
rmdir | Remove a directory and all its contents. |
rename | Rename a file or move a file. |
stat | Get detailed statistics information of a file. |
exit | Exit the program. |
OS/File
| Name | Description |
|---|---|
close | Close the file and release associated resources. |
puts | Write one or more strings to a file. |
printf | Write formatted data to file. |
flush | Flush the file buffer to ensure data is written to disk. |
tell | Get the current file pointer position. |
seek | Move the file pointer to a specified position. |
eof | Check if the file pointer has reached the end of file. |
read | Read data from a file. |
write | Write string data to a file. |
getline | Read the next line from the file. |
toString | Get the string representation of the file object. |
Structures
| Name | Description |
|---|---|
Ticker | Market data structure. |
Depth | Market depth data structure. |
OrderBook | Order structure in market depth. |
Trade | Data structure for market trade records. |
Record | Data structure for candlestick bars in standard OHLC format, used for charting candlesticks and calculating technical indicators. |
Market | Data structure for trading symbol market information. |
Order | Order structure. |
Condition | Conditional order configuration structure, used to set trigger conditions and execution prices for conditional orders. |
Account | Data structure for account information. |
Asset | Data structure for specific currency asset information. |
Position | Data structure for contract position information. |
Funding | Data structure for trading instrument funding rate information, only cryptocurrency perpetual contracts support funding rate functionality. |
OtherStruct
| Name | Description |
|---|---|
HttpQuery-options | This JSON structure is used to configure various parameters for HTTP requests sent by HttpQuery and HttpQuery_Go functions. |
HttpQuery-return | This JSON structure is the data structure returned by the HttpQuery function in debug mode, when the debug field is set to true in the options paramete... |
LogStatus-table | This JSON structure is used to configure the table content displayed in the strategy status bar. |
LogStatus-btnTypeOne | This JSON structure is used to configure button controls in the status bar. |
LogStatus-btnTypeTwo | This JSON structure is used to configure button controls in the status bar. |
Chart-options | This JSON is used to configure chart settings for the custom plotting function Chart(). |
KLineChart-options | This JSON is used to configure the chart settings for the custom drawing function KLineChart. |
SetData-data | This JSON is used to set the data to be loaded by the exchange.SetData() function. |
EventLoop-return | This JSON is the data structure returned by the EventLoop() function. |
DBExec-return | This JSON is the data structure returned by the DBExec() function; this JSON data structure is also returned when executing SQL statements using the ``... |
Thread.join-return | This JSON is the data structure returned by the join() member function of the Thread object, used to store information related to concurrent thre... |
Built-in Variables and Constants
EXCHANGE
| Name | Description |
|---|---|
exchange | exchange is an exchange object, and it is also the first exchange object added in the strategy live trading settings and backtesting settings. |
exchanges | exchanges is an array of exchange objects that contains all the exchange objects added in the strategy's live trading settings or backtesting settings, where... |
ORDER_STATE
| Name | Description |
|---|---|
ORDER_STATE_PENDING | ORDER_STATE_PENDING is the value of the Status property in the Order structure, indicating that the order status is pending. |
ORDER_STATE_CLOSED | ORDER_STATE_CLOSED is the value of the Status property in the Order structure, indicating that the order status is completed. |
ORDER_STATE_CANCELED | ORDER_STATE_CANCELED is the value of the Status property in the Order structure, indicating that the order status is canceled. |
ORDER_STATE_UNKNOWN | ORDER_STATE_UNKNOWN is the value of the Status property in the Order structure, indicating that the order status is unknown (other status). |
ORDER_TYPE
| Name | Description |
|---|---|
ORDER_TYPE_BUY | ORDER_TYPE_BUY is the value of the Type property in the Order structure, representing a buy order type. |
ORDER_TYPE_SELL | ORDER_TYPE_SELL is the Type property value in the Order structure, used to indicate a sell order type. |
ORDER_CONDITION_TYPE
| Name | Description |
|---|---|
ORDER_CONDITION_TYPE_OCO | ORDER_CONDITION_TYPE_OCO is the value of the ConditionType property in the Condition structure, representing OCO orders (One-Cancels-the-Other). |
ORDER_CONDITION_TYPE_TP | ORDER_CONDITION_TYPE_TP is the ConditionType attribute value in the Condition structure, representing a Take Profit order. |
ORDER_CONDITION_TYPE_SL | ORDER_CONDITION_TYPE_SL is the ConditionType attribute value in the Condition structure, representing a Stop Loss order. |
ORDER_CONDITION_TYPE_GENERIC | ORDER_CONDITION_TYPE_GENERIC is the ConditionType property value in the Condition structure, representing a generic conditional order. |
POSITION_DIRECTION
| Name | Description |
|---|---|
PD_LONG | PD_LONG is the value of the Type property in the Position structure, representing a long position type. |
PD_SHORT | PD_SHORT is the value of the Type property in the Position structure, representing a short position type. |
ORDER_OFFSET
| Name | Description |
|---|---|
ORDER_OFFSET_OPEN | ORDER_OFFSET_OPEN is a value for the Offset property in the Order structure, indicating that the order is an opening position operation. |
ORDER_OFFSET_CLOSE | ORDER_OFFSET_CLOSE is a value for the Offset property in the Order structure, indicating that the order is in the close position direction. |
PERIOD
| Name | Description |
|---|---|
PERIOD_M1 | Constant representing 1-minute candlestick period, with a value of 60. |
PERIOD_M3 | Constant representing the 3-minute candlestick period, with a value of 180. |
PERIOD_M5 | Constant representing the 5-minute candlestick period, with a value of 300. |
PERIOD_M15 | Constant representing the 15-minute candlestick period, with a value of 900. |
PERIOD_M30 | Constant representing the 30-minute candlestick period, with a value of 1800 seconds. |
PERIOD_H1 | Constant representing 1-hour candlestick period, with a value of 3600. |
PERIOD_H2 | Constant representing the 2-hour candlestick period, with a value of 7200. |
PERIOD_H4 | Constant representing the 4-hour candlestick period, with a value of 14400. |
PERIOD_H6 | Constant representing the 6-hour candlestick period, with a value of 21600. |
PERIOD_H12 | Constant representing the 12-hour candlestick period, with a value of 43200. |
PERIOD_D1 | Constant representing 1-day candlestick period, with a value of 86400. |
PERIOD_D3 | Constant representing the 3-day candlestick period, with a value of 259200. |
PERIOD_W1 | Constant representing 1-week candlestick period, with a value of 604800 seconds. |
LOG_TYPE
| Name | Description |
|---|---|
LOG_TYPE_BUY | LOG_TYPE_BUY is an optional value for the LogType parameter of the exchange.Log function, used to set the log type printed by the exchange.Log fu... |
LOG_TYPE_SELL | LOG_TYPE_SELL is an optional value for the LogType parameter of the exchange.Log function, used to set the exchange.Log function to print sell or... |
LOG_TYPE_CANCEL | LOG_TYPE_CANCEL is an optional value for the LogType parameter of the exchange.Log function, used to set the exchange.Log function to print order... |