Dollar cost averaging (DCA) is a popular strategy for buying assets like bitcoin or shares, where a fixed amount of money is spent each day, irrespective of the price of the asset. When the asset falls in price, more can be purchased for the same amount of money. It is common to buy daily, weekly or monthly.
A strategy was implemented to buy bitcoin every day on the the Binance cryptocurrency exchange. Rather than buy at a fixed time each day, the time of purchasing was chosen in what was believed might allow one to accumulated more bitcoin for the same outlay.
Initially an algorithm was though of, that checked the bitcoin price each minute, and made a decision whether to buy or not. The price every minute was stored for a period of March to June 2026, giving approximately 96,000 observations of price.
Method
Initial statergy, based on a gut feeling, rather than any statistical analysis.
The work started by crating a Python script, with the aid of ChatGPT, which used the Binance API and bought BTC once ever calandar day. The strategy was to execute a script every minute of every day using cron on a Debian server. The script determined.
This corresponds to a price 15% of the way between the 24-hour low and the 24-hour high.
If the current_price was below the trigger_price, BTC was purchased.
If BTC was bought, no further buys would take place that day.
If the condition current_price < trigger_price: was not met any time up until 23:59 UTC, a buy would occur at 23:59 UTC.
The amount spent on BTC was the same each day. irrespective of whether the buy occurred at 23:59 or before then.
It was believed this strategy may work, giving an improvement over DCA, but clearly this needed to be tested properly. Due to lack of time, this was not initially tested, and just allowed to run.
Statistical analysis of historical bitcoin price.
A historical data set of BTC price on the Bitstamp excange is available from Github reporisotry. This coverses the period 1st January 2002 to the present day. One file contains data up to 2015, and a second file, unpdated daily, contains more recent data. The
First the data was downloaded an. An inspection showed the start of the file to have very low prices and no volume. It was considered that trading patterns would be very different then, and so the time when prices were first above $10,000 were only to be considered.
Analysis was performed using R 4.5.3
library(data.table)csv_file_BTC_2012_to_2025 <-"C:/Users/pc2/Documents/btc2/data/btcusd_bitstamp_1min_2012-2025.csv"BTC_2012_to_2025 <-fread(csv_file_BTC_2012_to_2025)BTC_test <- BTC_2012_to_2025[ open >10000& close >10000& low >10000& volume >0]first_timestamp <- BTC_test$timestamp[1]first_datetime <-as.POSIXct( first_timestamp,origin ="1970-01-01",tz ="UTC")first_timestamp
[1] 1511941200
first_datetime
[1] "2017-11-29 07:40:00 UTC"
BTC_test[1]
timestamp open high low close volume
<int> <num> <num> <num> <num> <num>
1: 1511941200 10010 10035.39 10010 10035.39 76.33833