Σ

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)) = 25
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
coincheckjpy 473000.00 435003.00 453957.00 454229.00 454229.00 453837.24
bitfinexusd 4199.00 3890.00 4124.90 4125.00 4125.00 4124.95
gdaxusd 4126.64 4126.65 4125.00
okcoincny 28600.00 26821.00 28150.10 28156.00 28125.04
btcncny 28656.00 26658.01 28055.03 28117.18 28115.99 27816.29
geminiusd 4124.05 4124.75 4124.06
bitflyerjpy 471302.00 441674.00 454020.00 454333.00 454819.00 454655.06
bitstampusd 4198.55 3871.88 4121.92 4121.93 4121.93 4066.65
krakeneur 3572.24 3360.00 3519.34 3519.35 3521.00 3482.71
korbitkrw 4945000.00 4520000.00 4793000.00 4794000.00 4794000.00 4766164.56
krakenusd 4223.31 3821.00 4119.99 4120.00 4120.00 4061.47
zaifjpy 472490.00 435000.00 454280.00 454325.00 454335.00 454708.35
oitbitusd 4206.57 3886.97 4125.80 4129.54 4119.49
zyadoeur 3579.69 3253.22 3506.53 3508.79 3508.79 3472.01
coinbaseeur 3600.00 3248.52 3544.72 3545.10 3549.49 3472.24
coinsbankusd 4230.00 3850.00 4015.02 4145.02 4087.14 4034.01
coinsbankeur 3592.04 3229.31 3490.32 3534.00 3512.16 3474.97
coinsbankrub 251616.77 228959.90 239457.29 249240.76 244303.53 243415.31
bitstampeur 3579.85 3317.01 3529.99 3530.00 3529.99 3475.87
bitbaypln 15100.00 13550.00 14963.95 14972.00 14972.00 14640.98
cexusd 4320.13 3875.00 4236.40 4240.00 4240.39 4154.25
btcboxjpy 471660.00 439506.00 449500.00 454856.00 449500.00 456125.85
chbtccny 28449.69 26600.00 27850.08 27933.45 27931.35 27738.52
lakeusd 4290.05 4101.60 4267.25 4271.15 4279.55 4195.44
btcdeeur 7337.37 1524.56 3524.00 3540.00 3544.70 3471.44
hitbtcusd 4188.95 3800.00 3271.04 3288.91 4106.56 4069.40
cexiousd 4320.13 4005.00 4247.00 4253.15 4257.81
coinbaseusd 4062.45 4186.18
bitxzar 64994.00 57005.00 61904.00 61905.00 61904.00 62181.09
foxbitbrl 13988.00 11400.00 13765.02 13804.00 13804.00 13197.22
coinfloorgbp 3265.00 2955.00 3211.00 3224.00 3225.00 3139.11
coinsbankgbp 3180.00 2430.50 3094.99 3180.00 3137.50 3108.25
mrcdbrl 13981.77 11150.00 13790.00 13879.95 13880.00 13095.60
getbtcusd 4327.27 3870.70 4102.61 4227.53 4192.17 4153.78
bitmarketpln 15250.00 13599.29 14901.30 14975.00 14975.00 14510.07
btcoididr 58600000.00 53350100.00 56816000.00 56849900.00 56899700.00 56510393.42
okcoinusd 4397.03 4124.29 4350.00 4351.00 4343.00
jubicny 28999.00 27070.00 28102.00 28199.00 28199.00 28184.71
btcmarketsaud 5819.98 5007.00 5410.00 5499.00 5430.00 5414.54
bitxmyr 18949.00 17000.00 18480.00 18481.00 18481.00 18108.28

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
bittrexxem 15705.9839799 15748.03149606 15705.9839799
poloniexdash 18.39926403 18.4161893 18.38238673
gdaxeth 13.69300288 13.69487812 13.69300288
poloniexxem 15705.9839799 15708.45114672 15705.9839799
poloniexeth 13.7068317 13.71409513 13.7068317
poloniexxrp 26609.89888238 26631.15845539 26609.89888238
krakeneth 13.69863014 13.69900545 13.69900545
geminieth 13.70050692 13.70050692 13.69863014
poloniexltc 95.16558812 95.17120348 95.16558812
bittrexeth 13.67988869 13.67988869 13.6535603
bittrexxrp 26350.46113307 26455.02645503 26420.07926024
bitfinexeth 13.72683596 13.72683596 13.7055768
bittrexltc 94.87549015 94.92574434 94.87549015
bittrexdash 18.24862141 18.34862385 18.24862807
bitstampxrp 0.0000377 0.0000377 0.00003779

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