Σ

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,289.84 4,411.00 4,920.40 4,920.60 4,920.30 4,920.50
gdaxusd 4,706.94 4,708.91 4,706.94
bitstampusd 5,129.27 4,237.09 4,708.35 4,715.01 4,715.36 4,664.23
oitbitusd 5,130.00 4,210.27 4,708.73 4,712.14 4,712.07
bitflyerjpy 585,530.00 476,040.00 525,503.00 525,998.00 533,187.00 530,224.98
krakenusd 5,153.80 4,222.00 4,710.70 4,718.90 4,738.60 4,687.49
krakeneur 4,238.60 3,597.20 4,137.80 4,138.40 4,144.30 4,000.27
geminiusd 4,703.06 4,709.12 4,708.24
coinsbankeur 4,499.29 3,700.40 4,087.60 4,150.44 4,142.49 4,132.87
coinsbankusd 5,147.72 4,246.10 4,683.86 4,765.19 4,722.06 4,723.20
coinbaseeur 4,499.00 3,630.00 4,078.59 4,078.60 4,144.25 4,080.71
coincheckjpy 588,000.00 473,751.00 532,540.00 532,794.00 532,538.00 531,568.47
bitstampeur 4,481.46 3,695.00 4,135.00 4,137.98 4,138.50 4,066.34
bitbaypln 19,662.00 16,000.00 17,731.95 17,735.60 17,759.95 17,995.47
btcboxjpy 585,200.00 475,309.00 528,717.00 529,505.00 531,867.00 534,469.86
korbitkrw 5,998,500.00 5,000,000.00 5,551,000.00 5,553,000.00 5,553,000.00 5,462,123.89
coinbasegbp 4,015.34 3,260.00 3,641.74 3,649.68 3,715.16 3,662.85
zaifjpy 585,190.00 474,020.00 531,550.00 533,310.00 533,310.00 528,813.10
btcdeeur 8,570.21 2,350.00 4,135.00 4,150.00 4,200.00 3,970.90
cexusd 5,224.90 4,288.20 4,796.00 4,811.20 4,811.70 4,737.59
cexiousd 5,194.80 4,288.20 4,806.60 4,821.60 4,825.30
btcmarketsaud 7,038.31 5,751.03 6,458.46 6,474.00 6,483.86 6,318.56
bitxzar 76,575.00 61,459.00 69,987.00 69,988.00 69,990.00 68,632.46
coinsbankgbp 4,044.76 3,374.62 3,513.38 3,901.00 3,753.93 3,740.03
rockeur 4,506.77 3,740.67 4,127.79 4,143.78 4,142.33 4,162.15
coinbaseusd 4,650.74 4,792.45
cexeur 4,586.90 3,693.10 4,164.40 4,176.20 4,175.70 4,143.37
zyadoeur 4,110.98 3,755.65 4,109.19 4,110.98 4,110.98 3,881.20
cexioeur 4,548.70 3,693.10 4,192.10 4,199.80 4,199.80
coinfloorgbp 4,017.00 3,304.00 3,684.00 3,689.00 3,689.00 3,671.72
lakeusd 5,768.44 4,895.25 5,291.21 5,293.42 5,291.21 5,324.10
coinsbitiousd 5,249.00 4,470.90 4,874.20 4,978.70 4,903.00 4,901.52
btcoididr 77,090,000.00 62,098,000.00 69,005,000.00 69,568,000.00 69,021,000.00 69,329,349.82
bitmarketpln 19,800.00 15,815.52 17,801.10 17,898.84 17,900.00 17,364.36
bitflyerusd 5,161.20 4,248.70 4,652.40 4,660.84 4,707.40 4,714.78
mrcdbrl 19,255.00 15,550.00 16,821.10 16,995.01 16,992.78 17,577.06

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 65.81978543 66.16382162 65.82411796
bitfinexdash 44.345898 44.345898 44.34393153
poloniexxem 56,561.08597285 56,657.22379603 56,561.08597285
poloniexeth 33.35560376 33.35560376 33.3422913
bitfinexeth 33.36558673 33.38786685 33.35445782
bittrexxrp 10,279.60526316 10,279.60526316 10,265.8864593
bittrexxmr 66.34049258 66.33978842 65.59902074
krakendash 44.36557232 44.44444444 44.2086649
krakenxrp 10,111.22345804 10,111.22345804 10,101.01010101
bitfinexltc 135.04388926 135.13513514 135.05665627
bitfinexxmr 66.18133686 66.11570248 66.11133148
poloniexxrp 10,280.66207464 10,278.54866893 10,266.94045175
poloniexltc 134.97225645 135.13750917 134.62084712
bitfinexxrp 10,271.15858669 10,278.54866893 10,274.32446317
bitstampxrp 10,300.7828595 10,295.48028416 10,260.61974143
bittrexxem 56,721.49744753 56,785.91709256 56,721.49744753
krakeneth 33.32222592 33.31112592 33.28894807
geminieth 33.3000333 33.3000333 33.26679973
bittrexeth 33.35893075 33.35893075 33.35342321
gdaxltc 134.95276653 135.13513514 134.95276653
bittrexltc 135.66698639 135.68116013 134.68231136
poloniexdash 44.23980096 44.30870227 44.22657451
gdaxeth 33.3000333 33.3000333 33.27787022
krakenltc 135.06212858 135.13513514 134.71642193
poloniexxmr 66.09385327 66.22507785 66.09385327
bittrexdash 44.14024946 44.39219976 44.14040533

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