0bps

Strategy vault / Other

Market Center Delay

TestQuote CenterDelay

JavaScriptOther
Author
fmzero
Complexity
Starter · 52 lines
Parameters
0

TestQuote CenterDelay

IMG

Source JavaScript

function main() {
    mcc = $.NewMarketCenterClient()
    Log('support list: '+mcc.GetSupportList())
    mcc.SubscribeSpotTicker('binance.com', 'BTC_USDT', 200)
    Sleep(1000)
    Log("start...")
    var count = 0
    
    var max = -1
    var min = 9999999
    var ave = 0
    var sum = 0
    
    for(var i = 0; i < 1000; i++) {
        var start = new Date().getTime()
        var ticker = mcc.GetSpotTicker('binance.com', 'BTC_USDT')
        var end = new Date().getTime()
        if (ticker === null) {
            continue
        }
        count += 1
        var pass = end - start
        if (pass > max) {
            max = pass
        }
        if (pass < min) {
            min = pass
        }
        sum += pass
    }
    ave = sum / count
    
    var allstatus = 'Market center delay test\n'
    allstatus += "https://www.fmz.com/strategy/183009\n";
    allstatus += "♜Q:6510676#0000ff\n";
    allstatus += "♜QGroup:364655408#0000ff\n";
    allstatus += "♜WeChat: btstarinfo#0000ff\n";
    
    var table = {
        type: 'table',
        title: 'Delay test',
        cols: ['Number of tests', 'Maximum(ms)', 'Minimum(ms)', 'Avg.(ms)'],
        rows: [
            [
                count, max, min, ave
            ]
        ]
    }
    allstatus += "`" + JSON.stringify(table) + "`" + "\n";

    LogStatus(allstatus)
}

Published by fmzero on the FMZ strategy square · last modified 2020-02-10. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Market-Center-Delay.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open