P2P price equations

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
Sources market price BTC
Source Name high low bid ask close avg
bitfinexusdBTC/USD42354013.84220.34220.44220.3
bitfinexethBTC/ETH25.462827.054826.166426.145226.1458
bistampusdBTC/USD41373905.634123.464124.774123.46
bistampeurBTC/EUR36503452.513635.713643.933639.97
krakenusdBTC/USD4137.639114117.241204119.93997.3296
coinbaseusdBTC/USD4006.574005.540114012.44005.994006.308
krakeneurBTC/EUR3649.734543633.63634.73633.13523.7939
coinbaseeurBTC/EUR3504.133499.113504.123504.133501.153502.6357
gdaxusdBTC/USD4125.9941264126
gdaxeurBTC/EUR3638.9936393639
gdaxethETH/BTC26.157526.150626.1575
geminiusdBTC/USD4124.1941254125
rockusdBTC/USD149901390014990.01157901499014051.118
lakeusdBTC/USD4759.024546.074747.874748.024747.874604.9241
bitkonanusdBTC/USD40603864.614060.11414540604039.3368
hitbtcusdBTC/USD7939.937804.427906.6279107915.487866.8791
btcalphausdBTC/USD42123960.21400000.0014193.1294057.7851
btccusdBTC/USD6839.567006651.136899.7667006826.8182
cexusdBTC/USD41203937.54107.54112.64110.44004.6048
coinsbankusdBTC/USD4099.643910.584076.8441004098.553943.1335
allcoinusdBTC/USD165501650016500173501650016525.4316
getbtcusdBTC/USD42003947.764148.574181.794164.353985.848
okcoinusdBTC/USD4129.773905.474113.344121.794117.153951.4139
indacoinusdBTC/USD75007499.994500750075007499.9965
wexusdBTC/USD8179.9997900.017900.0118179.9997900.017915.7575
zyadoeurBTC/EUR3135.673123.753130.13130.993130.993130.3996
bitmarketeurBTC/EUR3600.34623456.45023601.76323697.22263600.34623503.1569
btcdeeurBTC/EUR3999.74345036623659.073659.073549.5064
hitbtceurBTC/EUR4499.994499.992501.314499.994499.994499.99
rockeurBTC/EUR3622.293453.013620.823622.293622.293518.1419
cexeurBTC/EUR3614.43446.13604.836163604.83507.8495
coinsbankeurBTC/EUR3642.23456.893603.236453634.713500.6259
cexrubBTC/RUB255000246017.7249556.2254987.9255000250559.1736
coinsbankrubBTC/RUB73.961970.74150.01340.013873.722573.5669
foxbitbrlBTC/BRL2538024664.0424666.0325199.9924664.0425133.0497
itbiteurBTC/EUR3110.93110.93114.653118.93110.93110.9
bitstampusdBTC/USD41373905.634122.14123.124118.93984.0918
Sources market price altcoins
Source Name high low bid ask close avg
krakenltcLTC/USD51.747.851.3351.4951.51
geminiethETH/USD157.62157.79157.57
USD exchange rates
Source Rate Currency
USD_in_RUB65.405361RUB
USD_in_AUD1.404688AUD
USD_in_BRL3.743637BRL
USD_in_CAD1.316649CAD
USD_in_CNY6.716035CNY
USD_in_GBP0.766557GBP
USD_in_HUF280.293998HUF
USD_in_IDR14044.148663IDR
USD_in_ILS3.613787ILS
USD_in_INR71.088721INR
USD_in_JPY110.699381JPY
USD_in_MXN19.164299MXN
USD_in_MYR4.077389MYR
USD_in_NZD1.46373NZD
USD_in_PHP52.080263PHP
USD_in_PLN3.824825PLN
USD_in_THB31.287176THB
USD_in_TRY5.323463TRY
USD_in_ZAR13.994359ZAR
USD_in_EUR0.882383EUR
BTC_in_USD4134.746587USD
ETH_in_USD157.990033USD
USD_in_AMD488.21AMD
USD_in_ARS39.169ARS
USD_in_AZN1.6995AZN
USD_in_CLP650.93CLP
USD_in_EGP17.49EGP
USD_in_GEL2.647GEL
USD_in_KES99.85KES
USD_in_KZT375.77KZT
USD_in_MAD9.5455MAD
USD_in_NGN359NGN
USD_in_PKR138.4PKR
USD_in_TND3.0475TND
USD_in_TWD30.768863TWD
USD_in_UAH26.9845UAH
USD_in_VEF248209VEF
USD_in_VND23159.993283VND
USD_in_DZD118.387DZD
USD_in_HKD7.847996HKD
USD_in_ALL109.5ALL
USD_in_AOA312.116AOA
USD_in_BSD1BSD
USD_in_BBD2BBD
USD_in_BGN1.726989BGN
USD_in_BHD0.3764BHD
USD_in_BWP10.5658BWP
USD_in_BYN2.13BYN
USD_in_GHS5.2685GHS
USD_in_GTQ7.7185GTQ
USD_in_SGD1.35213SGD
USD_in_XCD2.7XCD
USD_in_AED3.6725AED
USD_in_COP3105.5COP
USD_in_DKK6.581423DKK
USD_in_DOP50.43DOP
USD_in_GNF9094GNF
USD_in_HNL24.368HNL
USD_in_IQD1190IQD
USD_in_IRR42000IRR
USD_in_ISK119.64379ISK
USD_in_JOD0.708JOD
USD_in_KHR3980KHR
USD_in_KWD0.3032KWD
USD_in_PGK3.3125PGK
USD_in_QAR3.6403QAR
USD_in_TTD6.7433TTD
USD_in_ZMW11.9ZMW
USD_in_LAK8569LAK
USD_in_LBP1505.7LBP
USD_in_LKR179.42LKR
USD_in_MKD53.98MKD
USD_in_FJD2.108FJD
USD_in_MDL17.017MDL
USD_in_MMK1524MMK
USD_in_NAD13.99NAD
USD_in_NOK8.613824NOK
USD_in_OMR0.3844OMR
USD_in_PAB1PAB
USD_in_PEN3.305714PEN
USD_in_PYG6087PYG
USD_in_RON4.20064RON
USD_in_RSD103.905RSD
USD_in_SAR3.750075SAR
USD_in_SCR13.56SCR
USD_in_TJS9.4379TJS
USD_in_TZS2338TZS
USD_in_UYU32.705UYU
USD_in_UZS8360UZS
USD_in_XAF578.23XAF
USD_in_XOF578.23XOF
USD_in_XPF104.92XPF
USD_in_CHF1.000303CHF
USD_in_CZK22.625695CZK
USD_in_ETB28.25ETB
USD_in_HRK6.550235HRK
USD_in_JMD130.38JMD
USD_in_KRW1123.589065KRW
USD_in_SEK9.350866SEK