crypticorn 2.5.1__py3-none-any.whl → 2.5.2__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.
Files changed (128) hide show
  1. crypticorn/common/__init__.py +1 -0
  2. crypticorn/common/enums.py +3 -1
  3. crypticorn/common/errors.py +40 -4
  4. crypticorn/common/mixins.py +1 -0
  5. crypticorn/common/status_router.py +42 -0
  6. crypticorn/common/utils.py +5 -12
  7. crypticorn/klines/client/__init__.py +0 -5
  8. crypticorn/klines/client/api/change_in_timeframe_api.py +8 -9
  9. crypticorn/klines/client/api/ohlcv_data_api.py +7 -8
  10. crypticorn/klines/client/api/symbols_api.py +7 -8
  11. crypticorn/klines/client/models/__init__.py +0 -5
  12. crypticorn/klines/client/models/exception_detail.py +3 -6
  13. crypticorn/klines/client/models/search_symbol.py +4 -3
  14. crypticorn/klines/client/models/udf_config.py +1 -2
  15. crypticorn/metrics/client/__init__.py +1 -6
  16. crypticorn/metrics/client/api/exchanges_api.py +29 -31
  17. crypticorn/metrics/client/api/indicators_api.py +15 -16
  18. crypticorn/metrics/client/api/logs_api.py +1 -1
  19. crypticorn/metrics/client/api/marketcap_api.py +15 -16
  20. crypticorn/metrics/client/api/markets_api.py +15 -16
  21. crypticorn/metrics/client/api/status_api.py +1 -1
  22. crypticorn/metrics/client/api/tokens_api.py +1 -1
  23. crypticorn/metrics/client/api_client.py +1 -1
  24. crypticorn/metrics/client/configuration.py +3 -5
  25. crypticorn/metrics/client/exceptions.py +1 -1
  26. crypticorn/metrics/client/models/__init__.py +1 -6
  27. crypticorn/metrics/client/models/exception_detail.py +4 -7
  28. crypticorn/metrics/client/models/severity.py +1 -1
  29. crypticorn/metrics/client/models/time_interval.py +1 -1
  30. crypticorn/metrics/client/models/trading_status.py +1 -1
  31. crypticorn/metrics/client/rest.py +1 -1
  32. crypticorn/trade/client/__init__.py +1 -2
  33. crypticorn/trade/client/api/exchanges_api.py +6 -6
  34. crypticorn/trade/client/api/trading_actions_api.py +16 -15
  35. crypticorn/trade/client/configuration.py +2 -2
  36. crypticorn/trade/client/models/__init__.py +1 -2
  37. crypticorn/trade/client/models/action_model.py +1 -2
  38. crypticorn/trade/client/models/exchange_key_model.py +2 -11
  39. crypticorn/trade/client/models/futures_trading_action.py +1 -2
  40. crypticorn/trade/client/models/order_model.py +4 -14
  41. crypticorn/trade/client/models/spot_trading_action.py +1 -2
  42. crypticorn/trade/client/models/strategy_exchange_info.py +2 -3
  43. crypticorn/trade/client/models/strategy_model_input.py +1 -2
  44. crypticorn/trade/client/models/strategy_model_output.py +1 -2
  45. crypticorn/trade/client/models/tpsl.py +3 -1
  46. {crypticorn-2.5.1.dist-info → crypticorn-2.5.2.dist-info}/METADATA +1 -1
  47. {crypticorn-2.5.1.dist-info → crypticorn-2.5.2.dist-info}/RECORD +50 -127
  48. crypticorn/klines/client/api/health_check_api.py +0 -265
  49. crypticorn/klines/client/models/api_error_identifier.py +0 -108
  50. crypticorn/klines/client/models/api_error_level.py +0 -37
  51. crypticorn/klines/client/models/api_error_type.py +0 -37
  52. crypticorn/klines/client/models/base_response_health_check_response.py +0 -114
  53. crypticorn/klines/client/models/base_response_list_change_in_timeframe_response.py +0 -123
  54. crypticorn/klines/client/models/base_response_list_funding_rate_response.py +0 -118
  55. crypticorn/klines/client/models/base_response_list_str.py +0 -106
  56. crypticorn/klines/client/models/base_response_ohlcv_response.py +0 -114
  57. crypticorn/klines/client/models/change_in_timeframe_response.py +0 -86
  58. crypticorn/klines/client/models/error_response.py +0 -109
  59. crypticorn/klines/client/models/exchange.py +0 -91
  60. crypticorn/klines/client/models/funding_rate_response.py +0 -92
  61. crypticorn/klines/client/models/health_check_response.py +0 -91
  62. crypticorn/klines/client/models/history_error_response.py +0 -89
  63. crypticorn/klines/client/models/history_no_data_response.py +0 -99
  64. crypticorn/klines/client/models/history_success_response.py +0 -99
  65. crypticorn/klines/client/models/http_validation_error.py +0 -99
  66. crypticorn/klines/client/models/internal_exchange.py +0 -39
  67. crypticorn/klines/client/models/market.py +0 -35
  68. crypticorn/klines/client/models/market_type.py +0 -35
  69. crypticorn/klines/client/models/ohlcv_response.py +0 -105
  70. crypticorn/klines/client/models/response_get_history_udf_history_get.py +0 -198
  71. crypticorn/klines/client/models/response_get_udf_history.py +0 -198
  72. crypticorn/klines/client/models/search_symbol_response.py +0 -104
  73. crypticorn/klines/client/models/symbol_group_response.py +0 -83
  74. crypticorn/klines/client/models/symbol_info_response.py +0 -131
  75. crypticorn/klines/client/models/udf_config_response.py +0 -160
  76. crypticorn/klines/client/models/validation_error.py +0 -105
  77. crypticorn/klines/client/models/validation_error_loc_inner.py +0 -159
  78. crypticorn/metrics/client/api/health_check_api.py +0 -265
  79. crypticorn/metrics/client/models/api_error_identifier.py +0 -108
  80. crypticorn/metrics/client/models/api_error_level.py +0 -37
  81. crypticorn/metrics/client/models/api_error_type.py +0 -37
  82. crypticorn/metrics/client/models/base_response_dict.py +0 -106
  83. crypticorn/metrics/client/models/base_response_health_check_response.py +0 -114
  84. crypticorn/metrics/client/models/base_response_list_dict.py +0 -106
  85. crypticorn/metrics/client/models/base_response_list_exchange_mapping.py +0 -118
  86. crypticorn/metrics/client/models/base_response_list_str.py +0 -106
  87. crypticorn/metrics/client/models/error_response.py +0 -109
  88. crypticorn/metrics/client/models/exchange_mapping.py +0 -134
  89. crypticorn/metrics/client/models/health_check_response.py +0 -91
  90. crypticorn/metrics/client/models/http_validation_error.py +0 -99
  91. crypticorn/metrics/client/models/internal_exchange.py +0 -39
  92. crypticorn/metrics/client/models/market.py +0 -35
  93. crypticorn/metrics/client/models/market_type.py +0 -35
  94. crypticorn/metrics/client/models/validation_error.py +0 -105
  95. crypticorn/metrics/client/models/validation_error_loc_inner.py +0 -159
  96. crypticorn/pay/client/models/api_status_res.py +0 -83
  97. crypticorn/pay/client/models/body_create_now_invoice.py +0 -98
  98. crypticorn/pay/client/models/body_create_product.py +0 -98
  99. crypticorn/pay/client/models/body_get_products.py +0 -87
  100. crypticorn/pay/client/models/body_handle_now_webhook.py +0 -98
  101. crypticorn/pay/client/models/body_update_product.py +0 -98
  102. crypticorn/pay/client/models/combined_payment_history.py +0 -101
  103. crypticorn/pay/client/models/create_invoice_req.py +0 -188
  104. crypticorn/pay/client/models/create_invoice_res.py +0 -188
  105. crypticorn/pay/client/models/currency.py +0 -165
  106. crypticorn/pay/client/models/estimate_price_req.py +0 -91
  107. crypticorn/pay/client/models/estimate_price_res.py +0 -102
  108. crypticorn/pay/client/models/get_currencies_res.py +0 -99
  109. crypticorn/pay/client/models/get_payment_status_res.py +0 -222
  110. crypticorn/pay/client/models/get_payments_list_res.py +0 -109
  111. crypticorn/pay/client/models/min_amount_req.py +0 -124
  112. crypticorn/pay/client/models/min_amount_res.py +0 -105
  113. crypticorn/pay/client/models/now_fee_structure.py +0 -104
  114. crypticorn/pay/client/models/now_payment_model.py +0 -124
  115. crypticorn/pay/client/models/now_payment_status.py +0 -42
  116. crypticorn/pay/client/models/now_webhook_payload.py +0 -181
  117. crypticorn/pay/client/models/partial_product_update_model.py +0 -150
  118. crypticorn/pay/client/models/product.py +0 -87
  119. crypticorn/pay/client/models/product_model.py +0 -128
  120. crypticorn/pay/client/models/product_subs_model.py +0 -108
  121. crypticorn/pay/client/models/product_update_model.py +0 -150
  122. crypticorn/pay/client/models/unified_payment_model.py +0 -112
  123. crypticorn/trade/client/models/api_key_model.py +0 -156
  124. crypticorn/trade/client/models/exchange.py +0 -35
  125. crypticorn/trade/client/models/market_type.py +0 -35
  126. {crypticorn-2.5.1.dist-info → crypticorn-2.5.2.dist-info}/WHEEL +0 -0
  127. {crypticorn-2.5.1.dist-info → crypticorn-2.5.2.dist-info}/entry_points.txt +0 -0
  128. {crypticorn-2.5.1.dist-info → crypticorn-2.5.2.dist-info}/top_level.txt +0 -0
@@ -1,99 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Klines Service API
5
-
6
- API for retrieving OHLCV data, funding rates, and symbol information from Binance. ## WebSocket Support Connect to `/ws` to receive real-time OHLCV updates. Example subscription message: ```json { \"action\": \"subscribe\", \"market\": \"spot\", \"symbol\": \"BTCUSDT\", \"timeframe\": \"15m\" } ```
7
-
8
- The version of the OpenAPI document: 1.0.0
9
- Generated by OpenAPI Generator (https://openapi-generator.tech)
10
-
11
- Do not edit the class manually.
12
- """ # noqa: E501
13
-
14
-
15
- from __future__ import annotations
16
- import pprint
17
- import re # noqa: F401
18
- import json
19
-
20
- from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr
21
- from typing import Any, ClassVar, Dict, List, Optional, Union
22
- from typing import Optional, Set
23
- from typing_extensions import Self
24
-
25
-
26
- class HistoryNoDataResponse(BaseModel):
27
- """
28
- HistoryNoDataResponse
29
- """ # noqa: E501
30
-
31
- s: Optional[StrictStr] = "no_data"
32
- t: Optional[List[StrictInt]] = None
33
- o: Optional[List[Union[StrictFloat, StrictInt]]] = None
34
- h: Optional[List[Union[StrictFloat, StrictInt]]] = None
35
- l: Optional[List[Union[StrictFloat, StrictInt]]] = None
36
- c: Optional[List[Union[StrictFloat, StrictInt]]] = None
37
- v: Optional[List[Union[StrictFloat, StrictInt]]] = None
38
- __properties: ClassVar[List[str]] = ["s", "t", "o", "h", "l", "c", "v"]
39
-
40
- model_config = ConfigDict(
41
- populate_by_name=True,
42
- validate_assignment=True,
43
- protected_namespaces=(),
44
- )
45
-
46
- def to_str(self) -> str:
47
- """Returns the string representation of the model using alias"""
48
- return pprint.pformat(self.model_dump(by_alias=True))
49
-
50
- def to_json(self) -> str:
51
- """Returns the JSON representation of the model using alias"""
52
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
53
- return json.dumps(self.to_dict())
54
-
55
- @classmethod
56
- def from_json(cls, json_str: str) -> Optional[Self]:
57
- """Create an instance of HistoryNoDataResponse from a JSON string"""
58
- return cls.from_dict(json.loads(json_str))
59
-
60
- def to_dict(self) -> Dict[str, Any]:
61
- """Return the dictionary representation of the model using alias.
62
-
63
- This has the following differences from calling pydantic's
64
- `self.model_dump(by_alias=True)`:
65
-
66
- * `None` is only added to the output dict for nullable fields that
67
- were set at model initialization. Other fields with value `None`
68
- are ignored.
69
- """
70
- excluded_fields: Set[str] = set([])
71
-
72
- _dict = self.model_dump(
73
- by_alias=True,
74
- exclude=excluded_fields,
75
- exclude_none=True,
76
- )
77
- return _dict
78
-
79
- @classmethod
80
- def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
81
- """Create an instance of HistoryNoDataResponse from a dict"""
82
- if obj is None:
83
- return None
84
-
85
- if not isinstance(obj, dict):
86
- return cls.model_validate(obj)
87
-
88
- _obj = cls.model_validate(
89
- {
90
- "s": obj.get("s") if obj.get("s") is not None else "no_data",
91
- "t": obj.get("t"),
92
- "o": obj.get("o"),
93
- "h": obj.get("h"),
94
- "l": obj.get("l"),
95
- "c": obj.get("c"),
96
- "v": obj.get("v"),
97
- }
98
- )
99
- return _obj
@@ -1,99 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Klines Service API
5
-
6
- API for retrieving OHLCV data, funding rates, and symbol information from Binance. ## WebSocket Support Connect to `/ws` to receive real-time OHLCV updates. Example subscription message: ```json { \"action\": \"subscribe\", \"market\": \"spot\", \"symbol\": \"BTCUSDT\", \"timeframe\": \"15m\" } ```
7
-
8
- The version of the OpenAPI document: 1.0.0
9
- Generated by OpenAPI Generator (https://openapi-generator.tech)
10
-
11
- Do not edit the class manually.
12
- """ # noqa: E501
13
-
14
-
15
- from __future__ import annotations
16
- import pprint
17
- import re # noqa: F401
18
- import json
19
-
20
- from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr
21
- from typing import Any, ClassVar, Dict, List, Optional, Union
22
- from typing import Optional, Set
23
- from typing_extensions import Self
24
-
25
-
26
- class HistorySuccessResponse(BaseModel):
27
- """
28
- HistorySuccessResponse
29
- """ # noqa: E501
30
-
31
- s: Optional[StrictStr] = "ok"
32
- t: List[StrictInt]
33
- o: List[Union[StrictFloat, StrictInt]]
34
- h: List[Union[StrictFloat, StrictInt]]
35
- l: List[Union[StrictFloat, StrictInt]]
36
- c: List[Union[StrictFloat, StrictInt]]
37
- v: List[Union[StrictFloat, StrictInt]]
38
- __properties: ClassVar[List[str]] = ["s", "t", "o", "h", "l", "c", "v"]
39
-
40
- model_config = ConfigDict(
41
- populate_by_name=True,
42
- validate_assignment=True,
43
- protected_namespaces=(),
44
- )
45
-
46
- def to_str(self) -> str:
47
- """Returns the string representation of the model using alias"""
48
- return pprint.pformat(self.model_dump(by_alias=True))
49
-
50
- def to_json(self) -> str:
51
- """Returns the JSON representation of the model using alias"""
52
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
53
- return json.dumps(self.to_dict())
54
-
55
- @classmethod
56
- def from_json(cls, json_str: str) -> Optional[Self]:
57
- """Create an instance of HistorySuccessResponse from a JSON string"""
58
- return cls.from_dict(json.loads(json_str))
59
-
60
- def to_dict(self) -> Dict[str, Any]:
61
- """Return the dictionary representation of the model using alias.
62
-
63
- This has the following differences from calling pydantic's
64
- `self.model_dump(by_alias=True)`:
65
-
66
- * `None` is only added to the output dict for nullable fields that
67
- were set at model initialization. Other fields with value `None`
68
- are ignored.
69
- """
70
- excluded_fields: Set[str] = set([])
71
-
72
- _dict = self.model_dump(
73
- by_alias=True,
74
- exclude=excluded_fields,
75
- exclude_none=True,
76
- )
77
- return _dict
78
-
79
- @classmethod
80
- def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
81
- """Create an instance of HistorySuccessResponse from a dict"""
82
- if obj is None:
83
- return None
84
-
85
- if not isinstance(obj, dict):
86
- return cls.model_validate(obj)
87
-
88
- _obj = cls.model_validate(
89
- {
90
- "s": obj.get("s") if obj.get("s") is not None else "ok",
91
- "t": obj.get("t"),
92
- "o": obj.get("o"),
93
- "h": obj.get("h"),
94
- "l": obj.get("l"),
95
- "c": obj.get("c"),
96
- "v": obj.get("v"),
97
- }
98
- )
99
- return _obj
@@ -1,99 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Klines Service API
5
-
6
- API for retrieving OHLCV data, funding rates, and symbol information from Binance. ## WebSocket Support Connect to `/ws` to receive real-time OHLCV updates. Example subscription message: ```json { \"action\": \"subscribe\", \"market\": \"spot\", \"symbol\": \"BTCUSDT\", \"timeframe\": \"15m\" } ```
7
-
8
- The version of the OpenAPI document: 1.0.0
9
- Generated by OpenAPI Generator (https://openapi-generator.tech)
10
-
11
- Do not edit the class manually.
12
- """ # noqa: E501
13
-
14
-
15
- from __future__ import annotations
16
- import pprint
17
- import re # noqa: F401
18
- import json
19
-
20
- from pydantic import BaseModel, ConfigDict
21
- from typing import Any, ClassVar, Dict, List, Optional
22
- from crypticorn.klines.client.models.validation_error import ValidationError
23
- from typing import Optional, Set
24
- from typing_extensions import Self
25
-
26
-
27
- class HTTPValidationError(BaseModel):
28
- """
29
- HTTPValidationError
30
- """ # noqa: E501
31
-
32
- detail: Optional[List[ValidationError]] = None
33
- __properties: ClassVar[List[str]] = ["detail"]
34
-
35
- model_config = ConfigDict(
36
- populate_by_name=True,
37
- validate_assignment=True,
38
- protected_namespaces=(),
39
- )
40
-
41
- def to_str(self) -> str:
42
- """Returns the string representation of the model using alias"""
43
- return pprint.pformat(self.model_dump(by_alias=True))
44
-
45
- def to_json(self) -> str:
46
- """Returns the JSON representation of the model using alias"""
47
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48
- return json.dumps(self.to_dict())
49
-
50
- @classmethod
51
- def from_json(cls, json_str: str) -> Optional[Self]:
52
- """Create an instance of HTTPValidationError from a JSON string"""
53
- return cls.from_dict(json.loads(json_str))
54
-
55
- def to_dict(self) -> Dict[str, Any]:
56
- """Return the dictionary representation of the model using alias.
57
-
58
- This has the following differences from calling pydantic's
59
- `self.model_dump(by_alias=True)`:
60
-
61
- * `None` is only added to the output dict for nullable fields that
62
- were set at model initialization. Other fields with value `None`
63
- are ignored.
64
- """
65
- excluded_fields: Set[str] = set([])
66
-
67
- _dict = self.model_dump(
68
- by_alias=True,
69
- exclude=excluded_fields,
70
- exclude_none=True,
71
- )
72
- # override the default output from pydantic by calling `to_dict()` of each item in detail (list)
73
- _items = []
74
- if self.detail:
75
- for _item_detail in self.detail:
76
- if _item_detail:
77
- _items.append(_item_detail.to_dict())
78
- _dict["detail"] = _items
79
- return _dict
80
-
81
- @classmethod
82
- def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
83
- """Create an instance of HTTPValidationError from a dict"""
84
- if obj is None:
85
- return None
86
-
87
- if not isinstance(obj, dict):
88
- return cls.model_validate(obj)
89
-
90
- _obj = cls.model_validate(
91
- {
92
- "detail": (
93
- [ValidationError.from_dict(_item) for _item in obj["detail"]]
94
- if obj.get("detail") is not None
95
- else None
96
- )
97
- }
98
- )
99
- return _obj
@@ -1,39 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Klines Service API
5
-
6
- API for retrieving OHLCV data, funding rates, and symbol information from Binance.
7
-
8
- The version of the OpenAPI document: 1.0.0
9
- Generated by OpenAPI Generator (https://openapi-generator.tech)
10
-
11
- Do not edit the class manually.
12
- """ # noqa: E501
13
-
14
-
15
- from __future__ import annotations
16
- import json
17
- from enum import Enum
18
- from typing_extensions import Self
19
-
20
-
21
- class InternalExchange(str, Enum):
22
- """
23
- All exchanges we are using, including public (Exchange)
24
- """
25
-
26
- """
27
- allowed enum values
28
- """
29
- KUCOIN = "kucoin"
30
- BINGX = "bingx"
31
- BINANCE = "binance"
32
- BYBIT = "bybit"
33
- HYPERLIQUID = "hyperliquid"
34
- BITGET = "bitget"
35
-
36
- @classmethod
37
- def from_json(cls, json_str: str) -> Self:
38
- """Create an instance of InternalExchange from a JSON string"""
39
- return cls(json.loads(json_str))
@@ -1,35 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Klines Service API
5
-
6
- API for retrieving OHLCV data, funding rates, and symbol information from Binance. ## WebSocket Support Connect to `/ws` to receive real-time OHLCV updates. Example subscription message: ```json { \"action\": \"subscribe\", \"market\": \"spot\", \"symbol\": \"BTCUSDT\", \"timeframe\": \"15m\" } ```
7
-
8
- The version of the OpenAPI document: 1.0.0
9
- Generated by OpenAPI Generator (https://openapi-generator.tech)
10
-
11
- Do not edit the class manually.
12
- """ # noqa: E501
13
-
14
-
15
- from __future__ import annotations
16
- import json
17
- from enum import Enum
18
- from typing_extensions import Self
19
-
20
-
21
- class Market(str, Enum):
22
- """
23
- Market
24
- """
25
-
26
- """
27
- allowed enum values
28
- """
29
- SPOT = "spot"
30
- FUTURES = "futures"
31
-
32
- @classmethod
33
- def from_json(cls, json_str: str) -> Self:
34
- """Create an instance of Market from a JSON string"""
35
- return cls(json.loads(json_str))
@@ -1,35 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Klines Service API
5
-
6
- API for retrieving OHLCV data, funding rates, and symbol information from Binance.
7
-
8
- The version of the OpenAPI document: 1.0.0
9
- Generated by OpenAPI Generator (https://openapi-generator.tech)
10
-
11
- Do not edit the class manually.
12
- """ # noqa: E501
13
-
14
-
15
- from __future__ import annotations
16
- import json
17
- from enum import Enum
18
- from typing_extensions import Self
19
-
20
-
21
- class MarketType(str, Enum):
22
- """
23
- Market types
24
- """
25
-
26
- """
27
- allowed enum values
28
- """
29
- SPOT = "spot"
30
- FUTURES = "futures"
31
-
32
- @classmethod
33
- def from_json(cls, json_str: str) -> Self:
34
- """Create an instance of MarketType from a JSON string"""
35
- return cls(json.loads(json_str))
@@ -1,105 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Klines Service API
5
-
6
- API for retrieving OHLCV data, funding rates, and symbol information from Binance. ## WebSocket Support Connect to `/ws` to receive real-time OHLCV updates. Example subscription message: ```json { \"action\": \"subscribe\", \"market\": \"spot\", \"symbol\": \"BTCUSDT\", \"timeframe\": \"15m\" } ```
7
-
8
- The version of the OpenAPI document: 1.0.0
9
- Generated by OpenAPI Generator (https://openapi-generator.tech)
10
-
11
- Do not edit the class manually.
12
- """ # noqa: E501
13
-
14
-
15
- from __future__ import annotations
16
- import pprint
17
- import re # noqa: F401
18
- import json
19
-
20
- from datetime import datetime
21
- from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt
22
- from typing import Any, ClassVar, Dict, List, Union
23
- from typing import Optional, Set
24
- from typing_extensions import Self
25
-
26
-
27
- class OHLCVResponse(BaseModel):
28
- """
29
- OHLCVResponse
30
- """ # noqa: E501
31
-
32
- timestamp: List[datetime]
33
- open: List[Union[StrictFloat, StrictInt]]
34
- high: List[Union[StrictFloat, StrictInt]]
35
- low: List[Union[StrictFloat, StrictInt]]
36
- close: List[Union[StrictFloat, StrictInt]]
37
- volume: List[Union[StrictFloat, StrictInt]]
38
- __properties: ClassVar[List[str]] = [
39
- "timestamp",
40
- "open",
41
- "high",
42
- "low",
43
- "close",
44
- "volume",
45
- ]
46
-
47
- model_config = ConfigDict(
48
- populate_by_name=True,
49
- validate_assignment=True,
50
- protected_namespaces=(),
51
- )
52
-
53
- def to_str(self) -> str:
54
- """Returns the string representation of the model using alias"""
55
- return pprint.pformat(self.model_dump(by_alias=True))
56
-
57
- def to_json(self) -> str:
58
- """Returns the JSON representation of the model using alias"""
59
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
60
- return json.dumps(self.to_dict())
61
-
62
- @classmethod
63
- def from_json(cls, json_str: str) -> Optional[Self]:
64
- """Create an instance of OHLCVResponse from a JSON string"""
65
- return cls.from_dict(json.loads(json_str))
66
-
67
- def to_dict(self) -> Dict[str, Any]:
68
- """Return the dictionary representation of the model using alias.
69
-
70
- This has the following differences from calling pydantic's
71
- `self.model_dump(by_alias=True)`:
72
-
73
- * `None` is only added to the output dict for nullable fields that
74
- were set at model initialization. Other fields with value `None`
75
- are ignored.
76
- """
77
- excluded_fields: Set[str] = set([])
78
-
79
- _dict = self.model_dump(
80
- by_alias=True,
81
- exclude=excluded_fields,
82
- exclude_none=True,
83
- )
84
- return _dict
85
-
86
- @classmethod
87
- def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
88
- """Create an instance of OHLCVResponse from a dict"""
89
- if obj is None:
90
- return None
91
-
92
- if not isinstance(obj, dict):
93
- return cls.model_validate(obj)
94
-
95
- _obj = cls.model_validate(
96
- {
97
- "timestamp": obj.get("timestamp"),
98
- "open": obj.get("open"),
99
- "high": obj.get("high"),
100
- "low": obj.get("low"),
101
- "close": obj.get("close"),
102
- "volume": obj.get("volume"),
103
- }
104
- )
105
- return _obj