# 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 | 3520.6 | 3296.3 | 3371 | 3372 | 3372.2 | |

bitfinexeth | BTC/ETH | 37.6776 | 38.7597 | 38.2804 | 38.2746 | 38.2746 | |

bistampusd | BTC/USD | 3420.01 | 3200 | 3273.63 | 3273.64 | 3273.64 | |

bistampeur | BTC/EUR | 3014.38 | 2823.71 | 2885.01 | 2887 | 2887.18 | |

krakenusd | BTC/USD | 3438.2 | 3151.2 | 3274.9 | 3275 | 3272.6 | 3311.9623 |

coinbaseusd | BTC/USD | 3439.63 | 3203.32 | 3274.13 | 3274.73 | 3275.94 | 3319.7629 |

krakeneur | BTC/EUR | 3025.9 | 2825.4 | 2887.7 | 2890 | 2888.1 | 2930.692 |

coinbaseeur | BTC/EUR | 3028.06 | 2860 | 2904.29 | 2904.3 | 2902.5 | 2941.433 |

gdaxusd | BTC/USD | 3276.19 | 3276.2 | 3276.2 | |||

gdaxeur | BTC/EUR | 2902.5 | 2902.51 | 2902.5 | |||

gdaxeth | ETH/BTC | 38.2702 | 38.2555 | 38.2702 | |||

geminiusd | BTC/USD | 3273.36 | 3274.5 | 3274.87 | |||

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

lakeusd | BTC/USD | 4096.5 | 3875.01 | 3934.93 | 3940.37 | 3935.4 | 4009.0597 |

bitkonanusd | BTC/USD | 3473.97 | 3250 | 3250.01 | 3316.49 | 3250 | 3251.6004 |

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

btcalphausd | BTC/USD | 3612.637 | 3331.384 | 100000 | 0.002 | 3407.538 | 3477.5461 |

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

cexusd | BTC/USD | 3485 | 3268.2 | 3349.9 | 3354.4 | 3353.1 | 3404.0317 |

coinsbankusd | BTC/USD | 3522.81 | 3238.17 | 3241.81 | 3312.07 | 3269.04 | 3361.581 |

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

getbtcusd | BTC/USD | 3487.94 | 3252.46 | 3358.03 | 3388.49 | 3308.99 | 3388.902 |

okcoinusd | BTC/USD | 3437.72 | 3200.16 | 3269.08 | 3272.1 | 3270.05 | 3336.4645 |

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 | 3035.2 | 2852.68 | 2898.47 | 2901.24 | 2901.24 | 2968.0401 |

bitmarketeur | BTC/EUR | 3058.6162 | 2862.7308 | 2873.2421 | 2910.9958 | 2910.9957 | 2975.8541 |

btcdeeur | BTC/EUR | 9998.34 | 2789.78 | 2874.12 | 2909.08 | 2909.2 | 2935.8938 |

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

rockeur | BTC/EUR | 3016.22 | 2863.33 | 2885.15 | 2891.25 | 2891.27 | 2922.1101 |

cexeur | BTC/EUR | 3122.9 | 2923 | 2967.9 | 2977.2 | 2977.2 | 3047.5908 |

coinsbankeur | BTC/EUR | 3109.12 | 2850.83 | 2863.36 | 2915.2 | 2883.45 | 2960.5228 |

cexrub | BTC/RUB | 237887.7 | 225000.1 | 226900 | 229998.3 | 226900 | 230724.2578 |

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 | 3015.09 | 2826.44 | 2882.55 | 2886.06 | 2894.61 | 2925.092 |

bitstampusd | BTC/USD | 3441.13 | 3200 | 3272.62 | 3273.85 | 3273.85 | 3334.4738 |

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

USD_in_RUB | 66.318521 | RUB |

USD_in_AUD | 1.383823 | AUD |

USD_in_BRL | 3.879425 | BRL |

USD_in_CAD | 1.335081 | CAD |

USD_in_CNY | 6.880206 | CNY |

USD_in_GBP | 0.790408 | GBP |

USD_in_HUF | 284.266554 | HUF |

USD_in_IDR | 14504.200378 | IDR |

USD_in_ILS | 3.757406 | ILS |

USD_in_INR | 71.620659 | INR |

USD_in_JPY | 113.507617 | JPY |

USD_in_MXN | 20.240369 | MXN |

USD_in_MYR | 4.180727 | MYR |

USD_in_NZD | 1.457944 | NZD |

USD_in_PHP | 52.624374 | PHP |

USD_in_PLN | 3.777034 | PLN |

USD_in_THB | 32.736016 | THB |

USD_in_TRY | 5.347332 | TRY |

USD_in_ZAR | 14.163027 | ZAR |

USD_in_EUR | 0.879912 | EUR |

BTC_in_USD | 3329.80415 | USD |

ETH_in_USD | 87.147654 | USD |

USD_in_AMD | 484.73 | AMD |

USD_in_ARS | 37.8 | ARS |

USD_in_AZN | 1.6995 | AZN |

USD_in_CLP | 681.99 | CLP |

USD_in_EGP | 17.88 | EGP |

USD_in_GEL | 2.6542 | GEL |

USD_in_KES | 102.2 | KES |

USD_in_KZT | 369.97 | KZT |

USD_in_MAD | 9.5425 | MAD |

USD_in_NGN | 361 | NGN |

USD_in_PKR | 138.68 | PKR |

USD_in_TND | 2.9533 | TND |

USD_in_TWD | 30.770732 | TWD |

USD_in_UAH | 27.7255 | UAH |

USD_in_VEF | 248209 | VEF |

USD_in_VND | 23347.923224 | VND |

USD_in_DZD | 118.287 | DZD |