0bps

Strategy vault / Other

Test Real Network Latency Between Hosts and Exchange Servers Supports Testing Multiple Exchanges Simultaneously

Contact : [email protected] / WeChat@stay37 This strategy is to test the real network delay between the host and the server. The test method is: compare the time of sending the request and the time of receiving the…

PythonOther
Author
Xueqiu Bot
Complexity
Starter · 31 lines
Parameters
0

Contact : [email protected] / WeChat@stay37 This strategy is to test the real network delay between the host and the server. The test method is: compare the time of sending the request and the time of receiving the result, and take the average multiple times. Supports simultaneous testing of multiple exchanges. Just add different trading platforms, but the numpy module needs to be installed.

Source Python

# Contact : [email protected] / WeChat@stay37

import time
import numpy as np


def test():
    #Delayed data receiver
    delay_list = []
    for i in range(len(exchanges)):
        delay_list.append([])
    while True:
        #Delayed data acquisition
        for i in range(len(exchanges)):
            send_t = time.time()
            ticker = exchanges[i].GetTicker()
            delay_list[i].append(round((time.time() - send_t) * 1000 , 2))
        #Data Output 
        delay_table = {"type":'table',"title":'Latency Data',"cols": ['Account Serial Number','Latest Delay','Average Latency','Number of Tests Completed.''],"rows":[]}
        for i in range(len(delay_list)):
            delay_table['rows'].append([i + 1, str(delay_list[i][-1])+' ms', str(round(np.mean(delay_list[i]) , 2)) + ' ms', len(delay_list[i])])
        LogStatus("Output delay is: send onceget_tickerThe real time from request to data retrieval" + "\n" + "`" + json.dumps(delay_table) + "`")
        time.sleep(0.05)

                
def main():
    for i in range(len(exchanges)):
        exchanges[i].SetContractType('swap')
    test()
                

Published by Xueqiu Bot on the FMZ strategy square · last modified 2021-01-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/Test-Real-Network-Latency-Between-Hosts-and-Exchange-Servers-Supports-Testing-Multiple-Exchanges-Simultaneously.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