Algorithmic Trading: JUP accumulator DCA Bot - does it work?

Abstract

We’ve all heard time and again that Dollar Cost Averaging (DCA) is the smartest investment approach when compared to speculative retail day trading or lump sum timing the market - In this post we back test a DCA strategy to find out does it actually work.

TLDR - Scroll to the end to see data analysis :man_mechanic: - peace.


What on Jupiter is a DCA strategy?

A full discussion is beyond the scope of this work, and I will bore you, trust me.

Here is a simple explanation of the variation we will be looking at, we open a trade when the price is above a long term EMA but it has closed below a short term EMA. We do the opposite for our short trades.

As seen below, limit orders are set to ‘buy-the-dip’ with increasing size as the price moves away from our entry. Both the order volumes and limit orders have been set to scale exponentially as price moves against us so that we get the best average entry price.

Fundamentals, technicals… the price don’t care.

Before that lets go back to launch day, you were airdropped / purchased your first bags of JUP.

Jup York Times Breaking!! - 31 January 2024
"
Shadowy super cat @meow unleashes a hidden bag of JUP - “you thought stress testing Solana and zer0 business was a joke :joy_cat:” - The launchpad liquidity pool on the brink of bailout.
"
jk, but on a serious note we had and have no idea what will happen to a token’s price.

Tale of two traders on launch day:
Trader 1: Gets airdrop of 3000 JUP, sells half @ 1 USD => 1500 JUP & 1500 USD
Trader 2: Has 3000 USD capital, invests half @ 1 USD => 1500 JUP & 1500 USD

They want to accumulate JUP from the volatility but avoid being left behind or being caught in a disaster, so they decide to run a bi-directional DCA bot.


The boring stuff … how it works etc.

If you are familiar with DCA bots, and the concept of safety orders just skip this part.

How the bot works:
First we split our capital in half, we use the 1500 USD to buy more JUP as price goes lower. We do the opposite when selling our 1500 JUP, this way we are maintaining both buy and sell positions. Upon closing the trade, we pocket the difference in JUP (since our strategy is to accumulate)

Safety orders:
When in a trade, once a set price deviation (% from initial order) occurs we want to have limit orders ready and waiting.

Volume Scale / Multiple:
The volume multiplier we put on safety orders to ensure we get bigger orders filled at lower prices.

Step Scale or Step multiple.
We also want to ensure that our orders are skewed cover a sufficient price range, so we apply a multiplier to the first deviation, we exponentially increase the distance we wait to make a new safety order.

Lastly, we need to take special care to not exceed the max amount of capital available for safety order.

I know that is a lot to take in, perhaps the tabled illustration makes it clearer:

Table of sample trades:


The Results:

DCA params:
base_order = 20 USD
trade_max_amt = 1500 USD / 1500 JUP
target_profit = 3 %
base_deviation = 4 %
max_safety_orders = 6
vol_multiple = 2
step_multiple = 1.5
fast_ema_period = 10
slow_ema_period = 20


(Long Bot) Performance Metrics:

Profit: 272.6 JUP using 1500 USD !!!
Avg amount locked in deal: 143.26530612244898 USD
Avg trade duration: 19.88 hours
Total exposure time: 52.62% of 77.125 total days.
Amount of trades: 49 trades

Closer look at how it counter trades the trend in the last 200 bars and manages to exit despite longing the dip :slight_smile:

Seems to have trades all over the chart.


(Short Bot) Performance Metrics:

Profit: 224.72 JUP from 1500 JUP with a return of 14.98 % !!!
Avg amount locked in deal: 138.34 USD
Avg trade duration: 17.77 hours
Total exposure time: 46.08 %
In position 853.0 hours of 1851.0 total hours
Amount of trades: 48 trades

Last 200 Bars, very quick entries and exits with the trend.

Total shorts, managed to escape a legendary pump :slight_smile:


Conclusion:

The bi-directional DCA managed to increase our JUP holdings by 33%! We beat the buy and hold, since price has trended down in recent times.

Despite using half of our money (the USD portion) to short a legendary pump the total portfolio value increased by roughly 15% in about 2.5 months… roughly.

I am personally impressed by how the strategy manages to use about 10% of its capital on average, so this means the free capital can be used to fill the safety orders of other bots.

This fact that these strategies are unoptimized, literally “eye balled parameters values” shows how effective good trade management and lucid expectations can turn even a random strategy profitable.


Observations for further testing

  • allow for multiple deals to use free capital
  • run optimization as this seems very promising.

-end

9 Likes

This is great! May i ask which EMA’s you utilised within this example and on which time frame? (Sorry if i missed it above)

1 Like

Hi thanks for the feedback.

I used the 1hour timeframe and the for the exponential moving averages I used 10 for the fast and 20 for the slow.

Peace!

3 Likes

Thank you for the response.
Just wondering how the BOT may go if you set the condition to start ASAP after each completed trade? The additional (potential) drawdown may assist in driving up the ROI.

Interesting I’ll take a look.

So using the same parameters as above except that this opens a deal ASAP I got the following results:

Long Bot:
Profit: 393.0 JUP using 1500 USD
Avg amount locked in deal: 77.25190839694656 USD
Avg trade duration: 10.38 hours
Total exposure time: 73.3154% of 77.29166666666667 total days.
Amount of trades: 131 trades
*stuck in a deal but I believe it would have closed by now, I wanted to keep the dataset the same as the one in the example though.

Short Bot:
Profit: 203.75 JUP from 1500 JUP with a return of 13.58 %
Avg amount locked in deal: 92.82051282051282 USD
Avg trade duration: 19.69 hours
Total exposure time: 41.4016 %
In position 768.0 hours of 1855.0 total hours
Amount of trades: 39 trades

My interpretation of the results:
So we can see that the Long bot performed significantly better because the price action of JUP is net positive since launch, so that it as expected. However, the short bot performed worse. What is interesting about the results is that around the 5th of March it stopped taking deals, indicating that it got stuck somewhere i.e the max safety orders were reached and it has not been able to close the deal.

So I did some tinkering:
I found that the stuck deal manages to close after using 9 safety orders, in order to be fair to the other strategies needed to lower the base order amount to a staggering 2.5 dollars which results in max capital usage of 1394.31 JUP. here are the results:

Short bot(with amendments to exit stuck deal for the March Pump):
Profit: 74.84 JUP from 1500 JUP with a return of 4.99 %
Avg amount locked in deal: 41.170212765957444 USD
Avg trade duration: 38.0 hours
Total exposure time: 96.2803 %
In position 1786.0 hours of 1855.0 total hours
Amount of trades: 47 trades

As you can see the tradeoff of more safety results in a respectable but sad :smiley: return, since the average trade only fills about 2/3 safety orders.

2 Likes

I also forgot to add that the entry condition seems useful, at least in the comparison of these two backtests

1 Like