Type/to search
Built-in Functions
Global
Version
IsVirtual
GetOS
GetPid
GetMeta
Sleep
Unix
UnixNano
_D
GetCommand
GetLastError
SetErrorFilter
_N
_C
_Cross
JSON.parse
JSON.stringify
Encode
MD5
UUID
Log
Market
Trade
Account
Futures
Exchange
IO
Network
Storage
Threads
TA
Talib
Overlap Studies
Momentum Indicators
Volume Indicators
Volatility Indicators
Cycle Indicators
Price Transform
Statistic Functions
Math Transform
Math Operators
Pattern Recognition
OS
Structures
Built-in Variables and Constants
Conventions
Exchanges

Get the Meta value written when generating the strategy registration code.

GetMeta()

Examples

  • Read the Meta written when the registration code was generated.

    javascript
    function main() { var meta = GetMeta() Log("Meta", meta) // Output: Meta level1 (the value written with the registration code; null if none) }
    python
    def main(): meta = GetMeta() Log("Meta", meta) # Output: Meta level1 (the value written with the registration code; null if none)
    rust
    fn main() { let meta = GetMeta(); Log!("Meta", meta); // Output: Meta level1 (the value written with the registration code; null if none) }
  • Application scenario example: Use Meta to limit the number of assets the strategy can operate.

    javascript
    function main() { // The maximum asset value of the quote currency allowed by the strategy var maxBaseCurrency = null // Get the metadata when creating the registration code var level = GetMeta() // Check the condition corresponding to Meta if (level == "level1") { // -1 means no limit maxBaseCurrency = -1 } else if (level == "level2") { maxBaseCurrency = 10 } else if (level == "level3") { maxBaseCurrency = 1 } else { maxBaseCurrency = 0.5 } while(1) { Sleep(1000) var ticker = exchange.GetTicker() // Check the asset value var acc = exchange.GetAccount() if (maxBaseCurrency != -1 && maxBaseCurrency < acc.Stocks + acc.FrozenStocks) { // Stop executing the strategy trading logic LogStatus(_D(), "level:", level, "Position exceeds registration code limit, strategy trading logic will not execute!") continue } // Other trading logic // Normally output the status bar information LogStatus(_D(), "level:", level, "Strategy running normally! ticker data:\n", ticker) } }
    python
    def main(): maxBaseCurrency = None level = GetMeta() if level == "level1": maxBaseCurrency = -1 elif level == "level2": maxBaseCurrency = 10 elif level == "level3": maxBaseCurrency = 1 else: maxBaseCurrency = 0.5 while True: Sleep(1000) ticker = exchange.GetTicker() acc = exchange.GetAccount() if maxBaseCurrency != -1 and maxBaseCurrency < acc["Stocks"] + acc["FrozenStocks"]: LogStatus(_D(), "level:", level, "Position exceeds registration code limit, strategy trading logic will not execute!") continue # Other trading logic # Normally output the status bar information LogStatus(_D(), "level:", level, "Strategy running normally! ticker data:\n", ticker)
    rust
    fn main() { // The maximum asset value of the quote currency allowed by the strategy let maxBaseCurrency; // Get the metadata when creating the registration code, Rust's GetMeta() returns a JsonValue // type let meta = GetMeta(); let level = meta.as_str().unwrap_or(""); // Check the condition corresponding to Meta if level == "level1" { // -1 means no limit maxBaseCurrency = -1.0; } else if level == "level2" { maxBaseCurrency = 10.0; } else if level == "level3" { maxBaseCurrency = 1.0; } else { maxBaseCurrency = 0.5; } loop { Sleep(1000); let ticker = exchange.GetTicker(None).unwrap(); // Check the asset value let acc = exchange.GetAccount().unwrap(); if maxBaseCurrency != -1.0 && maxBaseCurrency < acc.Stocks + acc.FrozenStocks { // Stop executing the strategy trading logic LogStatus!(_D(None), "level:", level, "Position exceeds registration code limit, strategy trading logic will not execute!"); continue; } // Other trading logic // Normally output the status bar information LogStatus!(_D(None), "level:", level, "Strategy running normally! ticker data:\n", ticker); } }

Returns

TypeDescription

string

Meta data.

See Also

Remarks

Application scenario: You need to impose fund restrictions on different strategy lessees. The length of the Meta value set when generating the registration code cannot exceed 190 characters. The GetMeta() function is only supported in live trading and does not work in the backtesting system. If the metadata (Meta) is not set when generating the strategy registration code, the GetMeta() function will return an empty value.