0bps

Strategy vault / Tools & templates

Simple Iceberg order to sell Copy

Very simple, just for learn. Code is best annotation. Iceberg order selling, which divides orders into small sells to avoid market shocks, is a great strategy for beginners in Bitcoin quantitative trading The plug-in…

Author
小草
Complexity
Starter · 25 lines
Parameters
3

Very simple, just for learn. Code is best annotation.

Iceberg order selling, which divides orders into small sells to avoid market shocks, is a great strategy for beginners in Bitcoin quantitative trading The plug-in can be started with one click on the trading terminal, free of charge, and convenient for manual trading. Detailed introduction:https://www.fmz.com/digest-topic/5051

Parameters

NameDefaultWhat it controls
SELLAMOUNT2amount to sell
SELLSIZE0.1sell orders size
INTERVAL3order exist time(second)

Source JavaScript

function main(){
    var initAccount = _C(exchange.GetAccount)
    if (initAccount.Stocks < SELLAMOUNT){
        throw 'check your account amount to sell'
    }
    while(true){
        var account = _C(exchange.GetAccount)
        var dealAmount =  initAccount.Stocks - account.Stocks
        var ticker = _C(exchange.GetTicker)
        if(SELLAMOUNT - dealAmount >= SELLSIZE){
            var id = exchange.Sell(ticker.Buy, SELLSIZE)
            Sleep(INTERVAL*1000)
            if(id){
                exchange.CancelOrder(id) // May cause error log when the order is completed, which is all right.
            }else{
                throw 'sell error'
            }
        }else{
            account = _C(exchange.GetAccount)
            var avgCost = (account.Balance - initAccount.Balance)/(initAccount.Stocks - account.Stocks)
            return 'Iceberg order to sell is done, avg price is ' + avgCost
            
        }
    }
}

Published by 小草 on the FMZ strategy square · last modified 2020-03-24. 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 tested, production-ready module from strategies/Simple-Iceberg-order-to-sell-Copy.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