Backtesting Carbon’s Automated Trading Strategies

Nate Hindman
CarbonDeFi
6 min readFeb 9, 2023

--

(source: Boston Dynamics)

Leading up to the launch of Carbon, more time is being spent on testing the performance of Carbon automated trading strategies in various market conditions.

Supporting this research is the newly launched Carbon simulator, an open-source tool for backtesting Carbon strategies with real historical price data. Users can choose an asset pair, time period, initial funding amounts and the buy and sell ranges, and the simulator will provide a detailed analysis of the transactions executed, including the strategy’s profits over time.

In this post, we’ll use the simulator to measure the performance of Carbon strategies and observe how different buy/sell ranges and funding amounts affect profits. We’ll run four different strategies on the ETH/USDC pair from Oct 15 2022 to Feb 2 2023. Each strategy is assumed to persist for the entire time interval without modification, so as to demonstrate the automated, recurring nature of Carbon’s asymmetric liquidity design.

The goal of this exercise is to shed light on how users can customize their risk and return profile and build profitable on-chain trading strategies in Carbon.

Strategy #1 — wide ranges, large gap, 100% ETH

In the strategy below, we’re depositing .784 ETH (worth 1000 USDC at the time). Our ETH buy range (green) or “bid” is set at $1187.20–$1079.20 and our sell ETH range (red) or “ask” is $1436.50–$1580.10. Whenever prices move into the green bid area, the strategy sells USDC for ETH, and that ETH becomes available for trading within its red-colored counterpart range. As the price moves into the red ask area, ETH is sold for USDC, and that USDC becomes available for trading within its green-colored counterpart range. Thus, the liquidity is automatically cycled back and forth between the two ranges as the market price moves into either range.

The orange line is the daily ETH/USDC spot price; the solid blue line is the strategy’s portfolio value; the dotted blue line is the strategy’s portfolio value composition in cash (i.e., the amount of value currently held in USDC in this case); and the gray line is the ‘HOLD’ portfolio value — i.e., the value of simply holding the .784 ETH originally deposited. The distance between the solid blue line and the gray line is the strategy’s profits vs. HOLD.

In the first few weeks, the ETH/USDC price rises from approximately $1300 to $1650 and our sell order is completely filled, selling our ETH into USDC between $1436.50 and $1580.10.

In November, the ETH price drops to around $1104.17. Our strategy uses the USDC to start buying the ETH dip at $1187.20 and almost fills its entire order to sell USDC for ETH — leaving the strategy with 0.789070 ETH and 278.2907 USDC. In the next couple months, the ETH price trades between around $1100 and $1300, and we use our USDC to buy more ETH as its price dips. This leads to our portfolio value rising above the HOLD value, and our profits vs. HOLD during this period are around 20%.

Starting in mid-January, the ETH price climbs to around $1650, and our sell order sells all our ETH into a total of 1467.09577 USDC. We then withdraw on Feb 1 with the portfolio value of 1467.09 USDC. We’ve effectively bought ETH when it’s low and sold it when it’s high.

Performance:

  • Starting value: .784 ETH (1000 USDC)
  • Ending value: 1467.10 USDC
  • Profits vs. HOLD: +13.94%

Strategy #2 — thin ranges, large gap, 100% ETH

Let’s now replay the ETH strategy with thinner buy and sell ranges, and a wider gap between our ranges. The size or “width” of our ranges refers to the number of prices at which we’re willing to buy and sell ETH.

In this strategy, our buy range is $1135.50–$1124.30, and our sell range is $1501.80–$1516.80, indicating that we have relatively high confidence that the ETH price will touch these prices. And indeed it does, driving higher total profits compared to strategy #1, due to the thinner ranges buying more ETH at lower prices, and selling more ETH at higher prices.

Performance:

  • Starting value: .784 ETH (1000 USDC)
  • Ending value: 1581.34 USDC
  • Profits vs. HOLD: +22.81%

Strategy #3 — thin ranges, small gap, 100% ETH

In this strategy, we’ve kept our ranges thin and adjusted their location, indicating a high-conviction belief that ETH will trade in a relatively tight range between $1261 and $1351 USDC per ETH. This view, however, proves to underestimate the volatility of ETH.

In November, our sell order is executed and fully converts our ETH into 1055.120216 USDC. The reduced exposure to ETH serves us well after ETH eventually drops on Nov 8 and range trades between $1200–1300. In mid-January, as the price of ETH approaches $1600, our strategy sells all our ETH into USDC between $1338.50 and $1351.90. Since the strategy is depleted of ETH, we miss out on the gains from ETH’s continued rise. While we end up with 1100 USDC, higher than our starting value of 1000 USDC, we would have been better off just holding ETH.

Performance:

  • Starting value: .784 ETH (1000 USDC)
  • Ending value: 1119.62 USDC
  • Profits vs. HOLD: -13.05%

Strategy #4 — wide ranges, large gap, 100% USDC

Returning to our original strategy (#1), instead of initializing the strategy with 100% ETH, let’s start with a 100% USDC deposit and measure profits against holding 100% USDC.

Our strategy doesn’t react to the ETH price rise in November, since it is fully in USDC and has no ETH to sell. When the price of ETH dips in mid-November, our strategy sells a total of 764.504225 USDC for 0.667729 ETH. Then, beginning in January, as the price of ETH climbs, we start selling our acquired ETH at $1436.50 and continue selling until the ETH is fully converted into USDC, leaving the strategy with 1241.489046 USDC.

Performance:

  • Starting value: 1000 USDC
  • Ending value: 1241.49 USDC
  • Profits vs. HOLD: +24.15%

Summary

Looking at the four strategies above, strategy #4 is the top performer in terms of profits vs. HOLD (+24.15%), while the top performer in terms of absolute USD gains is strategy #2, with a return of +581.34 USDC (or +58.13%).

As shown here, Carbon gives users the ability to express their views on market direction with precision: If you have an intuition about the range in which a token will trade, Carbon can be used to try and automatically “buy the dips, and sell the rips”.

Try the Carbon Simulator for yourself and simulate strategies directly in your browser, and learn more at carbondefi.xyz.

Additional Resources

--

--