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/USD3520.63296.3337133723372.2
bitfinexethBTC/ETH37.677638.759738.280438.274638.2746
bistampusdBTC/USD3420.0132003273.633273.643273.64
bistampeurBTC/EUR3014.382823.712885.0128872887.18
krakenusdBTC/USD3438.23151.23274.932753272.63311.9623
coinbaseusdBTC/USD3439.633203.323274.133274.733275.943319.7629
krakeneurBTC/EUR3025.92825.42887.728902888.12930.692
coinbaseeurBTC/EUR3028.0628602904.292904.32902.52941.433
gdaxusdBTC/USD3276.193276.23276.2
gdaxeurBTC/EUR2902.52902.512902.5
gdaxethETH/BTC38.270238.255538.2702
geminiusdBTC/USD3273.363274.53274.87
rockusdBTC/USD149901390014990.01157901499014051.118
lakeusdBTC/USD4096.53875.013934.933940.373935.44009.0597
bitkonanusdBTC/USD3473.9732503250.013316.4932503251.6004
hitbtcusdBTC/USD7939.937804.427906.6279107915.487866.8791
btcalphausdBTC/USD3612.6373331.3841000000.0023407.5383477.5461
btccusdBTC/USD6839.567006651.136899.7667006826.8182
cexusdBTC/USD34853268.23349.93354.43353.13404.0317
coinsbankusdBTC/USD3522.813238.173241.813312.073269.043361.581
allcoinusdBTC/USD165501650016500173501650016525.4316
getbtcusdBTC/USD3487.943252.463358.033388.493308.993388.902
okcoinusdBTC/USD3437.723200.163269.083272.13270.053336.4645
indacoinusdBTC/USD75007499.994500750075007499.9965
wexusdBTC/USD8179.9997900.017900.0118179.9997900.017915.7575
zyadoeurBTC/EUR3035.22852.682898.472901.242901.242968.0401
bitmarketeurBTC/EUR3058.61622862.73082873.24212910.99582910.99572975.8541
btcdeeurBTC/EUR9998.342789.782874.122909.082909.22935.8938
hitbtceurBTC/EUR4499.994499.992501.314499.994499.994499.99
rockeurBTC/EUR3016.222863.332885.152891.252891.272922.1101
cexeurBTC/EUR3122.929232967.92977.22977.23047.5908
coinsbankeurBTC/EUR3109.122850.832863.362915.22883.452960.5228
cexrubBTC/RUB237887.7225000.1226900229998.3226900230724.2578
coinsbankrubBTC/RUB73.961970.74150.01340.013873.722573.5669
foxbitbrlBTC/BRL2538024664.0424666.0325199.9924664.0425133.0497
itbiteurBTC/EUR3015.092826.442882.552886.062894.612925.092
bitstampusdBTC/USD3441.1332003272.623273.853273.853334.4738
Sources market price altcoins
Source Name high low bid ask close avg
krakenltcLTC/USD22.8222.2622.7822.822.76
geminiethETH/USD85.5785.6585.6
USD exchange rates
Source Rate Currency
USD_in_RUB66.318521RUB
USD_in_AUD1.383823AUD
USD_in_BRL3.879425BRL
USD_in_CAD1.335081CAD
USD_in_CNY6.880206CNY
USD_in_GBP0.790408GBP
USD_in_HUF284.266554HUF
USD_in_IDR14504.200378IDR
USD_in_ILS3.757406ILS
USD_in_INR71.620659INR
USD_in_JPY113.507617JPY
USD_in_MXN20.240369MXN
USD_in_MYR4.180727MYR
USD_in_NZD1.457944NZD
USD_in_PHP52.624374PHP
USD_in_PLN3.777034PLN
USD_in_THB32.736016THB
USD_in_TRY5.347332TRY
USD_in_ZAR14.163027ZAR
USD_in_EUR0.879912EUR
BTC_in_USD3329.80415USD
ETH_in_USD87.147654USD
USD_in_AMD484.73AMD
USD_in_ARS37.8ARS
USD_in_AZN1.6995AZN
USD_in_CLP681.99CLP
USD_in_EGP17.88EGP
USD_in_GEL2.6542GEL
USD_in_KES102.2KES
USD_in_KZT369.97KZT
USD_in_MAD9.5425MAD
USD_in_NGN361NGN
USD_in_PKR138.68PKR
USD_in_TND2.9533TND
USD_in_TWD30.770732TWD
USD_in_UAH27.7255UAH
USD_in_VEF248209VEF
USD_in_VND23347.923224VND
USD_in_DZD118.287DZD