bitvavo-api-upgraded 1.16.0__py3-none-any.whl → 1.17.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bitvavo_api_upgraded/__init__.py +8 -0
- bitvavo_api_upgraded/bitvavo.py +86 -40
- bitvavo_api_upgraded/helper_funcs.py +1 -1
- bitvavo_api_upgraded/settings.py +54 -31
- bitvavo_api_upgraded/type_aliases.py +3 -1
- bitvavo_api_upgraded-1.17.1.dist-info/METADATA +320 -0
- bitvavo_api_upgraded-1.17.1.dist-info/RECORD +10 -0
- {bitvavo_api_upgraded-1.16.0.dist-info → bitvavo_api_upgraded-1.17.1.dist-info}/WHEEL +1 -1
- {bitvavo_api_upgraded-1.16.0.dist-info → bitvavo_api_upgraded-1.17.1.dist-info}/licenses/LICENSE.txt +2 -2
- bitvavo_api_upgraded-1.16.0.dist-info/METADATA +0 -2429
- bitvavo_api_upgraded-1.16.0.dist-info/RECORD +0 -10
@@ -0,0 +1,320 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: bitvavo-api-upgraded
|
3
|
+
Version: 1.17.1
|
4
|
+
Summary: A unit-tested fork of the Bitvavo API
|
5
|
+
Project-URL: homepage, https://github.com/Thaumatorium/bitvavo-api-upgraded
|
6
|
+
Project-URL: repository, https://github.com/Thaumatorium/bitvavo-api-upgraded
|
7
|
+
Project-URL: changelog, https://github.com/Thaumatorium/bitvavo-api-upgraded/blob/master/CHANGELOG.md
|
8
|
+
Author: Bitvavo BV (original code)
|
9
|
+
Author-email: NostraDavid <55331731+NostraDavid@users.noreply.github.com>
|
10
|
+
Maintainer-email: NostraDavid <55331731+NostraDavid@users.noreply.github.com>
|
11
|
+
License: ISC License
|
12
|
+
License-File: LICENSE.txt
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
14
|
+
Classifier: Environment :: Console
|
15
|
+
Classifier: Framework :: Pytest
|
16
|
+
Classifier: Framework :: tox
|
17
|
+
Classifier: Intended Audience :: Developers
|
18
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
19
|
+
Classifier: License :: OSI Approved :: ISC License (ISCL)
|
20
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
21
|
+
Classifier: Operating System :: Microsoft :: Windows
|
22
|
+
Classifier: Operating System :: POSIX
|
23
|
+
Classifier: Programming Language :: Python
|
24
|
+
Classifier: Programming Language :: Python :: 3.9
|
25
|
+
Classifier: Programming Language :: Python :: 3.10
|
26
|
+
Classifier: Programming Language :: Python :: 3.11
|
27
|
+
Classifier: Programming Language :: Python :: 3.12
|
28
|
+
Classifier: Programming Language :: Python :: 3.13
|
29
|
+
Classifier: Typing :: Typed
|
30
|
+
Requires-Python: >=3.9
|
31
|
+
Requires-Dist: pydantic-settings==2.*,>=2.6
|
32
|
+
Requires-Dist: requests==2.*,>=2.26
|
33
|
+
Requires-Dist: structlog==24.*,>=21.5
|
34
|
+
Requires-Dist: websocket-client==1.*,>=1.2
|
35
|
+
Description-Content-Type: text/markdown
|
36
|
+
|
37
|
+
# Bitvavo API (upgraded)
|
38
|
+
|
39
|
+
## Userguide
|
40
|
+
|
41
|
+
`pip install bitvavo_api_upgraded`
|
42
|
+
|
43
|
+
Works the same as the official API lib, but I have:
|
44
|
+
|
45
|
+
- typing for _all_ functions and classes
|
46
|
+
- unit tests (I already found three bugs that I fixed, because the original code
|
47
|
+
wasn't tested, at all)
|
48
|
+
- a changelog, so you can track of the changes that I make
|
49
|
+
- compatible with Python 3.7 and newer ([3.6 isn't supported as of
|
50
|
+
2021-12-23](https://endoflife.date/python))
|
51
|
+
|
52
|
+
## Devguide
|
53
|
+
|
54
|
+
```shell
|
55
|
+
echo "install development requirements"
|
56
|
+
uv sync
|
57
|
+
echo "run tox, a program that creates separate environments for different python versions, for testing purposes (among other things)"
|
58
|
+
uv run tox
|
59
|
+
```
|
60
|
+
|
61
|
+
### Semantic Versioning (SemVer)
|
62
|
+
|
63
|
+
I'm using semantic versioning, which means that changes mean this:
|
64
|
+
|
65
|
+
1. MAJOR version when you make incompatible API changes,
|
66
|
+
1. MINOR version when you add functionality in a backwards compatible manner,
|
67
|
+
and
|
68
|
+
1. PATCH version when you make backwards compatible bug fixes.
|
69
|
+
|
70
|
+
### Versioning
|
71
|
+
|
72
|
+
Copy the following block to CHANGELOG.md and add all information since last
|
73
|
+
version bump
|
74
|
+
|
75
|
+
```markdown
|
76
|
+
## $UNRELEASED
|
77
|
+
|
78
|
+
### Added
|
79
|
+
|
80
|
+
...
|
81
|
+
|
82
|
+
### Changed
|
83
|
+
|
84
|
+
...
|
85
|
+
|
86
|
+
### Removed
|
87
|
+
|
88
|
+
...
|
89
|
+
```
|
90
|
+
|
91
|
+
Commit those changes.
|
92
|
+
|
93
|
+
After that, run `bump-my-version bump (major|minor|patch)` to automatically
|
94
|
+
replace `$UNRELEASED` with the new version number, and also automatically tag
|
95
|
+
and commit (with tag) to release a new version via the Github workflow.
|
96
|
+
|
97
|
+
## py.typed
|
98
|
+
|
99
|
+
Perhaps a curious file, but it simply exists to let `mypy` know that the code is
|
100
|
+
typed: [Don't forget `py.typed` for your typed Python package
|
101
|
+
](https://blog.whtsky.me/tech/2021/dont-forget-py.typed-for-your-typed-python-package/)
|
102
|
+
|
103
|
+
## Last note
|
104
|
+
|
105
|
+
_below this line is the old README.md_
|
106
|
+
|
107
|
+
---
|
108
|
+
|
109
|
+
# Bitvavo SDK for Python
|
110
|
+
|
111
|
+
Crypto starts with Bitvavo. You use Bitvavo SDK for Python to buy, sell, and
|
112
|
+
store over 200 digital assets on Bitvavo from inside your app.
|
113
|
+
|
114
|
+
To trade and execute your advanced trading strategies, Bitvavo SDK for Python is
|
115
|
+
a wrapper that enables you to easily call every endpoint in [Bitvavo
|
116
|
+
API](https://docs.bitvavo.com/).
|
117
|
+
|
118
|
+
- [Prerequisites](#prerequisites) - what you need to start developing with
|
119
|
+
Bitvavo SDK for Python
|
120
|
+
- [Get started](#get-started) - rapidly create an app and start trading with
|
121
|
+
Bitvavo
|
122
|
+
- [About the SDK](#about-the-sdk) - general information about Bitvavo SDK for
|
123
|
+
Python
|
124
|
+
- [API reference](https://docs.bitvavo.com/) - information on the specifics of
|
125
|
+
every parameter
|
126
|
+
|
127
|
+
This page shows you how to use Bitvavo SDK for Python with WebSockets. For REST,
|
128
|
+
see the [REST readme](docs/rest.md).
|
129
|
+
|
130
|
+
## Prerequisites
|
131
|
+
|
132
|
+
To start programming with Bitvavo SDK for Python you need:
|
133
|
+
|
134
|
+
- [Python3](https://www.python.org/downloads/) installed on your development
|
135
|
+
environment
|
136
|
+
|
137
|
+
If you are working on macOS, ensure that you have installed SSH certificates:
|
138
|
+
|
139
|
+
```terminal
|
140
|
+
open /Applications/Python\ 3.12/Install\ Certificates.command
|
141
|
+
open /Applications/Python\ 3.12/Update\ Shell\ Profile.command
|
142
|
+
```
|
143
|
+
|
144
|
+
- A Python app. Use your favorite IDE, or run from the command line
|
145
|
+
- An [API key and
|
146
|
+
secret](https://support.bitvavo.com/hc/en-us/articles/4405059841809)
|
147
|
+
associated with your Bitvavo account
|
148
|
+
|
149
|
+
You control the actions your app can do using the rights you assign to the API
|
150
|
+
key. Possible rights are:
|
151
|
+
|
152
|
+
- **View**: retrieve information about your balance, account, deposit and
|
153
|
+
withdrawals
|
154
|
+
- **Trade**: place, update, view and cancel orders
|
155
|
+
- **Withdraw**: withdraw funds
|
156
|
+
|
157
|
+
Best practice is to not grant this privilege, withdrawals using the API do
|
158
|
+
not require 2FA and e-mail confirmation.
|
159
|
+
|
160
|
+
## Get started
|
161
|
+
|
162
|
+
Want to quickly make a trading app? Here you go:
|
163
|
+
|
164
|
+
1. **Install Bitvavo SDK for Python**
|
165
|
+
|
166
|
+
In your Python app, add [Bitvavo SDK for
|
167
|
+
Python](https://github.com/bitvavo/python-bitvavo-api) from
|
168
|
+
[pypi.org](https://pypi.org/project/python-bitvavo-api/):
|
169
|
+
|
170
|
+
```shell
|
171
|
+
python -m pip install python_bitvavo_api
|
172
|
+
```
|
173
|
+
|
174
|
+
If you installed from `test.pypi.com`, update the requests library: `pip
|
175
|
+
install --upgrade requests`.
|
176
|
+
|
177
|
+
1. **Create a simple Bitvavo implementation**
|
178
|
+
|
179
|
+
Add the following code to a new file in your app:
|
180
|
+
|
181
|
+
```python
|
182
|
+
from python_bitvavo_api.bitvavo import Bitvavo
|
183
|
+
import json
|
184
|
+
import time
|
185
|
+
|
186
|
+
# Use this class to connect to Bitvavo and make your first calls.
|
187
|
+
# Add trading strategies to implement your business logic.
|
188
|
+
class BitvavoImplementation:
|
189
|
+
api_key = "<Replace with your your API key from Bitvavo Dashboard>"
|
190
|
+
api_secret = "<Replace with your API secret from Bitvavo Dashboard>"
|
191
|
+
bitvavo_engine = None
|
192
|
+
bitvavo_socket = None
|
193
|
+
|
194
|
+
# Connect securely to Bitvavo, create the WebSocket and error callbacks.
|
195
|
+
def __init__(self):
|
196
|
+
self.bitvavo_engine = Bitvavo({
|
197
|
+
'APIKEY': self.api_key,
|
198
|
+
'APISECRET': self.api_secret
|
199
|
+
})
|
200
|
+
self.bitvavo_socket = self.bitvavo_engine.newWebsocket()
|
201
|
+
self.bitvavo_socket.setErrorCallback(self.error_callback)
|
202
|
+
|
203
|
+
# Handle errors.
|
204
|
+
def error_callback(self, error):
|
205
|
+
print("Add your error message.")
|
206
|
+
#print("Errors:", json.dumps(error, indent=2))
|
207
|
+
|
208
|
+
# Retrieve the data you need from Bitvavo in order to implement your
|
209
|
+
# trading logic. Use multiple workflows to return data to your
|
210
|
+
# callbacks.
|
211
|
+
def a_trading_strategy(self):
|
212
|
+
self.bitvavo_socket.ticker24h({}, self.a_trading_strategy_callback)
|
213
|
+
|
214
|
+
# In your app you analyse data returned by the trading strategy, then make
|
215
|
+
# calls to Bitvavo to respond to market conditions.
|
216
|
+
def a_trading_strategy_callback(self, response):
|
217
|
+
# Iterate through the markets
|
218
|
+
for market in response:
|
219
|
+
|
220
|
+
match market["market"]:
|
221
|
+
case "ZRX-EUR":
|
222
|
+
print("Eureka, the latest bid for ZRX-EUR is: ", market["bid"] )
|
223
|
+
# Implement calculations for your trading logic.
|
224
|
+
# If they are positive, place an order: For example:
|
225
|
+
# self.bitvavo_socket.placeOrder("ZRX-EUR",
|
226
|
+
# 'buy',
|
227
|
+
# 'limit',
|
228
|
+
# { 'amount': '1', 'price': '00001' },
|
229
|
+
# self.order_placed_callback)
|
230
|
+
case "a different market":
|
231
|
+
print("do something else")
|
232
|
+
case _:
|
233
|
+
print("Not this one: ", market["market"])
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
def order_placed_callback(self, response):
|
238
|
+
# The order return parameters explain the quote and the fees for this trade.
|
239
|
+
print("Order placed:", json.dumps(response, indent=2))
|
240
|
+
# Add your business logic.
|
241
|
+
|
242
|
+
|
243
|
+
# Sockets are fast, but asynchronous. Keep the socket open while you are
|
244
|
+
# trading.
|
245
|
+
def wait_and_close(self):
|
246
|
+
# Bitvavo uses a weight based rate limiting system. Your app is limited to 1000 weight points per IP or
|
247
|
+
# API key per minute. The rate weighting for each endpoint is supplied in Bitvavo API documentation.
|
248
|
+
# This call returns the amount of points left. If you make more requests than permitted by the weight limit,
|
249
|
+
# your IP or API key is banned.
|
250
|
+
limit = self.bitvavo_engine.getRemainingLimit()
|
251
|
+
try:
|
252
|
+
while (limit > 0):
|
253
|
+
time.sleep(0.5)
|
254
|
+
limit = self.bitvavo_engine.getRemainingLimit()
|
255
|
+
except KeyboardInterrupt:
|
256
|
+
self.bitvavo_socket.closeSocket()
|
257
|
+
|
258
|
+
|
259
|
+
# Shall I re-explain main? Naaaaaaaaaa.
|
260
|
+
if __name__ == '__main__':
|
261
|
+
bvavo = BitvavoImplementation()
|
262
|
+
bvavo.a_trading_strategy()
|
263
|
+
bvavo.wait_and_close()
|
264
|
+
```
|
265
|
+
|
266
|
+
1. **Add security information**
|
267
|
+
|
268
|
+
You must supply your security information to trade on Bitvavo and see your
|
269
|
+
account information using the authenticate methods. Replace the values of
|
270
|
+
`api_key` and `api_secret` with your credentials from [Bitvavo
|
271
|
+
Dashboard](https://account.bitvavo.com/user/api).
|
272
|
+
|
273
|
+
You can retrieve public information such as available markets, assets and
|
274
|
+
current market without supplying your key and secret. However,
|
275
|
+
unauthenticated calls have lower rate limits based on your IP address, and
|
276
|
+
your account is blocked for longer if you exceed your limit.
|
277
|
+
|
278
|
+
1. **Run your app**
|
279
|
+
|
280
|
+
- Command line warriors: `python3 <filename>`.
|
281
|
+
- IDE heroes: press the big green button.
|
282
|
+
|
283
|
+
Your app connects to Bitvavo and returns a list the latest trade price for each
|
284
|
+
market. You use this data to implement your trading logic.
|
285
|
+
|
286
|
+
## About the SDK
|
287
|
+
|
288
|
+
This section explains global concepts about Bitvavo SDK for Python.
|
289
|
+
|
290
|
+
### Rate limit
|
291
|
+
|
292
|
+
Bitvavo uses a weight based rate limiting system. Your app is limited to 1000
|
293
|
+
weight points per IP or API key per minute. When you make a call to Bitvavo API,
|
294
|
+
your remaining weight points are returned in the header of each REST request.
|
295
|
+
|
296
|
+
Websocket methods do not return your returning weight points, you track your
|
297
|
+
remaining weight points with a call to:
|
298
|
+
|
299
|
+
```python
|
300
|
+
limit = bitvavo.getRemainingLimit()
|
301
|
+
```
|
302
|
+
|
303
|
+
If you make more requests than permitted by the weight limit, your IP or API key
|
304
|
+
is banned.
|
305
|
+
|
306
|
+
The rate weighting for each endpoint is supplied in the [Bitvavo API
|
307
|
+
documentation](https://docs.bitvavo.com/).
|
308
|
+
|
309
|
+
### Requests
|
310
|
+
|
311
|
+
For all methods, required parameters are passed as separate values, optional
|
312
|
+
parameters are passed as a dictionary. Return parameters are in dictionary
|
313
|
+
format: `response['<key>'] = '<value>'`. However, as a limit order requires more
|
314
|
+
information than a market order, some optional parameters are required when you
|
315
|
+
place an order.
|
316
|
+
|
317
|
+
### Security
|
318
|
+
|
319
|
+
You must set your API key and secret for authenticated endpoints, public
|
320
|
+
endpoints do not require authentication.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
bitvavo_api_upgraded/__init__.py,sha256=CSK4JninN6nxMUqoT-S_Vl9UJc4NOqwfbbZf-Qnvpo4,222
|
2
|
+
bitvavo_api_upgraded/bitvavo.py,sha256=-0OAa3aKQ_KuDSJooNJLSL07v29e1zBfVvgSmPI0zDE,125972
|
3
|
+
bitvavo_api_upgraded/helper_funcs.py,sha256=4oBdQ1xB-C2XkQTmN-refzIzWfO-IUowDSWhOSFdCRU,3212
|
4
|
+
bitvavo_api_upgraded/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
+
bitvavo_api_upgraded/settings.py,sha256=ZH2sR9iUyOC_lSaqmT50wERngUuobvu8d0TLiYN5nTg,2266
|
6
|
+
bitvavo_api_upgraded/type_aliases.py,sha256=NAnMSk5n6SaEIvHFeSMKnXOxfOwnbFuEnRKaAXlcmYw,932
|
7
|
+
bitvavo_api_upgraded-1.17.1.dist-info/METADATA,sha256=EckCoKnMdi22Yxzx-2zklIFIvuSKNNIP9o7gBQ_Fg3E,11547
|
8
|
+
bitvavo_api_upgraded-1.17.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
9
|
+
bitvavo_api_upgraded-1.17.1.dist-info/licenses/LICENSE.txt,sha256=hiFyor_njVlzVblnb-78mzx1Um3CGvuFxEH3YR735rc,744
|
10
|
+
bitvavo_api_upgraded-1.17.1.dist-info/RECORD,,
|
{bitvavo_api_upgraded-1.16.0.dist-info → bitvavo_api_upgraded-1.17.1.dist-info}/licenses/LICENSE.txt
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
ISC License
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2024, Bitvavo B.V.
|
4
4
|
|
5
5
|
Permission to use, copy, modify, and/or distribute this software for any
|
6
6
|
purpose with or without fee is hereby granted, provided that the above
|
@@ -12,4 +12,4 @@ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
12
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
13
13
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
14
14
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
15
|
-
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|