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 | 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 | Decodes (parses) a JSON string; a method of the ECMAScript standard built-in object JSON. |
JSON.stringify | Converts JavaScript values to JSON strings; a method of the ECMAScript standard built-in object JSON. |
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 | Outputs logs. |
LogStatus | Refreshes the status bar of a backtest or live trading page with text, tables, buttons or component objects with a type (KPI cards, charts, tabs and more); each call replaces the previous content. |
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 | Outputs order placement and cancellation logs in the log column area. |
Market
| Name | Description |
|---|---|
exchange.GetTicker | Gets the Ticker structure (market data) of a spot instrument or contract; without symbol it uses the currently set trading pair and contract code. |
exchange.GetTickers | Retrieves aggregated market data from the exchange (an array of Ticker structures). |
exchange.GetDepth | Gets the Depth structure, i.e. the order book data, of the spot or contract corresponding to the currently set trading pair and contract code. |
exchange.GetTrades | Gets the Trade structure array of the spot or futures corresponding to the currently set trading pair and contract code, i.e. the market's trade (tick) data. |
exchange.GetRecords | Get the Record structure array (i.e. K-line data) of the spot or contract corresponding to the currently set trading pair or contract code. |
exchange.GetMarkets | Retrieves 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 | Sets the data loaded when the strategy is running. |
exchange.GetData | Retrieves data loaded by the exchange.SetData() function, or data provided by an external link. |
Trade
| Name | Description |
|---|---|
exchange.Buy | Places a buy order. |
exchange.Sell | Places a sell order. |
exchange.CreateOrder | Places orders. |
exchange.ModifyOrder | Modifies an existing regular order, allowing you to modify the order's price and quantity. |
exchange.CancelOrder | Cancels an order. |
exchange.GetOrder | Obtains order information. |
exchange.GetOrders | Obtains the current unfilled orders. |
exchange.GetHistoryOrders | Retrieves the historical orders of the current trading pair or contract, and supports specifying a particular trading instrument. |
exchange.CreateConditionOrder | Creates a conditional order. |
exchange.ModifyConditionOrder | Modifies an existing conditional order, allowing modification of the order amount, trigger condition, and execution price of the conditional order. |
exchange.CancelConditionOrder | Cancels a conditional order. |
exchange.GetConditionOrder | Retrieves information about a specified conditional order. |
exchange.GetConditionOrders | Obtains unfinished conditional orders (conditional orders that have not yet been triggered or canceled). |
exchange.GetHistoryConditionOrders | Retrieves the historical conditional orders (including triggered, canceled, and expired conditional orders) for the current trading pair or contract, and supports specifying a particular trading instrument. |
Account
| Name | Description |
|---|---|
exchange.GetAccount | Requests the exchange account information. |
exchange.GetAssets | Requests the asset information of the exchange account. |
Futures
| Name | Description |
|---|---|
exchange.SetContractType | Sets the current contract code of the exchange object. |
exchange.GetContractType | Gets the contract code currently set for the exchange object. |
exchange.SetDirection | Sets the order direction when calling the exchange.Buy function or exchange.Sell function to place futures contract orders. |
exchange.SetMarginLevel | Sets the leverage value for the trading pair or contract specified by the symbol parameter. |
exchange.GetPositions | Gets position information. |
exchange.GetFundings | Obtains the funding rate data for the current period. |
Exchange
| Name | Description |
|---|---|
exchange.GetName | Gets the name of the exchange bound to the current exchange object. |
exchange.GetLabel | Obtains the custom label set when configuring the exchange object. |
exchange.GetCurrency | Gets the currently set trading pair. |
exchange.SetCurrency | Switches the current trading pair of the exchange object exchange. |
exchange.GetQuoteCurrency | Gets the name of the quote currency of the current trading pair, i.e. quoteCurrency. |
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 default K-line period used when calling the exchange.GetRecords() function without… |
exchange.SetMaxBarLen | Set the maximum length of the K-line (candlestick chart). |
exchange.SetPrecision | Sets the precision of the price and order amount for the exchange object. |
exchange.GetRate | Get the exchange rate currently set for the exchange object. |
exchange.SetRate | Set the current exchange rate of the exchange object. |
exchange.SetBase | Sets the base URL of the exchange API interface used by the exchange object. |
exchange.GetBase | Gets the base address of the current exchange API interface. |
exchange.SetProxy | Sets the proxy configuration of the exchange object. |
exchange.SetTimeout | Sets the timeout for rest requests of the exchange object. |
exchange.Encode | Performs signature and encryption computations. |
IO
| Name | Description |
|---|---|
exchange.IO | Calls other interfaces related to the exchange object. |
exchange.IO("api", ...) | Calls a raw REST endpoint of the exchange that has no wrapper function; the platform signs the request. |
exchange.IO("currency", ...) | Switches the current trading pair of the exchange object at runtime. |
exchange.IO("base", ...) | Queries or switches the base address of the exchange API. |
exchange.IO(mode, value) | Switches the trading mode of an exchange, including demo/live trading, cross/isolated margin, hedge/one-way position mode, unified account, margin trading mode and self-trade prevention. |
exchange.IO("rate", ...) | Limits how often each API function is called: rate for smoothed limiting, quota for quota limiting. |
Network
| Name | Description |
|---|---|
HttpQuery | Sends an HTTP request. |
HttpQuery_Go | Sends an Http request. |
Dial | Used for raw Socket access, supporting the tcp and tls (also written as ssl) protocols as well as the WebSocket ws and wss 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() complete. |
ctx.subscribe | Subscribes to market data pushes for one instrument of an account, or to the order updates of an account, and returns an event stream ID. |
ctx.poll | Takes the next subscription event, optionally waiting with a timeout. |
ctx.book | Reads the order book maintained by the docker. |
Threads/threading
| Name | Description |
|---|---|
threading.Thread | Creates concurrent threads. |
threading.getThread | Gets a thread object based on the specified thread ID. |
threading.mainThread | Gets the thread object of the main thread, which is the thread where the main() function in the strategy is located. |
threading.currentThread | Gets the thread object of the current thread. |
threading.Lock | Creates a thread lock object. |
threading.Condition | Creates a condition variable object, which is used to implement synchronization and communication between threads in a multi-threaded concurrent environment. |
threading.Event | Creates a thread event object, which is used for synchronization between threads, allowing one thread to wait for notification or signal from another thread. |
threading.Dict | Creates a dictionary object for passing and sharing data between concurrent threads. |
threading.Serve | Starts an HTTP, TCP or WebSocket (over HTTP) service inside the strategy process and returns a Server object. |
threading.pending | Gets the number of concurrent threads currently running in the strategy program. |
Threads/Thread
| Name | Description |
|---|---|
Thread.peekMessage | Receives messages from a thread. |
Thread.postMessage | Sends messages to a thread. |
Thread.join | Waits for a thread to exit and reclaims its system resources. |
Thread.terminate | Forcibly terminates a thread and releases the hardware resources occupied when the thread was created. |
Thread.getData | Accesses variables recorded in the thread environment. |
Thread.setData | Stores variables in the thread environment. |
Thread.id | Returns the threadId of the current multi-threaded object instance. |
Thread.name | Returns the name of the current multi-threaded object instance. |
Thread.eventLoop | Listens for events received by the current thread (the thread of the caller). |
Threads/ThreadLock
| Name | Description |
|---|---|
ThreadLock.acquire | Requests a thread lock (acquire lock). |
ThreadLock.release | Releases a thread lock (unlock). |
Threads/ThreadEvent
| Name | Description |
|---|---|
ThreadEvent.set | Sets an event signal. |
ThreadEvent.clear | Clears the signal. |
ThreadEvent.wait | Sets event (signal) waiting, which will block until the event (signal) is set; supports setting timeout parameters. |
ThreadEvent.isSet | Determines whether an event (signal) has been set. |
Threads/ThreadCondition
| Name | Description |
|---|---|
ThreadCondition.notify | Wakes up one waiting thread (if any exists). |
ThreadCondition.notifyAll | Wakes up all waiting threads. |
ThreadCondition.wait | Puts a thread into a waiting state under specific conditions. |
ThreadCondition.acquire | Requests a thread lock (acquire lock). |
ThreadCondition.release | Releases the thread lock (unlock). |
Threads/ThreadDict
| Name | Description |
|---|---|
ThreadDict.get | Retrieves the value of a key recorded in a dictionary object. |
ThreadDict.set | Sets key-value pairs. |
Threads/Server
| Name | Description |
|---|---|
Server.addr | Returns the address and port the service actually listens on. |
Server.close | Stops accepting new connections; handlers already running finish normally (graceful shutdown). |
Server.stop | Closes the service (as close()) and then terminates every handler thread that is still running. |
Server.join | Waits until the service is closed and no handler is running. |
Server.pending | Returns the number of handlers currently running, i.e. connections or requests being handled. |
TA
| Name | Description |
|---|---|
TA.MACD | Calculates the Moving Average Convergence Divergence (MACD) indicator. |
TA.KDJ | Calculates the Stochastic Oscillator (KDJ). |
TA.RSI | Calculates the Relative Strength Index (RSI). |
TA.ATR | Calculates the Average True Range indicator (ATR). |
TA.OBV | Calculates the On-Balance Volume (OBV). |
TA.MA | Calculates the Moving Average indicator (Moving Average). |
TA.EMA | Calculates the Exponential Moving Average (EMA) indicator. |
TA.BOLL | Calculates the Bollinger Bands indicator. |
TA.Alligator | Calculates the Alligator indicator. |
TA.CMF | Calculates the Chaikin Money Flow (CMF) indicator. |
TA.Highest | Calculates the highest price within a period. |
TA.Lowest | Calculates the lowest price over a period. |
TA.SMA | Calculates the Simple Moving Average (SMA) indicator. |
Talib/OverlapStudies
| Name | Description |
|---|---|
talib.ACCBANDS | Calculates the Acceleration Bands and returns the upper band, middle band and lower band. |
talib.BBANDS | Calculates the Bollinger Bands and returns the upper band, middle band and lower band. |
talib.DEMA | Calculates the Double Exponential Moving Average. |
talib.EMA | Calculates the Exponential Moving Average. |
talib.HT_TRENDLINE | Calculates the Hilbert Transform - Instantaneous Trendline. |
talib.KAMA | Calculates the Kaufman Adaptive Moving Average. |
talib.MA | Calculates the Moving Average. |
talib.MAMA | Calculates the MESA Adaptive Moving Average and returns the MAMA and FAMA. |
talib.MAVP | Calculates the Moving Average with Variable Period. |
talib.MIDPOINT | Calculates the MidPoint over Period. |
talib.MIDPRICE | Calculates the Midpoint Price over Period. |
talib.SAR | Calculates the Parabolic SAR. |
talib.SAREXT | Calculates the Parabolic SAR - Extended. |
talib.SMA | Calculates the Simple Moving Average. |
talib.T3 | Calculates the Triple Exponential Moving Average (T3). |
talib.TEMA | Calculates the Triple Exponential Moving Average. |
talib.TRIMA | Calculates the Triangular Moving Average. |
talib.WMA | Calculates the Weighted Moving Average. |
Talib/MomentumIndicators
| Name | Description |
|---|---|
talib.ADX | Calculates the Average Directional Movement Index. |
talib.ADXR | Calculates the Average Directional Movement Index Rating. |
talib.APO | Calculates the Absolute Price Oscillator. |
talib.AROON | Calculates the Aroon and returns the Aroon Down and Aroon Up. |
talib.AROONOSC | Calculates the Aroon Oscillator. |
talib.BOP | Calculates the Balance Of Power. |
talib.CCI | Calculates the Commodity Channel Index. |
talib.CMO | Calculates the Chande Momentum Oscillator. |
talib.DX | Calculates the Directional Movement Index. |
talib.IMI | Calculates the Intraday Momentum Index. |
talib.MACD | Calculates the Moving Average Convergence/Divergence and returns the MACD line, signal line and histogram. |
talib.MACDEXT | Calculates the MACD with Controllable MA Type and returns the MACD line, signal line and histogram. |
talib.MACDFIX | Calculates the Moving Average Convergence/Divergence Fix 12/26 and returns the MACD line, signal line and histogram. |
talib.MFI | Calculates the Money Flow Index. |
talib.MINUS_DI | Calculates the Minus Directional Indicator. |
talib.MINUS_DM | Calculates the Minus Directional Movement. |
talib.MOM | Calculates the Momentum. |
talib.PLUS_DI | Calculates the Plus Directional Indicator. |
talib.PLUS_DM | Calculates the Plus Directional Movement. |
talib.PPO | Calculates the Percentage Price Oscillator. |
talib.ROC | Calculates the Rate of Change, defined as ((price/prevPrice)-1)*100. |
talib.ROCP | Calculates the Rate of Change Percentage, defined as (price-prevPrice)/prevPrice. |
talib.ROCR | Calculates the Rate of Change Ratio, defined as price/prevPrice. |
talib.ROCR100 | Calculates the Rate of Change Ratio 100 Scale, defined as (price/prevPrice)*100. |
talib.RSI | Calculates the Relative Strength Index. |
talib.STOCH | Calculates the Stochastic and returns the slow %K and slow %D. |
talib.STOCHF | Calculates the Stochastic Fast and returns the fast %K and fast %D. |
talib.STOCHRSI | Calculates the Stochastic Relative Strength Index and returns the fast %K and fast %D. |
talib.TRIX | Calculates the 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA. |
talib.ULTOSC | Calculates the Ultimate Oscillator. |
talib.WILLR | Calculates the Williams' %R. |
Talib/VolumeIndicators
| Name | Description |
|---|---|
talib.AD | Calculates the Chaikin A/D Line. |
talib.ADOSC | Calculates the Chaikin A/D Oscillator. |
talib.OBV | Calculates the On Balance Volume. |
Talib/VolatilityIndicators
| Name | Description |
|---|---|
talib.ATR | Calculates the Average True Range. |
talib.NATR | Calculates the Normalized Average True Range. |
talib.TRANGE | Calculates the True Range. |
Talib/CycleIndicators
| Name | Description |
|---|---|
talib.HT_DCPERIOD | Calculates the Hilbert Transform - Dominant Cycle Period. |
talib.HT_DCPHASE | Calculates the Hilbert Transform - Dominant Cycle Phase. |
talib.HT_PHASOR | Calculates the Hilbert Transform - Phasor Components and returns the in-phase component and quadrature component. |
talib.HT_SINE | Calculates the Hilbert Transform - SineWave and returns the sine and lead sine. |
talib.HT_TRENDMODE | Calculates the Hilbert Transform - Trend vs Cycle Mode. |
Talib/PriceTransform
| Name | Description |
|---|---|
talib.AVGDEV | Calculates the Average Deviation. |
talib.AVGPRICE | Calculates the Average Price. |
talib.MEDPRICE | Calculates the Median Price. |
talib.TYPPRICE | Calculates the Typical Price. |
talib.WCLPRICE | Calculates the Weighted Close Price. |
Talib/StatisticFunctions
| Name | Description |
|---|---|
talib.BETA | Calculates the Beta. |
talib.CORREL | Calculates the Pearson's Correlation Coefficient (r). |
talib.LINEARREG | Calculates the Linear Regression. |
talib.LINEARREG_ANGLE | Calculates the Linear Regression Angle. |
talib.LINEARREG_INTERCEPT | Calculates the Linear Regression Intercept. |
talib.LINEARREG_SLOPE | Calculates the Linear Regression Slope. |
talib.STDDEV | Calculates the Standard Deviation. |
talib.TSF | Calculates the Time Series Forecast. |
talib.VAR | Calculates the Variance. |
Talib/MathTransform
| Name | Description |
|---|---|
talib.ACOS | Calculates the arc cosine of each element (Vector Trigonometric ACos). |
talib.ASIN | Calculates the arc sine of each element (Vector Trigonometric ASin). |
talib.ATAN | Calculates the arc tangent of each element (Vector Trigonometric ATan). |
talib.CEIL | Rounds each element up to an integer (Vector Ceil). |
talib.COS | Calculates the cosine of each element (Vector Trigonometric Cos). |
talib.COSH | Calculates the hyperbolic cosine of each element (Vector Trigonometric Cosh). |
talib.EXP | Calculates the exponential (e to the power of x) of each element (Vector Arithmetic Exp). |
talib.FLOOR | Rounds each element down to an integer (Vector Floor). |
talib.LN | Calculates the natural logarithm of each element (Vector Log Natural). |
talib.LOG10 | Calculates the base-10 logarithm of each element (Vector Log10). |
talib.SIN | Calculates the sine of each element (Vector Trigonometric Sin). |
talib.SINH | Calculates the hyperbolic sine of each element (Vector Trigonometric Sinh). |
talib.SQRT | Calculates the square root of each element (Vector Square Root). |
talib.TAN | Calculates the tangent of each element (Vector Trigonometric Tan). |
talib.TANH | Calculates the hyperbolic tangent of each element (Vector Trigonometric Tanh). |
Talib/MathOperators
| Name | Description |
|---|---|
talib.ADD | Adds two arrays element by element (Vector Arithmetic Add). |
talib.DIV | Divides the first array by the second, element by element (Vector Arithmetic Div). |
talib.MAX | Calculates the Highest Value over a Specified Period. |
talib.MAXINDEX | Calculates the Index of Highest Value over a Specified Period. |
talib.MIN | Calculates the Lowest Value over a Specified Period. |
talib.MININDEX | Calculates the Index of Lowest Value over a Specified Period. |
talib.MINMAX | Calculates the Lowest and Highest Values over a Specified Period and returns the minimum and maximum. |
talib.MINMAXINDEX | Calculates the Indexes of Lowest and Highest Values over a Specified Period and returns the minimum index and maximum index. |
talib.MULT | Multiplies two arrays element by element (Vector Arithmetic Mult). |
talib.SUB | Subtracts the second array from the first, element by element (Vector Arithmetic Subtraction). |
talib.SUM | Calculates the Summation. |
Talib/PatternRecognition
| Name | Description |
|---|---|
talib.CDL2CROWS | Detects the Two Crows candlestick pattern. |
talib.CDL3BLACKCROWS | Detects the Three Black Crows candlestick pattern. |
talib.CDL3INSIDE | Detects the Three Inside Up/Down candlestick pattern. |
talib.CDL3LINESTRIKE | Detects the Three-Line Strike candlestick pattern. |
talib.CDL3OUTSIDE | Detects the Three Outside Up/Down candlestick pattern. |
talib.CDL3STARSINSOUTH | Detects the Three Stars In The South candlestick pattern. |
talib.CDL3WHITESOLDIERS | Detects the Three Advancing White Soldiers candlestick pattern. |
talib.CDLABANDONEDBABY | Detects the Abandoned Baby candlestick pattern. |
talib.CDLADVANCEBLOCK | Detects the Advance Block candlestick pattern. |
talib.CDLBELTHOLD | Detects the Belt-hold candlestick pattern. |
talib.CDLBREAKAWAY | Detects the Breakaway candlestick pattern. |
talib.CDLCLOSINGMARUBOZU | Detects the Closing Marubozu candlestick pattern. |
talib.CDLCONCEALBABYSWALL | Detects the Concealing Baby Swallow candlestick pattern. |
talib.CDLCOUNTERATTACK | Detects the Counterattack candlestick pattern. |
talib.CDLDARKCLOUDCOVER | Detects the Dark Cloud Cover candlestick pattern. |
talib.CDLDOJI | Detects the Doji candlestick pattern. |
talib.CDLDOJISTAR | Detects the Doji Star candlestick pattern. |
talib.CDLDRAGONFLYDOJI | Detects the Dragonfly Doji candlestick pattern. |
talib.CDLENGULFING | Detects the Engulfing Pattern candlestick pattern. |
talib.CDLEVENINGDOJISTAR | Detects the Evening Doji Star candlestick pattern. |
talib.CDLEVENINGSTAR | Detects the Evening Star candlestick pattern. |
talib.CDLGAPSIDESIDEWHITE | Detects the Up/Down-gap side-by-side white lines candlestick pattern. |
talib.CDLGRAVESTONEDOJI | Detects the Gravestone Doji candlestick pattern. |
talib.CDLHAMMER | Detects the Hammer candlestick pattern. |
talib.CDLHANGINGMAN | Detects the Hanging Man candlestick pattern. |
talib.CDLHARAMI | Detects the Harami Pattern candlestick pattern. |
talib.CDLHARAMICROSS | Detects the Harami Cross Pattern candlestick pattern. |
talib.CDLHIGHWAVE | Detects the High-Wave Candle candlestick pattern. |
talib.CDLHIKKAKE | Detects the Hikkake Pattern candlestick pattern. |
talib.CDLHIKKAKEMOD | Detects the Modified Hikkake Pattern candlestick pattern. |
talib.CDLHOMINGPIGEON | Detects the Homing Pigeon candlestick pattern. |
talib.CDLIDENTICAL3CROWS | Detects the Identical Three Crows candlestick pattern. |
talib.CDLINNECK | Detects the In-Neck Pattern candlestick pattern. |
talib.CDLINVERTEDHAMMER | Detects the Inverted Hammer candlestick pattern. |
talib.CDLKICKING | Detects the Kicking candlestick pattern. |
talib.CDLKICKINGBYLENGTH | Detects the Kicking - bull/bear determined by the longer marubozu candlestick pattern. |
talib.CDLLADDERBOTTOM | Detects the Ladder Bottom candlestick pattern. |
talib.CDLLONGLEGGEDDOJI | Detects the Long Legged Doji candlestick pattern. |
talib.CDLLONGLINE | Detects the Long Line Candle candlestick pattern. |
talib.CDLMARUBOZU | Detects the Marubozu candlestick pattern. |
talib.CDLMATCHINGLOW | Detects the Matching Low candlestick pattern. |
talib.CDLMATHOLD | Detects the Mat Hold candlestick pattern. |
talib.CDLMORNINGDOJISTAR | Detects the Morning Doji Star candlestick pattern. |
talib.CDLMORNINGSTAR | Detects the Morning Star candlestick pattern. |
talib.CDLONNECK | Detects the On-Neck Pattern candlestick pattern. |
talib.CDLPIERCING | Detects the Piercing Pattern candlestick pattern. |
talib.CDLRICKSHAWMAN | Detects the Rickshaw Man candlestick pattern. |
talib.CDLRISEFALL3METHODS | Detects the Rising/Falling Three Methods candlestick pattern. |
talib.CDLSEPARATINGLINES | Detects the Separating Lines candlestick pattern. |
talib.CDLSHOOTINGSTAR | Detects the Shooting Star candlestick pattern. |
talib.CDLSHORTLINE | Detects the Short Line Candle candlestick pattern. |
talib.CDLSPINNINGTOP | Detects the Spinning Top candlestick pattern. |
talib.CDLSTALLEDPATTERN | Detects the Stalled Pattern candlestick pattern. |
talib.CDLSTICKSANDWICH | Detects the Stick Sandwich candlestick pattern. |
talib.CDLTAKURI | Detects the Takuri (Dragonfly Doji with very long lower shadow) candlestick pattern. |
talib.CDLTASUKIGAP | Detects the Tasuki Gap candlestick pattern. |
talib.CDLTHRUSTING | Detects the Thrusting Pattern candlestick pattern. |
talib.CDLTRISTAR | Detects the Tristar Pattern candlestick pattern. |
talib.CDLUNIQUE3RIVER | Detects the Unique 3 River candlestick pattern. |
talib.CDLUPSIDEGAP2CROWS | Detects the Upside Gap Two Crows candlestick pattern. |
talib.CDLXSIDEGAP3METHODS | Detects the Upside/Downside Gap Three Methods candlestick pattern. |
OS
| Name | Description |
|---|---|
ListFilesResult | File list object used to record directory listing information. |
FileStat | File statistics information object. |
OS/os
| Name | Description |
|---|---|
os.open | Open a file in the specified mode. |
os.fgets | Read the entire file content at once. |
os.fputs | Write content to a file. |
os.mmap | Reads the whole file and returns its binary data as an ArrayBuffer. |
os.getRootDir | Get the root directory path for file operations. |
os.listFiles | List files and subdirectories in the specified directory. |
os.exists | Check if the specified file or directory exists. |
os.remove | Delete the specified file or empty directory. |
os.mkdir | Create a directory. |
os.rmdir | Remove a directory and all its contents. |
os.rename | Rename a file or move a file. |
os.stat | Get detailed statistics information of a file. |
os.exit | Exit the program. |
OS/File
| Name | Description |
|---|---|
File.close | Close the file and release associated resources. |
File.puts | Write one or more strings to a file. |
File.printf | Write formatted data to file. |
File.flush | Flush the file buffer to ensure data is written to disk. |
File.tell | Get the current file pointer position. |
File.seek | Move the file pointer to a specified position. |
File.eof | Check if the file pointer has reached the end of file. |
File.read | Read data from a file. |
File.write | Write string data to a file. |
File.getline | Read the next line from the file. |
File.toString | Get the string representation of the file object. |
Structures
| Name | Description |
|---|---|
Ticker | Market data returned by exchange.GetTicker(): high, low, best ask, best bid, last price, open, volume and open interest. |
Depth | Market depth returned by exchange.GetDepth(): the asks Asks and bids Bids (OrderBook arrays) and a timestamp. |
OrderBook | One price level of the asks or bids in market depth (Depth): price and amount. |
Trade | Returned by exchange.GetTrades(): a market trade's ID, time, price, amount and side. |
Record | Data structure for candlestick bars in standard OHLC format, used for charting candlesticks and calculating technical indicators. |
Market | Returned by exchange.GetMarkets(): an instrument's base and quote assets, price and amount steps and precisions, order quantity and notional limits, and contract value. |
Order | Returned by exchange.GetOrder(), exchange.GetOrders() and similar: order ID, price, amount, filled amount, average price, status, type, offset, contract code and conditional order settings. |
Condition | Conditional order settings: the conditional order type and the take-profit and stop-loss trigger and order prices, used to set the trigger conditions and execution prices of conditional orders. |
Account | Returned by exchange.GetAccount(): the available and frozen amounts of the quote and base currencies, plus equity and unrealized profit and loss on futures. |
Asset | One item of the array returned by exchange.GetAssets(): the available and frozen amounts of one currency. |
Position | Returned by exchange.GetPositions(): instrument, leverage, amount and frozen amount, average price, unrealized profit, direction, contract code and margin. |
Funding | Returned by exchange.GetFundings(): instrument, settlement interval, time and funding rate; only cryptocurrency perpetual contracts have funding rates. |
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 parameter structure while calling the HttpQuery function. |
LogStatus-table | Status bar table output with LogStatus: columns can set number formats, up/down colors and units; cells can be merged or hold buttons; several tables can be shown as tabs. |
LogStatus-btnTypeOne | Older form of the status bar button structure (input controls without settings), still supported. |
LogStatus-btnTypeTwo | JSON structure of a status bar button (current form, with settings on input controls). |
Chart-options | This JSON is used to configure chart settings for the custom plotting function Chart(). |
Chart-return | The chart object returned by Chart, used to write data, update the configuration and clear the chart. |
KLineChart-options | This JSON is used to configure the chart settings for the custom drawing function KLineChart. |
KLineChart-return | The chart object returned by KLineChart, which draws on K-lines in a Pine-like way. |
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. |
exchange.Go-return | The concurrent object returned by exchange.Go; its wait() method returns the result of the concurrent call. |
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 exec() method of objects created by the Dial() function. |
Dial-return | The connection object returned by Dial. |
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 threads in JavaScript language strategies. |
OtherStruct/LogStatus-display
| Name | Description |
|---|---|
grid | Arranges components in columns and drops columns automatically when the container gets narrow. |
tabs | Groups components into tabs; the selected tab is kept when the status bar refreshes. |
kpi | Shows one prominent number with optional unit, change and hint, for equity, returns or the last price. |
stat | Lists label and value pairs, for details such as balances, frozen funds, leverage or liquidation price. |
progress | Shows a ratio, or current value / total, as a bar. |
gauge | Shows where a value sits in a range on a half-circle dial, with optional threshold colors; for RSI, exposure or risk. |
sparkline | Shows a number with a small trend line, colored by the first-to-last change by default. |
chart | Draws line, bar or area charts with several series, a right axis and buy/sell marks; use Chart for more options. |
heatmap | Shades a 2D grid by value, for returns by period and symbol or correlation matrices. |
calendar | Shows returns as daily heat cells (like a contribution graph) or as a year × month table. |
histogram | Bins raw data automatically and shows the counts with sample size, mean, median and share of positive values. |
pie | Shows the share of each part in the total; a donut by default with the total in the center. |
timeline | Lists events in order, for fills, trading signals or risk events. |
markdown | Renders Markdown text with headings, lists, bold and tables, for strategy notes and market commentary. |
alert | Shows an info, success, warning or error message with an icon, for risk and error notices. |
badge | Shows small labels with a dot inline, so they can follow a line of text. |
Built-in Variables and Constants
EXCHANGE
| Name | Description |
|---|---|
exchange | The first exchange object added in the strategy live trading settings and backtesting settings. |
exchanges | An array of exchange objects that contains all the exchange objects added in the strategy's live trading settings or backtesting settings, where exchanges[0] is exchange. |
ORDER_STATE
| Name | Description |
|---|---|
ORDER_STATE_PENDING | The order is pending (open, possibly partially filled); the value is 0. |
ORDER_STATE_CLOSED | The order is completed (fully filled); the value is 1. |
ORDER_STATE_CANCELED | The order is canceled; the value is 2. |
ORDER_STATE_UNKNOWN | The order status is unknown (any other status); the value is 3. |
ORDER_TYPE
| Name | Description |
|---|---|
ORDER_TYPE_BUY | A buy order; the value is 0. |
ORDER_TYPE_SELL | A sell order; the value is 1. |
ORDER_CONDITION_TYPE
| Name | Description |
|---|---|
ORDER_CONDITION_TYPE_OCO | An OCO order (One-Cancels-the-Other): take-profit and stop-loss conditions are set together, and when one triggers the other is canceled automatically; the value is 0. |
ORDER_CONDITION_TYPE_TP | A take-profit order: an order is placed when the price reaches the take-profit trigger price; the value is 1. |
ORDER_CONDITION_TYPE_SL | A stop-loss order: an order is placed when the price reaches the stop-loss trigger price, to limit losses; the value is 2. |
ORDER_CONDITION_TYPE_GENERIC | A generic conditional order: its behavior depends on the exchange, and it only appears in query results; the value is 3. |
POSITION_DIRECTION
| Name | Description |
|---|---|
PD_LONG | A long position; the value is 0. |
PD_SHORT | A short position; the value is 1. |
ORDER_OFFSET
| Name | Description |
|---|---|
ORDER_OFFSET_OPEN | An opening order; the value is 0. |
ORDER_OFFSET_CLOSE | A closing order; the value is 1. |
PERIOD
| Name | Description |
|---|---|
PERIOD_M1 | 1-minute K-line period; the value is 60. |
PERIOD_M3 | 3-minute K-line period; the value is 180. |
PERIOD_M5 | 5-minute K-line period; the value is 300. |
PERIOD_M15 | 15-minute K-line period; the value is 900. |
PERIOD_M30 | 30-minute K-line period; the value is 1800. |
PERIOD_H1 | 1-hour K-line period; the value is 3600. |
PERIOD_H2 | 2-hour K-line period; the value is 7200. |
PERIOD_H4 | 4-hour K-line period; the value is 14400. |
PERIOD_H6 | 6-hour K-line period; the value is 21600. |
PERIOD_H12 | 12-hour K-line period; the value is 43200. |
PERIOD_D1 | 1-day K-line period; the value is 86400. |
PERIOD_D3 | 3-day K-line period; the value is 259200. |
PERIOD_W1 | 1-week K-line period; the value is 604800. |
LOG_TYPE
| Name | Description |
|---|---|
LOG_TYPE_BUY | A buy order log; the value is 0. |
LOG_TYPE_SELL | A sell order log; the value is 1. |
LOG_TYPE_CANCEL | An order cancellation log; the value is 2. |
Conventions
| Name | Description |
|---|---|
Symbols | Functions of exchange objects specify an instrument with the string parameter symbol. |
Failures and null values | ### Failed calls return a null value |
Exchanges
| Name | Description |
|---|---|
Capability Matrix | Support of the standard functions and trading-mode commands per exchange object. |