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-07-14 18:39:48 +08:00
|
|
|
> Author
|
2018-12-08 12:40:55 +08:00
|
|
|
|
|
|
|
|
ankye
|
|
|
|
|
|
2023-07-14 18:39:48 +08:00
|
|
|
> Strategy Description
|
2017-11-30 19:47:11 +08:00
|
|
|
|
|
|
|
|
数字货币通用定投策略,支持多交易所同时定投
|
|
|
|
|
|
|
|
|
|
# 参数说明
|
|
|
|
|
orderAmount #定投金额 BTCCNY和BCCCNY 单位 CNY, BCCBTC 单位 BTC 等等
|
|
|
|
|
|
|
|
|
|
accountLimitMoney #账户限额,保留一部分钱,账户达到最低限额就停止定投
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orderTimeInterval #定投间隔,单位秒, 每分钟=60 每小时= 3600 每天=86400 每周=604800
|
|
|
|
|
|
|
|
|
|
maxBidPrice #最大交易价格,超过价格就跳过,等待下次交易机会出现
|
|
|
|
|
|
2023-07-14 18:39:48 +08:00
|
|
|
> Strategy Arguments
|
2017-11-30 19:47:11 +08:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|----|----|----|
|
|
|
|
|
|orderAmount|true|order amount|
|
|
|
|
|
|maxBidPrice|false|max bid price|
|
|
|
|
|
|accountLimitMoney|false|account limit money|
|
|
|
|
|
|orderTimeInterval|60|Order Time Interval|
|
|
|
|
|
|
|
|
|
|
|
2023-07-14 18:39:48 +08:00
|
|
|
> Source (python)
|
2018-12-08 12:40:55 +08:00
|
|
|
|
|
|
|
|
``` python
|
2017-11-30 19:47:11 +08:00
|
|
|
def onTick():
|
|
|
|
|
|
|
|
|
|
exchange_count = len(exchanges)
|
|
|
|
|
for i in range(exchange_count):
|
|
|
|
|
account = exchanges[i].GetAccount()
|
|
|
|
|
|
|
|
|
|
marketName = exchanges[i].GetName()
|
|
|
|
|
depth = exchanges[i].GetDepth()
|
|
|
|
|
Log("Market ",marketName,exchanges[i].GetCurrency(),"Account Balance [",account["Balance"],"] Stocks[",account["Stocks"],"]")
|
|
|
|
|
if account and depth and account["Balance"] > accountLimitMoney :
|
|
|
|
|
bidPrice = depth["Asks"][0]["Price"]
|
|
|
|
|
if bidPrice < maxBidPrice :
|
|
|
|
|
amount = orderAmount
|
|
|
|
|
if amount <= account["Balance"]:
|
|
|
|
|
exchanges[i].Buy(amount)
|
|
|
|
|
else:
|
|
|
|
|
Log("Account Balance is less than bid Amount")
|
|
|
|
|
else:
|
|
|
|
|
Log("Bid Price >= maxBidPrice, not process")
|
|
|
|
|
else:
|
|
|
|
|
Log("Account Balance <= accountLimitMoney")
|
|
|
|
|
def main() :
|
|
|
|
|
while 1:
|
|
|
|
|
|
|
|
|
|
onTick()
|
|
|
|
|
time.sleep(orderTimeInterval)
|
2018-12-08 12:40:55 +08:00
|
|
|
```
|
|
|
|
|
|
2023-07-14 18:39:48 +08:00
|
|
|
> Detail
|
2018-12-08 12:40:55 +08:00
|
|
|
|
|
|
|
|
https://www.fmz.com/strategy/54256
|
|
|
|
|
|
2023-07-14 18:39:48 +08:00
|
|
|
> Last Modified
|
2018-12-08 12:40:55 +08:00
|
|
|
|
|
|
|
|
2017-09-08 14:43:38
|