# 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 | 4235 | 4013.8 | 4220.3 | 4220.4 | 4220.3 | |

bitfinexeth | BTC/ETH | 25.4628 | 27.0548 | 26.1664 | 26.1452 | 26.1458 | |

bistampusd | BTC/USD | 4137 | 3905.63 | 4123.46 | 4124.77 | 4123.46 | |

bistampeur | BTC/EUR | 3650 | 3452.51 | 3635.71 | 3643.93 | 3639.97 | |

krakenusd | BTC/USD | 4137.6 | 3911 | 4117.2 | 4120 | 4119.9 | 3997.3296 |

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

krakeneur | BTC/EUR | 3649.7 | 3454 | 3633.6 | 3634.7 | 3633.1 | 3523.7939 |

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

gdaxusd | BTC/USD | 4125.99 | 4126 | 4126 | |||

gdaxeur | BTC/EUR | 3638.99 | 3639 | 3639 | |||

gdaxeth | ETH/BTC | 26.1575 | 26.1506 | 26.1575 | |||

geminiusd | BTC/USD | 4124.19 | 4125 | 4125 | |||

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

lakeusd | BTC/USD | 4759.02 | 4546.07 | 4747.87 | 4748.02 | 4747.87 | 4604.9241 |

bitkonanusd | BTC/USD | 4060 | 3864.61 | 4060.11 | 4145 | 4060 | 4039.3368 |

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

btcalphausd | BTC/USD | 4212 | 3960.2 | 140000 | 0.001 | 4193.129 | 4057.7851 |

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

cexusd | BTC/USD | 4120 | 3937.5 | 4107.5 | 4112.6 | 4110.4 | 4004.6048 |

coinsbankusd | BTC/USD | 4099.64 | 3910.58 | 4076.84 | 4100 | 4098.55 | 3943.1335 |

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

getbtcusd | BTC/USD | 4200 | 3947.76 | 4148.57 | 4181.79 | 4164.35 | 3985.848 |

okcoinusd | BTC/USD | 4129.77 | 3905.47 | 4113.34 | 4121.79 | 4117.15 | 3951.4139 |

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 | 3600.3462 | 3456.4502 | 3601.7632 | 3697.2226 | 3600.3462 | 3503.1569 |

btcdeeur | BTC/EUR | 3999.74 | 3450 | 3662 | 3659.07 | 3659.07 | 3549.5064 |

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

rockeur | BTC/EUR | 3622.29 | 3453.01 | 3620.82 | 3622.29 | 3622.29 | 3518.1419 |

cexeur | BTC/EUR | 3614.4 | 3446.1 | 3604.8 | 3616 | 3604.8 | 3507.8495 |

coinsbankeur | BTC/EUR | 3642.2 | 3456.89 | 3603.2 | 3645 | 3634.71 | 3500.6259 |

cexrub | BTC/RUB | 255000 | 246017.7 | 249556.2 | 254987.9 | 255000 | 250559.1736 |

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 | 4137 | 3905.63 | 4122.1 | 4123.12 | 4118.9 | 3984.0918 |

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

USD_in_RUB | 65.405361 | RUB |

USD_in_AUD | 1.404688 | AUD |

USD_in_BRL | 3.743637 | BRL |

USD_in_CAD | 1.316649 | CAD |

USD_in_CNY | 6.716035 | CNY |

USD_in_GBP | 0.766557 | GBP |

USD_in_HUF | 280.293998 | HUF |

USD_in_IDR | 14044.148663 | IDR |

USD_in_ILS | 3.613787 | ILS |

USD_in_INR | 71.088721 | INR |

USD_in_JPY | 110.699381 | JPY |

USD_in_MXN | 19.164299 | MXN |

USD_in_MYR | 4.077389 | MYR |

USD_in_NZD | 1.46373 | NZD |

USD_in_PHP | 52.080263 | PHP |

USD_in_PLN | 3.824825 | PLN |

USD_in_THB | 31.287176 | THB |

USD_in_TRY | 5.323463 | TRY |

USD_in_ZAR | 13.994359 | ZAR |

USD_in_EUR | 0.882383 | EUR |

BTC_in_USD | 4134.746587 | USD |

ETH_in_USD | 157.990033 | USD |

USD_in_AMD | 488.21 | AMD |

USD_in_ARS | 39.169 | ARS |

USD_in_AZN | 1.6995 | AZN |

USD_in_CLP | 650.93 | CLP |

USD_in_EGP | 17.49 | EGP |

USD_in_GEL | 2.647 | GEL |

USD_in_KES | 99.85 | KES |

USD_in_KZT | 375.77 | KZT |

USD_in_MAD | 9.5455 | MAD |

USD_in_NGN | 359 | NGN |

USD_in_PKR | 138.4 | PKR |

USD_in_TND | 3.0475 | TND |

USD_in_TWD | 30.768863 | TWD |

USD_in_UAH | 26.9845 | UAH |

USD_in_VEF | 248209 | VEF |

USD_in_VND | 23159.993283 | VND |

USD_in_DZD | 118.387 | DZD |

USD_in_HKD | 7.847996 | HKD |

USD_in_ALL | 109.5 | ALL |

USD_in_AOA | 312.116 | AOA |

USD_in_BSD | 1 | BSD |

USD_in_BBD | 2 | BBD |

USD_in_BGN | 1.726989 | BGN |

USD_in_BHD | 0.3764 | BHD |

USD_in_BWP | 10.5658 | BWP |

USD_in_BYN | 2.13 | BYN |

USD_in_GHS | 5.2685 | GHS |

USD_in_GTQ | 7.7185 | GTQ |

USD_in_SGD | 1.35213 | SGD |

USD_in_XCD | 2.7 | XCD |

USD_in_AED | 3.6725 | AED |

USD_in_COP | 3105.5 | COP |

USD_in_DKK | 6.581423 | DKK |

USD_in_DOP | 50.43 | DOP |

USD_in_GNF | 9094 | GNF |

USD_in_HNL | 24.368 | HNL |

USD_in_IQD | 1190 | IQD |

USD_in_IRR | 42000 | IRR |

USD_in_ISK | 119.64379 | ISK |

USD_in_JOD | 0.708 | JOD |

USD_in_KHR | 3980 | KHR |

USD_in_KWD | 0.3032 | KWD |

USD_in_PGK | 3.3125 | PGK |

USD_in_QAR | 3.6403 | QAR |

USD_in_TTD | 6.7433 | TTD |

USD_in_ZMW | 11.9 | ZMW |

USD_in_LAK | 8569 | LAK |

USD_in_LBP | 1505.7 | LBP |

USD_in_LKR | 179.42 | LKR |

USD_in_MKD | 53.98 | MKD |

USD_in_FJD | 2.108 | FJD |

USD_in_MDL | 17.017 | MDL |

USD_in_MMK | 1524 | MMK |

USD_in_NAD | 13.99 | NAD |

USD_in_NOK | 8.613824 | NOK |

USD_in_OMR | 0.3844 | OMR |

USD_in_PAB | 1 | PAB |

USD_in_PEN | 3.305714 | PEN |

USD_in_PYG | 6087 | PYG |

USD_in_RON | 4.20064 | RON |

USD_in_RSD | 103.905 | RSD |

USD_in_SAR | 3.750075 | SAR |

USD_in_SCR | 13.56 | SCR |

USD_in_TJS | 9.4379 | TJS |

USD_in_TZS | 2338 | TZS |

USD_in_UYU | 32.705 | UYU |

USD_in_UZS | 8360 | UZS |

USD_in_XAF | 578.23 | XAF |

USD_in_XOF | 578.23 | XOF |

USD_in_XPF | 104.92 | XPF |

USD_in_CHF | 1.000303 | CHF |

USD_in_CZK | 22.625695 | CZK |

USD_in_ETB | 28.25 | ETB |

USD_in_HRK | 6.550235 | HRK |

USD_in_JMD | 130.38 | JMD |

USD_in_KRW | 1123.589065 | KRW |

USD_in_SEK | 9.350866 | SEK |