kalshi-python-sync 3.0.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.
- kalshi_python_sync/__init__.py +272 -0
- kalshi_python_sync/api/__init__.py +19 -0
- kalshi_python_sync/api/api_keys_api.py +1098 -0
- kalshi_python_sync/api/communications_api.py +3216 -0
- kalshi_python_sync/api/events_api.py +1941 -0
- kalshi_python_sync/api/exchange_api.py +1263 -0
- kalshi_python_sync/api/fcm_api.py +792 -0
- kalshi_python_sync/api/incentive_programs_api.py +346 -0
- kalshi_python_sync/api/live_data_api.py +564 -0
- kalshi_python_sync/api/market_api.py +2568 -0
- kalshi_python_sync/api/milestone_api.py +689 -0
- kalshi_python_sync/api/multivariate_api.py +1486 -0
- kalshi_python_sync/api/order_groups_api.py +1375 -0
- kalshi_python_sync/api/orders_api.py +2913 -0
- kalshi_python_sync/api/portfolio_api.py +1572 -0
- kalshi_python_sync/api/search_api.py +516 -0
- kalshi_python_sync/api/structured_targets_api.py +605 -0
- kalshi_python_sync/api_client.py +830 -0
- kalshi_python_sync/api_response.py +21 -0
- kalshi_python_sync/auth.py +89 -0
- kalshi_python_sync/configuration.py +626 -0
- kalshi_python_sync/exceptions.py +216 -0
- kalshi_python_sync/models/__init__.py +136 -0
- kalshi_python_sync/models/accept_quote_request.py +94 -0
- kalshi_python_sync/models/amend_order_request.py +120 -0
- kalshi_python_sync/models/amend_order_response.py +96 -0
- kalshi_python_sync/models/announcement.py +108 -0
- kalshi_python_sync/models/api_key.py +89 -0
- kalshi_python_sync/models/associated_event.py +105 -0
- kalshi_python_sync/models/batch_cancel_orders_individual_response.py +111 -0
- kalshi_python_sync/models/batch_cancel_orders_request.py +87 -0
- kalshi_python_sync/models/batch_cancel_orders_response.py +95 -0
- kalshi_python_sync/models/batch_create_orders_individual_response.py +114 -0
- kalshi_python_sync/models/batch_create_orders_request.py +95 -0
- kalshi_python_sync/models/batch_create_orders_response.py +95 -0
- kalshi_python_sync/models/batch_get_market_candlesticks_response.py +95 -0
- kalshi_python_sync/models/bid_ask_distribution.py +101 -0
- kalshi_python_sync/models/cancel_order_response.py +93 -0
- kalshi_python_sync/models/create_api_key_request.py +89 -0
- kalshi_python_sync/models/create_api_key_response.py +87 -0
- kalshi_python_sync/models/create_market_in_multivariate_event_collection_request.py +95 -0
- kalshi_python_sync/models/create_market_in_multivariate_event_collection_response.py +89 -0
- kalshi_python_sync/models/create_order_group_request.py +88 -0
- kalshi_python_sync/models/create_order_group_response.py +87 -0
- kalshi_python_sync/models/create_order_request.py +159 -0
- kalshi_python_sync/models/create_order_response.py +91 -0
- kalshi_python_sync/models/create_quote_request.py +93 -0
- kalshi_python_sync/models/create_quote_response.py +87 -0
- kalshi_python_sync/models/create_rfq_request.py +97 -0
- kalshi_python_sync/models/create_rfq_response.py +87 -0
- kalshi_python_sync/models/daily_schedule.py +89 -0
- kalshi_python_sync/models/decrease_order_request.py +90 -0
- kalshi_python_sync/models/decrease_order_response.py +91 -0
- kalshi_python_sync/models/error_response.py +93 -0
- kalshi_python_sync/models/event_data.py +133 -0
- kalshi_python_sync/models/event_position.py +105 -0
- kalshi_python_sync/models/exchange_status.py +97 -0
- kalshi_python_sync/models/fill.py +134 -0
- kalshi_python_sync/models/forecast_percentiles_point.py +101 -0
- kalshi_python_sync/models/generate_api_key_request.py +87 -0
- kalshi_python_sync/models/generate_api_key_response.py +89 -0
- kalshi_python_sync/models/get_api_keys_response.py +95 -0
- kalshi_python_sync/models/get_balance_response.py +91 -0
- kalshi_python_sync/models/get_communications_id_response.py +87 -0
- kalshi_python_sync/models/get_event_candlesticks_response.py +104 -0
- kalshi_python_sync/models/get_event_forecast_percentiles_history_response.py +95 -0
- kalshi_python_sync/models/get_event_metadata_response.py +123 -0
- kalshi_python_sync/models/get_event_response.py +101 -0
- kalshi_python_sync/models/get_events_response.py +107 -0
- kalshi_python_sync/models/get_exchange_announcements_response.py +95 -0
- kalshi_python_sync/models/get_exchange_schedule_response.py +91 -0
- kalshi_python_sync/models/get_fills_response.py +97 -0
- kalshi_python_sync/models/get_filters_by_sports_response.py +102 -0
- kalshi_python_sync/models/get_incentive_programs_response.py +97 -0
- kalshi_python_sync/models/get_live_data_response.py +91 -0
- kalshi_python_sync/models/get_live_datas_response.py +95 -0
- kalshi_python_sync/models/get_market_candlesticks_response.py +97 -0
- kalshi_python_sync/models/get_market_orderbook_response.py +91 -0
- kalshi_python_sync/models/get_market_response.py +91 -0
- kalshi_python_sync/models/get_markets_response.py +97 -0
- kalshi_python_sync/models/get_milestone_response.py +91 -0
- kalshi_python_sync/models/get_milestones_response.py +97 -0
- kalshi_python_sync/models/get_multivariate_event_collection_lookup_history_response.py +95 -0
- kalshi_python_sync/models/get_multivariate_event_collection_response.py +91 -0
- kalshi_python_sync/models/get_multivariate_event_collections_response.py +97 -0
- kalshi_python_sync/models/get_multivariate_events_response.py +97 -0
- kalshi_python_sync/models/get_order_group_response.py +89 -0
- kalshi_python_sync/models/get_order_groups_response.py +95 -0
- kalshi_python_sync/models/get_order_queue_position_response.py +87 -0
- kalshi_python_sync/models/get_order_queue_positions_response.py +95 -0
- kalshi_python_sync/models/get_order_response.py +91 -0
- kalshi_python_sync/models/get_orders_response.py +97 -0
- kalshi_python_sync/models/get_portfolio_resting_order_total_value_response.py +87 -0
- kalshi_python_sync/models/get_positions_response.py +107 -0
- kalshi_python_sync/models/get_quote_response.py +91 -0
- kalshi_python_sync/models/get_quotes_response.py +97 -0
- kalshi_python_sync/models/get_rfq_response.py +91 -0
- kalshi_python_sync/models/get_rfqs_response.py +97 -0
- kalshi_python_sync/models/get_series_fee_changes_response.py +95 -0
- kalshi_python_sync/models/get_series_list_response.py +95 -0
- kalshi_python_sync/models/get_series_response.py +91 -0
- kalshi_python_sync/models/get_settlements_response.py +97 -0
- kalshi_python_sync/models/get_structured_target_response.py +91 -0
- kalshi_python_sync/models/get_structured_targets_response.py +97 -0
- kalshi_python_sync/models/get_tags_for_series_categories_response.py +87 -0
- kalshi_python_sync/models/get_trades_response.py +97 -0
- kalshi_python_sync/models/get_user_data_timestamp_response.py +88 -0
- kalshi_python_sync/models/incentive_program.py +121 -0
- kalshi_python_sync/models/live_data.py +91 -0
- kalshi_python_sync/models/lookup_point.py +102 -0
- kalshi_python_sync/models/lookup_tickers_for_market_in_multivariate_event_collection_request.py +95 -0
- kalshi_python_sync/models/lookup_tickers_for_market_in_multivariate_event_collection_response.py +89 -0
- kalshi_python_sync/models/maintenance_window.py +90 -0
- kalshi_python_sync/models/market.py +307 -0
- kalshi_python_sync/models/market_candlestick.py +108 -0
- kalshi_python_sync/models/market_candlesticks_response.py +97 -0
- kalshi_python_sync/models/market_metadata.py +91 -0
- kalshi_python_sync/models/market_position.py +110 -0
- kalshi_python_sync/models/milestone.py +120 -0
- kalshi_python_sync/models/multivariate_event_collection.py +122 -0
- kalshi_python_sync/models/mve_selected_leg.py +91 -0
- kalshi_python_sync/models/order.py +189 -0
- kalshi_python_sync/models/order_group.py +89 -0
- kalshi_python_sync/models/order_queue_position.py +91 -0
- kalshi_python_sync/models/order_status.py +38 -0
- kalshi_python_sync/models/orderbook.py +94 -0
- kalshi_python_sync/models/percentile_point.py +93 -0
- kalshi_python_sync/models/price_distribution.py +157 -0
- kalshi_python_sync/models/price_range.py +91 -0
- kalshi_python_sync/models/quote.py +153 -0
- kalshi_python_sync/models/rfq.py +129 -0
- kalshi_python_sync/models/schedule.py +105 -0
- kalshi_python_sync/models/scope_list.py +87 -0
- kalshi_python_sync/models/self_trade_prevention_type.py +37 -0
- kalshi_python_sync/models/series.py +129 -0
- kalshi_python_sync/models/series_fee_change.py +103 -0
- kalshi_python_sync/models/settlement.py +118 -0
- kalshi_python_sync/models/settlement_source.py +89 -0
- kalshi_python_sync/models/sport_filter_details.py +102 -0
- kalshi_python_sync/models/structured_target.py +98 -0
- kalshi_python_sync/models/ticker_pair.py +98 -0
- kalshi_python_sync/models/trade.py +113 -0
- kalshi_python_sync/models/weekly_schedule.py +154 -0
- kalshi_python_sync/py.typed +0 -0
- kalshi_python_sync/rest.py +258 -0
- kalshi_python_sync-3.0.0.dist-info/METADATA +77 -0
- kalshi_python_sync-3.0.0.dist-info/RECORD +149 -0
- kalshi_python_sync-3.0.0.dist-info/WHEEL +5 -0
- kalshi_python_sync-3.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Kalshi Trade API Manual Endpoints
|
|
5
|
+
|
|
6
|
+
Manually defined OpenAPI spec for endpoints being migrated to spec-first approach
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 3.0.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from datetime import datetime
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
|
22
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
23
|
+
from typing import Optional, Set
|
|
24
|
+
from typing_extensions import Self
|
|
25
|
+
|
|
26
|
+
class MarketPosition(BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
MarketPosition
|
|
29
|
+
""" # noqa: E501
|
|
30
|
+
ticker: StrictStr = Field(description="Unique identifier for the market")
|
|
31
|
+
total_traded: StrictInt = Field(description="Total spent on this market in cents")
|
|
32
|
+
total_traded_dollars: StrictStr = Field(description="US dollar amount as a fixed-point decimal string with exactly 4 decimal places")
|
|
33
|
+
position: StrictInt = Field(description="Number of contracts bought in this market. Negative means NO contracts and positive means YES contracts")
|
|
34
|
+
market_exposure: StrictInt = Field(description="Cost of the aggregate market position in cents")
|
|
35
|
+
market_exposure_dollars: StrictStr = Field(description="US dollar amount as a fixed-point decimal string with exactly 4 decimal places")
|
|
36
|
+
realized_pnl: StrictInt = Field(description="Locked in profit and loss, in cents")
|
|
37
|
+
realized_pnl_dollars: StrictStr = Field(description="US dollar amount as a fixed-point decimal string with exactly 4 decimal places")
|
|
38
|
+
resting_orders_count: StrictInt = Field(description="[DEPRECATED] Aggregate size of resting orders in contract units")
|
|
39
|
+
fees_paid: StrictInt = Field(description="Fees paid on fill orders, in cents")
|
|
40
|
+
fees_paid_dollars: StrictStr = Field(description="US dollar amount as a fixed-point decimal string with exactly 4 decimal places")
|
|
41
|
+
last_updated_ts: Optional[datetime] = Field(default=None, description="Last time the position is updated")
|
|
42
|
+
__properties: ClassVar[List[str]] = ["ticker", "total_traded", "total_traded_dollars", "position", "market_exposure", "market_exposure_dollars", "realized_pnl", "realized_pnl_dollars", "resting_orders_count", "fees_paid", "fees_paid_dollars", "last_updated_ts"]
|
|
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 MarketPosition 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 MarketPosition 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
|
+
_obj = cls.model_validate({
|
|
95
|
+
"ticker": obj.get("ticker"),
|
|
96
|
+
"total_traded": obj.get("total_traded"),
|
|
97
|
+
"total_traded_dollars": obj.get("total_traded_dollars"),
|
|
98
|
+
"position": obj.get("position"),
|
|
99
|
+
"market_exposure": obj.get("market_exposure"),
|
|
100
|
+
"market_exposure_dollars": obj.get("market_exposure_dollars"),
|
|
101
|
+
"realized_pnl": obj.get("realized_pnl"),
|
|
102
|
+
"realized_pnl_dollars": obj.get("realized_pnl_dollars"),
|
|
103
|
+
"resting_orders_count": obj.get("resting_orders_count"),
|
|
104
|
+
"fees_paid": obj.get("fees_paid"),
|
|
105
|
+
"fees_paid_dollars": obj.get("fees_paid_dollars"),
|
|
106
|
+
"last_updated_ts": obj.get("last_updated_ts")
|
|
107
|
+
})
|
|
108
|
+
return _obj
|
|
109
|
+
|
|
110
|
+
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Kalshi Trade API Manual Endpoints
|
|
5
|
+
|
|
6
|
+
Manually defined OpenAPI spec for endpoints being migrated to spec-first approach
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 3.0.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from datetime import datetime
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
|
22
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
23
|
+
from typing import Optional, Set
|
|
24
|
+
from typing_extensions import Self
|
|
25
|
+
|
|
26
|
+
class Milestone(BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
Milestone
|
|
29
|
+
""" # noqa: E501
|
|
30
|
+
id: StrictStr = Field(description="Unique identifier for the milestone.")
|
|
31
|
+
category: StrictStr = Field(description="Category of the milestone.")
|
|
32
|
+
type: StrictStr = Field(description="Type of the milestone.")
|
|
33
|
+
start_date: datetime = Field(description="Start date of the milestone.")
|
|
34
|
+
end_date: Optional[datetime] = Field(default=None, description="End date of the milestone, if any.")
|
|
35
|
+
related_event_tickers: List[StrictStr] = Field(description="List of event tickers related to this milestone.")
|
|
36
|
+
title: StrictStr = Field(description="Title of the milestone.")
|
|
37
|
+
notification_message: StrictStr = Field(description="Notification message for the milestone.")
|
|
38
|
+
source_id: Optional[StrictStr] = Field(default=None, description="Source id of milestone if available.")
|
|
39
|
+
details: Dict[str, Any] = Field(description="Additional details about the milestone.")
|
|
40
|
+
primary_event_tickers: List[StrictStr] = Field(description="List of event tickers directly related to the outcome of this milestone.")
|
|
41
|
+
last_updated_ts: datetime = Field(description="Last time this structured target was updated.")
|
|
42
|
+
__properties: ClassVar[List[str]] = ["id", "category", "type", "start_date", "end_date", "related_event_tickers", "title", "notification_message", "source_id", "details", "primary_event_tickers", "last_updated_ts"]
|
|
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 Milestone 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
|
+
# set to None if end_date (nullable) is None
|
|
84
|
+
# and model_fields_set contains the field
|
|
85
|
+
if self.end_date is None and "end_date" in self.model_fields_set:
|
|
86
|
+
_dict['end_date'] = None
|
|
87
|
+
|
|
88
|
+
# set to None if source_id (nullable) is None
|
|
89
|
+
# and model_fields_set contains the field
|
|
90
|
+
if self.source_id is None and "source_id" in self.model_fields_set:
|
|
91
|
+
_dict['source_id'] = None
|
|
92
|
+
|
|
93
|
+
return _dict
|
|
94
|
+
|
|
95
|
+
@classmethod
|
|
96
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
97
|
+
"""Create an instance of Milestone from a dict"""
|
|
98
|
+
if obj is None:
|
|
99
|
+
return None
|
|
100
|
+
|
|
101
|
+
if not isinstance(obj, dict):
|
|
102
|
+
return cls.model_validate(obj)
|
|
103
|
+
|
|
104
|
+
_obj = cls.model_validate({
|
|
105
|
+
"id": obj.get("id"),
|
|
106
|
+
"category": obj.get("category"),
|
|
107
|
+
"type": obj.get("type"),
|
|
108
|
+
"start_date": obj.get("start_date"),
|
|
109
|
+
"end_date": obj.get("end_date"),
|
|
110
|
+
"related_event_tickers": obj.get("related_event_tickers"),
|
|
111
|
+
"title": obj.get("title"),
|
|
112
|
+
"notification_message": obj.get("notification_message"),
|
|
113
|
+
"source_id": obj.get("source_id"),
|
|
114
|
+
"details": obj.get("details"),
|
|
115
|
+
"primary_event_tickers": obj.get("primary_event_tickers"),
|
|
116
|
+
"last_updated_ts": obj.get("last_updated_ts")
|
|
117
|
+
})
|
|
118
|
+
return _obj
|
|
119
|
+
|
|
120
|
+
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Kalshi Trade API Manual Endpoints
|
|
5
|
+
|
|
6
|
+
Manually defined OpenAPI spec for endpoints being migrated to spec-first approach
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 3.0.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from datetime import datetime
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
|
|
22
|
+
from typing import Any, ClassVar, Dict, List
|
|
23
|
+
from kalshi_python_sync.models.associated_event import AssociatedEvent
|
|
24
|
+
from typing import Optional, Set
|
|
25
|
+
from typing_extensions import Self
|
|
26
|
+
|
|
27
|
+
class MultivariateEventCollection(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
MultivariateEventCollection
|
|
30
|
+
""" # noqa: E501
|
|
31
|
+
collection_ticker: StrictStr = Field(description="Unique identifier for the collection.")
|
|
32
|
+
series_ticker: StrictStr = Field(description="Series associated with the collection. Events produced in the collection will be associated with this series.")
|
|
33
|
+
title: StrictStr = Field(description="Title of the collection.")
|
|
34
|
+
description: StrictStr = Field(description="Short description of the collection.")
|
|
35
|
+
open_date: datetime = Field(description="The open date of the collection. Before this time, the collection cannot be interacted with.")
|
|
36
|
+
close_date: datetime = Field(description="The close date of the collection. After this time, the collection cannot be interacted with.")
|
|
37
|
+
associated_events: List[AssociatedEvent] = Field(description="List of events with their individual configuration.")
|
|
38
|
+
associated_event_tickers: List[StrictStr] = Field(description="[DEPRECATED - Use associated_events instead] A list of events associated with the collection. Markets in these events can be passed as inputs to the Lookup and Create endpoints.")
|
|
39
|
+
is_ordered: StrictBool = Field(description="Whether the collection is ordered. If true, the order of markets passed into Lookup/Create affects the output. If false, the order does not matter.")
|
|
40
|
+
is_single_market_per_event: StrictBool = Field(description="[DEPRECATED - Use associated_events instead] Whether the collection accepts multiple markets from the same event passed into Lookup/Create.")
|
|
41
|
+
is_all_yes: StrictBool = Field(description="[DEPRECATED - Use associated_events instead] Whether the collection requires that only the market side of 'yes' may be used.")
|
|
42
|
+
size_min: StrictInt = Field(description="The minimum number of markets that must be passed into Lookup/Create (inclusive).")
|
|
43
|
+
size_max: StrictInt = Field(description="The maximum number of markets that must be passed into Lookup/Create (inclusive).")
|
|
44
|
+
functional_description: StrictStr = Field(description="A functional description of the collection describing how inputs affect the output.")
|
|
45
|
+
__properties: ClassVar[List[str]] = ["collection_ticker", "series_ticker", "title", "description", "open_date", "close_date", "associated_events", "associated_event_tickers", "is_ordered", "is_single_market_per_event", "is_all_yes", "size_min", "size_max", "functional_description"]
|
|
46
|
+
|
|
47
|
+
model_config = ConfigDict(
|
|
48
|
+
populate_by_name=True,
|
|
49
|
+
validate_assignment=True,
|
|
50
|
+
protected_namespaces=(),
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def to_str(self) -> str:
|
|
55
|
+
"""Returns the string representation of the model using alias"""
|
|
56
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
57
|
+
|
|
58
|
+
def to_json(self) -> str:
|
|
59
|
+
"""Returns the JSON representation of the model using alias"""
|
|
60
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
61
|
+
return json.dumps(self.to_dict())
|
|
62
|
+
|
|
63
|
+
@classmethod
|
|
64
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
65
|
+
"""Create an instance of MultivariateEventCollection from a JSON string"""
|
|
66
|
+
return cls.from_dict(json.loads(json_str))
|
|
67
|
+
|
|
68
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
69
|
+
"""Return the dictionary representation of the model using alias.
|
|
70
|
+
|
|
71
|
+
This has the following differences from calling pydantic's
|
|
72
|
+
`self.model_dump(by_alias=True)`:
|
|
73
|
+
|
|
74
|
+
* `None` is only added to the output dict for nullable fields that
|
|
75
|
+
were set at model initialization. Other fields with value `None`
|
|
76
|
+
are ignored.
|
|
77
|
+
"""
|
|
78
|
+
excluded_fields: Set[str] = set([
|
|
79
|
+
])
|
|
80
|
+
|
|
81
|
+
_dict = self.model_dump(
|
|
82
|
+
by_alias=True,
|
|
83
|
+
exclude=excluded_fields,
|
|
84
|
+
exclude_none=True,
|
|
85
|
+
)
|
|
86
|
+
# override the default output from pydantic by calling `to_dict()` of each item in associated_events (list)
|
|
87
|
+
_items = []
|
|
88
|
+
if self.associated_events:
|
|
89
|
+
for _item_associated_events in self.associated_events:
|
|
90
|
+
if _item_associated_events:
|
|
91
|
+
_items.append(_item_associated_events.to_dict())
|
|
92
|
+
_dict['associated_events'] = _items
|
|
93
|
+
return _dict
|
|
94
|
+
|
|
95
|
+
@classmethod
|
|
96
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
97
|
+
"""Create an instance of MultivariateEventCollection from a dict"""
|
|
98
|
+
if obj is None:
|
|
99
|
+
return None
|
|
100
|
+
|
|
101
|
+
if not isinstance(obj, dict):
|
|
102
|
+
return cls.model_validate(obj)
|
|
103
|
+
|
|
104
|
+
_obj = cls.model_validate({
|
|
105
|
+
"collection_ticker": obj.get("collection_ticker"),
|
|
106
|
+
"series_ticker": obj.get("series_ticker"),
|
|
107
|
+
"title": obj.get("title"),
|
|
108
|
+
"description": obj.get("description"),
|
|
109
|
+
"open_date": obj.get("open_date"),
|
|
110
|
+
"close_date": obj.get("close_date"),
|
|
111
|
+
"associated_events": [AssociatedEvent.from_dict(_item) for _item in obj["associated_events"]] if obj.get("associated_events") is not None else None,
|
|
112
|
+
"associated_event_tickers": obj.get("associated_event_tickers"),
|
|
113
|
+
"is_ordered": obj.get("is_ordered"),
|
|
114
|
+
"is_single_market_per_event": obj.get("is_single_market_per_event"),
|
|
115
|
+
"is_all_yes": obj.get("is_all_yes"),
|
|
116
|
+
"size_min": obj.get("size_min"),
|
|
117
|
+
"size_max": obj.get("size_max"),
|
|
118
|
+
"functional_description": obj.get("functional_description")
|
|
119
|
+
})
|
|
120
|
+
return _obj
|
|
121
|
+
|
|
122
|
+
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Kalshi Trade API Manual Endpoints
|
|
5
|
+
|
|
6
|
+
Manually defined OpenAPI spec for endpoints being migrated to spec-first approach
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 3.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, Optional
|
|
22
|
+
from typing import Optional, Set
|
|
23
|
+
from typing_extensions import Self
|
|
24
|
+
|
|
25
|
+
class MveSelectedLeg(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
MveSelectedLeg
|
|
28
|
+
""" # noqa: E501
|
|
29
|
+
event_ticker: Optional[StrictStr] = Field(default=None, description="Unique identifier for the selected event")
|
|
30
|
+
market_ticker: Optional[StrictStr] = Field(default=None, description="Unique identifier for the selected market")
|
|
31
|
+
side: Optional[StrictStr] = Field(default=None, description="The side of the selected market")
|
|
32
|
+
__properties: ClassVar[List[str]] = ["event_ticker", "market_ticker", "side"]
|
|
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 MveSelectedLeg 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 MveSelectedLeg 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
|
+
_obj = cls.model_validate({
|
|
85
|
+
"event_ticker": obj.get("event_ticker"),
|
|
86
|
+
"market_ticker": obj.get("market_ticker"),
|
|
87
|
+
"side": obj.get("side")
|
|
88
|
+
})
|
|
89
|
+
return _obj
|
|
90
|
+
|
|
91
|
+
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Kalshi Trade API Manual Endpoints
|
|
5
|
+
|
|
6
|
+
Manually defined OpenAPI spec for endpoints being migrated to spec-first approach
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 3.0.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from datetime import datetime
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator
|
|
22
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
23
|
+
from kalshi_python_sync.models.order_status import OrderStatus
|
|
24
|
+
from kalshi_python_sync.models.self_trade_prevention_type import SelfTradePreventionType
|
|
25
|
+
from typing import Optional, Set
|
|
26
|
+
from typing_extensions import Self
|
|
27
|
+
|
|
28
|
+
class Order(BaseModel):
|
|
29
|
+
"""
|
|
30
|
+
Order
|
|
31
|
+
""" # noqa: E501
|
|
32
|
+
order_id: StrictStr
|
|
33
|
+
user_id: StrictStr = Field(description="Unique identifier for users")
|
|
34
|
+
client_order_id: StrictStr
|
|
35
|
+
ticker: StrictStr
|
|
36
|
+
side: StrictStr
|
|
37
|
+
action: StrictStr
|
|
38
|
+
type: StrictStr
|
|
39
|
+
status: OrderStatus
|
|
40
|
+
yes_price: StrictInt
|
|
41
|
+
no_price: StrictInt
|
|
42
|
+
yes_price_dollars: StrictStr = Field(description="US dollar amount as a fixed-point decimal string with exactly 4 decimal places")
|
|
43
|
+
no_price_dollars: StrictStr = Field(description="US dollar amount as a fixed-point decimal string with exactly 4 decimal places")
|
|
44
|
+
fill_count: StrictInt = Field(description="The number of contracts that have been filled")
|
|
45
|
+
remaining_count: StrictInt
|
|
46
|
+
initial_count: StrictInt = Field(description="The initial size of the order (contract units)")
|
|
47
|
+
taker_fees: StrictInt = Field(description="Fees paid on filled taker contracts, in cents")
|
|
48
|
+
maker_fees: StrictInt = Field(description="Fees paid on filled maker contracts, in cents")
|
|
49
|
+
taker_fill_cost: StrictInt = Field(description="The cost of filled taker orders in cents")
|
|
50
|
+
maker_fill_cost: StrictInt = Field(description="The cost of filled maker orders in cents")
|
|
51
|
+
taker_fill_cost_dollars: StrictStr = Field(description="US dollar amount as a fixed-point decimal string with exactly 4 decimal places")
|
|
52
|
+
maker_fill_cost_dollars: StrictStr = Field(description="US dollar amount as a fixed-point decimal string with exactly 4 decimal places")
|
|
53
|
+
queue_position: StrictInt = Field(description="**DEPRECATED**: This field is deprecated and will always return 0. Please use the GET /portfolio/orders/{order_id}/queue_position endpoint instead")
|
|
54
|
+
taker_fees_dollars: Optional[StrictStr] = Field(default=None, description="US dollar amount as a fixed-point decimal string with exactly 4 decimal places")
|
|
55
|
+
maker_fees_dollars: Optional[StrictStr] = Field(default=None, description="US dollar amount as a fixed-point decimal string with exactly 4 decimal places")
|
|
56
|
+
expiration_time: Optional[datetime] = None
|
|
57
|
+
created_time: Optional[datetime] = None
|
|
58
|
+
last_update_time: Optional[datetime] = Field(default=None, description="The last update to an order (modify, cancel, fill)")
|
|
59
|
+
self_trade_prevention_type: Optional[SelfTradePreventionType] = None
|
|
60
|
+
order_group_id: Optional[StrictStr] = Field(default=None, description="The order group this order is part of")
|
|
61
|
+
cancel_order_on_pause: Optional[StrictBool] = Field(default=None, description="If this flag is set to true, the order will be canceled if the order is open and trading on the exchange is paused for any reason.")
|
|
62
|
+
__properties: ClassVar[List[str]] = ["order_id", "user_id", "client_order_id", "ticker", "side", "action", "type", "status", "yes_price", "no_price", "yes_price_dollars", "no_price_dollars", "fill_count", "remaining_count", "initial_count", "taker_fees", "maker_fees", "taker_fill_cost", "maker_fill_cost", "taker_fill_cost_dollars", "maker_fill_cost_dollars", "queue_position", "taker_fees_dollars", "maker_fees_dollars", "expiration_time", "created_time", "last_update_time", "self_trade_prevention_type", "order_group_id", "cancel_order_on_pause"]
|
|
63
|
+
|
|
64
|
+
@field_validator('side')
|
|
65
|
+
def side_validate_enum(cls, value):
|
|
66
|
+
"""Validates the enum"""
|
|
67
|
+
if value not in set(['yes', 'no']):
|
|
68
|
+
raise ValueError("must be one of enum values ('yes', 'no')")
|
|
69
|
+
return value
|
|
70
|
+
|
|
71
|
+
@field_validator('action')
|
|
72
|
+
def action_validate_enum(cls, value):
|
|
73
|
+
"""Validates the enum"""
|
|
74
|
+
if value not in set(['buy', 'sell']):
|
|
75
|
+
raise ValueError("must be one of enum values ('buy', 'sell')")
|
|
76
|
+
return value
|
|
77
|
+
|
|
78
|
+
@field_validator('type')
|
|
79
|
+
def type_validate_enum(cls, value):
|
|
80
|
+
"""Validates the enum"""
|
|
81
|
+
if value not in set(['limit', 'market']):
|
|
82
|
+
raise ValueError("must be one of enum values ('limit', 'market')")
|
|
83
|
+
return value
|
|
84
|
+
|
|
85
|
+
model_config = ConfigDict(
|
|
86
|
+
populate_by_name=True,
|
|
87
|
+
validate_assignment=True,
|
|
88
|
+
protected_namespaces=(),
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def to_str(self) -> str:
|
|
93
|
+
"""Returns the string representation of the model using alias"""
|
|
94
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
95
|
+
|
|
96
|
+
def to_json(self) -> str:
|
|
97
|
+
"""Returns the JSON representation of the model using alias"""
|
|
98
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
99
|
+
return json.dumps(self.to_dict())
|
|
100
|
+
|
|
101
|
+
@classmethod
|
|
102
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
103
|
+
"""Create an instance of Order from a JSON string"""
|
|
104
|
+
return cls.from_dict(json.loads(json_str))
|
|
105
|
+
|
|
106
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
107
|
+
"""Return the dictionary representation of the model using alias.
|
|
108
|
+
|
|
109
|
+
This has the following differences from calling pydantic's
|
|
110
|
+
`self.model_dump(by_alias=True)`:
|
|
111
|
+
|
|
112
|
+
* `None` is only added to the output dict for nullable fields that
|
|
113
|
+
were set at model initialization. Other fields with value `None`
|
|
114
|
+
are ignored.
|
|
115
|
+
"""
|
|
116
|
+
excluded_fields: Set[str] = set([
|
|
117
|
+
])
|
|
118
|
+
|
|
119
|
+
_dict = self.model_dump(
|
|
120
|
+
by_alias=True,
|
|
121
|
+
exclude=excluded_fields,
|
|
122
|
+
exclude_none=True,
|
|
123
|
+
)
|
|
124
|
+
# set to None if expiration_time (nullable) is None
|
|
125
|
+
# and model_fields_set contains the field
|
|
126
|
+
if self.expiration_time is None and "expiration_time" in self.model_fields_set:
|
|
127
|
+
_dict['expiration_time'] = None
|
|
128
|
+
|
|
129
|
+
# set to None if created_time (nullable) is None
|
|
130
|
+
# and model_fields_set contains the field
|
|
131
|
+
if self.created_time is None and "created_time" in self.model_fields_set:
|
|
132
|
+
_dict['created_time'] = None
|
|
133
|
+
|
|
134
|
+
# set to None if last_update_time (nullable) is None
|
|
135
|
+
# and model_fields_set contains the field
|
|
136
|
+
if self.last_update_time is None and "last_update_time" in self.model_fields_set:
|
|
137
|
+
_dict['last_update_time'] = None
|
|
138
|
+
|
|
139
|
+
# set to None if order_group_id (nullable) is None
|
|
140
|
+
# and model_fields_set contains the field
|
|
141
|
+
if self.order_group_id is None and "order_group_id" in self.model_fields_set:
|
|
142
|
+
_dict['order_group_id'] = None
|
|
143
|
+
|
|
144
|
+
return _dict
|
|
145
|
+
|
|
146
|
+
@classmethod
|
|
147
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
148
|
+
"""Create an instance of Order from a dict"""
|
|
149
|
+
if obj is None:
|
|
150
|
+
return None
|
|
151
|
+
|
|
152
|
+
if not isinstance(obj, dict):
|
|
153
|
+
return cls.model_validate(obj)
|
|
154
|
+
|
|
155
|
+
_obj = cls.model_validate({
|
|
156
|
+
"order_id": obj.get("order_id"),
|
|
157
|
+
"user_id": obj.get("user_id"),
|
|
158
|
+
"client_order_id": obj.get("client_order_id"),
|
|
159
|
+
"ticker": obj.get("ticker"),
|
|
160
|
+
"side": obj.get("side"),
|
|
161
|
+
"action": obj.get("action"),
|
|
162
|
+
"type": obj.get("type"),
|
|
163
|
+
"status": obj.get("status"),
|
|
164
|
+
"yes_price": obj.get("yes_price"),
|
|
165
|
+
"no_price": obj.get("no_price"),
|
|
166
|
+
"yes_price_dollars": obj.get("yes_price_dollars"),
|
|
167
|
+
"no_price_dollars": obj.get("no_price_dollars"),
|
|
168
|
+
"fill_count": obj.get("fill_count"),
|
|
169
|
+
"remaining_count": obj.get("remaining_count"),
|
|
170
|
+
"initial_count": obj.get("initial_count"),
|
|
171
|
+
"taker_fees": obj.get("taker_fees"),
|
|
172
|
+
"maker_fees": obj.get("maker_fees"),
|
|
173
|
+
"taker_fill_cost": obj.get("taker_fill_cost"),
|
|
174
|
+
"maker_fill_cost": obj.get("maker_fill_cost"),
|
|
175
|
+
"taker_fill_cost_dollars": obj.get("taker_fill_cost_dollars"),
|
|
176
|
+
"maker_fill_cost_dollars": obj.get("maker_fill_cost_dollars"),
|
|
177
|
+
"queue_position": obj.get("queue_position"),
|
|
178
|
+
"taker_fees_dollars": obj.get("taker_fees_dollars"),
|
|
179
|
+
"maker_fees_dollars": obj.get("maker_fees_dollars"),
|
|
180
|
+
"expiration_time": obj.get("expiration_time"),
|
|
181
|
+
"created_time": obj.get("created_time"),
|
|
182
|
+
"last_update_time": obj.get("last_update_time"),
|
|
183
|
+
"self_trade_prevention_type": obj.get("self_trade_prevention_type"),
|
|
184
|
+
"order_group_id": obj.get("order_group_id"),
|
|
185
|
+
"cancel_order_on_pause": obj.get("cancel_order_on_pause")
|
|
186
|
+
})
|
|
187
|
+
return _obj
|
|
188
|
+
|
|
189
|
+
|