Σ

Price equations for Bitcoin advertisements

For most Bitcoin 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 more control over your price. This guide explains the fundamentals on how you can use complex price equations to your advantage to beat the competition.

What is a price equation?

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

The default price equation we use for advertisements uses a special market data source called btc_in_usd and a simple multiplication operator to place a margin on top of the market data price.

The market data source btc_in_usd returns the median price from several different trusted exchanges. This means that even if one or many of the exchanges start giving erroneous information the price source will still give an accurate median price.

Advertisement prices are on average updated once every five minutes. When there is extra load on the service or if an API is slow to respond this process may take longer 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, the equation is not valid and won't work. Market data sources may not always return a price if there is, for example, low to no recent volume in that market. If an equation is not valid or does not fully resolve the advertisement will be turned off automatically.

Make your own equation

Step 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 base your price on, you can find a list of all available market sources at the end of this guide. A simple equation only uses one market data source, the below market source takes the 24 hour average price from the Bitcoin exchange Bitstamp:

bitstampusd_avg

This is already on it's own a working equation, but to make some profit selling Bitcoin you will want to modify this with an operator.

Step 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 operators that are supported in the table below.


Operator Example equation Example value Description
+ 1 + 1 2 Add two values together
- 5 - 1 4 Subtract the right value from the left one
* 2 * 5 10 Multiply two values
/ 5 / 2 2.5 Divide the left value by the right one
min min(25, 100)
25 Minimum gives returns the smaller of the two values inside the parenthesis. You can chain min() inside another to get the smallest value of multiple numbers. e.g.
min(min(25, 100), min(20, 300)) = 20
max max(25, 100)
100 Maximum gives returns the larger of the two values inside the parenthesis. You can chain max() inside another to get the largest value of multiple numbers. e.g.
max(max(25, 100), max(20, 300)) = 300


The simplest equation ads just a percentage markup on top of the market price. To add, for example, a 12% margin on top of the price you need to multiply the market price source by 1.12 to increase the price by 12%. The resulting equation looks like this:

bitstampusd_avg*1.12

If you buy your Bitcoin that you sell from two different exchanges, let's say Bitstamp and Bitfinex, you probably want to make sure that your Bitcoin price is based off of the exchange that has the higher price so that your margin stays correct. Using two market data sources has the added benefit of protecting you in case one exchange experiences a sudden price crash while the other doesn't.

To do this the max() operator is useful. It is used to choose the larger of two values given to it. To use the max() operator you enter two values separated by a comma into the parenthesis. The values entered can be a market data source or any number.

In our example we want to use the higher price of two different exchanges, Bitstamp and Bitfinex. 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. We then multiply the whole max() operator with 1.12 to add our margin:

max(bitstampusd_avg, bitfinexusd_avg)*1.12

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

Step 3: Convert the price to your own currency

If you're using a price source that is not in your own currency the final step is to convert it to the correct currency. For this, you can convert the price from USD to another currency using the USD_in_[currency] data source. For example, if I trade in Euros I would need to convert the example equation in the Step 2 from USD to EUR by multiplying the whole equation by USD_in_EUR. The resulting equation looks like this:

max(bitstampusd_avg, bitfinexusd_avg)*1.12*USD_in_EUR

You can find a list of all of the USD exchange rate sources further down on this page.

Test your equation

You can play around with your own equations using the field below. Choose which currency you trade in and enter any equation to see what the price would be.

Market price sources

We have hundreds of market data sources available to use in your price equations. Here is a table that lists all available market data sources. For most sources we fetch six different prices: high, low, bid, ask, close, and avg. We recommend you use the avg (average) price, the other price types have specific meaning and fluctuate often and can result in your price not being what you expect. Each market data source always gives the price for one whole Bitcoin, this table shows the current price returned from each market data source and price type.

In order to use the market price sources you need to take the data source name from the market column and add to it the price type.
For example, if you want to use the average bitfinexusd price you take the name of the market and add an underline and the text avg.

bitfinexusd_avg

high The highest price of completed trade during the last 24h.
low The lowest price of completed trade during the last 24h.
bid The bid price is the highest price that a buyer is willing to pay.
ask The ask price is 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.


Market high low bid ask close avg
bitfinexusd 5,713.10 5,530.92 5,608.50 5,608.60 5,608.60 5,608.55
coinsbankeur 4,934.41 4,741.18 4,770.92 4,854.66 4,813.44 4,835.47
gdaxusd 5,484.43 5,486.19 5,486.62
coinsbankusd 5,606.03 5,411.99 5,433.82 5,530.96 5,483.59 5,505.28
bitstampusd 5,576.32 5,411.74 5,490.63 5,490.64 5,485.77 5,515.86
bitflyerjpy 631,620.00 611,792.00 624,633.00 624,817.00 621,059.00 623,446.73
btcboxjpy 631,896.00 612,979.00 621,675.00 621,806.00 621,762.00 624,123.60
krakeneur 4,822.90 4,772.50 4,802.90 4,807.50 4,807.60 4,838.51
krakenusd 5,579.50 5,413.00 5,484.80 5,487.50 5,486.50 5,510.66
geminiusd 5,485.28 5,488.23 5,488.23
coincheckjpy 633,456.00 613,183.00 621,393.00 621,707.00 621,382.00 623,594.18
bitbaypln 21,252.40 20,727.04 20,877.11 20,922.18 20,877.11 21,027.87
oitbitusd 5,572.84 5,420.50 5,484.35 5,488.40 5,489.64
lakeusd 6,200.55 6,052.03 6,106.86 7,030.00 6,111.54 6,140.28
bitstampeur 4,925.90 4,740.34 4,810.00 4,813.86 4,813.88 4,849.57
zyadoeur 4,936.23 4,843.11 4,858.95 4,860.96 4,861.73 4,890.44
coinsbankgbp 4,640.16 4,089.57 4,088.66 4,602.89 4,328.48 4,339.21
coinbaseusd 5,402.52 5,569.70
coinbaseeur 5,089.99 4,747.19 4,798.00 4,798.01 4,814.81 4,842.86
zaifjpy 632,000.00 612,605.00 620,965.00 621,325.00 620,580.00 623,557.65
cexusd 5,711.30 5,559.00 5,596.60 5,601.90 5,598.30 5,636.16
cexiousd 5,711.30 5,559.00 5,587.80 5,602.20 5,595.00
coinsbitiousd 5,700.10 5,554.80 5,549.20 5,661.70 5,605.40 5,630.25
korbitkrw 6,492,000.00 6,350,000.00 6,390,500.00 6,394,500.00 6,390,000.00 6,416,990.74
cexeur 5,040.50 4,840.50 4,889.60 4,905.90 4,897.80 4,947.93
cexioeur 5,040.50 4,840.50 4,889.60 4,896.40 4,896.50
bitxzar 83,881.00 80,102.00 81,400.00 81,401.00 81,401.00 82,287.17
coinbasegbp 4,469.78 4,255.01 4,340.46 4,349.46 4,367.23 4,336.48

Altcoin market price

If you want to trade your bitcoins for altcoins we provide market sources that return the price for one whole Bitcoin in the other cryptocurrency. Below you can find a table that lists all available altcoin market data sources. We fetch three different prices: bid, ask, and close. This table shows the latest price returned from each market data source and price type.

In order to use the market price sources you need to take the data source name from the market column and add to it the price type.
For example, if you want to use the close poloniexeth price you take the name of the market and add an underline and the text close.

poloniexeth_close

bid The bid price is the highest price that a buyer is willing to pay.
ask The ask price is the lowest price that a seller is willing to accept.
close The price of the latest completed trade.


Market close bid ask
krakenxmr 64.01229036 64.2921435 64.04098623
bitfinexdash 40.88641753 40.88641753 40.85968783
poloniexxem 59,594.7556615 59,630.29218843 59,382.42280285
poloniexeth 31.70399125 31.70399125 31.68979494
bitfinexeth 31.68567807 31.68567807 31.68467412
bittrexxrp 11,700.01170001 11,700.01170001 11,695.90643275
bittrexxmr 64.35006435 64.35006435 63.75180657
krakendash 40.81632653 40.91653028 40.81632653
krakenxrp 11,709.60187354 11,726.07879925 11,717.83454418
bitfinexltc 132.07422571 132.07422571 132.07248138
bitfinexxmr 64.1395677 64.20133539 64.14368185
poloniexxrp 11,728.82946282 11,730.20527859 11,728.82946282
poloniexltc 132.01320132 132.01320132 131.94056869
bitfinexxrp 11,730.20527859 11,731.58141718 11,730.20527859
bitstampxrp 11,737.08920188 11,739.84503405 11,715.08903468
bittrexxem 59,737.15651135 59,808.61244019 59,559.26146516
krakeneth 31.67564143 31.72588832 31.67564143
geminieth 31.69572108 31.74603175 31.65558721
bittrexeth 31.67561133 31.69097999 31.6751197
gdaxltc 131.92612137 132.1003963 131.92612137
bittrexltc 131.93586861 132.01320132 131.77175025
poloniexdash 40.90755874 40.90755874 40.83315979
gdaxeth 31.67564143 31.67564143 31.66561115
krakenltc 132.03063111 132.17023526 131.82177696
poloniexxmr 64.25702811 64.25702811 64.24670736
bittrexdash 40.89422586 40.89422586 40.70603809

USD exchange rates

You can get the exchange rate of 1 USD in other currencies using these data sources. To convert a price from USD simply multiply it with the correct USD_in data source. To convert other currencies into USD, get the inverse e.g. 1/USD_in_EUR and multiply it with your price.

Exchange rate data sources

Altcoin exchange rate data sources