Strategy vault / Tools & templates
Monitor and Display the Changes in the Total Assets Across Multiple Platforms
Monitor and display the total assets of multiple platforms. It will be re-displayed when the account funds change. The money and coins of all platforms will be converted into net assets and displayed in the income curve.
Monitor and display the total assets of multiple platforms. It will be re-displayed when the account funds change. The money and coins of all platforms will be converted into net assets and displayed in the income curve.
Parameters
| Name | Default | What it controls |
|---|---|---|
| Interval | 1000 | Retry on failure (milliseconds)) |
| TickInterval | 5000 | monitoring frequency (milliseconds)) |
Source JavaScript
var LastState = null;
function adjustFloat(v) {
return Math.floor(v*1000)/1000;
}
function getExchangesState() {
var isUpdate = false;
var allBalance = 0;
var allNetStocks = 0;
var Cache = [];
var CurrencyCache = [];
for (var i = 0; i < exchanges.length; i++) {
var account = null;
var ticker = null;
while (!(account = exchanges[i].GetAccount())) {
Sleep(Interval);
}
while (!(ticker = exchanges[i].GetTicker())) {
Sleep(Interval);
}
var name = typeof(exchanges[i].GetLabel) == 'undefined' ? exchanges[i].GetName() : exchanges[i].GetLabel();
var currency = exchanges[i].GetCurrency();
if (typeof(CurrencyCache[currency]) == 'undefined') {
CurrencyCache[currency] = 0;
}
CurrencyCache[currency] = adjustFloat(CurrencyCache[currency] + account.Stocks + account.FrozenStocks);
if (typeof(Cache[name]) == 'undefined') {
Cache[name] = true;
allBalance += account.Balance + account.FrozenBalance;
}
allNetStocks += (account.Stocks + account.FrozenStocks) * ticker.Last;
}
var update = false;
var str = "";
for (var currency in CurrencyCache) {
str += ' '+currency + ': ' + CurrencyCache[currency];
if (LastState != null) {
if (LastState.CurrencyCache[currency] != CurrencyCache[currency]) {
update = true;
}
}
}
allBalance = adjustFloat(allBalance);
if (LastState != null) {
if (LastState.allBalance != allBalance) {
update = true;
}
}
return {allStocks: str, Net: adjustFloat(allNetStocks + allBalance), CurrencyCache: CurrencyCache, allBalance: allBalance, update: (LastState == null) || update};
}
function main() {
Log("All platform funds and coins will be converted into net assets and displayed on the profit curve");
while (true) {
var state = getExchangesState();
if (state.update) {
LastState = state;
Log('Total Money: ', state.allBalance, 'Total Coins: ', state.allStocks);
LogProfit(state.Net);
}
Sleep(Math.max(TickInterval, 100));
}
}Published by Zero on the FMZ strategy square · last modified 2014-12-04. 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 tested, production-ready module from strategies/Monitor-and-Display-the-Changes-in-the-Total-Assets-Across-Multiple-Platforms.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.
Related specs
- Binance Account Cross Transfer Small ToolJavaScript · Tools & templates
- Get cryptocurrency current and max supplyJavaScript · Tools & templates
- Interaction TemplateJavaScript · Tools & templates
- KuCoin Fund Transfer PluginJavaScript · Tools & templates
- Moving Average Bot 30 linesJavaScript · Tools & templates · 1d
- OKEx V5 Candlestick Data Paginated Query ExampleJavaScript · Tools & templates