Files
strategies/冰山委托卖出简单版Simple-Iceberg-order-to-sell.md
T

65 lines
1.5 KiB
Markdown
Raw Normal View History

2018-12-08 12:40:55 +08:00
2023-07-14 18:39:48 +08:00
> Name
2018-12-08 12:40:55 +08:00
2023-04-18 23:12:35 +08:00
冰山委托卖出简单版Simple-Iceberg-order-to-sell
2018-12-08 12:40:55 +08:00
2023-07-14 18:39:48 +08:00
> Author
2018-12-08 12:40:55 +08:00
2020-01-02 17:51:10 +08:00
小草
2018-12-08 12:40:55 +08:00
2023-07-14 18:39:48 +08:00
> Strategy Description
2018-12-08 12:40:55 +08:00
Very simple, just for learn.
Code is best annotation.
2019-07-09 12:09:54 +08:00
冰山委托卖出,将订单分成小笔卖出,避免冲击市场,是很好的简单入门比特币量化交易的学习策略
2023-07-14 18:39:48 +08:00
> Strategy Arguments
2018-12-08 12:40:55 +08:00
2023-07-14 18:39:48 +08:00
|Argument|Default|Description|
2018-12-08 12:40:55 +08:00
|----|----|----|
|SELLAMOUNT|2|amount to sell|
|SELLSIZE|0.1|sell orders size|
|INTERVAL|3|order exist time(second)|
2023-07-14 18:39:48 +08:00
> Source (javascript)
2018-12-08 12:40:55 +08:00
``` 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)
Log('Iceberg order to sell is done, avg price is ', avgCost) // including fee cost
return
}
}
}
```
2023-07-14 18:39:48 +08:00
> Detail
2018-12-08 12:40:55 +08:00
https://www.fmz.com/strategy/121524
2023-07-14 18:39:48 +08:00
> Last Modified
2018-12-08 12:40:55 +08:00
2019-07-09 12:09:54 +08:00
2019-07-03 16:39:19