0bps

Strategy vault / Other

Statistics of the Maximum Price Difference Between Platforms by JackConan

Statistics of the largest price difference between various platforms; If you want to print the market conditions of each exchange at that time, you can remove the comment // in front of //printCurPrice();;

JavaScriptOther
Author
[email protected]
Complexity
Starter · 48 lines
Parameters
0

Statistics of the largest price difference between various platforms; If you want to print the market conditions of each exchange at that time, you can remove the comment // in front of //printCurPrice();;

Source JavaScript

var maxSpace = 0;

function adjustFloat(v) {
    return Math.floor(v*1000)/1000;
}

function printCurPrice() {
    for (var i = 0; i < exchanges.length; i++) {
        Log(exchanges[i].GetName(),'=',exchanges[i].GetTicker());
    }
}

function onTick() {
    // TODO something.
    var smallPrice = 99999;
    var bigPrice = 0;
    var curPrice = 0;
    var curSpace = 0;
    
    for (var i = 0; i < exchanges.length; i++) {
        curPrice = exchanges[i].GetTicker().Buy;
        if (curPrice < smallPrice){
            smallPrice = curPrice;
        }
        if (curPrice > bigPrice){
            bigPrice = curPrice;
        }
        curSpace = bigPrice - smallPrice;
    }
    
    if (curSpace > maxSpace){
        maxSpace = curSpace;
        Log('Spread:', adjustFloat(maxSpace),'High price:', bigPrice,'Low price:', smallPrice, 'Occurrence Time →_→');
        //Print the current market quotes of each exchange;
        printCurPrice();
    }
}

function main() {
    if (exchanges.length < 2) {
        Log("The number of exchanges must be at least two to complete the statistics");
        return;
    }
    while(true) {
        onTick();
        Sleep(60000);
    }
}

Published by [email protected] on the FMZ strategy square · last modified 2014-06-22. 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/Statistics-of-the-Maximum-Price-Difference-Between-Platforms-by-JackConan.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