संसाधन लोड हो रहा है... लोड करना...

onexit ((()

onexit(), प्रसंस्करण सफाई कार्य, अधिकतम 5 मिनट के निष्पादन समय के साथ, जो उपयोगकर्ता द्वारा महसूस किया जाता है।

function main(){
    Log("Start running, stop after 5 seconds, and execute onexit function!")
    Sleep(1000 * 5)
}

// onexit function implementation
function onexit(){
    var beginTime = new Date().getTime()
    while(true){
        var nowTime = new Date().getTime()
        Log("The program stops counting down..The cleaning starts and has passed:", (nowTime - beginTime) / 1000, "Seconds!")
        Sleep(1000)
    }
}
import time 
def main():
    Log("Start running, stop after 5 seconds, and execute onexit function!")
    Sleep(1000 * 5)

def onexit():
    beginTime = time.time() * 1000
    while True:
        ts = time.time() * 1000
        Log("The program stops counting down.The cleaning starts and has passed:", (nowTime - beginTime) / 1000, "Seconds!")
        Sleep(1000)
void main() {
    Log("Start running, stop after 5 seconds, and execute onexit function!");
    Sleep(1000 * 5);
}

void onexit() {
    auto beginTime = Unix() * 1000;
    while(true) {
        auto ts = Unix() * 1000;
        Log("The program stops counting down.The cleaning starts and has passed:", (nowTime - beginTime) / 1000, "Seconds!");
        Sleep(1000);
    }
}

परीक्षण करेंonexit()कार्य:

function main() {
    if (exchange.GetName().startsWith("Futures_")) {
        Log("The exchange is futures")
        exchange.SetContractType("swap")
    } else {
        Log("The 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("Execute the sweep function") 
}
def main():
    if exchange.GetName().startswith("Futures_"):
        Log("The exchange is futures")
    else:
        Log("The 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("Execute the sweep function")
#include <iostream>
#include <exception>
#include <string>

void onTick() {
    while (true) {
        auto ticker = exchange.GetTicker();
        LogStatus(_D(), ticker);
        Sleep(500);
    } 
}

void main() {
    std::string prefix = "Futures_";
    bool startsWith = exchange.GetName().substr(0, prefix.length()) == prefix;
    if (startsWith) {
        Log("The exchange is futures");
        exchange.SetContractType("swap");
    } else {
        Log("The exchange is spot");
    }

    if (IsVirtual()) {
        try {
            onTick();
        } catch (...) {
            std::cerr << "Caught unknown exception" << std::endl;
        }        
    } else {
        onTick();
    }
}

void onexit() { 
    Log("Execute the sweep function");
}

चूंकि बैकटेस्टिंग प्रणाली में रणनीति आमतौर पर एक अंतहीन लूप के रूप में डिज़ाइन की जाती है,onexit()निष्पादन रणनीति में कार्यान्वित फ़ंक्शन को बैकटेस्टिंग प्रणाली में ट्रिगर नहीं किया जा सकता है।onexit()कार्य backtesting प्रणाली के अंत चिह्न का पता लगाकर ट्रिगर किया जा सकता है (EOF अपवाद) ।

बैकटेस्ट प्रणाली आरंभ करना