Price equations

Price equations for cryptocurrency advertisements

For most cryptocurrency traders, adjusting the price of advertisements by setting a margin works well enough. But if you are a high volume trader the price equation feature allows you to have more control over your price. With this guide, you’ll understand how to use complex price equations to get an advantage to beat the competition.

What is the price equation?

Price equations allow you to update your price automatically with the price fluctuations of cryptocurrency. They work by taking price information that we automatically fetch from market data sources (other cryptocurrency exchanges) and updating the price of your advertisement as soon as new price information is fetched. To create a custom price equation you need to select your market data sources and combine or modify them using operators.

The default price equation is btc_in_usd for all the BTC ads and the same if for other cryptocyrrencies. Below we will describe how automatic calculation works using bitcoin as an example.

The market data source btc_in_usd returns the median price from several different trusted exchanges. Thus, even if one or several exchanges will start giving erroneous data, the price source will still give an accurate median price. Advertisement prices are updated every minute. When there is extra load on the service or if an API is slow to respond, this process might take more time to run. The final price calculated from the price equation is for 1 BTC. Market data sources also always return the price for 1 BTC.

If the equation returns more than one value or no value, it’s invalid and won’t work. Market data sources may not always return a price if there is, for example, low or missing recent volume in that market. If an equation invalid or doesn’t fully resolve, the advertisement is turned off automatically.

Make your own equation

1. Choose your pricing sources

The first and most important part of your equation is the selection of market price source(s). You should carefully choose which exchange you’ll use. You can find a list of all available market sources at the end of this guide. A simple equation formula uses only one market data source. For example, if you want to receive a price from the cryptocurrency exchange WhiteBIT, use the next formula:


All available sources:

Exchange Equation
WhiteBIT whitebit_usd
Bitstamp bitstamp_usd
Kraken kraken_usd
Coinbase coinbase_usd
Bitfinex bitfinex_usd

You can use different price options. For example, if you want to get the average daily USD price from WhiteBIT, you should add “avg” to your formula:


Below you can see all the available exchange options:

Name Description
high The highest price of completed trade during the last 24h
low The lowest price of completed trade during the last 24h
bid The highest price that a buyer is willing to pay
ask The lowest price that a seller is willing to accept
close The price of the latest completed trade
avg The average price of completed trades for the last 24 hours
last The last price

Using the listed options you’ll have a working equation, but you can modify it and make more profit by using additional operators.

2. Use operators to modify your equation

Operators are different mathematical functions that you can use to adjust and change your price equation to fit your own needs. You can see the supported operators in the table below.

Operator Description
+ Add two values together
- Subtract the right value from the left one
* Multiply two values
/ Divide the left value by the right one
min The smaller of the two values inside the parenthesis. E.g. min(20, 300) = 20
max The larger of the two values inside the parenthesis. E.g. max(20, 300) = 300

The simplest equation ads just a percentage markup on top of the market price. For adding a 12% margin on top of the price you need to multiply the market price source with 1.12 to increase the price by 12%. The resulting equation looks like this:


If you use two sources for your ads, for example, Bitstamp and WhiteBIT, you probably want to be sure that your cryptocurrency price is based on the highest one, so your margin stays correct. Usage of two market data sources protects you in case one exchange experiences a sudden price crash while the other doesn’t.

To do this, use the max() operator. You need to enter two values separated by a comma into the parenthesis, it can be numbers or market data sources. In our example we want to use the higher price of two different exchanges – Bitstamp and WhiteBIT. First, we search for their market data source name from the table below and then we add _avg after the market data source name to get the 24h average price. Then we multiply the whole max() operator with 1.12 to add our margin:

max(bitstamp_usd_avg, whitebit_usd_avg)*1.12

This equation will first fetch pricing data from the two exchanges – WhiteBIT and Bitstamp, and turn it into two numbers. The max() operator selects the bigger price. Finally, it multiplies that price with 1.12 to get the final advertisement price.

3. Convert the price to your own currency

If you’re using a price source that is not in your local currency, the final step is to convert it to the correct currency. You can convert the price from USD to another currency using the USD_in_(currency) data source. For example, for trading in Euros, we would need to convert the example equation from the previous step from USD to EUR by multiplying the whole equation with USD_in_EUR. The result looks like this:

max(bitstamp_usd_avg, whitebit_usd_avg)*USD_in_EUR*1.12




Exchange rate data sources