0bps

Strategy vault / DCA & fixed investment

Digital Currency Fixed Investment

Universal fixed investment strategy for digital currencies, supporting simultaneous fixed investment on multiple exchanges orderAmount Fixed investment amount: BTCCNY and BCCCNY in CNY, BCCBTC in BTC, etc…

Author
ankye
Complexity
Starter · 26 lines
Parameters
4

Universal fixed investment strategy for digital currencies, supporting simultaneous fixed investment on multiple exchanges

Parameter description

orderAmount #Fixed investment amount: BTCCNY and BCCCNY in CNY, BCCBTC in BTC, etc.

accountLimitMoney #Account limit: keep some money. When the account reaches the minimum limit, stop fixed investment

orderTimeInterval #Regular casting interval, in seconds, per minute = 60 Per hour = 3600 per day = 86400 per week=604800

maxBidPrice #Maximum trading price. Skip if exceeded, wait for the next trading opportunity

Parameters

NameDefaultWhat it controls
orderAmounttrueorder amount
maxBidPricefalsemax bid price
accountLimitMoneyfalseaccount limit money
orderTimeInterval60Order Time Interval

Source Python

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)

Published by ankye on the FMZ strategy square · last modified 2017-09-08. 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 production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Digital-Currency-Fixed-Investment.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