krijnsent / crypto_vba

An Excel/VBA project to communicate with various cryptocurrency exchanges APIs
MIT License
155 stars 54 forks source link

Place Buy/Sell order? #80

Open slobox opened 3 years ago

slobox commented 3 years ago

Hello,

How to place buy or sell order.

Thanks

krijnsent commented 3 years ago

Hi slobox,

Koen

slobox commented 3 years ago

Hello,

Thanks for your reply.

I have Binance account and I tested with my APi,everything works very well.

I know the VB programming language but I'm not as skilled as you are.

I will share with you the idea I have.

I would like to make a boot for an automated trade whose trigger would be an Excel formula that tracks the value of the cryptocurrency and at some point sends a request to buy or sell.

I would ask you for help in that part of how to make a trade from excel via api.

Thanks

pon, 28. jun 2021. 10:39 Koen Rijnsent @.***> је написао/ла:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/krijnsent/crypto_vba/issues/80#issuecomment-869491542, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMGVR5UA3H4HX22C6GIY5NTTVAYL7ANCNFSM47MQZD4A .

krijnsent commented 3 years ago

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

infoletrico commented 2 years ago

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 commented 2 years ago

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

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 commented 2 years ago

Thank you very much, I will try to use this code and create retrofits. I'm not as good at VBA as you are but I know how to do a lot of things in VBA. Keep up the good work, you are an inspiration.

Em seg., 25 de out. de 2021 às 06:18, Koen Rijnsent < @.***> escreveu:

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 https://github.com/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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/krijnsent/crypto_vba/issues/80#issuecomment-950708422, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6I5NUKKEXJOGXODTRPG2DUIUOGLANCNFSM47MQZD4A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

infoletrico commented 2 years ago

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?