Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Place Buy/Sell order? #80

Open
slobox opened this issue Jun 27, 2021 · 7 comments
Open

Place Buy/Sell order? #80

slobox opened this issue Jun 27, 2021 · 7 comments
Labels
testing needed Please help by testing the code/solution

Comments

@slobox
Copy link

slobox commented Jun 27, 2021

Hello,

How to place buy or sell order.

Thanks

@krijnsent
Copy link
Owner

Hi slobox,

  • what exchange are you trying to connect to? Every exchange has API documentation, the answer should be there and/or in the examples that are at the top of the exchange modules.
  • my code base is built for people who do know some VBA, how is your VBA?

Koen

@slobox
Copy link
Author

slobox commented Jun 28, 2021 via email

@krijnsent
Copy link
Owner

If you look in the ModExchBinance:

Set Test = Suite.Test("TestBinancePrivate POST/DELETE") ->
The part below that creates an order and sends it to the Binance test endpoint (order/test), which matches this part of the Binance API documentation:
https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#new-order--trade

Hope that helps,
Koen

@krijnsent krijnsent added the testing needed Please help by testing the code/solution label Jun 29, 2021
@infoletrico
Copy link

infoletrico commented Oct 22, 2021

Hi friend, I'm from Brazil and I liked your work. Could you make a video explaining how to connect to the binance API?, how to make a purchase and a sale?. Makes a simple video explaining how to use your code, I understand a little bit about VBA, if you want to charge for your video I pay, I really need to learn how to access the binance api through VBA. My whatsapp is +55 (92) 984472839. I will be forever grateful for this help.

@krijnsent
Copy link
Owner

Hi friend, I'm from Brazil and I liked your work. Could you make a video explaining how to connect to the binance API?, how to make a purchase and a sale?. Makes a simple video explaining how to use your code, I understand a little bit about VBA, if you want to charge for your video I pay, I really need to learn how to access the binance api through VBA. My whatsapp is +55 (92) 984472839. I will be forever grateful for this help.

Hi @infoletrico ,
thanks for the feedback. Currently I have no "ready to use" tool, but as I write on the readme: "Please consider the code I provide as simple building blocks: if you want to build a project based on this code, you will have to know (some) VBA." Making a video is not something I planned, I can give you a short howto here:
So the steps to connect to the Binance API

  • Create an API key in your Binance account. You should get a Private Key & a Public Key
  • Open the Excel file - crypto_vba_example.xlsm and go to the Binance Sheet
  • Place your API keys in the right cells
  • Go to VBA (ALT+F11), to the Binance Sheet and start the macro called GetMyBinanceData
  • That macro uses the code in ModExchBinance to pull in some basic data. In that module, there is also an example of an order, just under the line Set Test = Suite.Test("TestBinancePrivate POST/DELETE")
  • To get a good Buy or Sell order, check out the Binance API data to see what the right endpoint is and what parameters are needed. https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md

So the simplest form of a BUY order is:

Sub BuyOrder()

'Put the credentials in a dictionary
Dim Cred As New Dictionary
Cred.Add "apiKey", "YOURAPIKEYHERE"
Cred.Add "secretKey", "YOURSECRETKEYHERE"

'Put all required parameters in a dictionary
Dim Params3 As New Dictionary
Params3.Add "symbol", "LTCBTC"
Params3.Add "side", "BUY"
Params3.Add "type", "LIMIT"
Params3.Add "price", 0.01
Params3.Add "quantity", 1
Params3.Add "timeInForce", "GTC"
Params3.Add "timestamp", GetBinanceTime()

'Run the PrivateBinance Function (in ModExchBinance) to send the order and receive an answer from the server
Dim TestResult as String
TestResult = PrivateBinance("api/v3/order", "POST", Cred, Params3)

'Display the result
MsgBox TestResult, vbOkOnly

End Sub

@infoletrico
Copy link

infoletrico commented Oct 25, 2021 via email

@infoletrico
Copy link

Hello friend, I'm trying to make this call

Dim Params As New Dictionary
Params.Add "timestamp", GetBinanceTime()
JsonResponse = PrivateBinance("sapi/v1/capital/config/getall", "GET", Cred, Params)

but it comes with all the coins from binance and I would like it to show only for one currency, is there a way to get information for only one currency?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing needed Please help by testing the code/solution
Projects
None yet
Development

No branches or pull requests

3 participants