{binance} P2P Trades

[This article was first published on R - datawookie, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Peer-to-Peer (P2P) cryptocurrency trading refers to trades that occur directly between two parties without a central authority (like an exchange) being involved.

It’s possible to execute P2P trades using a Binance account. You’d start by browsing the listings of adverts. Suppose, for example, that you wanted to buy ETH using GBP. This is what your choices might look like:

Adverts to buy ETH using GBP via P2P trading.

Each offer lists the following details:

  • information about the advertiser
  • price
  • amount available (with minimum and maximum amounts) and
  • payment methods.

There are only four options for buying ETH with GBP, but for other combinations there are a huge variety.

It’d be really useful to be able to gather these data in R for analysis. This ability has now been built into the {binance} package.

library(binance)

packageVersion("binance")
[1] '0.0.4'

Searching P2P Adverts

You can search for P2P adverts using p2p_search(). You need to specify a cryptocurrency, a fiat currency and whether you want to buy or sell the cryptocurrency.

ethgbp_buy <- p2p_search(coin = "ETH", fiat = "GBP", side = "BUY")
# A tibble: 3 × 10
  advert_id            side  asset fiat  price available min_amount max_amount advertiser       payment         
  <chr>                <chr> <chr> <chr> <dbl>     <dbl>      <dbl>      <dbl> <list>           <list>          
1 11291184040943738880 BUY   ETH   GBP   3841.    0.100         100       384. <tibble [1 × 5]> <tibble [1 × 2]>
2 11290554839186268160 BUY   ETH   GBP   3944.    0.0280         25       111. <tibble [1 × 5]> <tibble [2 × 2]>
3 11274997241972600832 BUY   ETH   GBP   4150.    2.28          210      5000  <tibble [1 × 5]> <tibble [3 × 2]>

Let’s compare those prices to the current market price for ETH/GBP.

market_price_ticker("ETHGBP")
# A tibble: 1 × 2
  symbol price
  <chr>  <dbl>
1 ETHGBP 3408.

So, relative to the market these P2P adverts are rather expensive. But, given time, they might become appealing options.

Let’s retrieve the adverts to sell ETH for GBP.

ethgbp_sell <- p2p_search("ETH", "GBP", side = "SELL")
DEBUG [2021-11-10 04:11:38] Retrieve page 1.
DEBUG [2021-11-10 04:11:39] 10 records.
DEBUG [2021-11-10 04:11:39] Retrieve page 2.
DEBUG [2021-11-10 04:11:40] 10 records.
DEBUG [2021-11-10 04:11:40] Retrieve page 3.
DEBUG [2021-11-10 04:11:41] 7 records.

Now there are multiple pages of results.

# A tibble: 27 × 10
   advert_id            side  asset fiat  price available min_amount max_amount advertiser       payment         
   <chr>                <chr> <chr> <chr> <dbl>     <dbl>      <dbl>      <dbl> <list>           <list>          
 1 11192451152210288640 SELL  ETH   GBP   3320.  238.8           200       3000 <tibble [1 × 5]> <tibble [4 × 2]>
 2 11196715384016052224 SELL  ETH   GBP   3320.  215.4           150       3000 <tibble [1 × 5]> <tibble [3 × 2]>
 3 11200760404927963136 SELL  ETH   GBP   3320.  243.4           300       3000 <tibble [1 × 5]> <tibble [4 × 2]>
 4 11279154989629005824 SELL  ETH   GBP   3290.    0.9301          5        100 <tibble [1 × 5]> <tibble [2 × 2]>
 5 11282657218708013056 SELL  ETH   GBP   3263. 5000             100       4300 <tibble [1 × 5]> <tibble [1 × 2]>
 6 11278966078512259072 SELL  ETH   GBP   3249.    5              10       1000 <tibble [1 × 5]> <tibble [3 × 2]>
 7 11275037404312793088 SELL  ETH   GBP   3244. 4953.           5000      50000 <tibble [1 × 5]> <tibble [5 × 2]>
 8 11273419959738163200 SELL  ETH   GBP   3242.   64.17         5000      50000 <tibble [1 × 5]> <tibble [4 × 2]>
 9 11290026526151233536 SELL  ETH   GBP   3214.   49.78           50       1000 <tibble [1 × 5]> <tibble [3 × 2]>
10 11270028949867687936 SELL  ETH   GBP   3185.  129.5          1000      50000 <tibble [1 × 5]> <tibble [4 × 2]>
11 11290367713051439104 SELL  ETH   GBP   3183. 4958.            500      10000 <tibble [1 × 5]> <tibble [2 × 2]>
12 11279379728860016640 SELL  ETH   GBP   3182.    1.85          170       5000 <tibble [1 × 5]> <tibble [5 × 2]>
13 11283824496913539072 SELL  ETH   GBP   3180.    2              50        499 <tibble [1 × 5]> <tibble [2 × 2]>
14 11286420141616021504 SELL  ETH   GBP   3179.    0.7942         10       1000 <tibble [1 × 5]> <tibble [2 × 2]>
15 11253682571961200640 SELL  ETH   GBP   3160.  239.6           500       1600 <tibble [1 × 5]> <tibble [4 × 2]>
16 11290256313290911744 SELL  ETH   GBP   3119. 4598.           1500      10000 <tibble [1 × 5]> <tibble [2 × 2]>
17 11264166215091884032 SELL  ETH   GBP   3111.  200             200       2000 <tibble [1 × 5]> <tibble [1 × 2]>
18 11289644893749825536 SELL  ETH   GBP   3100    97.95          110      50000 <tibble [1 × 5]> <tibble [3 × 2]>
19 11217282142004260864 SELL  ETH   GBP   3086.  433.7          5000      26000 <tibble [1 × 5]> <tibble [4 × 2]>
20 11276480970994933760 SELL  ETH   GBP   2938.   86.78          200      50000 <tibble [1 × 5]> <tibble [5 × 2]>
21 11275030775683301376 SELL  ETH   GBP   2937. 4946.           1000      10000 <tibble [1 × 5]> <tibble [5 × 2]>
22 11283482898014212096 SELL  ETH   GBP   2931.   95.28          500      10000 <tibble [1 × 5]> <tibble [5 × 2]>
23 11285962428794703872 SELL  ETH   GBP   2868.  998.4           100      30000 <tibble [1 × 5]> <tibble [4 × 2]>
24 11289831448491343872 SELL  ETH   GBP   2840     9.666          10      10000 <tibble [1 × 5]> <tibble [3 × 2]>
25 10212826124033101824 SELL  ETH   GBP   2767.    5               1       1000 <tibble [1 × 5]> <tibble [3 × 2]>
26 11269092753552330752 SELL  ETH   GBP   2765.   49.93           30       1000 <tibble [1 × 5]> <tibble [5 × 2]>
27 11277272442930212864 SELL  ETH   GBP   2765.   99.53           50       2200 <tibble [1 × 5]> <tibble [2 × 2]>

These prices are a lot closer to the market. Evidently there’s more interest in selling ETH for GBP via P2P.

Advertiser Information

One of the primary concerns with P2P trading is the ability to trust the other party. We can look at some data on the advertisers.

ethgbp_sell %>% select(advert_id, advertiser) %>% unnest(col = advertiser) %>% head(15)
# A tibble: 15 × 6
   advert_id            id                                name                 type     orders completion
   <chr>                <chr>                             <chr>                <chr>     <int>      <dbl>
 1 11192451152210288640 se37c6c00929f3d368344659b41d1ad3b "HaastrupBTC"        user         18     0.8182
 2 11196715384016052224 sd6c9edff893439c18447cb66e4fd3cb7 "3TBTC"              user        350     0.9831
 3 11200760404927963136 s965fab140ee8307581e48d34f3832ff3 "B3Crypto"           user         97     0.8661
 4 11279154989629005824 s61cdc5ad449635f0b74a7080d81ed3d9 "GetCashBack"        user        314     0.8156
 5 11282657218708013056 sa647e62ff3b738ad80a8d62639263485 "ibnjarir"           merchant    179     0.8995
 6 11278966078512259072 scec35009dc7e328fb069d11d2dae112a "umar innocent "     user        107     0.8699
 7 11275037404312793088 sa04c6fa43dc53f4db1540ce983d9adcb "TheLightOfTheWorld" merchant    280     0.9091
 8 11273419959738163200 s9ba10d50cd82337e9e57902a97bcc4bc "CRYPTO EXPERT"      merchant     43     0.8571
 9 11290026526151233536 s5266fc79f0423798bf6bb44efc416155 "AL_Maqsood786"      user         56     0.9492
10 11270028949867687936 sa6305df346253cf5a48ed79a5a352962 "cptope"             merchant    287     0.9169
11 11290367713051439104 s0d0f3163a0c738b59c1c942bb4cf8922 "Shurik_inc"         merchant    455     0.9305
12 11279379728860016640 s28b16ca595fd35be984ac5baef27671e "EurHufEth"          user         66     1     
13 11283824496913539072 s50c83e695aa43630ba1138d9cc76049a "winni"              user        148     0.8457
14 11286420141616021504 s899de69a413b398db36e209a45d0887c "HHBOSS"             user        208     0.8595
15 11253682571961200640 sf7cfccc60e82308aa656a0f3d438e54e "BDN"                merchant    120     0.9023

You can see what type of account it is (either a merchant or a user), the username and ID, as well as some statistics on their P2P trading history: the number of orders and the completion rate. Using these data it would be a simple matter to filter the adverts according to the characteristics of the advertiser. Personally I’d be looking for advertisers wtih a decent number of orders and a high completion rate.

We can use the p2p_advertiser_detail() function to dig a bit deeper.

details <- p2p_advertiser_detail("s0d0f3163a0c738b59c1c942bb4cf8922")

That returns a lot of data (which is, unfortunately, a little untidy at present). Let’s look at some more of the user statistics.

# A tibble: 1 × 2
  register_days first_order_days
          <int>            <int>
1           237              237

The user has been active on the platform for 237 days. What’s the total order count? (The orders count in the table above is only for the last 30 days).

# A tibble: 1 × 3
  completed_order_num completed_buy_order_num completed_sell_order_num
                <int>                   <int>                    <int>
1                1951                     690                     1261

How long does it typically take this user to complete an order?

# A tibble: 1 × 2
  avg_release_time_of_latest30day avg_pay_time_of_latest30day
                            <dbl>                       <dbl>
1                           2178.                       2161.

Those numbers are in seconds, so it’s typically around half an hour.

Payment Information

Another consideration is the payment options: what channels are available for transferring fiat currency?

ethgbp_sell %>% unnest(payment) %>% count(name) %>% arrange(n)
# A tibble: 16 × 2
   name                             n
   <chr>                        <int>
 1 AirTM                            1
 2 Faster Payment System (FPS)      1
 3 International Wire (SWIFT)       1
 4 Paysera                          1
 5 Perfect Money                    1
 6 Transfers with specific bank     1
 7 Uphold                           1
 8 Faster Payments                  2
 9 Payeer                           2
10 SEPA (EU) bank transfer          2
11 Advcash                          3
12 Cash app                         4
13 Revolut                         11
14 Lloyds Bank                     15
15 Transferwise                    20
16 Bank Transfer                   24

It looks like bank transfer and TransferWise are the most commonly accepted payment methods, but there are some adverts that use more niche methods.

Again, these data can be used to filter the adverts according to payment method.

Next Steps

I’ll be adding further P2P functionality to {binance}. If there are particular features that you’re interested in, please let me know.


The {binance} package is developed & supported by Fathom Data.

To leave a comment for the author, please follow the link and comment on their blog: R - datawookie.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)