kilimchoi / coingenius

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Binance Integration

kilimchoi opened this issue · comments

As a user, they can integrate with their binance account to pull their transactions.

Api key: HyYahPtxThsVSakIf6L34fCEC6wfya8nGSACAlAnNkTxXWnHFhcJ0hG4hjCeVdqM
Api secret: kUSygGbS1quCTb0WhBKWibMlbf1jeNkFRrVRSqI6CoenDBvDSpkiBwwNu6X2fna7

Background
Similar to bittrex api integration, user can enter their api key and secret and we pull their transactions regularly(i.e. every 24 hours). Binance however does not give all of user's orders so we have to come up with a way to overcome this limitation. I've detailed my solution below.

Implementation detail
We should include the following types of transactions: deposit, withdrawal, buy, and sell transactions.
There's no way to get all transactions using a single endpoint. There's /api/v3/allOrders but you have to specify the coin pair e.g. BTC/ETH.

  1. You'd have to get the deposit history from /wapi/v3/depositHistory.html Find which asset names have been deposited. Create transactions of type deposit.
  2. Find the orders that contain that asset name. You can do this in 2 steps. First, fetch all possible orders using either /api/v1/ticker/allBookTickers or /api/v1/ticker/allPrices. Second, check for which pair user made an order by trying out every pair in /api/v3/allOrders For example, If I deposited BTC, then iterate through all possible pairs that contain BTC like <coin_name>/BTC or BTC/<coin_name>, get the orders by trying every possible pair and find the one that has been filled. Finally create those transactions.
  3. Get the withdrawal history from /wapi/v3/withdrawHistory.html Create transactions of type withdrawal.

Please make this feature accessible from the grey arrow dropdown menu next to the chart. Add the following text "Import from Binance" And show a modal where user can enter their api key and secret. In the modal please add the following instructions:

Read the following to create a Binance api job

  1. Login to your binance account
  2. Visit https://www.binance.com/userCenter/createApi.html
  3. Name your key and press submit (Note: You will need to enable 2FA before this)
  4. Copy your API key and secret
  5. Press edit and then press on the checkbox just to the left of the "Read info"
  6. Click "Save"