0bps

Strategy vault / DCA & fixed investment

100USDT Invested Every Week Regular Variable Investment

Fixed investment of about 100 USDT every week, with no fixed amount on a regular basis. Buy more when it goes down, buy less when it goes up, and the rate of return is better than the fixed amount.

Author
jfyh5388
Complexity
Starter · 23 lines
Parameters
0

Fixed investment of about 100 USDT every week, with no fixed amount on a regular basis. Buy more when it goes down, buy less when it goes up, and the rate of return is better than the fixed amount.

Source Python

def main():
    amountAll = 0                                              #Total Holdings
    cost = 0                                                   #Cost
    marketValueCurrent = 0                                     #Current total market value of holdings
    marketValueExpected = 0                                    #Current expected total market capitalization
    rateOfReturn = 0                                           #Yield
    eachBuy = 100
    while True:
        marketValueExpected = marketValueExpected + eachBuy        #Calculate the current expected total market value
        ticker = exchange.GetTicker()
        price = ticker['Last']                                 #Get current price
        amount = marketValueExpected / price - amountAll       #Calculate the purchase amount this time
        if amount > 0:
            exchange.Buy(price,amount)                         #buy         
        else:
            amount = 0
        amountAll = amountAll + amount                         #Calculate total holding amount
        cost = cost + amount * price                           #Calculate total cost
        marketValueCurrent = amountAll * price                 #Calculate the current total market value held
        rateOfReturn = (marketValueCurrent - cost) / cost      #Calculate return rate
        Log("Amount invested this time:", amount * price, "Principal:", cost,"Current total holdings", amountAll,"Current total market value:", marketValueCurrent, "Yield:", rateOfReturn * 100,"%" ,"Current Price:", price, )
        Sleep(7 * 24 * 60 * 60 * 1000)                         #Wait for a Week
                    

Published by jfyh5388 on the FMZ strategy square · last modified 2021-04-16. 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/100USDT-Invested-Every-Week-Regular-Variable-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