Multi Threaded Retrieval of Depth Information for Multiple Trades
Multi-threaded retrieval of depth information for multiple trades
JavaScriptOther
Multi-threaded retrieval of depth information for multiple trades
Source JavaScript
function main() {
var depths = [];
while (true) {
for (var i = 0; i < exchanges.length; i++) {
if (depths[i] == null) {
// Create Asynchronous Operation
depths[i] = exchanges[i].Go("GetDepth");
}
}
var failed = 0;
for (var i = 0; i < exchanges.length; i++) {
if (typeof(depths[i].wait) != "undefined") {
// Waiting for results
var ret = depths[i].wait();
if (ret) {
depths[i] = ret;
Log(exchanges[i].GetName(), depths[i]);
} else {
// Try again
depths[i] = null;
failed++;
}
}
}
if (failed == 0) {
break;
} else {
Sleep(100);
}
}
}
Published by Zero on the FMZ strategy square · last modified 2015-01-02. 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.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Multi-Threaded-Retrieval-of-Depth-Information-for-Multiple-Trades.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- 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.