Simple Iceberg order to buy
Very simple, just for learn. Code is best annotation. Iceberg entrusted buying, which divides the order into small M purchases to avoid impacting the market, is a good learning strategy for simple entry into Bitcoin…
Very simple, just for learn. Code is best annotation.
Iceberg entrusted buying, which divides the order into small M purchases to avoid impacting the market, is a good learning strategy for simple entry into Bitcoin quantitative trading.
Parameters
| Name | Default | What it controls |
|---|---|---|
| BUYAMOUNT | 2 | amount to buy |
| BUYSIZE | 0.1 | iceberg order size |
| INTERVAL | 3 | orders exist time(second) |
Source JavaScript
function main(){
var initAccount = _C(exchange.GetAccount)
while(true){
var account = _C(exchange.GetAccount)
var dealAmount = account.Stocks - initAccount.Stocks
var ticker = _C(exchange.GetTicker)
if(BUYAMOUNT - dealAmount > BUYSIZE){
var id = exchange.Buy(ticker.Sell, BUYSIZE)
Sleep(INTERVAL*1000)
if(id){
exchange.CancelOrder(id) // May cause error log when the order is completed, which is all right.
}else{
throw 'buy error'
}
}else{
account = _C(exchange.GetAccount)
var avgCost = (initAccount.Balance - account.Balance)/(account.Stocks - initAccount.Stocks)
Log('Iceberg order to buy is done, avg cost is ', avgCost) // including fee cost
return
}
}
}Published by 小草 on the FMZ strategy square · last modified 2020-03-20. 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/Simple-Iceberg-order-to-buy.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.