lighter-sdk 0.1.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. lighter/__init__.py +140 -0
  2. lighter/api/__init__.py +11 -0
  3. lighter/api/account_api.py +2371 -0
  4. lighter/api/block_api.py +863 -0
  5. lighter/api/candlestick_api.py +718 -0
  6. lighter/api/info_api.py +282 -0
  7. lighter/api/order_api.py +2734 -0
  8. lighter/api/root_api.py +529 -0
  9. lighter/api/transaction_api.py +3525 -0
  10. lighter/api_client.py +784 -0
  11. lighter/api_response.py +21 -0
  12. lighter/configuration.py +475 -0
  13. lighter/exceptions.py +199 -0
  14. lighter/models/__init__.py +112 -0
  15. lighter/models/account.py +110 -0
  16. lighter/models/account_api_keys.py +104 -0
  17. lighter/models/account_market_stats.py +98 -0
  18. lighter/models/account_metadata.py +94 -0
  19. lighter/models/account_pn_l.py +106 -0
  20. lighter/models/account_position.py +112 -0
  21. lighter/models/account_stats.py +102 -0
  22. lighter/models/accounts.py +106 -0
  23. lighter/models/api_key.py +98 -0
  24. lighter/models/block.py +124 -0
  25. lighter/models/blocks.py +106 -0
  26. lighter/models/bridge_supported_network.py +96 -0
  27. lighter/models/candlestick.py +106 -0
  28. lighter/models/candlesticks.py +106 -0
  29. lighter/models/contract_address.py +94 -0
  30. lighter/models/current_height.py +96 -0
  31. lighter/models/cursor.py +92 -0
  32. lighter/models/deposit_history.py +106 -0
  33. lighter/models/deposit_history_item.py +105 -0
  34. lighter/models/detailed_account.py +152 -0
  35. lighter/models/detailed_accounts.py +106 -0
  36. lighter/models/detailed_candlestick.py +108 -0
  37. lighter/models/enriched_tx.py +129 -0
  38. lighter/models/exchange_stats.py +110 -0
  39. lighter/models/fee_bucket.py +96 -0
  40. lighter/models/funding.py +98 -0
  41. lighter/models/fundings.py +106 -0
  42. lighter/models/is_whitelisted.py +98 -0
  43. lighter/models/l1_provider_info.py +98 -0
  44. lighter/models/layer2_basic_info.py +100 -0
  45. lighter/models/liquidation.py +100 -0
  46. lighter/models/market_info.py +116 -0
  47. lighter/models/next_nonce.py +96 -0
  48. lighter/models/order.py +159 -0
  49. lighter/models/order_book.py +119 -0
  50. lighter/models/order_book_depth.py +115 -0
  51. lighter/models/order_book_detail.py +151 -0
  52. lighter/models/order_book_details.py +104 -0
  53. lighter/models/order_book_orders.py +117 -0
  54. lighter/models/order_book_stats.py +102 -0
  55. lighter/models/order_books.py +104 -0
  56. lighter/models/orders.py +106 -0
  57. lighter/models/pn_l_entry.py +94 -0
  58. lighter/models/position_funding.py +111 -0
  59. lighter/models/price_level.py +94 -0
  60. lighter/models/public_pool.py +128 -0
  61. lighter/models/public_pool_info.py +100 -0
  62. lighter/models/public_pool_share.py +96 -0
  63. lighter/models/public_pools.py +106 -0
  64. lighter/models/req_get_account.py +101 -0
  65. lighter/models/req_get_account_active_orders.py +96 -0
  66. lighter/models/req_get_account_api_keys.py +94 -0
  67. lighter/models/req_get_account_by_l1_address.py +92 -0
  68. lighter/models/req_get_account_inactive_orders.py +103 -0
  69. lighter/models/req_get_account_orders.py +99 -0
  70. lighter/models/req_get_account_pending_txs.py +106 -0
  71. lighter/models/req_get_account_pn_l.py +118 -0
  72. lighter/models/req_get_account_txs.py +111 -0
  73. lighter/models/req_get_block.py +101 -0
  74. lighter/models/req_get_block_txs.py +101 -0
  75. lighter/models/req_get_by_account.py +101 -0
  76. lighter/models/req_get_candlesticks.py +109 -0
  77. lighter/models/req_get_deposit_history.py +106 -0
  78. lighter/models/req_get_fee_bucket.py +92 -0
  79. lighter/models/req_get_fundings.py +107 -0
  80. lighter/models/req_get_l1_tx.py +92 -0
  81. lighter/models/req_get_latest_deposit.py +92 -0
  82. lighter/models/req_get_next_nonce.py +94 -0
  83. lighter/models/req_get_order_book_details.py +92 -0
  84. lighter/models/req_get_order_book_orders.py +95 -0
  85. lighter/models/req_get_order_books.py +92 -0
  86. lighter/models/req_get_public_pools.py +109 -0
  87. lighter/models/req_get_range_with_cursor.py +95 -0
  88. lighter/models/req_get_range_with_index.py +95 -0
  89. lighter/models/req_get_range_with_index_sortable.py +107 -0
  90. lighter/models/req_get_recent_trades.py +95 -0
  91. lighter/models/req_get_trades.py +126 -0
  92. lighter/models/req_get_tx.py +101 -0
  93. lighter/models/req_get_withdraw_history.py +106 -0
  94. lighter/models/req_is_whitelisted.py +92 -0
  95. lighter/models/result_code.py +94 -0
  96. lighter/models/simple_order.py +102 -0
  97. lighter/models/status.py +94 -0
  98. lighter/models/sub_accounts.py +106 -0
  99. lighter/models/ticker.py +103 -0
  100. lighter/models/trade.py +125 -0
  101. lighter/models/trades.py +106 -0
  102. lighter/models/tx.py +121 -0
  103. lighter/models/tx_hash.py +96 -0
  104. lighter/models/tx_hashes.py +96 -0
  105. lighter/models/txs.py +104 -0
  106. lighter/models/validator_info.py +94 -0
  107. lighter/models/withdraw_history.py +110 -0
  108. lighter/models/withdraw_history_cursor.py +94 -0
  109. lighter/models/withdraw_history_item.py +114 -0
  110. lighter/models/zk_lighter_info.py +92 -0
  111. lighter/py.typed +0 -0
  112. lighter/rest.py +215 -0
  113. lighter/signer_client.py +440 -0
  114. lighter/signers/signer-amd64.so +0 -0
  115. lighter/signers/signer-arm64.dylib +0 -0
  116. lighter/transactions/__init__.py +3 -0
  117. lighter/transactions/cancel_order.py +27 -0
  118. lighter/transactions/create_order.py +33 -0
  119. lighter/transactions/withdraw.py +25 -0
  120. lighter/ws_client.py +160 -0
  121. lighter_sdk-0.1.0.dist-info/LICENSE +201 -0
  122. lighter_sdk-0.1.0.dist-info/METADATA +26 -0
  123. lighter_sdk-0.1.0.dist-info/RECORD +125 -0
  124. lighter_sdk-0.1.0.dist-info/WHEEL +5 -0
  125. lighter_sdk-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,100 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document:
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, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class Layer2BasicInfo(BaseModel):
26
+ """
27
+ Layer2BasicInfo
28
+ """ # noqa: E501
29
+ code: StrictInt
30
+ message: Optional[StrictStr] = None
31
+ block_committed: StrictInt
32
+ block_verified: StrictInt
33
+ total_transaction_count: StrictInt
34
+ __properties: ClassVar[List[str]] = ["code", "message", "block_committed", "block_verified", "total_transaction_count"]
35
+
36
+ model_config = ConfigDict(
37
+ populate_by_name=True,
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
40
+ )
41
+
42
+
43
+ def to_str(self) -> str:
44
+ """Returns the string representation of the model using alias"""
45
+ return pprint.pformat(self.model_dump(by_alias=True))
46
+
47
+ def to_json(self) -> str:
48
+ """Returns the JSON representation of the model using alias"""
49
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
50
+ return json.dumps(self.to_dict())
51
+
52
+ @classmethod
53
+ def from_json(cls, json_str: str) -> Optional[Self]:
54
+ """Create an instance of Layer2BasicInfo from a JSON string"""
55
+ return cls.from_dict(json.loads(json_str))
56
+
57
+ def to_dict(self) -> Dict[str, Any]:
58
+ """Return the dictionary representation of the model using alias.
59
+
60
+ This has the following differences from calling pydantic's
61
+ `self.model_dump(by_alias=True)`:
62
+
63
+ * `None` is only added to the output dict for nullable fields that
64
+ were set at model initialization. Other fields with value `None`
65
+ are ignored.
66
+ """
67
+ excluded_fields: Set[str] = set([
68
+ ])
69
+
70
+ _dict = self.model_dump(
71
+ by_alias=True,
72
+ exclude=excluded_fields,
73
+ exclude_none=True,
74
+ )
75
+ return _dict
76
+
77
+ @classmethod
78
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
79
+ """Create an instance of Layer2BasicInfo from a dict"""
80
+ if obj is None:
81
+ return None
82
+
83
+ if not isinstance(obj, dict):
84
+ return cls.model_validate(obj)
85
+
86
+ # raise errors for additional fields in the input
87
+ for _key in obj.keys():
88
+ if _key not in cls.__properties:
89
+ raise ValueError("Error due to additional fields (not defined in Layer2BasicInfo) in the input: " + _key)
90
+
91
+ _obj = cls.model_validate({
92
+ "code": obj.get("code"),
93
+ "message": obj.get("message"),
94
+ "block_committed": obj.get("block_committed"),
95
+ "block_verified": obj.get("block_verified"),
96
+ "total_transaction_count": obj.get("total_transaction_count")
97
+ })
98
+ return _obj
99
+
100
+
@@ -0,0 +1,100 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document:
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, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class Liquidation(BaseModel):
26
+ """
27
+ Liquidation
28
+ """ # noqa: E501
29
+ liquidation_id: StrictInt
30
+ account_index: StrictInt
31
+ liquidation_type: StrictInt
32
+ portfolio_value: StrictStr
33
+ margin_requirement: StrictStr
34
+ __properties: ClassVar[List[str]] = ["liquidation_id", "account_index", "liquidation_type", "portfolio_value", "margin_requirement"]
35
+
36
+ model_config = ConfigDict(
37
+ populate_by_name=True,
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
40
+ )
41
+
42
+
43
+ def to_str(self) -> str:
44
+ """Returns the string representation of the model using alias"""
45
+ return pprint.pformat(self.model_dump(by_alias=True))
46
+
47
+ def to_json(self) -> str:
48
+ """Returns the JSON representation of the model using alias"""
49
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
50
+ return json.dumps(self.to_dict())
51
+
52
+ @classmethod
53
+ def from_json(cls, json_str: str) -> Optional[Self]:
54
+ """Create an instance of Liquidation from a JSON string"""
55
+ return cls.from_dict(json.loads(json_str))
56
+
57
+ def to_dict(self) -> Dict[str, Any]:
58
+ """Return the dictionary representation of the model using alias.
59
+
60
+ This has the following differences from calling pydantic's
61
+ `self.model_dump(by_alias=True)`:
62
+
63
+ * `None` is only added to the output dict for nullable fields that
64
+ were set at model initialization. Other fields with value `None`
65
+ are ignored.
66
+ """
67
+ excluded_fields: Set[str] = set([
68
+ ])
69
+
70
+ _dict = self.model_dump(
71
+ by_alias=True,
72
+ exclude=excluded_fields,
73
+ exclude_none=True,
74
+ )
75
+ return _dict
76
+
77
+ @classmethod
78
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
79
+ """Create an instance of Liquidation from a dict"""
80
+ if obj is None:
81
+ return None
82
+
83
+ if not isinstance(obj, dict):
84
+ return cls.model_validate(obj)
85
+
86
+ # raise errors for additional fields in the input
87
+ for _key in obj.keys():
88
+ if _key not in cls.__properties:
89
+ raise ValueError("Error due to additional fields (not defined in Liquidation) in the input: " + _key)
90
+
91
+ _obj = cls.model_validate({
92
+ "liquidation_id": obj.get("liquidation_id"),
93
+ "account_index": obj.get("account_index"),
94
+ "liquidation_type": obj.get("liquidation_type"),
95
+ "portfolio_value": obj.get("portfolio_value"),
96
+ "margin_requirement": obj.get("margin_requirement")
97
+ })
98
+ return _obj
99
+
100
+
@@ -0,0 +1,116 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document:
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, Union
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class MarketInfo(BaseModel):
26
+ """
27
+ MarketInfo
28
+ """ # noqa: E501
29
+ market_id: StrictInt
30
+ index_price: StrictStr
31
+ mark_price: StrictStr
32
+ open_interest: StrictStr
33
+ last_trade_price: StrictStr
34
+ current_funding_rate: StrictStr
35
+ funding_rate: StrictStr
36
+ funding_timestamp: StrictInt
37
+ daily_base_token_volume: Union[StrictFloat, StrictInt]
38
+ daily_quote_token_volume: Union[StrictFloat, StrictInt]
39
+ daily_price_low: Union[StrictFloat, StrictInt]
40
+ daily_price_high: Union[StrictFloat, StrictInt]
41
+ daily_price_change: Union[StrictFloat, StrictInt]
42
+ __properties: ClassVar[List[str]] = ["market_id", "index_price", "mark_price", "open_interest", "last_trade_price", "current_funding_rate", "funding_rate", "funding_timestamp", "daily_base_token_volume", "daily_quote_token_volume", "daily_price_low", "daily_price_high", "daily_price_change"]
43
+
44
+ model_config = ConfigDict(
45
+ populate_by_name=True,
46
+ validate_assignment=True,
47
+ protected_namespaces=(),
48
+ )
49
+
50
+
51
+ def to_str(self) -> str:
52
+ """Returns the string representation of the model using alias"""
53
+ return pprint.pformat(self.model_dump(by_alias=True))
54
+
55
+ def to_json(self) -> str:
56
+ """Returns the JSON representation of the model using alias"""
57
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
58
+ return json.dumps(self.to_dict())
59
+
60
+ @classmethod
61
+ def from_json(cls, json_str: str) -> Optional[Self]:
62
+ """Create an instance of MarketInfo from a JSON string"""
63
+ return cls.from_dict(json.loads(json_str))
64
+
65
+ def to_dict(self) -> Dict[str, Any]:
66
+ """Return the dictionary representation of the model using alias.
67
+
68
+ This has the following differences from calling pydantic's
69
+ `self.model_dump(by_alias=True)`:
70
+
71
+ * `None` is only added to the output dict for nullable fields that
72
+ were set at model initialization. Other fields with value `None`
73
+ are ignored.
74
+ """
75
+ excluded_fields: Set[str] = set([
76
+ ])
77
+
78
+ _dict = self.model_dump(
79
+ by_alias=True,
80
+ exclude=excluded_fields,
81
+ exclude_none=True,
82
+ )
83
+ return _dict
84
+
85
+ @classmethod
86
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
87
+ """Create an instance of MarketInfo from a dict"""
88
+ if obj is None:
89
+ return None
90
+
91
+ if not isinstance(obj, dict):
92
+ return cls.model_validate(obj)
93
+
94
+ # raise errors for additional fields in the input
95
+ for _key in obj.keys():
96
+ if _key not in cls.__properties:
97
+ raise ValueError("Error due to additional fields (not defined in MarketInfo) in the input: " + _key)
98
+
99
+ _obj = cls.model_validate({
100
+ "market_id": obj.get("market_id"),
101
+ "index_price": obj.get("index_price"),
102
+ "mark_price": obj.get("mark_price"),
103
+ "open_interest": obj.get("open_interest"),
104
+ "last_trade_price": obj.get("last_trade_price"),
105
+ "current_funding_rate": obj.get("current_funding_rate"),
106
+ "funding_rate": obj.get("funding_rate"),
107
+ "funding_timestamp": obj.get("funding_timestamp"),
108
+ "daily_base_token_volume": obj.get("daily_base_token_volume"),
109
+ "daily_quote_token_volume": obj.get("daily_quote_token_volume"),
110
+ "daily_price_low": obj.get("daily_price_low"),
111
+ "daily_price_high": obj.get("daily_price_high"),
112
+ "daily_price_change": obj.get("daily_price_change")
113
+ })
114
+ return _obj
115
+
116
+
@@ -0,0 +1,96 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document:
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, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class NextNonce(BaseModel):
26
+ """
27
+ NextNonce
28
+ """ # noqa: E501
29
+ code: StrictInt
30
+ message: Optional[StrictStr] = None
31
+ nonce: StrictInt
32
+ __properties: ClassVar[List[str]] = ["code", "message", "nonce"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
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 NextNonce 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
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ return _dict
74
+
75
+ @classmethod
76
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
77
+ """Create an instance of NextNonce from a dict"""
78
+ if obj is None:
79
+ return None
80
+
81
+ if not isinstance(obj, dict):
82
+ return cls.model_validate(obj)
83
+
84
+ # raise errors for additional fields in the input
85
+ for _key in obj.keys():
86
+ if _key not in cls.__properties:
87
+ raise ValueError("Error due to additional fields (not defined in NextNonce) in the input: " + _key)
88
+
89
+ _obj = cls.model_validate({
90
+ "code": obj.get("code"),
91
+ "message": obj.get("message"),
92
+ "nonce": obj.get("nonce")
93
+ })
94
+ return _obj
95
+
96
+
@@ -0,0 +1,159 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document:
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, Field, StrictBool, StrictInt, StrictStr, field_validator
21
+ from typing import Any, ClassVar, Dict, List
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class Order(BaseModel):
26
+ """
27
+ Order
28
+ """ # noqa: E501
29
+ order_index: StrictInt
30
+ client_order_index: StrictInt
31
+ market_index: StrictInt
32
+ owner_account_index: StrictInt
33
+ initial_base_amount: StrictStr
34
+ price: StrictStr
35
+ nonce: StrictInt
36
+ remaining_base_amount: StrictStr
37
+ is_ask: StrictBool
38
+ base_size: StrictInt
39
+ base_price: StrictInt
40
+ filled_base_amount: StrictStr
41
+ filled_quote_amount: StrictStr
42
+ side: StrictStr = Field(description=" TODO: remove this")
43
+ type: StrictStr
44
+ time_in_force: StrictStr
45
+ reduce_only: StrictBool
46
+ trigger_price: StrictStr
47
+ order_expiry: StrictInt
48
+ status: StrictStr
49
+ trigger_time: StrictInt
50
+ parent_order_index: StrictInt
51
+ block_height: StrictInt
52
+ timestamp: StrictInt
53
+ __properties: ClassVar[List[str]] = ["order_index", "client_order_index", "market_index", "owner_account_index", "initial_base_amount", "price", "nonce", "remaining_base_amount", "is_ask", "base_size", "base_price", "filled_base_amount", "filled_quote_amount", "side", "type", "time_in_force", "reduce_only", "trigger_price", "order_expiry", "status", "trigger_time", "parent_order_index", "block_height", "timestamp"]
54
+
55
+ @field_validator('type')
56
+ def type_validate_enum(cls, value):
57
+ """Validates the enum"""
58
+ if value not in set(['limit', 'market', 'stop-loss', 'stop-loss-limit', 'take-profit', 'take-profit-limit', 'twap', 'twap-sub', 'liquidation']):
59
+ raise ValueError("must be one of enum values ('limit', 'market', 'stop-loss', 'stop-loss-limit', 'take-profit', 'take-profit-limit', 'twap', 'twap-sub', 'liquidation')")
60
+ return value
61
+
62
+ @field_validator('time_in_force')
63
+ def time_in_force_validate_enum(cls, value):
64
+ """Validates the enum"""
65
+ if value not in set(['good-till-time', 'immediate-or-cancel', 'post-only', 'Unknown']):
66
+ raise ValueError("must be one of enum values ('good-till-time', 'immediate-or-cancel', 'post-only', 'Unknown')")
67
+ return value
68
+
69
+ @field_validator('status')
70
+ def status_validate_enum(cls, value):
71
+ """Validates the enum"""
72
+ if value not in set(['in-progress', 'pending', 'open', 'filled', 'canceled', 'canceled-post-only', 'canceled-reduce-only', 'canceled-position-not-allowed', 'canceled-margin-not-allowed', 'canceled-too-much-slippage', 'canceled-not-enough-liquidity', 'canceled-self-trade', 'canceled-expired']):
73
+ raise ValueError("must be one of enum values ('in-progress', 'pending', 'open', 'filled', 'canceled', 'canceled-post-only', 'canceled-reduce-only', 'canceled-position-not-allowed', 'canceled-margin-not-allowed', 'canceled-too-much-slippage', 'canceled-not-enough-liquidity', 'canceled-self-trade', 'canceled-expired')")
74
+ return value
75
+
76
+ model_config = ConfigDict(
77
+ populate_by_name=True,
78
+ validate_assignment=True,
79
+ protected_namespaces=(),
80
+ )
81
+
82
+
83
+ def to_str(self) -> str:
84
+ """Returns the string representation of the model using alias"""
85
+ return pprint.pformat(self.model_dump(by_alias=True))
86
+
87
+ def to_json(self) -> str:
88
+ """Returns the JSON representation of the model using alias"""
89
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
90
+ return json.dumps(self.to_dict())
91
+
92
+ @classmethod
93
+ def from_json(cls, json_str: str) -> Optional[Self]:
94
+ """Create an instance of Order from a JSON string"""
95
+ return cls.from_dict(json.loads(json_str))
96
+
97
+ def to_dict(self) -> Dict[str, Any]:
98
+ """Return the dictionary representation of the model using alias.
99
+
100
+ This has the following differences from calling pydantic's
101
+ `self.model_dump(by_alias=True)`:
102
+
103
+ * `None` is only added to the output dict for nullable fields that
104
+ were set at model initialization. Other fields with value `None`
105
+ are ignored.
106
+ """
107
+ excluded_fields: Set[str] = set([
108
+ ])
109
+
110
+ _dict = self.model_dump(
111
+ by_alias=True,
112
+ exclude=excluded_fields,
113
+ exclude_none=True,
114
+ )
115
+ return _dict
116
+
117
+ @classmethod
118
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
119
+ """Create an instance of Order from a dict"""
120
+ if obj is None:
121
+ return None
122
+
123
+ if not isinstance(obj, dict):
124
+ return cls.model_validate(obj)
125
+
126
+ # raise errors for additional fields in the input
127
+ for _key in obj.keys():
128
+ if _key not in cls.__properties:
129
+ raise ValueError("Error due to additional fields (not defined in Order) in the input: " + _key)
130
+
131
+ _obj = cls.model_validate({
132
+ "order_index": obj.get("order_index"),
133
+ "client_order_index": obj.get("client_order_index"),
134
+ "market_index": obj.get("market_index"),
135
+ "owner_account_index": obj.get("owner_account_index"),
136
+ "initial_base_amount": obj.get("initial_base_amount"),
137
+ "price": obj.get("price"),
138
+ "nonce": obj.get("nonce"),
139
+ "remaining_base_amount": obj.get("remaining_base_amount"),
140
+ "is_ask": obj.get("is_ask"),
141
+ "base_size": obj.get("base_size"),
142
+ "base_price": obj.get("base_price"),
143
+ "filled_base_amount": obj.get("filled_base_amount"),
144
+ "filled_quote_amount": obj.get("filled_quote_amount"),
145
+ "side": obj.get("side") if obj.get("side") is not None else 'buy',
146
+ "type": obj.get("type"),
147
+ "time_in_force": obj.get("time_in_force") if obj.get("time_in_force") is not None else 'good-till-time',
148
+ "reduce_only": obj.get("reduce_only"),
149
+ "trigger_price": obj.get("trigger_price"),
150
+ "order_expiry": obj.get("order_expiry"),
151
+ "status": obj.get("status"),
152
+ "trigger_time": obj.get("trigger_time"),
153
+ "parent_order_index": obj.get("parent_order_index"),
154
+ "block_height": obj.get("block_height"),
155
+ "timestamp": obj.get("timestamp")
156
+ })
157
+ return _obj
158
+
159
+
@@ -0,0 +1,119 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document:
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, StrictInt, StrictStr, field_validator
21
+ from typing import Any, ClassVar, Dict, List
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class OrderBook(BaseModel):
26
+ """
27
+ OrderBook
28
+ """ # noqa: E501
29
+ symbol: StrictStr
30
+ market_id: StrictInt
31
+ status: StrictStr
32
+ taker_fee: StrictStr
33
+ maker_fee: StrictStr
34
+ liquidation_fee: StrictStr
35
+ min_base_amount: StrictStr
36
+ min_quote_amount: StrictStr
37
+ supported_size_decimals: StrictInt
38
+ supported_price_decimals: StrictInt
39
+ supported_quote_decimals: StrictInt
40
+ __properties: ClassVar[List[str]] = ["symbol", "market_id", "status", "taker_fee", "maker_fee", "liquidation_fee", "min_base_amount", "min_quote_amount", "supported_size_decimals", "supported_price_decimals", "supported_quote_decimals"]
41
+
42
+ @field_validator('status')
43
+ def status_validate_enum(cls, value):
44
+ """Validates the enum"""
45
+ if value not in set(['frozen', 'active']):
46
+ raise ValueError("must be one of enum values ('frozen', 'active')")
47
+ return value
48
+
49
+ model_config = ConfigDict(
50
+ populate_by_name=True,
51
+ validate_assignment=True,
52
+ protected_namespaces=(),
53
+ )
54
+
55
+
56
+ def to_str(self) -> str:
57
+ """Returns the string representation of the model using alias"""
58
+ return pprint.pformat(self.model_dump(by_alias=True))
59
+
60
+ def to_json(self) -> str:
61
+ """Returns the JSON representation of the model using alias"""
62
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
63
+ return json.dumps(self.to_dict())
64
+
65
+ @classmethod
66
+ def from_json(cls, json_str: str) -> Optional[Self]:
67
+ """Create an instance of OrderBook from a JSON string"""
68
+ return cls.from_dict(json.loads(json_str))
69
+
70
+ def to_dict(self) -> Dict[str, Any]:
71
+ """Return the dictionary representation of the model using alias.
72
+
73
+ This has the following differences from calling pydantic's
74
+ `self.model_dump(by_alias=True)`:
75
+
76
+ * `None` is only added to the output dict for nullable fields that
77
+ were set at model initialization. Other fields with value `None`
78
+ are ignored.
79
+ """
80
+ excluded_fields: Set[str] = set([
81
+ ])
82
+
83
+ _dict = self.model_dump(
84
+ by_alias=True,
85
+ exclude=excluded_fields,
86
+ exclude_none=True,
87
+ )
88
+ return _dict
89
+
90
+ @classmethod
91
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
92
+ """Create an instance of OrderBook from a dict"""
93
+ if obj is None:
94
+ return None
95
+
96
+ if not isinstance(obj, dict):
97
+ return cls.model_validate(obj)
98
+
99
+ # raise errors for additional fields in the input
100
+ for _key in obj.keys():
101
+ if _key not in cls.__properties:
102
+ raise ValueError("Error due to additional fields (not defined in OrderBook) in the input: " + _key)
103
+
104
+ _obj = cls.model_validate({
105
+ "symbol": obj.get("symbol"),
106
+ "market_id": obj.get("market_id"),
107
+ "status": obj.get("status"),
108
+ "taker_fee": obj.get("taker_fee"),
109
+ "maker_fee": obj.get("maker_fee"),
110
+ "liquidation_fee": obj.get("liquidation_fee"),
111
+ "min_base_amount": obj.get("min_base_amount"),
112
+ "min_quote_amount": obj.get("min_quote_amount"),
113
+ "supported_size_decimals": obj.get("supported_size_decimals"),
114
+ "supported_price_decimals": obj.get("supported_price_decimals"),
115
+ "supported_quote_decimals": obj.get("supported_quote_decimals")
116
+ })
117
+ return _obj
118
+
119
+