New TWAP Algorithm Manages Bitcoin Price Volatility for Everyday Users

Originally published on Bitcoin Magazine.

Bitcoin prices are fun, if you like roller coasters. For traders who see volatility as an opportunity to make money and are willing to accept the risks, this is great. However this volatility presents a risk for long-term investors, fund managers and businesses who use digital currency for day-to-day operations. The newly launched algorithm for Bitcoin trading, TWAP (Time Weighted Average Price), could save both money and headaches for people and companies not equipped for higher risk.

Benchmarking Your Trades

On January 15, 2016 at 21:58 GMT (Figure 1), the price for bitcoin was $390. In an hour, it dropped to $365. I’m sure you have your own annoying price drop stories. This kind of volatility creates multiple challenges. First, it increases risk; and second, it makes it difficult for your stakeholders to know whether you are providing them a fair price.

Companies using Bitcoin for operations rely on the price of bitcoin. If in one hour — about the time it takes for six confirmations — the price of BTC can swing by 7 percent (and it does!), companies need to add a buffer to account for it. Thus, volatility increases the overall cost of using digital currency.

Stakeholders care about your Bitcoin trading strategies. This includes the CFOs of firms (e.g. Bitcoin mining firms), your limited partners, suppliers, merchants and customers who are relying on you to get them the best price. Using digital currency is risky enough for customers, and asking them to take on additional trading risk is cumbersome. They don’t ask you to predict the market but they do ask that you give them a fair rate.

One way to evaluate and communicate your performance is to use a benchmark. A good benchmark averages out the volatility and provides you with a price that your stakeholders can trust. Digital currency fund managers, for example, use benchmarks to evaluate their trading strategies and make sure they are not undertaking additional risk. Payment companies who have inflows of digital currency throughout the day often use a benchmark rate to communicate to their customers.

How TWAP Works

To gauge trading performance, many traders in different asset classes (equity, fixed income, currency) often use average price as a benchmark. The two common ways to calculate an average are a time-weighted average price (TWAP) and a volume-weighted average price (VWAP). TWAP is the average price of a bitcoin over the course of a specified period of time and VWAP is price multiplied by number of bitcoins traded, and then divided by the total number of bitcoins traded during a time period.

While these benchmarks are great, they are not very useful if you can’t trade on those prices. If you have to commit to a benchmark and don’t have any tools to make sure you can get that price when trading, you are now exposing yourself to additional risk. To solve the problem, we propose a time-weighted average price algorithm which will get you as close as possible to TWAP.

The algorithm trades over the desired time, either 1, 6, 12 or 24 hour(s), and will give you a TWAP over that time period. For example, if you set the TWAP algorithm to sell 12 bitcoins over 12 hours, the algorithm will sell throughout the period, aiming to get a 12-hour TWAP.

How Good Is It?

As good as a safety bar on a roller coaster. Using historical data, SFOX simulated how the TWAP algorithm would perform. We ran simulations on multiple days with high and low volatility. We also ran simulations at different lengths. Included below are two different simulations.

The x-axis represents specific minutes. At any given minute (time=0), a trader has a choice: she could trade now (open) or in an hour from now (close), or she could use a TWAP algorithm during that hour. The chart shows the open price (price you would get if you traded at a specific time), a close price (price one hour from the open price) and the TWAP price.

TWAP does exactly as expected — it gets an average price. We also included a VWAP graph to show you what the volume-weighted average price during that hour would be.

Our TWAP algorithm comes fairly close to VWAP and TWAP in the simulations. The performance of the algorithm depends on market conditions, liquidity, volatility, time of day and size of the order.

We also ran a simulation over a 12-hour period, given the option to trade at the beginning of the period (open), at the end of the 12-hour period (close) or using TWAP. Also provided for reference is the VWAP calculated over a one-hour period. As expected, TWAP came fairly close to the average price over a 12-hour period.

Average doesn’t always feel good but keep in mind the trade-off yields stability and reduced-risk.


With TWAP, loss aversion bias can kick in. If bitcoin’s price moves +$30, the trader using TWAP to sell would have yielded a lower amount (~+$15) and thus may feel bad about “leaving money on the table.” Average doesn’t always feel good but keep in mind the trade-off yields stability and reduced risk.

We all want to minimize risk; however, the question is, are we willing to pay the price by settling for an average price? Many of us think we can time the market better than the rest (aka overconfidence bias). No one aspires to buy or sell at an “average” price. In an average, half the time you are on the winning side, while the other half of the time you are on the losing side. That means, given our loss aversion bias, the times when we lose will cause us to feel more pain. The fact is, risk mitigation is important and averages are a bedrock in that strategy. (It’s all risk vs. reward: lower the risk, lower the reward.) Think of TWAP as dollar cost averaging, an important tool to help minimize risk. You can’t predict where the market is going, so why put all your money in at once? If you don’t use TWAP and lose to the full price swing, you will feel even worse.

For a number of types of investors and strategies, TWAP is ideal — and especially so when trading a large number of bitcoins.