crypticorn 2.13.0__py3-none-any.whl → 2.13.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 (35) hide show
  1. crypticorn/auth/client/models/create_user_request.py +4 -16
  2. crypticorn/auth/main.py +8 -0
  3. crypticorn/client.py +24 -21
  4. crypticorn/common/auth.py +44 -12
  5. crypticorn/common/errors.py +78 -75
  6. crypticorn/hive/client/configuration.py +2 -2
  7. crypticorn/hive/client/models/api_error_identifier.py +2 -2
  8. crypticorn/hive/main.py +9 -5
  9. crypticorn/klines/client/models/api_error_identifier.py +1 -1
  10. crypticorn/klines/main.py +7 -0
  11. crypticorn/metrics/client/models/api_error_identifier.py +1 -1
  12. crypticorn/metrics/main.py +8 -3
  13. crypticorn/pay/client/api/products_api.py +228 -1
  14. crypticorn/pay/client/configuration.py +2 -2
  15. crypticorn/pay/client/models/api_error_identifier.py +7 -3
  16. crypticorn/pay/main.py +7 -0
  17. crypticorn/trade/client/__init__.py +1 -0
  18. crypticorn/trade/client/api/strategies_api.py +296 -26
  19. crypticorn/trade/client/api/trading_actions_api.py +4 -4
  20. crypticorn/trade/client/models/__init__.py +1 -0
  21. crypticorn/trade/client/models/api_error_identifier.py +6 -2
  22. crypticorn/trade/client/models/futures_trading_action.py +23 -37
  23. crypticorn/trade/client/models/futures_trading_action_create.py +28 -42
  24. crypticorn/trade/client/models/order.py +40 -34
  25. crypticorn/trade/client/models/spot_trading_action_create.py +10 -25
  26. crypticorn/trade/client/models/strategy_exchange_info.py +3 -3
  27. crypticorn/trade/client/models/tpsl.py +7 -16
  28. crypticorn/trade/client/models/tpsl_create.py +103 -0
  29. crypticorn/trade/main.py +8 -2
  30. {crypticorn-2.13.0.dist-info → crypticorn-2.13.2.dist-info}/METADATA +30 -3
  31. {crypticorn-2.13.0.dist-info → crypticorn-2.13.2.dist-info}/RECORD +35 -34
  32. {crypticorn-2.13.0.dist-info → crypticorn-2.13.2.dist-info}/WHEEL +0 -0
  33. {crypticorn-2.13.0.dist-info → crypticorn-2.13.2.dist-info}/entry_points.txt +0 -0
  34. {crypticorn-2.13.0.dist-info → crypticorn-2.13.2.dist-info}/licenses/LICENSE +0 -0
  35. {crypticorn-2.13.0.dist-info → crypticorn-2.13.2.dist-info}/top_level.txt +0 -0
@@ -16,8 +16,9 @@ from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
16
16
  from typing import Any, Dict, List, Optional, Tuple, Union
17
17
  from typing_extensions import Annotated
18
18
 
19
- from pydantic import StrictInt, StrictStr
20
- from typing import List, Optional
19
+ from pydantic import Field, StrictInt, StrictStr
20
+ from typing import Any, List, Optional
21
+ from typing_extensions import Annotated
21
22
  from crypticorn.trade.client.models.strategy import Strategy
22
23
  from crypticorn.trade.client.models.strategy_create import StrategyCreate
23
24
  from crypticorn.trade.client.models.strategy_update import StrategyUpdate
@@ -57,6 +58,7 @@ class StrategiesApi:
57
58
  ) -> Strategy:
58
59
  """Create Strategy
59
60
 
61
+ Creates a new strategy.
60
62
 
61
63
  :param strategy_create: (required)
62
64
  :type strategy_create: StrategyCreate
@@ -120,6 +122,7 @@ class StrategiesApi:
120
122
  ) -> ApiResponse[Strategy]:
121
123
  """Create Strategy
122
124
 
125
+ Creates a new strategy.
123
126
 
124
127
  :param strategy_create: (required)
125
128
  :type strategy_create: StrategyCreate
@@ -183,6 +186,7 @@ class StrategiesApi:
183
186
  ) -> RESTResponseType:
184
187
  """Create Strategy
185
188
 
189
+ Creates a new strategy.
186
190
 
187
191
  :param strategy_create: (required)
188
192
  :type strategy_create: StrategyCreate
@@ -291,8 +295,18 @@ class StrategiesApi:
291
295
  @validate_call
292
296
  async def get_strategies(
293
297
  self,
294
- limit: Optional[StrictInt] = None,
295
- offset: Optional[StrictInt] = None,
298
+ limit: Annotated[
299
+ Optional[StrictInt],
300
+ Field(
301
+ description="Limit the number of strategies returned. 0 means no limit."
302
+ ),
303
+ ] = None,
304
+ offset: Annotated[
305
+ Optional[StrictInt],
306
+ Field(
307
+ description="Offset the number of strategies returned. 0 means no offset."
308
+ ),
309
+ ] = None,
296
310
  _request_timeout: Union[
297
311
  None,
298
312
  Annotated[StrictFloat, Field(gt=0)],
@@ -307,10 +321,11 @@ class StrategiesApi:
307
321
  ) -> List[Strategy]:
308
322
  """Get Strategies
309
323
 
324
+ Get all strategies.
310
325
 
311
- :param limit:
326
+ :param limit: Limit the number of strategies returned. 0 means no limit.
312
327
  :type limit: int
313
- :param offset:
328
+ :param offset: Offset the number of strategies returned. 0 means no offset.
314
329
  :type offset: int
315
330
  :param _request_timeout: timeout setting for this request. If one
316
331
  number provided, it will be total request
@@ -358,8 +373,18 @@ class StrategiesApi:
358
373
  @validate_call
359
374
  async def get_strategies_with_http_info(
360
375
  self,
361
- limit: Optional[StrictInt] = None,
362
- offset: Optional[StrictInt] = None,
376
+ limit: Annotated[
377
+ Optional[StrictInt],
378
+ Field(
379
+ description="Limit the number of strategies returned. 0 means no limit."
380
+ ),
381
+ ] = None,
382
+ offset: Annotated[
383
+ Optional[StrictInt],
384
+ Field(
385
+ description="Offset the number of strategies returned. 0 means no offset."
386
+ ),
387
+ ] = None,
363
388
  _request_timeout: Union[
364
389
  None,
365
390
  Annotated[StrictFloat, Field(gt=0)],
@@ -374,10 +399,11 @@ class StrategiesApi:
374
399
  ) -> ApiResponse[List[Strategy]]:
375
400
  """Get Strategies
376
401
 
402
+ Get all strategies.
377
403
 
378
- :param limit:
404
+ :param limit: Limit the number of strategies returned. 0 means no limit.
379
405
  :type limit: int
380
- :param offset:
406
+ :param offset: Offset the number of strategies returned. 0 means no offset.
381
407
  :type offset: int
382
408
  :param _request_timeout: timeout setting for this request. If one
383
409
  number provided, it will be total request
@@ -425,8 +451,18 @@ class StrategiesApi:
425
451
  @validate_call
426
452
  async def get_strategies_without_preload_content(
427
453
  self,
428
- limit: Optional[StrictInt] = None,
429
- offset: Optional[StrictInt] = None,
454
+ limit: Annotated[
455
+ Optional[StrictInt],
456
+ Field(
457
+ description="Limit the number of strategies returned. 0 means no limit."
458
+ ),
459
+ ] = None,
460
+ offset: Annotated[
461
+ Optional[StrictInt],
462
+ Field(
463
+ description="Offset the number of strategies returned. 0 means no offset."
464
+ ),
465
+ ] = None,
430
466
  _request_timeout: Union[
431
467
  None,
432
468
  Annotated[StrictFloat, Field(gt=0)],
@@ -441,10 +477,11 @@ class StrategiesApi:
441
477
  ) -> RESTResponseType:
442
478
  """Get Strategies
443
479
 
480
+ Get all strategies.
444
481
 
445
- :param limit:
482
+ :param limit: Limit the number of strategies returned. 0 means no limit.
446
483
  :type limit: int
447
- :param offset:
484
+ :param offset: Offset the number of strategies returned. 0 means no offset.
448
485
  :type offset: int
449
486
  :param _request_timeout: timeout setting for this request. If one
450
487
  number provided, it will be total request
@@ -546,10 +583,237 @@ class StrategiesApi:
546
583
  _request_auth=_request_auth,
547
584
  )
548
585
 
586
+ @validate_call
587
+ async def get_strategy_usage(
588
+ self,
589
+ _request_timeout: Union[
590
+ None,
591
+ Annotated[StrictFloat, Field(gt=0)],
592
+ Tuple[
593
+ Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
594
+ ],
595
+ ] = None,
596
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
597
+ _content_type: Optional[StrictStr] = None,
598
+ _headers: Optional[Dict[StrictStr, Any]] = None,
599
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
600
+ ) -> List[List[object]]:
601
+ """Get Strategy Usage
602
+
603
+ Get the usage count of each strategy.
604
+
605
+ :param _request_timeout: timeout setting for this request. If one
606
+ number provided, it will be total request
607
+ timeout. It can also be a pair (tuple) of
608
+ (connection, read) timeouts.
609
+ :type _request_timeout: int, tuple(int, int), optional
610
+ :param _request_auth: set to override the auth_settings for an a single
611
+ request; this effectively ignores the
612
+ authentication in the spec for a single request.
613
+ :type _request_auth: dict, optional
614
+ :param _content_type: force content-type for the request.
615
+ :type _content_type: str, Optional
616
+ :param _headers: set to override the headers for a single
617
+ request; this effectively ignores the headers
618
+ in the spec for a single request.
619
+ :type _headers: dict, optional
620
+ :param _host_index: set to override the host_index for a single
621
+ request; this effectively ignores the host_index
622
+ in the spec for a single request.
623
+ :type _host_index: int, optional
624
+ :return: Returns the result object.
625
+ """ # noqa: E501
626
+
627
+ _param = self._get_strategy_usage_serialize(
628
+ _request_auth=_request_auth,
629
+ _content_type=_content_type,
630
+ _headers=_headers,
631
+ _host_index=_host_index,
632
+ )
633
+
634
+ _response_types_map: Dict[str, Optional[str]] = {
635
+ "200": "List[List[object]]",
636
+ }
637
+ response_data = await self.api_client.call_api(
638
+ *_param, _request_timeout=_request_timeout
639
+ )
640
+ await response_data.read()
641
+ return self.api_client.response_deserialize(
642
+ response_data=response_data,
643
+ response_types_map=_response_types_map,
644
+ ).data
645
+
646
+ @validate_call
647
+ async def get_strategy_usage_with_http_info(
648
+ self,
649
+ _request_timeout: Union[
650
+ None,
651
+ Annotated[StrictFloat, Field(gt=0)],
652
+ Tuple[
653
+ Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
654
+ ],
655
+ ] = None,
656
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
657
+ _content_type: Optional[StrictStr] = None,
658
+ _headers: Optional[Dict[StrictStr, Any]] = None,
659
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
660
+ ) -> ApiResponse[List[List[object]]]:
661
+ """Get Strategy Usage
662
+
663
+ Get the usage count of each strategy.
664
+
665
+ :param _request_timeout: timeout setting for this request. If one
666
+ number provided, it will be total request
667
+ timeout. It can also be a pair (tuple) of
668
+ (connection, read) timeouts.
669
+ :type _request_timeout: int, tuple(int, int), optional
670
+ :param _request_auth: set to override the auth_settings for an a single
671
+ request; this effectively ignores the
672
+ authentication in the spec for a single request.
673
+ :type _request_auth: dict, optional
674
+ :param _content_type: force content-type for the request.
675
+ :type _content_type: str, Optional
676
+ :param _headers: set to override the headers for a single
677
+ request; this effectively ignores the headers
678
+ in the spec for a single request.
679
+ :type _headers: dict, optional
680
+ :param _host_index: set to override the host_index for a single
681
+ request; this effectively ignores the host_index
682
+ in the spec for a single request.
683
+ :type _host_index: int, optional
684
+ :return: Returns the result object.
685
+ """ # noqa: E501
686
+
687
+ _param = self._get_strategy_usage_serialize(
688
+ _request_auth=_request_auth,
689
+ _content_type=_content_type,
690
+ _headers=_headers,
691
+ _host_index=_host_index,
692
+ )
693
+
694
+ _response_types_map: Dict[str, Optional[str]] = {
695
+ "200": "List[List[object]]",
696
+ }
697
+ response_data = await self.api_client.call_api(
698
+ *_param, _request_timeout=_request_timeout
699
+ )
700
+ await response_data.read()
701
+ return self.api_client.response_deserialize(
702
+ response_data=response_data,
703
+ response_types_map=_response_types_map,
704
+ )
705
+
706
+ @validate_call
707
+ async def get_strategy_usage_without_preload_content(
708
+ self,
709
+ _request_timeout: Union[
710
+ None,
711
+ Annotated[StrictFloat, Field(gt=0)],
712
+ Tuple[
713
+ Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
714
+ ],
715
+ ] = None,
716
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
717
+ _content_type: Optional[StrictStr] = None,
718
+ _headers: Optional[Dict[StrictStr, Any]] = None,
719
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
720
+ ) -> RESTResponseType:
721
+ """Get Strategy Usage
722
+
723
+ Get the usage count of each strategy.
724
+
725
+ :param _request_timeout: timeout setting for this request. If one
726
+ number provided, it will be total request
727
+ timeout. It can also be a pair (tuple) of
728
+ (connection, read) timeouts.
729
+ :type _request_timeout: int, tuple(int, int), optional
730
+ :param _request_auth: set to override the auth_settings for an a single
731
+ request; this effectively ignores the
732
+ authentication in the spec for a single request.
733
+ :type _request_auth: dict, optional
734
+ :param _content_type: force content-type for the request.
735
+ :type _content_type: str, Optional
736
+ :param _headers: set to override the headers for a single
737
+ request; this effectively ignores the headers
738
+ in the spec for a single request.
739
+ :type _headers: dict, optional
740
+ :param _host_index: set to override the host_index for a single
741
+ request; this effectively ignores the host_index
742
+ in the spec for a single request.
743
+ :type _host_index: int, optional
744
+ :return: Returns the result object.
745
+ """ # noqa: E501
746
+
747
+ _param = self._get_strategy_usage_serialize(
748
+ _request_auth=_request_auth,
749
+ _content_type=_content_type,
750
+ _headers=_headers,
751
+ _host_index=_host_index,
752
+ )
753
+
754
+ _response_types_map: Dict[str, Optional[str]] = {
755
+ "200": "List[List[object]]",
756
+ }
757
+ response_data = await self.api_client.call_api(
758
+ *_param, _request_timeout=_request_timeout
759
+ )
760
+ return response_data.response
761
+
762
+ def _get_strategy_usage_serialize(
763
+ self,
764
+ _request_auth,
765
+ _content_type,
766
+ _headers,
767
+ _host_index,
768
+ ) -> RequestSerialized:
769
+
770
+ _host = None
771
+
772
+ _collection_formats: Dict[str, str] = {}
773
+
774
+ _path_params: Dict[str, str] = {}
775
+ _query_params: List[Tuple[str, str]] = []
776
+ _header_params: Dict[str, Optional[str]] = _headers or {}
777
+ _form_params: List[Tuple[str, str]] = []
778
+ _files: Dict[
779
+ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
780
+ ] = {}
781
+ _body_params: Optional[bytes] = None
782
+
783
+ # process the path parameters
784
+ # process the query parameters
785
+ # process the header parameters
786
+ # process the form parameters
787
+ # process the body parameter
788
+
789
+ # set the HTTP header `Accept`
790
+ if "Accept" not in _header_params:
791
+ _header_params["Accept"] = self.api_client.select_header_accept(
792
+ ["application/json"]
793
+ )
794
+
795
+ # authentication setting
796
+ _auth_settings: List[str] = ["APIKeyHeader", "HTTPBearer"]
797
+
798
+ return self.api_client.param_serialize(
799
+ method="GET",
800
+ resource_path="/strategies/usage",
801
+ path_params=_path_params,
802
+ query_params=_query_params,
803
+ header_params=_header_params,
804
+ body=_body_params,
805
+ post_params=_form_params,
806
+ files=_files,
807
+ auth_settings=_auth_settings,
808
+ collection_formats=_collection_formats,
809
+ _host=_host,
810
+ _request_auth=_request_auth,
811
+ )
812
+
549
813
  @validate_call
550
814
  async def kill_strategy(
551
815
  self,
552
- id: StrictStr,
816
+ id: Annotated[StrictStr, Field(description="The ID of the strategy to kill.")],
553
817
  _request_timeout: Union[
554
818
  None,
555
819
  Annotated[StrictFloat, Field(gt=0)],
@@ -566,7 +830,7 @@ class StrategiesApi:
566
830
 
567
831
  Kills a strategy by disabling it and deleting all bots associated with it.
568
832
 
569
- :param id: (required)
833
+ :param id: The ID of the strategy to kill. (required)
570
834
  :type id: str
571
835
  :param _request_timeout: timeout setting for this request. If one
572
836
  number provided, it will be total request
@@ -613,7 +877,7 @@ class StrategiesApi:
613
877
  @validate_call
614
878
  async def kill_strategy_with_http_info(
615
879
  self,
616
- id: StrictStr,
880
+ id: Annotated[StrictStr, Field(description="The ID of the strategy to kill.")],
617
881
  _request_timeout: Union[
618
882
  None,
619
883
  Annotated[StrictFloat, Field(gt=0)],
@@ -630,7 +894,7 @@ class StrategiesApi:
630
894
 
631
895
  Kills a strategy by disabling it and deleting all bots associated with it.
632
896
 
633
- :param id: (required)
897
+ :param id: The ID of the strategy to kill. (required)
634
898
  :type id: str
635
899
  :param _request_timeout: timeout setting for this request. If one
636
900
  number provided, it will be total request
@@ -677,7 +941,7 @@ class StrategiesApi:
677
941
  @validate_call
678
942
  async def kill_strategy_without_preload_content(
679
943
  self,
680
- id: StrictStr,
944
+ id: Annotated[StrictStr, Field(description="The ID of the strategy to kill.")],
681
945
  _request_timeout: Union[
682
946
  None,
683
947
  Annotated[StrictFloat, Field(gt=0)],
@@ -694,7 +958,7 @@ class StrategiesApi:
694
958
 
695
959
  Kills a strategy by disabling it and deleting all bots associated with it.
696
960
 
697
- :param id: (required)
961
+ :param id: The ID of the strategy to kill. (required)
698
962
  :type id: str
699
963
  :param _request_timeout: timeout setting for this request. If one
700
964
  number provided, it will be total request
@@ -791,7 +1055,9 @@ class StrategiesApi:
791
1055
  @validate_call
792
1056
  async def update_strategy(
793
1057
  self,
794
- id: StrictStr,
1058
+ id: Annotated[
1059
+ StrictStr, Field(description="The ID of the strategy to update.")
1060
+ ],
795
1061
  strategy_update: StrategyUpdate,
796
1062
  _request_timeout: Union[
797
1063
  None,
@@ -809,7 +1075,7 @@ class StrategiesApi:
809
1075
 
810
1076
  Updates a strategy. If the strategy is being disabled, all bots associated with it will be set to stopping.
811
1077
 
812
- :param id: (required)
1078
+ :param id: The ID of the strategy to update. (required)
813
1079
  :type id: str
814
1080
  :param strategy_update: (required)
815
1081
  :type strategy_update: StrategyUpdate
@@ -859,7 +1125,9 @@ class StrategiesApi:
859
1125
  @validate_call
860
1126
  async def update_strategy_with_http_info(
861
1127
  self,
862
- id: StrictStr,
1128
+ id: Annotated[
1129
+ StrictStr, Field(description="The ID of the strategy to update.")
1130
+ ],
863
1131
  strategy_update: StrategyUpdate,
864
1132
  _request_timeout: Union[
865
1133
  None,
@@ -877,7 +1145,7 @@ class StrategiesApi:
877
1145
 
878
1146
  Updates a strategy. If the strategy is being disabled, all bots associated with it will be set to stopping.
879
1147
 
880
- :param id: (required)
1148
+ :param id: The ID of the strategy to update. (required)
881
1149
  :type id: str
882
1150
  :param strategy_update: (required)
883
1151
  :type strategy_update: StrategyUpdate
@@ -927,7 +1195,9 @@ class StrategiesApi:
927
1195
  @validate_call
928
1196
  async def update_strategy_without_preload_content(
929
1197
  self,
930
- id: StrictStr,
1198
+ id: Annotated[
1199
+ StrictStr, Field(description="The ID of the strategy to update.")
1200
+ ],
931
1201
  strategy_update: StrategyUpdate,
932
1202
  _request_timeout: Union[
933
1203
  None,
@@ -945,7 +1215,7 @@ class StrategiesApi:
945
1215
 
946
1216
  Updates a strategy. If the strategy is being disabled, all bots associated with it will be set to stopping.
947
1217
 
948
- :param id: (required)
1218
+ :param id: The ID of the strategy to update. (required)
949
1219
  :type id: str
950
1220
  :param strategy_update: (required)
951
1221
  :type strategy_update: StrategyUpdate
@@ -285,7 +285,7 @@ class TradingActionsApi:
285
285
  )
286
286
 
287
287
  # authentication setting
288
- _auth_settings: List[str] = ["APIKeyHeader", "HTTPBearer"]
288
+ _auth_settings: List[str] = ["HTTPBearer"]
289
289
 
290
290
  return self.api_client.param_serialize(
291
291
  method="GET",
@@ -320,7 +320,7 @@ class TradingActionsApi:
320
320
  ) -> PostFuturesAction:
321
321
  """Post Futures Action
322
322
 
323
- Endpoint to receive futures trading actions. The action is queued for processing and the response is returned immediately.
323
+ Endpoint to send futures trading actions. The action is queued for processing and the response is returned immediately. Only API key authentication is supported.
324
324
 
325
325
  :param futures_trading_action_create: (required)
326
326
  :type futures_trading_action_create: FuturesTradingActionCreate
@@ -384,7 +384,7 @@ class TradingActionsApi:
384
384
  ) -> ApiResponse[PostFuturesAction]:
385
385
  """Post Futures Action
386
386
 
387
- Endpoint to receive futures trading actions. The action is queued for processing and the response is returned immediately.
387
+ Endpoint to send futures trading actions. The action is queued for processing and the response is returned immediately. Only API key authentication is supported.
388
388
 
389
389
  :param futures_trading_action_create: (required)
390
390
  :type futures_trading_action_create: FuturesTradingActionCreate
@@ -448,7 +448,7 @@ class TradingActionsApi:
448
448
  ) -> RESTResponseType:
449
449
  """Post Futures Action
450
450
 
451
- Endpoint to receive futures trading actions. The action is queued for processing and the response is returned immediately.
451
+ Endpoint to send futures trading actions. The action is queued for processing and the response is returned immediately. Only API key authentication is supported.
452
452
 
453
453
  :param futures_trading_action_create: (required)
454
454
  :type futures_trading_action_create: FuturesTradingActionCreate
@@ -49,4 +49,5 @@ from crypticorn.trade.client.models.strategy_create import StrategyCreate
49
49
  from crypticorn.trade.client.models.strategy_exchange_info import StrategyExchangeInfo
50
50
  from crypticorn.trade.client.models.strategy_update import StrategyUpdate
51
51
  from crypticorn.trade.client.models.tpsl import TPSL
52
+ from crypticorn.trade.client.models.tpsl_create import TPSLCreate
52
53
  from crypticorn.trade.client.models.trading_action_type import TradingActionType
@@ -33,6 +33,7 @@ class ApiErrorIdentifier(str, Enum):
33
33
  BOT_DISABLED = "bot_disabled"
34
34
  BOT_STOPPING_COMPLETED = "bot_stopping_completed"
35
35
  BOT_STOPPING_STARTED = "bot_stopping_started"
36
+ CANCELLED_OPEN_ORDER = "cancelled_open_order"
36
37
  CLIENT_ORDER_ID_ALREADY_EXISTS = "client_order_id_already_exists"
37
38
  INVALID_CONTENT_TYPE = "invalid_content_type"
38
39
  DELETE_BOT_ERROR = "delete_bot_error"
@@ -55,6 +56,7 @@ class ApiErrorIdentifier(str, Enum):
55
56
  EXCHANGE_USER_ACCOUNT_IS_FROZEN = "exchange_user_account_is_frozen"
56
57
  API_KEY_EXPIRED = "api_key_expired"
57
58
  BEARER_TOKEN_EXPIRED = "bearer_token_expired"
59
+ OPEN_ORDER_EXPIRED = "open_order_expired"
58
60
  FORBIDDEN = "forbidden"
59
61
  HEDGE_MODE_NOT_ACTIVE = "hedge_mode_not_active"
60
62
  HTTP_REQUEST_ERROR = "http_request_error"
@@ -68,7 +70,7 @@ class ApiErrorIdentifier(str, Enum):
68
70
  INVALID_EXCHANGE_KEY = "invalid_exchange_key"
69
71
  INVALID_MARGIN_MODE = "invalid_margin_mode"
70
72
  INVALID_MODEL_NAME = "invalid_model_name"
71
- INVALID_PARAMETER_PROVIDED = "invalid_parameter_provided"
73
+ INVALID_PARAMETER_PROVIDED = "exchange_invalid_parameter"
72
74
  LEVERAGE_LIMIT_EXCEEDED = "leverage_limit_exceeded"
73
75
  ORDER_VIOLATES_LIQUIDATION_PRICE_CONSTRAINTS = (
74
76
  "order_violates_liquidation_price_constraints"
@@ -90,6 +92,8 @@ class ApiErrorIdentifier(str, Enum):
90
92
  ORDER_PRICE_IS_INVALID = "order_price_is_invalid"
91
93
  ORDER_SIZE_TOO_LARGE = "order_size_too_large"
92
94
  ORDER_SIZE_TOO_SMALL = "order_size_too_small"
95
+ ORPHAN_OPEN_ORDER = "orphan_open_order"
96
+ ORPHAN_CLOSE_ORDER = "orphan_close_order"
93
97
  POSITION_LIMIT_EXCEEDED = "position_limit_exceeded"
94
98
  POSITION_DOES_NOT_EXIST = "position_does_not_exist"
95
99
  POSITION_OPENING_TEMPORARILY_SUSPENDED = "position_opening_temporarily_suspended"
@@ -105,7 +109,7 @@ class ApiErrorIdentifier(str, Enum):
105
109
  SUCCESS = "success"
106
110
  SYMBOL_DOES_NOT_EXIST = "symbol_does_not_exist"
107
111
  TRADING_ACTION_EXPIRED = "trading_action_expired"
108
- TRADING_ACTION_SKIPPED = "trading_action_skipped"
112
+ TRADING_ACTION_SKIPPED_BOT_STOPPING = "TRADING_ACTION_SKIPPED_BOT_STOPPING"
109
113
  TRADING_HAS_BEEN_LOCKED = "trading_has_been_locked"
110
114
  TRADING_IS_SUSPENDED = "trading_is_suspended"
111
115
  UNKNOWN_ERROR_OCCURRED = "unknown_error_occurred"
@@ -17,16 +17,8 @@ import pprint
17
17
  import re # noqa: F401
18
18
  import json
19
19
 
20
- from pydantic import (
21
- BaseModel,
22
- ConfigDict,
23
- Field,
24
- StrictBool,
25
- StrictFloat,
26
- StrictInt,
27
- StrictStr,
28
- )
29
- from typing import Any, ClassVar, Dict, List, Optional, Union
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
30
22
  from typing_extensions import Annotated
31
23
  from crypticorn.trade.client.models.margin_mode import MarginMode
32
24
  from crypticorn.trade.client.models.market_type import MarketType
@@ -41,6 +33,8 @@ class FuturesTradingAction(BaseModel):
41
33
  Model for futures trading actions
42
34
  """ # noqa: E501
43
35
 
36
+ leverage: Optional[Annotated[int, Field(strict=True, ge=1)]]
37
+ margin_mode: Optional[MarginMode] = None
44
38
  created_at: Optional[StrictInt] = Field(
45
39
  default=None, description="Timestamp of creation"
46
40
  )
@@ -59,24 +53,18 @@ class FuturesTradingAction(BaseModel):
59
53
  description="Trading symbol or asset pair in format: 'symbol/quote_currency' (see market service for valid symbols)"
60
54
  )
61
55
  is_limit: Optional[StrictBool] = None
62
- limit_price: Optional[Union[StrictFloat, StrictInt]] = None
63
- allocation: Optional[
64
- Union[
65
- Annotated[float, Field(le=1.0, strict=True)],
66
- Annotated[int, Field(le=1, strict=True)],
67
- ]
68
- ] = Field(
69
- default=None,
70
- description="How much of bot's balance to use for the order (for open actions). How much of the reference open order (open_order_execution_id) to close (for close actions). 0=0%, 1=100%.",
56
+ limit_price: Optional[StrictStr] = None
57
+ allocation: StrictStr = Field(
58
+ description="How much of bot's balance to use for the order (for open actions). How much of the reference open order (open_order_execution_id) to close (for close actions). 0=0%, 1=100%."
71
59
  )
72
60
  take_profit: Optional[List[TPSL]] = None
73
61
  stop_loss: Optional[List[TPSL]] = None
74
62
  expiry_timestamp: Optional[StrictInt] = None
75
63
  client_order_id: Optional[StrictStr] = None
76
64
  position_id: Optional[StrictStr] = None
77
- leverage: Optional[Annotated[int, Field(strict=True, ge=1)]]
78
- margin_mode: Optional[MarginMode] = None
79
65
  __properties: ClassVar[List[str]] = [
66
+ "leverage",
67
+ "margin_mode",
80
68
  "created_at",
81
69
  "updated_at",
82
70
  "id",
@@ -94,8 +82,6 @@ class FuturesTradingAction(BaseModel):
94
82
  "expiry_timestamp",
95
83
  "client_order_id",
96
84
  "position_id",
97
- "leverage",
98
- "margin_mode",
99
85
  ]
100
86
 
101
87
  model_config = ConfigDict(
@@ -149,6 +135,16 @@ class FuturesTradingAction(BaseModel):
149
135
  if _item_stop_loss:
150
136
  _items.append(_item_stop_loss.to_dict())
151
137
  _dict["stop_loss"] = _items
138
+ # set to None if leverage (nullable) is None
139
+ # and model_fields_set contains the field
140
+ if self.leverage is None and "leverage" in self.model_fields_set:
141
+ _dict["leverage"] = None
142
+
143
+ # set to None if margin_mode (nullable) is None
144
+ # and model_fields_set contains the field
145
+ if self.margin_mode is None and "margin_mode" in self.model_fields_set:
146
+ _dict["margin_mode"] = None
147
+
152
148
  # set to None if execution_id (nullable) is None
153
149
  # and model_fields_set contains the field
154
150
  if self.execution_id is None and "execution_id" in self.model_fields_set:
@@ -200,16 +196,6 @@ class FuturesTradingAction(BaseModel):
200
196
  if self.position_id is None and "position_id" in self.model_fields_set:
201
197
  _dict["position_id"] = None
202
198
 
203
- # set to None if leverage (nullable) is None
204
- # and model_fields_set contains the field
205
- if self.leverage is None and "leverage" in self.model_fields_set:
206
- _dict["leverage"] = None
207
-
208
- # set to None if margin_mode (nullable) is None
209
- # and model_fields_set contains the field
210
- if self.margin_mode is None and "margin_mode" in self.model_fields_set:
211
- _dict["margin_mode"] = None
212
-
213
199
  return _dict
214
200
 
215
201
  @classmethod
@@ -223,6 +209,10 @@ class FuturesTradingAction(BaseModel):
223
209
 
224
210
  _obj = cls.model_validate(
225
211
  {
212
+ "leverage": (
213
+ obj.get("leverage") if obj.get("leverage") is not None else 1
214
+ ),
215
+ "margin_mode": obj.get("margin_mode"),
226
216
  "created_at": obj.get("created_at"),
227
217
  "updated_at": obj.get("updated_at"),
228
218
  "id": obj.get("id"),
@@ -248,10 +238,6 @@ class FuturesTradingAction(BaseModel):
248
238
  "expiry_timestamp": obj.get("expiry_timestamp"),
249
239
  "client_order_id": obj.get("client_order_id"),
250
240
  "position_id": obj.get("position_id"),
251
- "leverage": (
252
- obj.get("leverage") if obj.get("leverage") is not None else 1
253
- ),
254
- "margin_mode": obj.get("margin_mode"),
255
241
  }
256
242
  )
257
243
  return _obj