Skip to content

Commit 05dcdba

Browse files
Review updates.
1 parent 7bb9c69 commit 05dcdba

File tree

1 file changed

+35
-25
lines changed

1 file changed

+35
-25
lines changed

README.md

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
<td>
55
<table cellspacing="3" border="0">
66
<tr>
7-
<td><a href="https://bitvavo.com"><img src="./assets/bitvavo-mark-square-blue.svg" width="100" title="Bitvavo Logo"></td>
7+
<td><a href="https://bitvavo.com"><img alt="Bitvavo" src="./assets/bitvavo-mark-square-blue.svg" width="100" title="Bitvavo Logo"></a></td>
88
<td><h1>Bitvavo SDK for Python</h1></td>
99
</tr>
1010
</table>
1111
</td>
1212
</tr>
1313
</table>
1414

15-
Crypto starts with Bitvavo. You use Bitvavo SDK for Python to buy, sell, and store over 200 digital assets on Bitvavo from inside your own app.
15+
Crypto starts with Bitvavo. You use Bitvavo SDK for Python to buy, sell, and store over 200 digital assets on Bitvavo from inside your app.
1616

1717
To trade and execute your advanced trading strategies, Bitvavo SDK for Python is a wrapper that enables you to easily call every endpoint in [Bitvavo API](https://docs.bitvavo.com/).
1818

1919
- [Prerequisites](#prerequisites) - what you need to start developing with Bitvavo SDK for Python.
20-
- [Get started](#get-started) - rapidy create an app and start trading with Bitvavo.
20+
- [Get started](#get-started) - rapidly create an app and start trading with Bitvavo.
2121
- [API reference](#api-reference) - in-depth information about Bitvavo SDK for Python
2222

2323
This page shows you how to use Bitvavo SDK for Python with websockets. For REST, see [Readme-rest](./README-REST.md).
@@ -28,7 +28,7 @@ To start programming with Bitvavo SDK for Python you need:
2828

2929
- [Python3](https://www.python.org/downloads/) installed on your development environment
3030

31-
If you are working on MacOS, ensure that that you have installed SSH certificates:
31+
If you are working on macOS, ensure that you have installed SSH certificates:
3232
```terminal
3333
open /Applications/Python\ 3.12/Install\ Certificates.command
3434
open /Applications/Python\ 3.12/Update\ Shell\ Profile.command
@@ -41,11 +41,11 @@ To start programming with Bitvavo SDK for Python you need:
4141
- **Trade**: place, update, view and cancel orders.
4242
- **Withdraw**: withdraw funds.
4343
44-
Best practice is to not grant his privilage, withdrawals using the API do not require 2FA and e-mail confirmation.
44+
Best practice is to not grant his privilege, withdrawals using the API do not require 2FA and e-mail confirmation.
4545
4646
## Get started
4747
48-
Want to quickly make a first app? Here we go:
48+
Want to quickly make a trading app? Here you go:
4949
5050
1. **Install Bitvavo SDK for Python**
5151
@@ -58,21 +58,21 @@ Want to quickly make a first app? Here we go:
5858
Add the following code to a new file in your app:
5959
6060
```python
61-
# Import Bitvavo SDK for Python
61+
# Import Bitvavo SDK for Python.
6262
from python_bitvavo_api.bitvavo import Bitvavo
6363
import json
6464
import time
6565
6666
67-
# Use this class to connect to Bitvavo and make your first calls
67+
# Use this class to connect to Bitvavo and make your first calls.
6868
# Add trading strategies to implement your business logic.
6969
class bitvavo_implementation:
7070
api_key = "<Replace with your your API key from Bitvavo Dashboard>"
7171
api_secret = "<Replace with your API secrete from Bitvavo Dashboard>"
7272
bitvavo_engine = None
7373
bitvavo_socket = None
7474
75-
# Connect securely to Bitvavo, create the websocket and error callbacks
75+
# Connect securely to Bitvavo, create the websocket and error callbacks.
7676
def __init__(self):
7777
self.bitvavo_engine = Bitvavo({
7878
'APIKEY': self.api_key,
@@ -81,44 +81,50 @@ Want to quickly make a first app? Here we go:
8181
self.bitvavo_socket = self.bitvavo_engine.newWebsocket()
8282
self.bitvavo_socket.setErrorCallback(self.error_callback)
8383
84-
# Handle errors
84+
# Handle errors.
8585
def error_callback(self, error):
8686
print("Errors:", json.dumps(error, indent=2))
8787
8888
# Retrieve the data you need from Bitvavo in order to implement your
89-
# Trading logic. Use multiple workflows to return data to your
90-
# Callbacks
89+
# trading logic. Use multiple workflows to return data to your
90+
# callbacks.
9191
def a_trading_strategy(self):
9292
self.bitvavo_socket.ticker24h({}, self.a_trading_strategy_callback)
93-
# You can also filter the ticker to retrieve specific markets only.
9493
95-
# In your app you analyse data returned by the workflow, then make
96-
# calls to Bitvavo to respond to market conditions
94+
# In your app you analyse data returned by the trading strategy, then make
95+
# calls to Bitvavo to respond to market conditions.
9796
def a_trading_strategy_callback(self, response):
97+
print("All the latest trades:", json.dumps(response, indent=2))
9898
# Iterate through the
9999
for market in response:
100+
print("Iterate through markets:", market["market"] )
100101
match market["market"]:
101102
case "A market":
102103
print("Check data against your trading strategy. For example, the bid is: ", market["bid"] )
103-
# Implement calculations for your trading logic
104+
# Implement calculations for your trading logic.
104105
# If they are positive, place an order: For example:
105106
# self.bitvavo_socket.placeOrder("A market",
106107
# 'buy',
107108
# 'limit',
108109
# { 'amount': '1', 'price': '00001' },
109110
# self.order_placed_callback)
110111
case "a different market":
111-
print("Implement a different strategy for this market")
112+
print("do something else")
112113
113114
114115
def order_placed_callback(self, response):
116+
# The order return parameters explain the quote and the fees for this trade.
115117
print("Order placed:", json.dumps(response, indent=2))
116-
# Add your business logic to handle orders
118+
# Add your business logic.
117119
118120
119121
# Sockets are fast, but asynchronous. Keep the socket open while you are
120122
# trading.
121123
def wait_and_close(self):
124+
# Bitvavo uses a weight based rate limiting system. Your app is limited to 1000 weight points per IP or
125+
# API key per minute. The rate weighting for each endpoint is supplied in the Bitvavo API documentation.
126+
# This call returns the amount of points left. If you make more requests than permitted by the weight limit,
127+
# your IP or API key is banned.
122128
limit = self.bitvavo_engine.getRemainingLimit()
123129
try:
124130
while (limit > 0):
@@ -133,7 +139,9 @@ Want to quickly make a first app? Here we go:
133139
bvavo = bitvavo_implementation()
134140
bvavo.a_trading_strategy()
135141
bvavo.wait_and_close()
142+
136143
```
144+
137145
1. **Add security information**
138146
139147
Replace the values of `api_key` and `api_secret` with your credentials from [Bitvavo Dashboard](https://account.bitvavo.com/user/api).
@@ -146,8 +154,8 @@ Want to quickly make a first app? Here we go:
146154
- Command line warriors: `python3 <filename>`.
147155
- IDE heroes: press the big green button.
148156
149-
Your app connects to Bitvavo and returns a list the latest trade price for each market. The callback cycles through the
150-
market data so you can implement your trading logic.
157+
Your app connects to Bitvavo and returns a list the latest trade price for each market. You use this data to implement
158+
your trading logic.
151159
152160
## API reference
153161
@@ -208,8 +216,9 @@ The rate weighting for each endpoint is supplied in the [Bitvavo API documentati
208216
209217
#### REST requests
210218
211-
For all functions, required parameters are passed as separate values, optional parameters are passed as a dictionary;
212-
return parameters are in dictionary format such that `response['<key>'] = '<value>'`. Only when [placing orders](#place-order) some of the optional parameters are required, since a limit order requires more information than a market order.
219+
For all functions, required parameters are passed as separate values, optional parameters are passed as a dictionary.
220+
Return parameters are in dictionary format: `response['<key>'] = '<value>'`. However, as a limit order requires
221+
more information than a market order, some optional parameters are required when you [place an order](#place-order).
213222
214223
#### Get time
215224
```python
@@ -697,7 +706,7 @@ websocket.ticker24h({}, timeCallback)
697706
```
698707
</details>
699708

700-
### Private
709+
### Private trading data
701710

702711
#### Place order
703712
When placing an order, make sure that the correct optional parameters are set. For a limit order it is required to set both the amount and price. A market order is valid if either amount or amountQuote has been set.
@@ -739,7 +748,8 @@ websocket.placeOrder('BTC-EUR', 'buy', 'limit', { 'amount': '1', 'price': '3000'
739748
</details>
740749

741750
#### Update order
742-
When updating an order make sure that at least one of the optional parameters has been set. Otherwise nothing can be updated.
751+
752+
When updating an order make sure that at least one of the optional parameters has been set, otherwise nothing can be updated.
743753
```python
744754
# Optional parameters: limit:(amount, amountRemaining, price, timeInForce, selfTradePrevention, postOnly)
745755
# untriggered stopLoss/takeProfit:(amount, amountQuote, disableMarketProtection, triggerType, triggerReference, triggerAmount)
@@ -923,7 +933,7 @@ websocket.cancelOrders({}, ownCallback)
923933
"orderId": "4f9a809b-859f-4d8d-97b3-037113cdf2d0"
924934
},
925935
{
926-
"orderId": "95313ae5-ad65-4430-a0fb-63591bbc337c".
936+
"orderId": "95313ae5-ad65-4430-a0fb-63591bbc337c"
927937
},
928938
{
929939
"orderId": "2465c3ab-5ae2-4d4d-bec7-345f51b3494d"

0 commit comments

Comments
 (0)