Giter Site home page Giter Site logo

binance's Introduction

binance

CRAN status GitHub Actions build status Codecov test coverage Lifecycle: experimental

{binance} is a wrapper for the Binance API. The documentation for {binance} can be found here.

Installation

Install the development version from GitHub.

remotes::install_github("datawookie/binance")

Load the Library

Load the library.

library(binance)

Authenticate

Many of the functions are available without authentication. However, if you want to access information relating to your wallet or trades then you’ll need to create an API key and secret.

authenticate(
  key = Sys.getenv("BINANCE_API_KEY"),
  secret = Sys.getenv("BINANCE_API_SECRET")
)

Changing Service

By default the package uses Binance Global. If you want to use a Binance US account then select the corresponding API as follows:

base_url("https://api.binance.us")

Endpoints

The Binance API is extensive. Below is the current coverage of the {binance} package.

  • GET /sapi/v1/system/status
  • GET /sapi/v1/capital/config/getall (HMAC SHA256)
  • GET /sapi/v1/accountSnapshot (HMAC SHA256)
  • POST /sapi/v1/account/disableFastWithdrawSwitch (HMAC SHA256)
  • POST /sapi/v1/account/enableFastWithdrawSwitch (HMAC SHA256)
  • POST /sapi/v1/capital/withdraw/apply (HMAC SHA256)
  • GET /sapi/v1/capital/deposit/hisrec (HMAC SHA256)
  • GET /sapi/v1/capital/deposit/address (HMAC SHA256)
  • GET /sapi/v1/capital/withdraw/history (HMAC SHA256)
  • GET /sapi/v1/account/status
  • GET /sapi/v1/account/apiTradingStatus (HMAC SHA256)
  • GET /sapi/v1/asset/dribblet (HMAC SHA256)
  • POST /sapi/v1/asset/dust (HMAC SHA256)
  • GET /sapi/v1/asset/assetDividend (HMAC SHA256)
  • GET /sapi/v1/asset/assetDetail (HMAC SHA256)
  • GET /sapi/v1/asset/tradeFee (HMAC SHA256)
  • POST /sapi/v1/asset/transfer (HMAC SHA256)
  • GET /sapi/v1/asset/transfer (HMAC SHA256)
  • POST /sapi/v1/asset/get-funding-asset (HMAC SHA256)
  • GET /sapi/v1/account/apiRestrictions (HMAC SHA256)
  • POST /sapi/v1/sub-account/virtualSubAccount (HMAC SHA256)
  • GET /sapi/v1/sub-account/list (HMAC SHA256)
  • GET /sapi/v1/sub-account/sub/transfer/history (HMAC SHA256)
  • GET /sapi/v1/sub-account/futures/internalTransfer (HMAC SHA256)
  • POST /sapi/v1/sub-account/futures/internalTransfer (HMAC SHA256)
  • GET /sapi/v3/sub-account/assets (HMAC SHA256)
  • GET /sapi/v1/capital/deposit/subAddress (HMAC SHA256)
  • GET /sapi/v1/capital/deposit/subHisrec (HMAC SHA256)
  • GET /sapi/v1/sub-account/status (HMAC SHA256)
  • POST /sapi/v1/sub-account/margin/enable (HMAC SHA256)
  • GET /sapi/v1/sub-account/margin/account (HMAC SHA256)
  • GET /sapi/v1/sub-account/margin/accountSummary (HMAC SHA256)
  • POST /sapi/v1/sub-account/futures/enable (HMAC SHA256)
  • GET /sapi/v1/sub-account/futures/account (HMAC SHA256)
  • GET /sapi/v1/sub-account/futures/accountSummary (HMAC SHA256)
  • GET /sapi/v1/sub-account/futures/positionRisk (HMAC SHA256)
  • POST /sapi/v1/sub-account/futures/transfer (HMAC SHA256)
  • POST /sapi/v1/sub-account/margin/transfer (HMAC SHA256)
  • POST /sapi/v1/sub-account/transfer/subToSub (HMAC SHA256)
  • POST /sapi/v1/sub-account/transfer/subToMaster (HMAC SHA256)
  • GET /sapi/v1/sub-account/transfer/subUserHistory (HMAC SHA256)
  • POST /sapi/v1/sub-account/universalTransfer (HMAC SHA256)
  • GET /sapi/v1/sub-account/universalTransfer (HMAC SHA256)
  • GET /sapi/v2/sub-account/futures/account (HMAC SHA256)
  • GET /sapi/v2/sub-account/futures/accountSummary (HMAC SHA256)
  • GET /sapi/v2/sub-account/futures/positionRisk (HMAC SHA256)
  • POST /sapi/v1/sub-account/blvt/enable (HMAC SHA256)
  • POST /sapi/v1/managed-subaccount/deposit (HMAC SHA256)
  • GET /sapi/v1/managed-subaccount/asset (HMAC SHA256)
  • POST /sapi/v1/managed-subaccount/withdraw (HMAC SHA256)
  • GET /api/v3/ping
  • GET /api/v3/time
  • GET /api/v3/exchangeInfo
  • GET /api/v3/depth
  • GET /api/v3/trades
  • GET /api/v3/historicalTrades
  • GET /api/v3/aggTrades
  • GET /api/v3/klines
  • GET /api/v3/avgPrice
  • GET /api/v3/ticker/24hr
  • GET /api/v3/ticker/price
  • GET /api/v3/ticker/bookTicker
  • POST /api/v3/order/test (HMAC SHA256)
  • POST /api/v3/order (HMAC SHA256)
  • DELETE /api/v3/order (HMAC SHA256)
  • DELETE /api/v3/openOrders
  • GET /api/v3/order (HMAC SHA256)
  • GET /api/v3/openOrders (HMAC SHA256)
  • GET /api/v3/allOrders (HMAC SHA256)
  • POST /api/v3/order/oco (HMAC SHA256)
  • DELETE /api/v3/orderList (HMAC SHA256)
  • GET /api/v3/orderList (HMAC SHA256)
  • GET /api/v3/allOrderList (HMAC SHA256)
  • GET /api/v3/openOrderList (HMAC SHA256)
  • GET /api/v3/account (HMAC SHA256)
  • GET /api/v3/myTrades (HMAC SHA256)
  • POST /sapi/v1/margin/transfer (HMAC SHA256)
  • POST /sapi/v1/margin/loan (HMAC SHA256)
  • POST /sapi/v1/margin/repay (HMAC SHA256)
  • GET /sapi/v1/margin/asset
  • GET /sapi/v1/margin/pair
  • GET /sapi/v1/margin/allAssets
  • GET /sapi/v1/margin/allPairs
  • GET /sapi/v1/margin/priceIndex
  • POST /sapi/v1/margin/order (HMAC SHA256)
  • DELETE /sapi/v1/margin/order (HMAC SHA256)
  • DELETE /sapi/v1/margin/openOrders (HMAC SHA256)
  • GET /sapi/v1/margin/transfer (HMAC SHA256)
  • GET /sapi/v1/margin/loan (HMAC SHA256)
  • GET /sapi/v1/margin/repay (HMAC SHA256)
  • GET /sapi/v1/margin/interestHistory (HMAC SHA256)
  • GET /sapi/v1/margin/forceLiquidationRec (HMAC SHA256)
  • GET /sapi/v1/margin/account (HMAC SHA256)
  • GET /sapi/v1/margin/order (HMAC SHA256)
  • GET /sapi/v1/margin/openOrders (HMAC SHA256)
  • GET /sapi/v1/margin/allOrders (HMAC SHA256)
  • POST /sapi/v1/margin/order/oco (HMAC SHA256)
  • DELETE /sapi/v1/margin/orderList (HMAC SHA256)
  • GET /sapi/v1/margin/orderList (HMAC SHA256)
  • GET /sapi/v1/margin/allOrderList (HMAC SHA256)
  • GET /sapi/v1/margin/openOrderList (HMAC SHA256)
  • GET /sapi/v1/margin/myTrades (HMAC SHA256)
  • GET /sapi/v1/margin/maxBorrowable (HMAC SHA256)
  • GET /sapi/v1/margin/maxTransferable (HMAC SHA256)
  • POST /sapi/v1/margin/isolated/transfer (HMAC SHA256)
  • GET /sapi/v1/margin/isolated/transfer (HMAC SHA256)
  • GET /sapi/v1/margin/isolated/account (HMAC SHA256)
  • DELETE /sapi/v1/margin/isolated/account (HMAC SHA256)
  • POST /sapi/v1/margin/isolated/account (HMAC SHA256)
  • GET /sapi/v1/margin/isolated/accountLimit (HMAC SHA256)
  • GET /sapi/v1/margin/isolated/pair (HMAC SHA256)
  • GET /sapi/v1/margin/isolated/allPairs (HMAC SHA256)
  • POST /sapi/v1/bnbBurn (HMAC SHA256)
  • GET /sapi/v1/bnbBurn (HMAC SHA256)
  • GET /sapi/v1/margin/interestRateHistory (HMAC SHA256)
  • POST /api/v3/userDataStream
  • DELETE /api/v3/userDataStream
  • POST /sapi/v1/userDataStream
  • DELETE /sapi/v1/userDataStream
  • POST /sapi/v1/userDataStream/isolated
  • DELETE /sapi/v1/userDataStream/isolated
  • GET /sapi/v1/lending/daily/product/list (HMAC SHA256)
  • GET /sapi/v1/lending/daily/userLeftQuota (HMAC SHA256)
  • POST /sapi/v1/lending/daily/purchase (HMAC SHA256)
  • GET /sapi/v1/lending/daily/userRedemptionQuota (HMAC SHA256)
  • POST /sapi/v1/lending/daily/redeem (HMAC SHA256)
  • GET /sapi/v1/lending/daily/token/position (HMAC SHA256)
  • GET /sapi/v1/lending/project/list (HMAC SHA256)
  • POST /sapi/v1/lending/customizedFixed/purchase (HMAC SHA256)
  • GET /sapi/v1/lending/project/position/list (HMAC SHA256)
  • GET /sapi/v1/lending/union/account (HMAC SHA256)
  • GET /sapi/v1/lending/union/purchaseRecord (HMAC SHA256)
  • GET /sapi/v1/lending/union/redemptionRecord (HMAC SHA256)
  • GET /sapi/v1/lending/union/interestHistory (HMAC SHA256)
  • POST /sapi/v1/lending/positionChanged (HMAC SHA256)
  • GET /sapi/v1/mining/pub/algoList (HMAC SHA256)
  • GET /sapi/v1/mining/worker/detail (HMAC SHA256)
  • GET /sapi/v1/mining/worker/list (HMAC SHA256)
  • GET /sapi/v1/mining/payment/list (HMAC SHA256)
  • GET /sapi/v1/mining/payment/other (HMAC SHA256)
  • GET /sapi/v1/mining/hash-transfer/config/details/list (HMAC SHA256)
  • GET /sapi/v1/mining/hash-transfer/profit/details (HMAC SHA256)
  • POST /sapi/v1/mining/hash-transfer/config (HMAC SHA256)
  • POST /sapi/v1/mining/hash-transfer/config/cancel (HMAC SHA256)
  • GET /sapi/v1/mining/statistics/user/status (HMAC SHA256)
  • GET /sapi/v1/mining/statistics/user/list (HMAC SHA256)
  • POST /sapi/v1/futures/transfer (HMAC SHA256)
  • GET /sapi/v1/futures/transfer (HMAC SHA256)
  • POST /sapi/v1/futures/loan/borrow (HMAC SHA256)
  • GET /sapi/v1/futures/loan/borrow/history (HMAC SHA256)
  • POST /sapi/v1/futures/loan/repay (HMAC SHA256)
  • GET /sapi/v1/futures/loan/repay/history HMAC SHA256)
  • GET /sapi/v1/futures/loan/wallet (HMAC SHA256)
  • GET /sapi/v2/futures/loan/wallet (HMAC SHA256)
  • GET /sapi/v1/futures/loan/configs (HMAC SHA256)
  • GET /sapi/v2/futures/loan/configs (HMAC SHA256)
  • GET /sapi/v1/futures/loan/calcAdjustLevel (HMAC SHA256)
  • GET /sapi/v2/futures/loan/calcAdjustLevel (HMAC SHA256)
  • GET /sapi/v1/futures/loan/calcMaxAdjustAmount (HMAC SHA256)
  • GET /sapi/v2/futures/loan/calcMaxAdjustAmount (HMAC SHA256)
  • POST /sapi/v1/futures/loan/adjustCollateral (HMAC SHA256)
  • POST /sapi/v2/futures/loan/adjustCollateral (HMAC SHA256)
  • GET /sapi/v1/futures/loan/adjustCollateral/history (HMAC SHA256)
  • GET /sapi/v1/futures/loan/liquidationHistory (HMAC SHA256)
  • GET /sapi/v1/futures/loan/collateralRepayLimit (HMAC SHA256)
  • GET /sapi/v1/futures/loan/collateralRepay (HMAC SHA256)
  • POST /sapi/v1/futures/loan/collateralRepay (HMAC SHA256)
  • GET /sapi/v1/futures/loan/collateralRepayResult (HMAC SHA256)
  • GET /sapi/v1/futures/loan/interestHistory (HMAC SHA256)
  • GET /sapi/v1/blvt/tokenInfo
  • POST /sapi/v1/blvt/subscribe (HMAC SHA256)
  • GET /sapi/v1/blvt/subscribe/record (HMAC SHA256)
  • POST /sapi/v1/blvt/redeem (HMAC SHA256)
  • GET /sapi/v1/blvt/redeem/record (HMAC SHA256)
  • GET /sapi/v1/blvt/userLimit (HMAC SHA256)
  • GET /sapi/v1/bswap/pools
  • GET /sapi/v1/bswap/liquidity (HMAC SHA256)
  • POST /sapi/v1/bswap/liquidityAdd (HMAC SHA256)
  • POST /sapi/v1/bswap/liquidityRemove (HMAC SHA256)
  • GET /sapi/v1/bswap/liquidityOps (HMAC SHA256)
  • GET /sapi/v1/bswap/quote (HMAC SHA256)
  • POST /sapi/v1/bswap/swap (HMAC SHA256)
  • GET /sapi/v1/bswap/swap (HMAC SHA256)
  • GET /sapi/v1/bswap/poolConfigure (HMAC SHA256)
  • GET /sapi/v1/bswap/addLiquidityPreview (HMAC SHA256)
  • GET /sapi/v1/bswap/removeLiquidityPreview (HMAC SHA256)
  • GET /sapi/v1/fiat/orders (HMAC SHA256)
  • GET /sapi/v1/fiat/payments (HMAC SHA256)
  • GET /sapi/v1/c2c/orderMatch/listUserOrderHistory (HMAC SHA256)

binance's People

Contributors

datawookie avatar laresbernardo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

binance's Issues

Validate and give more insightful error messages

Better handling on some errors. For example:

> wallet_deposit_history("TRASH")
Error: Problem with `mutate()` column `address_tag`.
ℹ `address_tag = ifelse(address_tag == "", NA, address_tag)`.
x object 'address_tag' not found
Run `rlang::last_error()` to see where the error occurred.

Error Documentation

The link to the Documentation Leads to a 404:Error

Also, is there any chance to get a pdf document on this library (like the rgdax one)?

R >= 3.5.0 enforced (not by DESCRIPTION file)

Warning when installing the package. This happens because there are rda objects created with this limitation.

     NB: this package now depends on R (>= 3.5.0)
     WARNING: Added dependency on R >= 3.5.0 because serialized objects in
     serialize/load version 3 cannot be read in older versions of R.
     File(s) containing such objects:
       ‘binance/data/coins.rda’ ‘binance/data/fiat.rda’

We can change DESCRIPTION file OR re-create these objects with version = 2 (i.e. save(dfr, file = "data/fiat.rda", version = 2))

Funding balance

Is there a way to fetch our "Funding" (tab) balance? Preferably with daily break down.
Opening new ticket to follow up on this ticket.

Parameters not documented

I just tried ?wallet_daily_snapshot and noticed type is not documented. Are there other options that are not spot? Which options exist? I actually think: SPOT, MARGIN, FUTURES. Thanks!

STOP_LOSS and TAKE_PROFIT

I see that "TAKE_PROFIT" and "STOP_LOSS" are options for the 'order_type' argument of the 'spot_new_order()' function. However, I can't seem to successfully place one of these orders. I've tried adding the 'stopPrice' argument, but that doesn't seem to help.

I tried running a test using this code:

spot_new_order(
  order_type = 'STOP_LOSS',
  symbol = 'BTCUSDT',
  side = 'SELL',
  stopPrice = 20000,
  test = TRUE
)

Any help or examples would be greatly appreciated as I really enjoy using this package so far!

[BUG]: spot_new_order, test and fills TRUE = column not found.

Description of the bug

When running the code at spot_new_order, test and fill set to true. The script cannot find a column. Full traceback can be found below.

Traceback found at:
bug_binance.txt

Steps To Reproduce

Spot new order, crashes with these parameters.

spot_new_order(
order_type = "LIMIT",
symbol = "LTCUSDT",
side = "SELL",
quantity = 1,
price = 67,
time_in_force = "GTC",
test = TRUE,
fills = TRUE
)

To remove the bug, remove test and fills, as example below:

spot_new_order(
order_type = "LIMIT",
symbol = "LTCUSDT",
side = "SELL",
quantity = 1,
price = 67,
time_in_force = "GTC"
)

Additional Information

binance 0.0.5

Payment movements (Funding)

Is there a way to fetch "Pay" movements? I use this functionality for internal transactions to other Binance users from the "Funding" tab. Attached screenshots.

AEB2D9A5-719F-4B6F-AF56-D1BE562524FB_1_201_a
0D4A02BE-044A-4AEF-9886-256F7C33009D_1_201_a

Non-imported functions

Error: Error in map_dfr(., ~{ : could not find function "map_dfr".
Solution: I guess you must include @importFrom purrr map_dfr somewhere
Btw, congrats, I was looking to start this project on my own!! Loved it <3

Interface for posting ads in p2p

Great work!
I saw from ur blogpost that u implemented interfaces for fetching ads in p2p markets
Does the package also offer interfaces for creating ads, and clicking the payment confirmation button ?

GET P2P, Funding, and Pay data

Hi! Is is possible to fetch an of the following information through the API?

  1. P2P personal buys and sells
  2. P2P quotes for buy and sell given crypto and currency
  3. Funding (tab) daily balance
  4. Pay movements - internal transactions to other Binance users

Maybe if you know at least the endpoint I could help implement any/some of these.
Thanks!

[BUG]: New, order_list_id not found

Description of the bug

Order_list_id does not exist when running spot_new_order.

Steps To Reproduce

spot_new_order(
order_type = "MARKET",
symbol = "TRXUSDT",
side = "SELL",
quantity = 5
)

Ran in previous update. However, it does not longer run. Error returned is order_list_id doesn't exist;

Traceback found in file:
bug_binance2.txt

Additional Information

No response

Adapt it to Binance.us

Hi,

A great package! I'm working on adapting this for binance.us but i keep getting errors like this one.

`

wallet_daily_snapshot(type="SPOT",start_time = "2021-10-02", limit = 30)
Error: Must extract column with a single valid subscript.
x Subscript var has the wrong type function.
i It must be numeric or character.
Run rlang::last_error() to see where the error occurred `

The API keys work well when I check them with python-binance. Any way of introducing binance.US support?

wallet_withdrawal_history: Column `info` doesn't exist

Description of the bug

Hey there again!! Hope you're well. I've just got this error:

> wallet_withdrawal_history(coin = "USDT")
Error in `stop_subscript()`:
! Can't subset columns that don't exist.
x Column `info` doesn't exist.
Run `rlang::last_error()` to see where the error occurred.

Checking rlang::last_error():

Backtrace:
  1. binance::wallet_withdrawal_history(coin = "USDT")
  4. dplyr:::select.data.frame(., -info)
  5. tidyselect::eval_select(expr(c(...)), .data)
  6. tidyselect:::eval_select_impl(...)
 14. tidyselect:::vars_select_eval(...)
 15. tidyselect:::walk_data_tree(expr, data_mask, context_mask)
 16. tidyselect:::eval_c(expr, data_mask, context_mask)
 17. tidyselect:::reduce_sels(node, data_mask, context_mask, init = init)
 18. tidyselect:::walk_data_tree(new, data_mask, context_mask)
 19. tidyselect:::as_indices_sel_impl(...)
 20. tidyselect:::as_indices_impl(x, vars, strict = strict)
 21. tidyselect:::chr_as_locations(x, vars)
 22. vctrs::vec_as_location(x, n = length(vars), names = vars)
 23. vctrs `<fn>`()
 24. vctrs:::stop_subscript_oob(...)
 25. vctrs:::stop_subscript(...)

Steps To Reproduce

wallet_withdrawal_history(coin = "USDT")

Additional Information

I'm using binance_0.0.4 (latest version as of today)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.