Regular Fixed Amount Investment in BTC Profit Verification
Buy Bitcoin each time according to a fixed amount and hold
JavaScriptOther
Buy Bitcoin each time according to a fixed amount and hold
Parameters
| Name | Default | What it controls |
|---|---|---|
| FIXED_AMOUNT | 100 | How much RMB to buy each time |
| PERIOD | 86400 | Period (unit seconds) |
Source JavaScript
var total_cny = 0;
var days = 0;
var total_btc = 0;
function main() {
var chart = createChart();
while( true) {
total_cny+=FIXED_AMOUNT;
days++;
var ticker = exchange.GetTicker();
total_btc += FIXED_AMOUNT/ticker.Last;
var current_value = ticker.Last * total_btc;
LogProfit(current_value - total_cny);
var time = new Date().getTime();
chart.add([0, [time, total_cny ]]);
chart.add([1, [time, current_value]]);
Sleep(PERIOD*1000);
}
}
function createChart() {
var options = {
rangeSelector: {
selected: 4
},
__isStock: true,
yAxis: {
labels: {
formatter: function () {
return (this.value > 0 ? ' + ' : '') + this.value + '%';
}
},
plotLines: [{
value: 0,
width: 2,
color: 'silver'
}]
},
plotOptions: {
series: {
compare: 'percent'
}
},
tooltip: {
pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/> {point.text}',
valueDecimals: 2
},
series: [
{
name: 'Cost',
data: []
},
{
name: 'Account Value',
data: []
}
]
};
return Chart(options);
}
Published by 春哥 on the FMZ strategy square · last modified 2016-06-17. 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/Regular-Fixed-Amount-Investment-in-BTC-Profit-Verification.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.