Multi Platform Forced Sliding Closing Buy One Price
Support closing positions across multiple platforms; sell as many coins as available.
JavaScriptOther
Support closing positions across multiple platforms; sell as many coins as available.
Parameters
| Name | Default | What it controls |
|---|---|---|
| RetryInterval | 5 | Retry Interval (Seconds)) |
| SlidePrice | 0.3 | Slide Value |
| KeepStock | false | Reserved coins |
Source JavaScript
function cancelAllOrders() {
var orders = null;
while (!(orders = exchange.GetOrders())) {
Sleep(Interval);
}
if (orders.length > 0) {
for (var j = 0; j < orders.length; j++) {
exchange.CancelOrder(orders[j].Id);
if (j < (orders.length-1)) {
Sleep(2000);
}
}
}
}
function sellAll() {
cancelAllOrders();
var initAccount = _C(exchange.GetAccount);
Log(exchange.GetName(), exchange.GetCurrency(), initAccount);
if (initAccount.Stocks == 0) {
Log("Short position");
return;
}
var remaind = initAccount.Stocks - KeepStock;
var account = initAccount;
while (remaind >= 0.001) {
var ticker = _C(exchange.GetTicker);
exchange.Sell(ticker.Buy - SlidePrice, remaind);
Sleep(RetryInterval * 1000);
cancelAllOrders();
account = _C(exchange.GetAccount);
remaind = account.Stocks - KeepStock;
}
Log("Average selling price", (account.Balance - initAccount.Balance) / (initAccount.Stocks - account.Stocks));
Log(account);
}
function main() {
for (var i = 0; i < exchanges.length; i++) {
exchange = exchanges[i];
sellAll();
}
}
Published by Zero on the FMZ strategy square · last modified 2018-03-27. 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-Forced-Sliding-Closing-Buy-One-Price.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.