bitvavo-api-upgraded 1.17.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.
@@ -1,3 +1,8 @@
1
1
  from bitvavo_api_upgraded.bitvavo import Bitvavo
2
+ from bitvavo_api_upgraded.settings import BitvavoApiUpgradedSettings, BitvavoSettings
2
3
 
3
- __all__ = ["Bitvavo"]
4
+ __all__ = [
5
+ "Bitvavo",
6
+ "BitvavoApiUpgradedSettings",
7
+ "BitvavoSettings",
8
+ ]
@@ -14,7 +14,7 @@ from structlog.stdlib import get_logger
14
14
  from websocket import WebSocketApp # missing stubs for WebSocketApp
15
15
 
16
16
  from bitvavo_api_upgraded.helper_funcs import configure_loggers, time_ms, time_to_wait
17
- from bitvavo_api_upgraded.settings import BITVAVO_API_UPGRADED
17
+ from bitvavo_api_upgraded.settings import bitvavo_upgraded_settings
18
18
  from bitvavo_api_upgraded.type_aliases import anydict, errordict, intdict, ms, s_f, strdict, strintdict
19
19
 
20
20
  configure_loggers()
@@ -332,7 +332,7 @@ class Bitvavo:
332
332
  list[list[str]]
333
333
  ```
334
334
  """
335
- if (self.rateLimitRemaining - rateLimitingWeight) <= BITVAVO_API_UPGRADED.RATE_LIMITING_BUFFER:
335
+ if (self.rateLimitRemaining - rateLimitingWeight) <= bitvavo_upgraded_settings.RATE_LIMITING_BUFFER:
336
336
  self.sleep_until_can_continue()
337
337
  if self.debugging:
338
338
  logger.debug(
@@ -344,7 +344,7 @@ class Bitvavo:
344
344
  },
345
345
  )
346
346
  if self.APIKEY != "":
347
- now = time_ms() + BITVAVO_API_UPGRADED.LAG
347
+ now = time_ms() + bitvavo_upgraded_settings.LAG
348
348
  sig = createSignature(now, "GET", url.replace(self.base, ""), None, self.APISECRET)
349
349
  headers = {
350
350
  "bitvavo-access-key": self.APIKEY,
@@ -391,10 +391,10 @@ class Bitvavo:
391
391
  list[list[str]]
392
392
  ```
393
393
  """
394
- if (self.rateLimitRemaining - rateLimitingWeight) <= BITVAVO_API_UPGRADED.RATE_LIMITING_BUFFER:
394
+ if (self.rateLimitRemaining - rateLimitingWeight) <= bitvavo_upgraded_settings.RATE_LIMITING_BUFFER:
395
395
  self.sleep_until_can_continue()
396
396
  # if this method breaks: add `= {}` after `body: dict`
397
- now = time_ms() + BITVAVO_API_UPGRADED.LAG
397
+ now = time_ms() + bitvavo_upgraded_settings.LAG
398
398
  sig = createSignature(now, method, (endpoint + postfix), body, self.APISECRET)
399
399
  url = self.base + endpoint + postfix
400
400
  headers = {
@@ -1832,7 +1832,7 @@ class Bitvavo:
1832
1832
  self.subscriptionBook(market, self.callbacks["subscriptionBookUser"][market])
1833
1833
 
1834
1834
  def on_open(self, ws: Any) -> None: # noqa: ARG002
1835
- now = time_ms() + BITVAVO_API_UPGRADED.LAG
1835
+ now = time_ms() + bitvavo_upgraded_settings.LAG
1836
1836
  self.open = True
1837
1837
  self.reconnectTimer = 0.5
1838
1838
  if self.APIKEY != "":
@@ -1,47 +1,70 @@
1
1
  import logging
2
2
  from pathlib import Path
3
3
 
4
- from decouple import AutoConfig, Choices
4
+ from pydantic import Field, field_validator, model_validator
5
+ from pydantic_settings import BaseSettings, SettingsConfigDict
5
6
 
6
7
  from bitvavo_api_upgraded.type_aliases import ms
7
8
 
8
- # don't use/import python-decouple's `config`` variable, because the search_path isn't set,
9
- # which means applications that use a .env file can't override these variables :(
10
- config = AutoConfig(search_path=Path.cwd())
11
9
 
10
+ class BitvavoApiUpgradedSettings(BaseSettings):
11
+ """
12
+ These settings provide extra functionality. Originally I wanted to combine
13
+ then, but I figured that would be a bad idea.
14
+ """
12
15
 
13
- class _BitvavoApiUpgraded:
14
- # default LOG_LEVEL is WARNING, so users don't get their ass spammed.
15
- LOG_LEVEL: str = config(
16
- "BITVAVO_API_UPGRADED_LOG_LEVEL",
17
- default="INFO",
18
- cast=Choices(list(logging._nameToLevel.keys())), # noqa: SLF001
19
- )
20
- LOG_EXTERNAL_LEVEL: str = config(
21
- "BITVAVO_API_UPGRADED_EXTERNAL_LOG_LEVEL",
22
- default="WARNING",
23
- cast=Choices(list(logging._nameToLevel.keys())), # noqa: SLF001
16
+ LOG_LEVEL: str = Field("INFO")
17
+ LOG_EXTERNAL_LEVEL: str = Field("WARNING")
18
+ LAG: ms = Field(ms(50))
19
+ RATE_LIMITING_BUFFER: int = Field(25)
20
+
21
+ # Configuration for Pydantic Settings
22
+ model_config = SettingsConfigDict(
23
+ env_file=Path.cwd() / ".env",
24
+ env_file_encoding="utf-8",
25
+ env_prefix="BITVAVO_API_UPGRADED_",
26
+ extra="ignore",
24
27
  )
25
- LAG: ms = config("BITVAVO_API_UPGRADED_LAG", default=ms(50), cast=ms)
26
- RATE_LIMITING_BUFFER: int = config("BITVAVO_API_UPGRADED_RATE_LIMITING_BUFFER", default=25, cast=int)
27
28
 
29
+ @classmethod
30
+ @field_validator("LOG_LEVEL", "LOG_EXTERNAL_LEVEL", mode="before")
31
+ def validate_log_level(cls, v: str) -> str:
32
+ if v not in logging._nameToLevel: # noqa: SLF001
33
+ msg = f"Invalid log level: {v}"
34
+ raise ValueError(msg)
35
+ return v
28
36
 
29
- class _Bitvavo:
37
+
38
+ class BitvavoSettings(BaseSettings):
30
39
  """
31
- Changeable variables are handled by the decouple lib, anything else is just static, because they are based on
32
- Bitvavo's documentation and thus should not be able to be set outside of the application.
40
+ These are the base settings from the original library.
33
41
  """
34
42
 
35
- ACCESSWINDOW: int = config("BITVAVO_ACCESSWINDOW", default=10_000, cast=int)
36
- API_RATING_LIMIT_PER_MINUTE: int = 1000
37
- API_RATING_LIMIT_PER_SECOND: float = API_RATING_LIMIT_PER_MINUTE / 60
38
- APIKEY: str = config("BITVAVO_APIKEY", default="BITVAVO_APIKEY is missing")
39
- APISECRET: str = config("BITVAVO_APISECRET", default="BITVAVO_APISECRET is missing")
40
- DEBUGGING: bool = config("BITVAVO_DEBUGGING", default=False, cast=bool)
41
- RESTURL: str = "https://api.bitvavo.com/v2"
42
- WSURL: str = "wss://ws.bitvavo.com/v2/"
43
+ ACCESSWINDOW: int = Field(10_000)
44
+ API_RATING_LIMIT_PER_MINUTE: int = Field(default=1000)
45
+ API_RATING_LIMIT_PER_SECOND: int = Field(default=1000)
46
+ APIKEY: str = Field(default="BITVAVO_APIKEY is missing")
47
+ APISECRET: str = Field(default="BITVAVO_APISECRET is missing")
48
+ DEBUGGING: bool = Field(default=False)
49
+ RESTURL: str = Field(default="https://api.bitvavo.com/v2")
50
+ WSURL: str = Field(default="wss://ws.bitvavo.com/v2/")
51
+
52
+ # Configuration for Pydantic Settings
53
+ model_config = SettingsConfigDict(
54
+ env_file=Path.cwd() / ".env",
55
+ env_file_encoding="utf-8",
56
+ env_prefix="BITVAVO_",
57
+ extra="ignore",
58
+ )
59
+
60
+ @model_validator(mode="after")
61
+ def set_api_rating_limit_per_second(self) -> "BitvavoSettings":
62
+ self.API_RATING_LIMIT_PER_SECOND = self.API_RATING_LIMIT_PER_SECOND // 60
63
+ return self
43
64
 
44
65
 
45
- # Just import these variables to use the settings :)
46
- BITVAVO_API_UPGRADED = _BitvavoApiUpgraded()
47
- BITVAVO = _Bitvavo()
66
+ # Initialize the settings
67
+ bitvavo_upgraded_settings = BitvavoApiUpgradedSettings()
68
+ BITVAVO_API_UPGRADED = bitvavo_upgraded_settings
69
+ bitvavo_settings = BitvavoSettings()
70
+ BITVAVO = bitvavo_settings
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: bitvavo-api-upgraded
3
- Version: 1.17.0
3
+ Version: 1.17.1
4
4
  Summary: A unit-tested fork of the Bitvavo API
5
5
  Project-URL: homepage, https://github.com/Thaumatorium/bitvavo-api-upgraded
6
6
  Project-URL: repository, https://github.com/Thaumatorium/bitvavo-api-upgraded
@@ -9,6 +9,7 @@ Author: Bitvavo BV (original code)
9
9
  Author-email: NostraDavid <55331731+NostraDavid@users.noreply.github.com>
10
10
  Maintainer-email: NostraDavid <55331731+NostraDavid@users.noreply.github.com>
11
11
  License: ISC License
12
+ License-File: LICENSE.txt
12
13
  Classifier: Development Status :: 5 - Production/Stable
13
14
  Classifier: Environment :: Console
14
15
  Classifier: Framework :: Pytest
@@ -27,7 +28,7 @@ Classifier: Programming Language :: Python :: 3.12
27
28
  Classifier: Programming Language :: Python :: 3.13
28
29
  Classifier: Typing :: Typed
29
30
  Requires-Python: >=3.9
30
- Requires-Dist: python-decouple==3.*,>=3.5
31
+ Requires-Dist: pydantic-settings==2.*,>=2.6
31
32
  Requires-Dist: requests==2.*,>=2.26
32
33
  Requires-Dist: structlog==24.*,>=21.5
33
34
  Requires-Dist: websocket-client==1.*,>=1.2
@@ -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,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.26.3
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,10 +0,0 @@
1
- bitvavo_api_upgraded/__init__.py,sha256=IS9Ci2orRtYKHyFNXq_9qk9bB6zt4KU4tPbQAxkkCUM,72
2
- bitvavo_api_upgraded/bitvavo.py,sha256=-AgVq4hXHEsuQhCLEweyjJ_DhAPwbwtCeCPSNeweisA,125942
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=MalcO2buJso4NZktDRGGSZ7poF593ceb66zrmX-8dc4,1903
6
- bitvavo_api_upgraded/type_aliases.py,sha256=NAnMSk5n6SaEIvHFeSMKnXOxfOwnbFuEnRKaAXlcmYw,932
7
- bitvavo_api_upgraded-1.17.0.dist-info/METADATA,sha256=Csu9ntgiu7tVaEvKXJmBjrFEMAxlVfHhIHRlvYwflIo,11519
8
- bitvavo_api_upgraded-1.17.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
9
- bitvavo_api_upgraded-1.17.0.dist-info/licenses/LICENSE.txt,sha256=hiFyor_njVlzVblnb-78mzx1Um3CGvuFxEH3YR735rc,744
10
- bitvavo_api_upgraded-1.17.0.dist-info/RECORD,,