# P2P price equations

It is very important for many traders to conduct trades according to the current exchange rate. This guide explains how to use complex price equations to control the exchange rate in your ads better.

## What is the equation for setting the exchange rate?

The equation of exchange rate allows you to automatically update the rate, according to the fluctuations of prices on various exchanges. At P2PCOINEX.COM, we automatically receive information from market data sources, and update the price of your ad immediately after new information is received. To create your own exchange Price equation, select your market data sources and combine or modify them with the help of operators.

The default price equation used for ads uses a special market data source called
**btc_in_usd** and a simple multiplication operator to consider a profit beyond the market price.

Source of market data **btc_in_usd** gives an average price from several different trustworthy exchanges. This means that even if one or several exchanges start to produce erroneous information, the source of the price will still offer an accurate average price.

Exchange rates in the ad are updated on average once every five minutes. If the service is overloaded, or if the API is slow, this process may take more time. The final price calculated by the equation corresponds to 1 unit selected for the exchange of the base currency of the P2P platform, for convenience in the ad.

If the result of the calculation of the equation is several values or the absence of a value, such an equation is invalid and does not apply. Sources of market data do not always have information about the price, if, for example, in a particular market the amount of trades is small or trades are absent. If the equation is invalid or cannot be fully resolved, the ad automatically becomes inactive.

## Create your own equation

### Step 1. Choosing a source of pricing

The first and most important part of your equation is the choice of one or several sources of the market price. You should carefully approach the choice of the exchange, the data of which will be the base for your pricing. A list of all available market sources is listed at the end of this guide. A simple equation uses only one source of market data. The following market source takes data on the average daily price from Bitcoin Exchange: bitfinexusd_avg

This formula itself is an effective equation.

### Step 2: Use the operators to change your equation.

Operators are various mathematical functions that you can use to adjust and change the price equation according to your needs. Supported operators are listed in the table below.

Operator | Equation example | Value example | Description |
---|---|---|---|

+ | 1 + 1 | 2 | Add two values |

- | 2 - 1 | 1 | Subtract the value to the right from the value on the left |

* | 3 * 4 | 12 | Multiply two values |

/ | 5 / 2 | 2.5 | Divide the value on the left by the value on the right |

min | min(10, 20) | 10 | The operation of determining the minimum finds the smallest of two values written in brackets. The min operator can be used to find the smallest of several values, for example, min(10, 30, 40, 5) = 5 |

max | max(20, 100) | 100 | The operation of determining the maximum finds the greater of the two values written in brackets. The max operator can be used to determine the largest of several values, for example, max(10, 15, 20, 3) = 20 |

^ | 4 ^ 2 | 16 | Exponent - the value on the left, raised to the power indicated on the right |

sin, cos, tan | sin(pi/2) | 1 | Trigonometric operators. Use radians to enter data. To create accurate values in radians, use the constant pi |

abs | abs(-10) | 10 | Absolute value. Transforms negative values into positive ones, and positive values remain positive |

trunc | trunc(6.7) trunc(-6.7) |
6 -6 |
All decimals after the decimal point are discarded without rounding |

ceil | ceil(5.9) ceil(-5.9) |
6 -5 |
The “ceiling” function selects the smallest number that is greater or equal to the value |

floor | floor(5.9) floor(-5.9) |
5 -6 |
The "floor" function selects the largest number that is less or equal to the value |

round | round(5.9) round(-5.4) |
6 -5 |
Round to the nearest whole number, which drops the digits after the decimal point |

sgn | sgn(-5) sgn(5) |
-1 1 |
Gives a value sign. Possible values are 1, 0, -1 |

The simplest equation **wexusd_avg** with a value set in the field "profit" (for example 10%) provides a profit over the market price and corresponds to the equation **wexusd_avg*1.1**, written in the field of the price equation. If you buy bitcoin offered on several exchanges, let’s suppose you do it on WEX, Bitfinex and Bitstamp, you probably want its price to be based on a higher quote to make the deal profitable. To do this, you must use the max () operator. It determines the largest of the given values. In order to take profit into account, it is necessary to multiply the whole operator max () by 1.1.

**max(wexusd_avg, bitfinexusd_avg)*1.1**

This equation first receives data on prices from three exchanges: WEX, Bitfinex, Bitstamp, and determines the largest value of the price from these exchanges and finally multiplies this price by 1.1, resulting in the final price, which will be indicated in the ad.

If you use a source in which prices are quoted in a currency other than yours, then the last step is to convert to the appropriate currency. To do this, you can convert the price from US dollars to another currency using the data source USD_in_ [currency]. For example, if I make a deal in euros, I need to convert the equation given in the example for "Step 2" from US dollars to euros, multiplying the entire equation by USD_in_EUR. The final equation is as follows:

**max(wexusd_avg, bitfinexusd_avg)*1.1*USD_in_EUR.**

You can experiment with your own equations by using the field below. To find out the price, select the currency in which you trade, and enter any equation.

We get six different price indices for most sources: high price, low price, demand price, offer price, closing price and average price. These tables show the current price obtained from each source of market data, as well as the price type.

Low |
The lowest price of the completed trade in the last 24 hours |

Average |
The average price of completed trades in the last 24 hours |

High |
The highest price of the completed trade for the last 24 hours |

Demand |
The demand price is the highest price that the buyer is willing to pay |

Offer |
The offer price is the lowest price that the seller is willing to accept |

Closing |
Price of the latest completed trade |

Source | Name | high | low | bid | ask | close | avg |
---|---|---|---|---|---|---|---|

bitfinexusd | BTC/USD | 5355.7568 | 5255 | 5306.3 | 5317 | 5317.2 | |

bitfinexeth | BTC/ETH | 30.8034 | 31.2754 | 31.0058 | 31.0049 | 31.0049 | |

bistampusd | BTC/USD | 5329.09 | 5229.59 | 5301.23 | 5304.66 | 5301.23 | |

bistampeur | BTC/EUR | 4740.71 | 4661.08 | 4719.25 | 4722.65 | 4722.72 | |

krakenusd | BTC/USD | 5325 | 5200 | 5306.9 | 5307 | 5307 | 5272.6243 |

coinbaseusd | BTC/USD | 4006.57 | 4005.5 | 4011 | 4012.4 | 4005.99 | 4006.308 |

krakeneur | BTC/EUR | 4743.4 | 4651.2 | 4726.1 | 4726.9 | 4726.1 | 4707.2939 |

coinbaseeur | BTC/EUR | 3504.13 | 3499.11 | 3504.12 | 3504.13 | 3501.15 | 3502.6357 |

gdaxusd | BTC/USD | 5305 | 5305.01 | 5305.01 | |||

gdaxeur | BTC/EUR | 4720 | 4724.04 | 4720 | |||

gdaxeth | ETH/BTC | 30.9981 | 30.9885 | 30.9789 | |||

geminiusd | BTC/USD | 5305.72 | 5306.12 | 5305 | |||

rockusd | BTC/USD | 14990 | 13900 | 14990.01 | 15790 | 14990 | 14051.118 |

lakeusd | BTC/USD | 5905.35 | 5786.15 | 5874.9 | 5884.76 | 5876.73 | 5847.5933 |

bitkonanusd | BTC/USD | 5300 | 5260 | 5255 | 5365.25 | 5300 | 5296.9965 |

hitbtcusd | BTC/USD | 7939.93 | 7804.42 | 7906.62 | 7910 | 7915.48 | 7866.8791 |

btcalphausd | BTC/USD | 5340 | 5221.01 | 100000 | 0.002 | 5306.335 | 5278.033 |

btccusd | BTC/USD | 6839.5 | 6700 | 6651.13 | 6899.76 | 6700 | 6826.8182 |

cexusd | BTC/USD | 5361.9 | 5270.1 | 5344 | 5346.2 | 5344.2 | 5328.735 |

coinsbankusd | BTC/USD | 5336.01 | 5129.92 | 5320 | 5364.21 | 5320.22 | 5278.0997 |

allcoinusd | BTC/USD | 16550 | 16500 | 16500 | 17350 | 16500 | 16525.4316 |

getbtcusd | BTC/USD | 3909.93 | 3793.81 | 3841.55 | 3876.58 | 3793.81 | 3814.0193 |

okcoinusd | BTC/USD | 5323.86 | 5218.07 | 5307.92 | 5308.58 | 5308.26 | 5276.4217 |

indacoinusd | BTC/USD | 7500 | 7499.99 | 4500 | 7500 | 7500 | 7499.9965 |

wexusd | BTC/USD | 8179.999 | 7900.01 | 7900.011 | 8179.999 | 7900.01 | 7915.7575 |

zyadoeur | BTC/EUR | 3135.67 | 3123.75 | 3130.1 | 3130.99 | 3130.99 | 3130.3996 |

bitmarketeur | BTC/EUR | 4701.6232 | 4701.6232 | 4630.9891 | 4725.7138 | 4701.6232 | 4701.6232 |

btcdeeur | BTC/EUR | 5999.41 | 4660 | 4740 | 4746 | 4700.69 | 4729.4324 |

hitbtceur | BTC/EUR | 4499.99 | 4499.99 | 2501.31 | 4499.99 | 4499.99 | 4499.99 |

rockeur | BTC/EUR | 4737.22 | 4667.01 | 4728.06 | 4736.52 | 4737.22 | 4699.0522 |

cexeur | BTC/EUR | 4742.2 | 4659.2 | 4711.5 | 4733.1 | 4731.3 | 4706.0892 |

coinsbankeur | BTC/EUR | 5131.26 | 4665.65 | 4680.76 | 4775.52 | 4732.38 | 4703.9408 |

cexrub | BTC/RUB | 340934.1 | 310000.2 | 332712.1 | 336588.4 | 340934.1 | 326677.1586 |

coinsbankrub | BTC/RUB | 73.9619 | 70.7415 | 0.0134 | 0.0138 | 73.7225 | 73.5669 |

foxbitbrl | BTC/BRL | 25380 | 24664.04 | 24666.03 | 25199.99 | 24664.04 | 25133.0497 |

itbiteur | BTC/EUR | 3110.9 | 3110.9 | 3114.65 | 3118.9 | 3110.9 | 3110.9 |

bitstampusd | BTC/USD | 5329.09 | 5212.8 | 5308.36 | 5308.86 | 5309.37 | 5275.6054 |

Source | Rate | Currency |
---|---|---|

USD_in_RUB | 63.926195 | RUB |

USD_in_AUD | 1.398364 | AUD |

USD_in_BRL | 3.92342 | BRL |

USD_in_CAD | 1.336506 | CAD |

USD_in_CNY | 6.703497 | CNY |

USD_in_GBP | 0.768942 | GBP |

USD_in_HUF | 283.876143 | HUF |

USD_in_IDR | 14066.834998 | IDR |

USD_in_ILS | 3.587603 | ILS |

USD_in_INR | 69.481036 | INR |

USD_in_JPY | 111.935433 | JPY |

USD_in_MXN | 18.821659 | MXN |

USD_in_MYR | 4.137373 | MYR |

USD_in_NZD | 1.495293 | NZD |

USD_in_PHP | 51.672428 | PHP |

USD_in_PLN | 3.79631 | PLN |

USD_in_THB | 31.818438 | THB |

USD_in_TRY | 5.806275 | TRY |

USD_in_ZAR | 14.07245 | ZAR |

USD_in_EUR | 0.88824 | EUR |

BTC_in_USD | 5327.801888 | USD |

ETH_in_USD | 171.299185 | USD |

USD_in_AMD | 481.48 | AMD |

USD_in_ARS | 41.79 | ARS |

USD_in_AZN | 1.6995 | AZN |

USD_in_CLP | 661.81 | CLP |

USD_in_EGP | 17.12 | EGP |

USD_in_GEL | 2.6835 | GEL |

USD_in_KES | 101 | KES |

USD_in_KZT | 376.8 | KZT |

USD_in_MAD | 9.601 | MAD |

USD_in_NGN | 357 | NGN |

USD_in_PKR | 141.3 | PKR |

USD_in_TND | 3.0023 | TND |

USD_in_TWD | 30.82066 | TWD |

USD_in_UAH | 26.668 | UAH |

USD_in_VEF | 248209 | VEF |

USD_in_VND | 23114.193666 | VND |

USD_in_DZD | 118.997 | DZD |

USD_in_HKD | 7.844679 | HKD |

USD_in_ALL | 110.06 | ALL |

USD_in_AOA | 317.839 | AOA |

USD_in_BSD | 1 | BSD |

USD_in_BBD | 2 | BBD |

USD_in_BGN | 1.738505 | BGN |

USD_in_BHD | 0.377 | BHD |

USD_in_BWP | 10.577 | BWP |

USD_in_BYN | 2.09 | BYN |

USD_in_GHS | 5.1433 | GHS |

USD_in_GTQ | 7.628 | GTQ |

USD_in_SGD | 1.355327 | SGD |

USD_in_XCD | 2.7 | XCD |

USD_in_AED | 3.6727 | AED |

USD_in_COP | 3145 | COP |

USD_in_DKK | 6.627197 | DKK |

USD_in_DOP | 50.41 | DOP |

USD_in_GNF | 9126 | GNF |

USD_in_HNL | 24.373 | HNL |

USD_in_IQD | 1190 | IQD |

USD_in_IRR | 42000 | IRR |

USD_in_ISK | 120.463195 | ISK |

USD_in_JOD | 0.7075 | JOD |

USD_in_KHR | 4033.7 | KHR |

USD_in_KWD | 0.3041 | KWD |

USD_in_PGK | 3.3759 | PGK |

USD_in_QAR | 3.639 | QAR |

USD_in_TTD | 6.7447 | TTD |

USD_in_ZMW | 12.24 | ZMW |

USD_in_LAK | 8591.4 | LAK |

USD_in_LBP | 1503.5 | LBP |

USD_in_LKR | 174.49 | LKR |

USD_in_MKD | 54.44 | MKD |

USD_in_FJD | 2.1125 | FJD |

USD_in_MDL | 17.7 | MDL |

USD_in_MMK | 1524 | MMK |

USD_in_NAD | 14.109 | NAD |

USD_in_NOK | 8.509289 | NOK |

USD_in_OMR | 0.3848 | OMR |

USD_in_PAB | 1 | PAB |

USD_in_PEN | 3.290823 | PEN |

USD_in_PYG | 6196 | PYG |

USD_in_RON | 4.229759 | RON |

USD_in_RSD | 104.7497 | RSD |

USD_in_SAR | 3.749807 | SAR |

USD_in_SCR | 13.68 | SCR |

USD_in_TJS | 9.4392 | TJS |

USD_in_TZS | 2298 | TZS |

USD_in_UYU | 34.244 | UYU |

USD_in_UZS | 8400 | UZS |

USD_in_XAF | 582.67 | XAF |

USD_in_XOF | 582.67 | XOF |

USD_in_XPF | 105.8 | XPF |

USD_in_CHF | 1.01296 | CHF |

USD_in_CZK | 22.796334 | CZK |

USD_in_ETB | 28.5813 | ETB |

USD_in_HRK | 6.604003 | HRK |

USD_in_JMD | 129.32 | JMD |

USD_in_KRW | 1136.392862 | KRW |

USD_in_SEK | 9.297204 | SEK |