crypticorn 2.15.0__py3-none-any.whl → 2.17.0__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.
- crypticorn/__init__.py +2 -2
- crypticorn/auth/client/api/admin_api.py +397 -13
- crypticorn/auth/client/api/auth_api.py +3610 -341
- crypticorn/auth/client/api/service_api.py +249 -7
- crypticorn/auth/client/api/user_api.py +2295 -179
- crypticorn/auth/client/api/wallet_api.py +1468 -81
- crypticorn/auth/client/configuration.py +2 -2
- crypticorn/auth/client/models/create_api_key_request.py +2 -1
- crypticorn/auth/client/models/get_api_keys200_response_inner.py +2 -1
- crypticorn/auth/client/rest.py +23 -4
- crypticorn/auth/main.py +8 -5
- crypticorn/cli/init.py +1 -1
- crypticorn/cli/templates/.env.docker.temp +3 -0
- crypticorn/cli/templates/.env.example.temp +4 -0
- crypticorn/cli/templates/Dockerfile +5 -2
- crypticorn/client.py +226 -59
- crypticorn/common/__init__.py +1 -0
- crypticorn/common/auth.py +45 -14
- crypticorn/common/decorators.py +1 -2
- crypticorn/common/enums.py +0 -2
- crypticorn/common/errors.py +10 -0
- crypticorn/common/metrics.py +30 -0
- crypticorn/common/middleware.py +94 -1
- crypticorn/common/pagination.py +252 -18
- crypticorn/common/router/admin_router.py +2 -2
- crypticorn/common/router/status_router.py +40 -2
- crypticorn/common/scopes.py +2 -0
- crypticorn/common/warnings.py +8 -0
- crypticorn/dex/__init__.py +6 -0
- crypticorn/dex/client/__init__.py +49 -0
- crypticorn/dex/client/api/__init__.py +6 -0
- crypticorn/dex/client/api/admin_api.py +2986 -0
- crypticorn/dex/client/api/signals_api.py +1798 -0
- crypticorn/dex/client/api/status_api.py +892 -0
- crypticorn/dex/client/api_client.py +758 -0
- crypticorn/dex/client/api_response.py +20 -0
- crypticorn/dex/client/configuration.py +620 -0
- crypticorn/dex/client/exceptions.py +220 -0
- crypticorn/dex/client/models/__init__.py +30 -0
- crypticorn/dex/client/models/api_error_identifier.py +121 -0
- crypticorn/dex/client/models/api_error_level.py +37 -0
- crypticorn/dex/client/models/api_error_type.py +37 -0
- crypticorn/dex/client/models/exception_detail.py +117 -0
- crypticorn/dex/client/models/log_level.py +38 -0
- crypticorn/dex/client/models/paginated_response_signal_with_token.py +134 -0
- crypticorn/dex/client/models/risk.py +86 -0
- crypticorn/dex/client/models/signal_overview_stats.py +158 -0
- crypticorn/dex/client/models/signal_volume.py +84 -0
- crypticorn/dex/client/models/signal_with_token.py +163 -0
- crypticorn/dex/client/models/token_data.py +127 -0
- crypticorn/dex/client/models/token_detail.py +116 -0
- crypticorn/dex/client/py.typed +0 -0
- crypticorn/dex/client/rest.py +217 -0
- crypticorn/dex/main.py +1 -0
- crypticorn/hive/client/api/admin_api.py +1173 -47
- crypticorn/hive/client/api/data_api.py +499 -17
- crypticorn/hive/client/api/models_api.py +1595 -87
- crypticorn/hive/client/api/status_api.py +397 -16
- crypticorn/hive/client/api_client.py +0 -5
- crypticorn/hive/client/models/api_error_identifier.py +1 -1
- crypticorn/hive/client/models/coin_info.py +1 -1
- crypticorn/hive/client/models/exception_detail.py +1 -1
- crypticorn/hive/client/models/target_info.py +1 -1
- crypticorn/hive/client/rest.py +23 -4
- crypticorn/hive/main.py +99 -25
- crypticorn/hive/utils.py +2 -2
- crypticorn/klines/client/api/admin_api.py +1173 -47
- crypticorn/klines/client/api/change_in_timeframe_api.py +269 -11
- crypticorn/klines/client/api/funding_rates_api.py +315 -11
- crypticorn/klines/client/api/ohlcv_data_api.py +390 -11
- crypticorn/klines/client/api/status_api.py +397 -16
- crypticorn/klines/client/api/symbols_api.py +216 -11
- crypticorn/klines/client/api/udf_api.py +1268 -51
- crypticorn/klines/client/api_client.py +0 -5
- crypticorn/klines/client/models/api_error_identifier.py +3 -1
- crypticorn/klines/client/models/exception_detail.py +1 -1
- crypticorn/klines/client/models/ohlcv.py +1 -1
- crypticorn/klines/client/models/symbol_group.py +1 -1
- crypticorn/klines/client/models/udf_config.py +1 -1
- crypticorn/klines/client/rest.py +23 -4
- crypticorn/klines/main.py +89 -12
- crypticorn/metrics/client/api/admin_api.py +1173 -47
- crypticorn/metrics/client/api/exchanges_api.py +1370 -145
- crypticorn/metrics/client/api/indicators_api.py +622 -17
- crypticorn/metrics/client/api/logs_api.py +296 -11
- crypticorn/metrics/client/api/marketcap_api.py +1207 -67
- crypticorn/metrics/client/api/markets_api.py +343 -11
- crypticorn/metrics/client/api/quote_currencies_api.py +228 -11
- crypticorn/metrics/client/api/status_api.py +397 -16
- crypticorn/metrics/client/api/tokens_api.py +382 -15
- crypticorn/metrics/client/api_client.py +0 -5
- crypticorn/metrics/client/configuration.py +4 -2
- crypticorn/metrics/client/models/exception_detail.py +1 -1
- crypticorn/metrics/client/models/exchange_mapping.py +1 -1
- crypticorn/metrics/client/models/marketcap_ranking.py +1 -1
- crypticorn/metrics/client/models/marketcap_symbol_ranking.py +1 -1
- crypticorn/metrics/client/models/ohlcv.py +1 -1
- crypticorn/metrics/client/rest.py +23 -4
- crypticorn/metrics/main.py +113 -19
- crypticorn/pay/client/api/admin_api.py +1585 -57
- crypticorn/pay/client/api/now_payments_api.py +961 -39
- crypticorn/pay/client/api/payments_api.py +562 -17
- crypticorn/pay/client/api/products_api.py +880 -30
- crypticorn/pay/client/api/status_api.py +397 -16
- crypticorn/pay/client/api_client.py +0 -5
- crypticorn/pay/client/configuration.py +2 -2
- crypticorn/pay/client/models/api_error_identifier.py +7 -7
- crypticorn/pay/client/models/exception_detail.py +1 -1
- crypticorn/pay/client/models/now_create_invoice_req.py +1 -1
- crypticorn/pay/client/models/now_create_invoice_res.py +1 -1
- crypticorn/pay/client/models/product.py +1 -1
- crypticorn/pay/client/models/product_create.py +1 -1
- crypticorn/pay/client/models/product_update.py +1 -1
- crypticorn/pay/client/models/scope.py +1 -0
- crypticorn/pay/client/rest.py +23 -4
- crypticorn/pay/main.py +10 -6
- crypticorn/trade/client/__init__.py +11 -1
- crypticorn/trade/client/api/__init__.py +0 -1
- crypticorn/trade/client/api/admin_api.py +1184 -55
- crypticorn/trade/client/api/api_keys_api.py +1678 -162
- crypticorn/trade/client/api/bots_api.py +7563 -187
- crypticorn/trade/client/api/exchanges_api.py +565 -19
- crypticorn/trade/client/api/notifications_api.py +1290 -116
- crypticorn/trade/client/api/orders_api.py +393 -55
- crypticorn/trade/client/api/status_api.py +397 -13
- crypticorn/trade/client/api/strategies_api.py +1133 -77
- crypticorn/trade/client/api/trading_actions_api.py +786 -65
- crypticorn/trade/client/models/__init__.py +11 -0
- crypticorn/trade/client/models/actions_count.py +88 -0
- crypticorn/trade/client/models/api_error_identifier.py +8 -7
- crypticorn/trade/client/models/bot.py +7 -18
- crypticorn/trade/client/models/bot_create.py +17 -1
- crypticorn/trade/client/models/bot_update.py +17 -1
- crypticorn/trade/client/models/exchange.py +6 -1
- crypticorn/trade/client/models/exchange_key.py +1 -1
- crypticorn/trade/client/models/exchange_key_balance.py +111 -0
- crypticorn/trade/client/models/exchange_key_create.py +17 -1
- crypticorn/trade/client/models/exchange_key_update.py +17 -1
- crypticorn/trade/client/models/execution_ids.py +1 -1
- crypticorn/trade/client/models/futures_balance.py +27 -25
- crypticorn/trade/client/models/futures_trading_action.py +6 -28
- crypticorn/trade/client/models/futures_trading_action_create.py +10 -13
- crypticorn/trade/client/models/notification.py +17 -1
- crypticorn/trade/client/models/notification_create.py +18 -2
- crypticorn/trade/client/models/notification_update.py +17 -1
- crypticorn/trade/client/models/order.py +2 -14
- crypticorn/trade/client/models/orders_count.py +88 -0
- crypticorn/trade/client/models/paginated_response_futures_trading_action.py +134 -0
- crypticorn/trade/client/models/paginated_response_order.py +134 -0
- crypticorn/trade/client/models/pn_l.py +95 -0
- crypticorn/trade/client/models/post_futures_action.py +1 -1
- crypticorn/trade/client/models/spot_balance.py +109 -0
- crypticorn/trade/client/models/spot_trading_action_create.py +4 -1
- crypticorn/trade/client/models/strategy.py +22 -4
- crypticorn/trade/client/models/strategy_create.py +23 -5
- crypticorn/trade/client/models/strategy_exchange_info.py +16 -4
- crypticorn/trade/client/models/strategy_update.py +19 -3
- crypticorn/trade/client/models/tpsl.py +4 -27
- crypticorn/trade/client/models/tpsl_create.py +6 -19
- crypticorn/trade/client/rest.py +23 -4
- crypticorn/trade/main.py +15 -12
- {crypticorn-2.15.0.dist-info → crypticorn-2.17.0.dist-info}/METADATA +65 -20
- {crypticorn-2.15.0.dist-info → crypticorn-2.17.0.dist-info}/RECORD +167 -132
- crypticorn/trade/client/api/futures_trading_panel_api.py +0 -1285
- {crypticorn-2.15.0.dist-info → crypticorn-2.17.0.dist-info}/WHEEL +0 -0
- {crypticorn-2.15.0.dist-info → crypticorn-2.17.0.dist-info}/entry_points.txt +0 -0
- {crypticorn-2.15.0.dist-info → crypticorn-2.17.0.dist-info}/licenses/LICENSE +0 -0
- {crypticorn-2.15.0.dist-info → crypticorn-2.17.0.dist-info}/top_level.txt +0 -0
@@ -14,6 +14,7 @@ Do not edit the class manually.
|
|
14
14
|
|
15
15
|
|
16
16
|
# import models into model package
|
17
|
+
from crypticorn.trade.client.models.actions_count import ActionsCount
|
17
18
|
from crypticorn.trade.client.models.api_error_identifier import ApiErrorIdentifier
|
18
19
|
from crypticorn.trade.client.models.api_error_level import ApiErrorLevel
|
19
20
|
from crypticorn.trade.client.models.api_error_type import ApiErrorType
|
@@ -24,6 +25,7 @@ from crypticorn.trade.client.models.bot_update import BotUpdate
|
|
24
25
|
from crypticorn.trade.client.models.exception_detail import ExceptionDetail
|
25
26
|
from crypticorn.trade.client.models.exchange import Exchange
|
26
27
|
from crypticorn.trade.client.models.exchange_key import ExchangeKey
|
28
|
+
from crypticorn.trade.client.models.exchange_key_balance import ExchangeKeyBalance
|
27
29
|
from crypticorn.trade.client.models.exchange_key_create import ExchangeKeyCreate
|
28
30
|
from crypticorn.trade.client.models.exchange_key_update import ExchangeKeyUpdate
|
29
31
|
from crypticorn.trade.client.models.execution_ids import ExecutionIds
|
@@ -40,7 +42,16 @@ from crypticorn.trade.client.models.notification_create import NotificationCreat
|
|
40
42
|
from crypticorn.trade.client.models.notification_update import NotificationUpdate
|
41
43
|
from crypticorn.trade.client.models.order import Order
|
42
44
|
from crypticorn.trade.client.models.order_status import OrderStatus
|
45
|
+
from crypticorn.trade.client.models.orders_count import OrdersCount
|
46
|
+
from crypticorn.trade.client.models.paginated_response_futures_trading_action import (
|
47
|
+
PaginatedResponseFuturesTradingAction,
|
48
|
+
)
|
49
|
+
from crypticorn.trade.client.models.paginated_response_order import (
|
50
|
+
PaginatedResponseOrder,
|
51
|
+
)
|
52
|
+
from crypticorn.trade.client.models.pn_l import PnL
|
43
53
|
from crypticorn.trade.client.models.post_futures_action import PostFuturesAction
|
54
|
+
from crypticorn.trade.client.models.spot_balance import SpotBalance
|
44
55
|
from crypticorn.trade.client.models.spot_trading_action_create import (
|
45
56
|
SpotTradingActionCreate,
|
46
57
|
)
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
"""
|
4
|
+
Trading API
|
5
|
+
|
6
|
+
API for automated trading and exchange interface. This API is used to trade on the exchange and manage bots, API keys, orders, and more.
|
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, Field, StrictInt
|
21
|
+
from typing import Any, ClassVar, Dict, List
|
22
|
+
from typing import Optional, Set
|
23
|
+
from typing_extensions import Self
|
24
|
+
|
25
|
+
|
26
|
+
class ActionsCount(BaseModel):
|
27
|
+
"""
|
28
|
+
The number of actions for a user by day
|
29
|
+
""" # noqa: E501
|
30
|
+
|
31
|
+
timestamp: StrictInt = Field(
|
32
|
+
description="Timestamp of the latest action for the day"
|
33
|
+
)
|
34
|
+
count: StrictInt = Field(description="The number of actions for the day")
|
35
|
+
__properties: ClassVar[List[str]] = ["timestamp", "count"]
|
36
|
+
|
37
|
+
model_config = ConfigDict(
|
38
|
+
populate_by_name=True,
|
39
|
+
validate_assignment=True,
|
40
|
+
protected_namespaces=(),
|
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 ActionsCount 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
|
+
_dict = self.model_dump(
|
70
|
+
by_alias=True,
|
71
|
+
exclude=excluded_fields,
|
72
|
+
exclude_none=True,
|
73
|
+
)
|
74
|
+
return _dict
|
75
|
+
|
76
|
+
@classmethod
|
77
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
78
|
+
"""Create an instance of ActionsCount from a dict"""
|
79
|
+
if obj is None:
|
80
|
+
return None
|
81
|
+
|
82
|
+
if not isinstance(obj, dict):
|
83
|
+
return cls.model_validate(obj)
|
84
|
+
|
85
|
+
_obj = cls.model_validate(
|
86
|
+
{"timestamp": obj.get("timestamp"), "count": obj.get("count")}
|
87
|
+
)
|
88
|
+
return _obj
|
@@ -28,15 +28,17 @@ class ApiErrorIdentifier(str, Enum):
|
|
28
28
|
"""
|
29
29
|
ALLOCATION_BELOW_CURRENT_EXPOSURE = "allocation_below_current_exposure"
|
30
30
|
ALLOCATION_BELOW_MIN_AMOUNT = "allocation_below_min_amount"
|
31
|
+
ALLOCATION_LIMIT_EXCEEDED = "allocation_limit_exceeded"
|
31
32
|
BLACK_SWAN = "black_swan"
|
32
33
|
BOT_ALREADY_DELETED = "bot_already_deleted"
|
33
|
-
BOT_DISABLED = "bot_disabled"
|
34
34
|
BOT_STOPPING_COMPLETED = "bot_stopping_completed"
|
35
35
|
BOT_STOPPING_STARTED = "bot_stopping_started"
|
36
36
|
CANCELLED_OPEN_ORDER = "cancelled_open_order"
|
37
37
|
CLIENT_ORDER_ID_ALREADY_EXISTS = "client_order_id_already_exists"
|
38
38
|
INVALID_CONTENT_TYPE = "invalid_content_type"
|
39
39
|
DELETE_BOT_ERROR = "delete_bot_error"
|
40
|
+
EXCHANGE_HTTP_REQUEST_ERROR = "exchange_http_request_error"
|
41
|
+
EXCHANGE_INVALID_PARAMETER = "exchange_invalid_parameter"
|
40
42
|
EXCHANGE_INVALID_SIGNATURE = "exchange_invalid_signature"
|
41
43
|
EXCHANGE_INVALID_TIMESTAMP = "exchange_invalid_timestamp"
|
42
44
|
EXCHANGE_IP_ADDRESS_IS_NOT_AUTHORIZED = "exchange_ip_address_is_not_authorized"
|
@@ -56,27 +58,27 @@ class ApiErrorIdentifier(str, Enum):
|
|
56
58
|
EXCHANGE_USER_ACCOUNT_IS_FROZEN = "exchange_user_account_is_frozen"
|
57
59
|
API_KEY_EXPIRED = "api_key_expired"
|
58
60
|
BEARER_TOKEN_EXPIRED = "bearer_token_expired"
|
59
|
-
|
61
|
+
FAILED_OPEN_ORDER = "failed_open_order"
|
60
62
|
FORBIDDEN = "forbidden"
|
61
63
|
HEDGE_MODE_NOT_ACTIVE = "hedge_mode_not_active"
|
62
|
-
HTTP_REQUEST_ERROR = "http_request_error"
|
63
64
|
INSUFFICIENT_BALANCE = "insufficient_balance"
|
64
65
|
INSUFFICIENT_MARGIN = "insufficient_margin"
|
65
66
|
INSUFFICIENT_SCOPES = "insufficient_scopes"
|
66
67
|
INVALID_API_KEY = "invalid_api_key"
|
68
|
+
INVALID_BASIC_AUTH = "invalid_basic_auth"
|
67
69
|
INVALID_BEARER = "invalid_bearer"
|
68
70
|
INVALID_DATA = "invalid_data"
|
69
71
|
INVALID_DATA_RESPONSE = "invalid_data_response"
|
70
72
|
INVALID_EXCHANGE_KEY = "invalid_exchange_key"
|
71
|
-
INVALID_MARGIN_MODE = "invalid_margin_mode"
|
72
73
|
INVALID_MODEL_NAME = "invalid_model_name"
|
73
|
-
INVALID_PARAMETER_PROVIDED = "exchange_invalid_parameter"
|
74
74
|
LEVERAGE_LIMIT_EXCEEDED = "leverage_limit_exceeded"
|
75
75
|
ORDER_VIOLATES_LIQUIDATION_PRICE_CONSTRAINTS = (
|
76
76
|
"order_violates_liquidation_price_constraints"
|
77
77
|
)
|
78
78
|
MARGIN_MODE_CLASH = "margin_mode_clash"
|
79
79
|
NAME_NOT_UNIQUE = "name_not_unique"
|
80
|
+
NO_API_KEY = "no_api_key"
|
81
|
+
NO_BEARER = "no_bearer"
|
80
82
|
NO_CREDENTIALS = "no_credentials"
|
81
83
|
NOW_API_DOWN = "now_api_down"
|
82
84
|
OBJECT_ALREADY_EXISTS = "object_already_exists"
|
@@ -102,14 +104,13 @@ class ApiErrorIdentifier(str, Enum):
|
|
102
104
|
RISK_LIMIT_EXCEEDED = "risk_limit_exceeded"
|
103
105
|
RPC_TIMEOUT = "rpc_timeout"
|
104
106
|
SYSTEM_SETTLEMENT_IN_PROCESS = "system_settlement_in_process"
|
105
|
-
STRATEGY_ALREADY_EXISTS = "strategy_already_exists"
|
106
107
|
STRATEGY_DISABLED = "strategy_disabled"
|
107
108
|
STRATEGY_LEVERAGE_MISMATCH = "strategy_leverage_mismatch"
|
108
109
|
STRATEGY_NOT_SUPPORTING_EXCHANGE = "strategy_not_supporting_exchange"
|
109
110
|
SUCCESS = "success"
|
110
111
|
SYMBOL_DOES_NOT_EXIST = "symbol_does_not_exist"
|
111
112
|
TRADING_ACTION_EXPIRED = "trading_action_expired"
|
112
|
-
TRADING_ACTION_SKIPPED_BOT_STOPPING = "
|
113
|
+
TRADING_ACTION_SKIPPED_BOT_STOPPING = "trading_action_skipped_bot_stopping"
|
113
114
|
TRADING_HAS_BEEN_LOCKED = "trading_has_been_locked"
|
114
115
|
TRADING_IS_SUSPENDED = "trading_is_suspended"
|
115
116
|
UNKNOWN_ERROR_OCCURRED = "unknown_error_occurred"
|
@@ -18,8 +18,7 @@ import re # noqa: F401
|
|
18
18
|
import json
|
19
19
|
|
20
20
|
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
21
|
-
from typing import Any, ClassVar, Dict, List, Optional
|
22
|
-
from typing_extensions import Annotated
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
23
22
|
from crypticorn.trade.client.models.api_error_identifier import ApiErrorIdentifier
|
24
23
|
from crypticorn.trade.client.models.bot_status import BotStatus
|
25
24
|
from typing import Optional, Set
|
@@ -49,22 +48,12 @@ class Bot(BaseModel):
|
|
49
48
|
)
|
50
49
|
api_key_id: StrictStr = Field(description="UID for the API key")
|
51
50
|
status_code: Optional[ApiErrorIdentifier] = None
|
52
|
-
current_allocation: Optional[
|
53
|
-
|
54
|
-
Annotated[float, Field(strict=True, ge=0.0)],
|
55
|
-
Annotated[int, Field(strict=True, ge=0)],
|
56
|
-
]
|
57
|
-
] = Field(
|
58
|
-
default=0,
|
51
|
+
current_allocation: Optional[StrictStr] = Field(
|
52
|
+
default="0",
|
59
53
|
description="Initial allocation for the bot + accumulated PnL of the orders after the last allocation change",
|
60
54
|
)
|
61
|
-
current_exposure: Optional[
|
62
|
-
|
63
|
-
Annotated[float, Field(strict=True, ge=0.0)],
|
64
|
-
Annotated[int, Field(strict=True, ge=0)],
|
65
|
-
]
|
66
|
-
] = Field(
|
67
|
-
default=0,
|
55
|
+
current_exposure: Optional[StrictStr] = Field(
|
56
|
+
default="0",
|
68
57
|
description="Current exposure of the bot, aka. the sum of the absolute values of the open positions",
|
69
58
|
)
|
70
59
|
__properties: ClassVar[List[str]] = [
|
@@ -150,12 +139,12 @@ class Bot(BaseModel):
|
|
150
139
|
"current_allocation": (
|
151
140
|
obj.get("current_allocation")
|
152
141
|
if obj.get("current_allocation") is not None
|
153
|
-
else 0
|
142
|
+
else "0"
|
154
143
|
),
|
155
144
|
"current_exposure": (
|
156
145
|
obj.get("current_exposure")
|
157
146
|
if obj.get("current_exposure") is not None
|
158
|
-
else 0
|
147
|
+
else "0"
|
159
148
|
),
|
160
149
|
}
|
161
150
|
)
|
@@ -36,6 +36,7 @@ class BotCreate(BaseModel):
|
|
36
36
|
description="UID for the trading strategy used by the bot"
|
37
37
|
)
|
38
38
|
api_key_id: StrictStr = Field(description="UID for the API key")
|
39
|
+
additional_properties: Dict[str, Any] = {}
|
39
40
|
__properties: ClassVar[List[str]] = [
|
40
41
|
"name",
|
41
42
|
"allocation",
|
@@ -73,14 +74,24 @@ class BotCreate(BaseModel):
|
|
73
74
|
* `None` is only added to the output dict for nullable fields that
|
74
75
|
were set at model initialization. Other fields with value `None`
|
75
76
|
are ignored.
|
77
|
+
* Fields in `self.additional_properties` are added to the output dict.
|
76
78
|
"""
|
77
|
-
excluded_fields: Set[str] = set(
|
79
|
+
excluded_fields: Set[str] = set(
|
80
|
+
[
|
81
|
+
"additional_properties",
|
82
|
+
]
|
83
|
+
)
|
78
84
|
|
79
85
|
_dict = self.model_dump(
|
80
86
|
by_alias=True,
|
81
87
|
exclude=excluded_fields,
|
82
88
|
exclude_none=True,
|
83
89
|
)
|
90
|
+
# puts key-value pairs in additional_properties in the top level
|
91
|
+
if self.additional_properties is not None:
|
92
|
+
for _key, _value in self.additional_properties.items():
|
93
|
+
_dict[_key] = _value
|
94
|
+
|
84
95
|
return _dict
|
85
96
|
|
86
97
|
@classmethod
|
@@ -101,4 +112,9 @@ class BotCreate(BaseModel):
|
|
101
112
|
"api_key_id": obj.get("api_key_id"),
|
102
113
|
}
|
103
114
|
)
|
115
|
+
# store additional fields in additional_properties
|
116
|
+
for _key in obj.keys():
|
117
|
+
if _key not in cls.__properties:
|
118
|
+
_obj.additional_properties[_key] = obj.get(_key)
|
119
|
+
|
104
120
|
return _obj
|
@@ -32,6 +32,7 @@ class BotUpdate(BaseModel):
|
|
32
32
|
name: Optional[StrictStr] = None
|
33
33
|
allocation: Optional[StrictInt] = None
|
34
34
|
status: Optional[BotStatus] = None
|
35
|
+
additional_properties: Dict[str, Any] = {}
|
35
36
|
__properties: ClassVar[List[str]] = ["name", "allocation", "status"]
|
36
37
|
|
37
38
|
model_config = ConfigDict(
|
@@ -63,14 +64,24 @@ class BotUpdate(BaseModel):
|
|
63
64
|
* `None` is only added to the output dict for nullable fields that
|
64
65
|
were set at model initialization. Other fields with value `None`
|
65
66
|
are ignored.
|
67
|
+
* Fields in `self.additional_properties` are added to the output dict.
|
66
68
|
"""
|
67
|
-
excluded_fields: Set[str] = set(
|
69
|
+
excluded_fields: Set[str] = set(
|
70
|
+
[
|
71
|
+
"additional_properties",
|
72
|
+
]
|
73
|
+
)
|
68
74
|
|
69
75
|
_dict = self.model_dump(
|
70
76
|
by_alias=True,
|
71
77
|
exclude=excluded_fields,
|
72
78
|
exclude_none=True,
|
73
79
|
)
|
80
|
+
# puts key-value pairs in additional_properties in the top level
|
81
|
+
if self.additional_properties is not None:
|
82
|
+
for _key, _value in self.additional_properties.items():
|
83
|
+
_dict[_key] = _value
|
84
|
+
|
74
85
|
# set to None if name (nullable) is None
|
75
86
|
# and model_fields_set contains the field
|
76
87
|
if self.name is None and "name" in self.model_fields_set:
|
@@ -104,4 +115,9 @@ class BotUpdate(BaseModel):
|
|
104
115
|
"status": obj.get("status"),
|
105
116
|
}
|
106
117
|
)
|
118
|
+
# store additional fields in additional_properties
|
119
|
+
for _key in obj.keys():
|
120
|
+
if _key not in cls.__properties:
|
121
|
+
_obj.additional_properties[_key] = obj.get(_key)
|
122
|
+
|
107
123
|
return _obj
|
@@ -20,7 +20,7 @@ from typing_extensions import Self
|
|
20
20
|
|
21
21
|
class Exchange(str, Enum):
|
22
22
|
"""
|
23
|
-
|
23
|
+
All exchanges used in the crypticorn ecosystem. Refer to the APIs for support for a specific usecase (data, trading, etc.).
|
24
24
|
"""
|
25
25
|
|
26
26
|
"""
|
@@ -28,7 +28,12 @@ class Exchange(str, Enum):
|
|
28
28
|
"""
|
29
29
|
KUCOIN = "kucoin"
|
30
30
|
BINGX = "bingx"
|
31
|
+
BINANCE = "binance"
|
32
|
+
BYBIT = "bybit"
|
31
33
|
HYPERLIQUID = "hyperliquid"
|
34
|
+
BITGET = "bitget"
|
35
|
+
GATEIO = "gateio"
|
36
|
+
BITSTAMP = "bitstamp"
|
32
37
|
|
33
38
|
@classmethod
|
34
39
|
def from_json(cls, json_str: str) -> Self:
|
@@ -26,7 +26,7 @@ from typing_extensions import Self
|
|
26
26
|
|
27
27
|
class ExchangeKey(BaseModel):
|
28
28
|
"""
|
29
|
-
Exchange key model
|
29
|
+
Exchange API key model without sensitive credentials for safe read operations.
|
30
30
|
""" # noqa: E501
|
31
31
|
|
32
32
|
user_id: StrictStr = Field(description="UID for the user")
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
"""
|
4
|
+
Trading API
|
5
|
+
|
6
|
+
API for automated trading and exchange interface. This API is used to trade on the exchange and manage bots, API keys, orders, and more.
|
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, Field, StrictStr
|
21
|
+
from typing import Any, ClassVar, Dict, List
|
22
|
+
from crypticorn.trade.client.models.futures_balance import FuturesBalance
|
23
|
+
from crypticorn.trade.client.models.spot_balance import SpotBalance
|
24
|
+
from typing import Optional, Set
|
25
|
+
from typing_extensions import Self
|
26
|
+
|
27
|
+
|
28
|
+
class ExchangeKeyBalance(BaseModel):
|
29
|
+
"""
|
30
|
+
Balance information for an exchange API key including futures and spot balances.
|
31
|
+
""" # noqa: E501
|
32
|
+
|
33
|
+
api_key_id: StrictStr = Field(description="API key ID.")
|
34
|
+
futures: FuturesBalance = Field(description="Futures balance information.")
|
35
|
+
spot: List[SpotBalance] = Field(description="Spot balance information.")
|
36
|
+
__properties: ClassVar[List[str]] = ["api_key_id", "futures", "spot"]
|
37
|
+
|
38
|
+
model_config = ConfigDict(
|
39
|
+
populate_by_name=True,
|
40
|
+
validate_assignment=True,
|
41
|
+
protected_namespaces=(),
|
42
|
+
)
|
43
|
+
|
44
|
+
def to_str(self) -> str:
|
45
|
+
"""Returns the string representation of the model using alias"""
|
46
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
47
|
+
|
48
|
+
def to_json(self) -> str:
|
49
|
+
"""Returns the JSON representation of the model using alias"""
|
50
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
51
|
+
return json.dumps(self.to_dict())
|
52
|
+
|
53
|
+
@classmethod
|
54
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
55
|
+
"""Create an instance of ExchangeKeyBalance from a JSON string"""
|
56
|
+
return cls.from_dict(json.loads(json_str))
|
57
|
+
|
58
|
+
def to_dict(self) -> Dict[str, Any]:
|
59
|
+
"""Return the dictionary representation of the model using alias.
|
60
|
+
|
61
|
+
This has the following differences from calling pydantic's
|
62
|
+
`self.model_dump(by_alias=True)`:
|
63
|
+
|
64
|
+
* `None` is only added to the output dict for nullable fields that
|
65
|
+
were set at model initialization. Other fields with value `None`
|
66
|
+
are ignored.
|
67
|
+
"""
|
68
|
+
excluded_fields: Set[str] = set([])
|
69
|
+
|
70
|
+
_dict = self.model_dump(
|
71
|
+
by_alias=True,
|
72
|
+
exclude=excluded_fields,
|
73
|
+
exclude_none=True,
|
74
|
+
)
|
75
|
+
# override the default output from pydantic by calling `to_dict()` of futures
|
76
|
+
if self.futures:
|
77
|
+
_dict["futures"] = self.futures.to_dict()
|
78
|
+
# override the default output from pydantic by calling `to_dict()` of each item in spot (list)
|
79
|
+
_items = []
|
80
|
+
if self.spot:
|
81
|
+
for _item_spot in self.spot:
|
82
|
+
if _item_spot:
|
83
|
+
_items.append(_item_spot.to_dict())
|
84
|
+
_dict["spot"] = _items
|
85
|
+
return _dict
|
86
|
+
|
87
|
+
@classmethod
|
88
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
89
|
+
"""Create an instance of ExchangeKeyBalance from a dict"""
|
90
|
+
if obj is None:
|
91
|
+
return None
|
92
|
+
|
93
|
+
if not isinstance(obj, dict):
|
94
|
+
return cls.model_validate(obj)
|
95
|
+
|
96
|
+
_obj = cls.model_validate(
|
97
|
+
{
|
98
|
+
"api_key_id": obj.get("api_key_id"),
|
99
|
+
"futures": (
|
100
|
+
FuturesBalance.from_dict(obj["futures"])
|
101
|
+
if obj.get("futures") is not None
|
102
|
+
else None
|
103
|
+
),
|
104
|
+
"spot": (
|
105
|
+
[SpotBalance.from_dict(_item) for _item in obj["spot"]]
|
106
|
+
if obj.get("spot") is not None
|
107
|
+
else None
|
108
|
+
),
|
109
|
+
}
|
110
|
+
)
|
111
|
+
return _obj
|
@@ -34,6 +34,7 @@ class ExchangeKeyCreate(BaseModel):
|
|
34
34
|
secret: StrictStr = Field(description="API secret")
|
35
35
|
passphrase: Optional[StrictStr] = None
|
36
36
|
exchange: Exchange = Field(description="The exchange the API key is for.")
|
37
|
+
additional_properties: Dict[str, Any] = {}
|
37
38
|
__properties: ClassVar[List[str]] = [
|
38
39
|
"label",
|
39
40
|
"api_key",
|
@@ -71,14 +72,24 @@ class ExchangeKeyCreate(BaseModel):
|
|
71
72
|
* `None` is only added to the output dict for nullable fields that
|
72
73
|
were set at model initialization. Other fields with value `None`
|
73
74
|
are ignored.
|
75
|
+
* Fields in `self.additional_properties` are added to the output dict.
|
74
76
|
"""
|
75
|
-
excluded_fields: Set[str] = set(
|
77
|
+
excluded_fields: Set[str] = set(
|
78
|
+
[
|
79
|
+
"additional_properties",
|
80
|
+
]
|
81
|
+
)
|
76
82
|
|
77
83
|
_dict = self.model_dump(
|
78
84
|
by_alias=True,
|
79
85
|
exclude=excluded_fields,
|
80
86
|
exclude_none=True,
|
81
87
|
)
|
88
|
+
# puts key-value pairs in additional_properties in the top level
|
89
|
+
if self.additional_properties is not None:
|
90
|
+
for _key, _value in self.additional_properties.items():
|
91
|
+
_dict[_key] = _value
|
92
|
+
|
82
93
|
# set to None if passphrase (nullable) is None
|
83
94
|
# and model_fields_set contains the field
|
84
95
|
if self.passphrase is None and "passphrase" in self.model_fields_set:
|
@@ -104,4 +115,9 @@ class ExchangeKeyCreate(BaseModel):
|
|
104
115
|
"exchange": obj.get("exchange"),
|
105
116
|
}
|
106
117
|
)
|
118
|
+
# store additional fields in additional_properties
|
119
|
+
for _key in obj.keys():
|
120
|
+
if _key not in cls.__properties:
|
121
|
+
_obj.additional_properties[_key] = obj.get(_key)
|
122
|
+
|
107
123
|
return _obj
|
@@ -32,6 +32,7 @@ class ExchangeKeyUpdate(BaseModel):
|
|
32
32
|
api_key: Optional[StrictStr] = None
|
33
33
|
secret: Optional[StrictStr] = None
|
34
34
|
passphrase: Optional[StrictStr] = None
|
35
|
+
additional_properties: Dict[str, Any] = {}
|
35
36
|
__properties: ClassVar[List[str]] = ["label", "api_key", "secret", "passphrase"]
|
36
37
|
|
37
38
|
model_config = ConfigDict(
|
@@ -63,14 +64,24 @@ class ExchangeKeyUpdate(BaseModel):
|
|
63
64
|
* `None` is only added to the output dict for nullable fields that
|
64
65
|
were set at model initialization. Other fields with value `None`
|
65
66
|
are ignored.
|
67
|
+
* Fields in `self.additional_properties` are added to the output dict.
|
66
68
|
"""
|
67
|
-
excluded_fields: Set[str] = set(
|
69
|
+
excluded_fields: Set[str] = set(
|
70
|
+
[
|
71
|
+
"additional_properties",
|
72
|
+
]
|
73
|
+
)
|
68
74
|
|
69
75
|
_dict = self.model_dump(
|
70
76
|
by_alias=True,
|
71
77
|
exclude=excluded_fields,
|
72
78
|
exclude_none=True,
|
73
79
|
)
|
80
|
+
# puts key-value pairs in additional_properties in the top level
|
81
|
+
if self.additional_properties is not None:
|
82
|
+
for _key, _value in self.additional_properties.items():
|
83
|
+
_dict[_key] = _value
|
84
|
+
|
74
85
|
# set to None if label (nullable) is None
|
75
86
|
# and model_fields_set contains the field
|
76
87
|
if self.label is None and "label" in self.model_fields_set:
|
@@ -110,4 +121,9 @@ class ExchangeKeyUpdate(BaseModel):
|
|
110
121
|
"passphrase": obj.get("passphrase"),
|
111
122
|
}
|
112
123
|
)
|
124
|
+
# store additional fields in additional_properties
|
125
|
+
for _key in obj.keys():
|
126
|
+
if _key not in cls.__properties:
|
127
|
+
_obj.additional_properties[_key] = obj.get(_key)
|
128
|
+
|
113
129
|
return _obj
|
@@ -25,7 +25,7 @@ from typing_extensions import Self
|
|
25
25
|
|
26
26
|
class ExecutionIds(BaseModel):
|
27
27
|
"""
|
28
|
-
|
28
|
+
Execution IDs for trading actions including main order and stop loss/take profit orders.
|
29
29
|
""" # noqa: E501
|
30
30
|
|
31
31
|
main: StrictStr = Field(description="Main execution ID.")
|
@@ -28,29 +28,35 @@ class FuturesBalance(BaseModel):
|
|
28
28
|
Model for futures balance
|
29
29
|
""" # noqa: E501
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
asset: StrictStr = Field(description="Asset the balance values are in")
|
32
|
+
equity: Union[StrictFloat, StrictInt] = Field(
|
33
|
+
description="Net asset value including unrealized profit and loss"
|
34
|
+
)
|
35
|
+
balance: Union[StrictFloat, StrictInt] = Field(
|
36
|
+
description="Actual account balance (equity - unrealized)"
|
37
|
+
)
|
34
38
|
available: Union[StrictFloat, StrictInt] = Field(
|
35
39
|
description="Available balance for trading/withdrawal"
|
36
40
|
)
|
37
|
-
|
38
|
-
description="Unrealized profit and loss"
|
41
|
+
unrealized: Union[StrictFloat, StrictInt] = Field(
|
42
|
+
description="Unrealized profit and loss"
|
39
43
|
)
|
40
|
-
|
41
|
-
|
44
|
+
used: Union[StrictFloat, StrictInt] = Field(
|
45
|
+
description="Margin used in open positions"
|
42
46
|
)
|
43
|
-
|
44
|
-
|
47
|
+
frozen: Union[StrictFloat, StrictInt] = Field(
|
48
|
+
description="Frozen funds not available for use"
|
45
49
|
)
|
50
|
+
allocated: Optional[Union[StrictFloat, StrictInt]] = None
|
46
51
|
__properties: ClassVar[List[str]] = [
|
47
|
-
"apiKeyId",
|
48
52
|
"asset",
|
53
|
+
"equity",
|
49
54
|
"balance",
|
50
55
|
"available",
|
51
|
-
"
|
52
|
-
"
|
53
|
-
"
|
56
|
+
"unrealized",
|
57
|
+
"used",
|
58
|
+
"frozen",
|
59
|
+
"allocated",
|
54
60
|
]
|
55
61
|
|
56
62
|
model_config = ConfigDict(
|
@@ -90,15 +96,10 @@ class FuturesBalance(BaseModel):
|
|
90
96
|
exclude=excluded_fields,
|
91
97
|
exclude_none=True,
|
92
98
|
)
|
93
|
-
# set to None if
|
94
|
-
# and model_fields_set contains the field
|
95
|
-
if self.used_margin is None and "used_margin" in self.model_fields_set:
|
96
|
-
_dict["usedMargin"] = None
|
97
|
-
|
98
|
-
# set to None if frozen_amount (nullable) is None
|
99
|
+
# set to None if allocated (nullable) is None
|
99
100
|
# and model_fields_set contains the field
|
100
|
-
if self.
|
101
|
-
_dict["
|
101
|
+
if self.allocated is None and "allocated" in self.model_fields_set:
|
102
|
+
_dict["allocated"] = None
|
102
103
|
|
103
104
|
return _dict
|
104
105
|
|
@@ -113,13 +114,14 @@ class FuturesBalance(BaseModel):
|
|
113
114
|
|
114
115
|
_obj = cls.model_validate(
|
115
116
|
{
|
116
|
-
"apiKeyId": obj.get("apiKeyId"),
|
117
117
|
"asset": obj.get("asset"),
|
118
|
+
"equity": obj.get("equity"),
|
118
119
|
"balance": obj.get("balance"),
|
119
120
|
"available": obj.get("available"),
|
120
|
-
"
|
121
|
-
"
|
122
|
-
"
|
121
|
+
"unrealized": obj.get("unrealized"),
|
122
|
+
"used": obj.get("used"),
|
123
|
+
"frozen": obj.get("frozen"),
|
124
|
+
"allocated": obj.get("allocated"),
|
123
125
|
}
|
124
126
|
)
|
125
127
|
return _obj
|