Multi Platform Account Statistics
Multi-Platform Account Statistics
JavaScriptOther
Multi-Platform Account Statistics
Parameters
| Name | Default | What it controls |
|---|---|---|
| Interval | 20 | Detection Interval (Seconds)) |
| Type | 0 | Display type: Total assets | Net assets | Total money | Total coins |
| coverStocks | false | Total coins to close |
| Thr | 0.1 | Report threshold |
Source JavaScript
function EnsureCall(e, method) {
var r;
while (!(r = e[method].apply(this, Array.prototype.slice.call(arguments).slice(2)))) {
Sleep(Interval);
}
return r;
}
var lastReport = 0;
function onTick() {
var allBalance = 0;
var allStocks = 0;
var asset = 0;
for (var i = 0; i < exchanges.length; i++) {
var account = EnsureCall(exchanges[i],"GetAccount");
var ticker = EnsureCall(exchanges[i],"GetTicker");
allBalance += account.Balance + account.FrozenBalance;
allStocks += account.Stocks + account.FrozenStocks;
asset += (account.Balance + account.FrozenBalance) + (account.Stocks + account.FrozenStocks) * ticker.Last;
}
if (Type === 0 && Math.abs(asset - lastReport) >= Thr) {
LogProfit(asset, "Total money:", allBalance, "Total coins:", allStocks, "Total assets:", asset);
lastReport = asset;
}
else if (Type == 1) {
var netAsset = asset - coverStocks * (asset - allBalance) / allStocks;
if (Math.abs(netAsset - lastReport) >= Thr) {
LogProfit(netAsset, "Total money:", allBalance, "Total coins:", allStocks, "Total assets:", asset);
lastReport = netAsset;
}
}
else if (Type == 2 && Math.abs(allBalance - lastReport) >= Thr){
LogProfit(allBalance, "Total money:", allBalance, "Total coins:", allStocks, "Total assets:", asset);
lastReport = allBalance;
}
else if (Type == 3 && Math.abs(allStocks - lastReport) >= Thr) {
LogProfit(allStocks, "Total money:", allBalance, "Total coins:", allStocks, "Total assets:", asset);
lastReport = allStocks;
}
}
function main() {
while (1) {
onTick();
Sleep(Interval*1000);
}
}
Published by 数·狂 on the FMZ strategy square · last modified 2015-12-08. 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-Platform-Account-Statistics.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.