리소스 로딩... 로딩...

1번 출력 (()

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()기능은 백트테스팅 시스템의 최종 표시를 감지하여 작동할 수 있습니다 (EOF 예외).

백테스트 시스템 init()