Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions kalshi/fix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,17 @@
EventResendRejectReason,
ExecInst,
ExecType,
MDEntryType,
MDReqRejReason,
MDUpdateAction,
MsgType,
OrdStatus,
OrdType,
SecurityTradingStatus,
SelfTradePreventionType,
SessionRejectReason,
Side,
SubscriptionRequestType,
TimeInForce,
)
from kalshi.fix.errors import (
Expand All @@ -78,7 +83,13 @@
Heartbeat,
Logon,
Logout,
MarketDataIncrementalRefresh,
MarketDataRequest,
MarketDataRequestReject,
MarketDataSnapshotFullRefresh,
MarketSettlementParty,
MDIncrementalEntry,
MDSnapshotEntry,
MiscFee,
MultivariateSelectedLeg,
NewOrderSingle,
Expand All @@ -89,12 +100,16 @@
OrderMassCancelRequest,
Party,
Reject,
RelatedSymbol,
ResendRequest,
SecurityStatus,
SecurityStatusRequest,
SequenceReset,
TestRequest,
decode_app_message,
groupfield,
)
from kalshi.fix.orderbook import BookLevel, FixOrderBook, MarketDataBook
from kalshi.fix.session import FixSession, FixSessionState
from kalshi.fix.tags import Tag

Expand All @@ -104,6 +119,7 @@
"BEGIN_STRING_FIXT11",
"SOH",
"ApplVerID",
"BookLevel",
"BusinessMessageReject",
"CollateralAmountChange",
"EncryptMethod",
Expand All @@ -124,6 +140,7 @@
"FixGroupMeta",
"FixLogonError",
"FixMessage",
"FixOrderBook",
"FixParser",
"FixProduct",
"FixRejectError",
Expand All @@ -137,6 +154,16 @@
"KalshiFixError",
"Logon",
"Logout",
"MDEntryType",
"MDIncrementalEntry",
"MDReqRejReason",
"MDSnapshotEntry",
"MDUpdateAction",
"MarketDataBook",
"MarketDataIncrementalRefresh",
"MarketDataRequest",
"MarketDataRequestReject",
"MarketDataSnapshotFullRefresh",
"MarketSettlementParty",
"MiscFee",
"MsgType",
Expand All @@ -152,11 +179,16 @@
"Party",
"RawMessage",
"Reject",
"RelatedSymbol",
"ResendRequest",
"SecurityStatus",
"SecurityStatusRequest",
"SecurityTradingStatus",
"SelfTradePreventionType",
"SequenceReset",
"SessionRejectReason",
"Side",
"SubscriptionRequestType",
"Tag",
"TestRequest",
"TimeInForce",
Expand Down
47 changes: 47 additions & 0 deletions kalshi/fix/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,50 @@ class EventResendRejectReason(IntEnum):
SERVER_ERROR = 2
BEGIN_EXECID_TOO_SMALL = 3
END_EXECID_TOO_LARGE = 4


class SubscriptionRequestType(StrEnum):
"""Tag 263 — market-data / security-status subscription action.

For ``MarketDataRequest`` (35=V): ``0``=snapshot, ``1``=snapshot plus updates,
``2``=disable a previous subscription. For ``SecurityStatusRequest`` (35=e)
only ``1`` (subscribe) and ``2`` (unsubscribe) are valid.
"""

SNAPSHOT = "0"
SNAPSHOT_PLUS_UPDATES = "1"
DISABLE = "2"


class MDEntryType(StrEnum):
"""Tag 269 — side of a market-data book level."""

BID = "0"
OFFER = "1"


class MDUpdateAction(StrEnum):
"""Tag 279 — action for an incremental market-data entry (35=X).

FIX 5.0SP2 also defines New=0; Kalshi MD does not emit it, so it is
intentionally absent (an action='0' is dropped as unknown).
"""

CHANGE = "1"
DELETE = "2"


class MDReqRejReason(StrEnum):
"""Tag 281 — why a MarketDataRequest (35=V) was rejected (35=Y)."""

INSUFFICIENT_BANDWIDTH = "2"
UNSUPPORTED_SUBSCRIPTION_REQUEST_TYPE = "4"


class SecurityTradingStatus(IntEnum):
"""Tag 326 — per-market trading-status change streamed via SecurityStatus (35=f)."""

TRADING_HALT = 2
RESUME = 3
KALSHI_DETERMINED = 100
KALSHI_SETTLED = 101
20 changes: 20 additions & 0 deletions kalshi/fix/messages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
EventResendReject,
EventResendRequest,
)
from kalshi.fix.messages.market_data import (
MarketDataIncrementalRefresh,
MarketDataRequest,
MarketDataRequestReject,
MarketDataSnapshotFullRefresh,
MDIncrementalEntry,
MDSnapshotEntry,
RelatedSymbol,
SecurityStatus,
SecurityStatusRequest,
)
from kalshi.fix.messages.order_entry import (
BusinessMessageReject,
ExecutionReport,
Expand Down Expand Up @@ -64,6 +75,12 @@
"Heartbeat",
"Logon",
"Logout",
"MDIncrementalEntry",
"MDSnapshotEntry",
"MarketDataIncrementalRefresh",
"MarketDataRequest",
"MarketDataRequestReject",
"MarketDataSnapshotFullRefresh",
"MarketSettlementParty",
"MiscFee",
"MultivariateSelectedLeg",
Expand All @@ -75,7 +92,10 @@
"OrderMassCancelRequest",
"Party",
"Reject",
"RelatedSymbol",
"ResendRequest",
"SecurityStatus",
"SecurityStatusRequest",
"SequenceReset",
"TestRequest",
"decode_app_message",
Expand Down
10 changes: 10 additions & 0 deletions kalshi/fix/messages/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
from kalshi.fix.enums import MsgType
from kalshi.fix.messages.base import FixMessage
from kalshi.fix.messages.drop_copy import EventResendComplete, EventResendReject
from kalshi.fix.messages.market_data import (
MarketDataIncrementalRefresh,
MarketDataRequestReject,
MarketDataSnapshotFullRefresh,
SecurityStatus,
)
from kalshi.fix.messages.order_entry import (
BusinessMessageReject,
ExecutionReport,
Expand All @@ -36,6 +42,10 @@
MsgType.BUSINESS_MESSAGE_REJECT.value: BusinessMessageReject,
MsgType.EVENT_RESEND_COMPLETE.value: EventResendComplete,
MsgType.EVENT_RESEND_REJECT.value: EventResendReject,
MsgType.MARKET_DATA_SNAPSHOT_FULL_REFRESH.value: MarketDataSnapshotFullRefresh,
MsgType.MARKET_DATA_INCREMENTAL_REFRESH.value: MarketDataIncrementalRefresh,
MsgType.MARKET_DATA_REQUEST_REJECT.value: MarketDataRequestReject,
MsgType.SECURITY_STATUS.value: SecurityStatus,
}
)

Expand Down
Loading