Σ

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 7,483.90 6,666.00 7,298.30 7,299.10 7,299.00 7,298.70
gdaxusd 7,299.99 7,300.00 7,300.00
bitstampusd 7,468.31 6,657.95 7,296.30 7,298.80 7,296.30 7,014.34
zaifjpy 838,000.00 744,710.00 820,505.00 820,600.00 820,090.00 775,897.23
fiscojpy 838,000.00 744,710.00 820,505.00 820,600.00 820,090.00 775,897.23
bitflyerjpy 854,710.00 744,809.00 827,414.00 827,700.00 819,246.00 786,629.38
krakenusd 7,475.00 6,649.90 7,288.60 7,288.70 7,292.90 7,046.90
krakeneur 6,375.50 5,679.50 6,248.60 6,249.40 6,248.60 6,051.13
oitbitusd 7,469.85 6,660.87 7,299.10 7,303.74 7,300.73
geminiusd 7,301.35 7,302.48 7,299.88
coincheckjpy 839,783.00 744,431.00 819,679.00 820,255.00 819,892.00 787,219.02
btcboxjpy 837,700.00 743,610.00 819,943.00 820,808.00 819,206.00 771,348.83
coinsbankusd 7,495.89 6,335.93 7,245.52 7,335.14 7,288.13 6,896.81
zyadoeur 6,339.23 5,689.95 6,309.28 6,310.64 6,306.50 5,892.06
coinbaseeur 6,400.00 5,651.00 6,316.84 6,316.85 6,296.69 6,049.08
bitstampeur 6,400.00 5,671.47 6,239.53 6,249.68 6,243.99 6,051.67
coinsbankeur 6,396.80 5,425.23 6,248.10 6,282.40 6,248.10 5,829.99
bitbaypln 27,345.33 24,390.68 26,570.18 26,574.31 26,562.07 25,499.29
korbitkrw 8,149,500.00 7,410,000.00 8,054,000.00 8,059,500.00 8,054,000.00 7,642,090.51
lakeusd 8,129.74 7,335.15 8,004.65 8,006.61 8,002.33 7,529.54
coinsbankgbp 5,652.06 4,829.03 5,217.62 5,965.50 5,561.40 5,181.63
coinbaseusd 7,170.58 7,398.14
wexrub 485,000.00 449,911.99 480,271.94 483,193.21 482,914.97 461,936.29
wexusd 9,217.29 8,212.39 9,200.00 9,216.51 9,216.51 8,734.21
bitxzar 100,000.00 91,100.00 99,002.00 99,003.00 99,003.00 95,511.82
cexiousd 7,379.90 6,621.90 7,220.50 7,258.40 7,251.70
cexusd 7,379.90 6,621.90 7,275.00 7,281.80 7,229.00 7,010.78
btcoididr 104,995,000.00 95,201,000.00 103,100,000.00 103,134,000.00 102,866,000.00 99,036,141.95
coinbasegbp 5,700.00 5,053.18 5,637.71 5,649.49 5,570.28 5,344.58
btcmarketsaud 9,999.00 8,913.75 9,815.14 9,851.02 9,851.02 9,342.30

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 50.59704513 50.73824141 50.55867334
bitfinexdash 27.95248078 27.93062034 27.87767277
poloniexxem 39,123.63067293 39,138.94324853 39,123.63067293
poloniexeth 14.60610974 14.6092038 14.60616094
bitfinexeth 14.61368718 14.62223457 14.61368718
bittrexxrp 14,363.68859523 14,359.56346927 14,267.37052361
bittrexxmr 50.95518033 50.95515437 50.58726759
krakendash 27.88622421 27.89400279 27.80867631
krakenxrp 14,316.39226915 14,316.39226915 14,304.10527821
bitfinexltc 82.01427048 82.10180624 82.00754469
bitfinexxmr 50.78720163 50.78720163 50.76399817
poloniexxrp 14,302.05949657 14,306.15164521 14,304.10527821
poloniexltc 82.134849 82.12722657 81.93363376
bitfinexxrp 14,328.70038687 14,326.64756447 14,316.39226915
bitstampxrp 14,338.97332951 14,343.08663224 14,306.15164521
bittrexxem 39,200.31360251 39,277.29772192 39,200.31360251
krakeneth 14.60706982 14.6113384 14.60706982
geminieth 14.59854015 14.61774594 14.58789205
bittrexeth 14.61283726 14.647379 14.56220267
gdaxltc 82.10180624 82.03445447 81.96721311
bittrexltc 82.30303649 82.29768554 81.9000819
poloniexdash 27.92810858 27.92811638 27.8598172
gdaxeth 14.59854015 14.59854015 14.59640928
krakenltc 82.01427048 82.03445447 81.88666885
poloniexxmr 50.76139555 50.75603654 50.72282563
bittrexdash 27.93016788 27.93296089 27.79711221

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