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
40 changes: 40 additions & 0 deletions kalshi/fix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
)
from kalshi.fix.connection import FixConnection
from kalshi.fix.enums import (
AcceptQuoteResult,
ApplVerID,
EncryptMethod,
EventResendRejectReason,
Expand All @@ -54,6 +55,12 @@
OrderGroupAction,
OrdStatus,
OrdType,
QuoteCancelResult,
QuoteConfirmResult,
QuoteRequestRejectReason,
QuoteRequestType,
QuoteStatus,
RFQCancelResult,
SecurityTradingStatus,
SelfTradePreventionType,
SessionRejectReason,
Expand All @@ -72,6 +79,8 @@
)
from kalshi.fix.messages import (
APP_MESSAGE_MODELS,
AcceptQuote,
AcceptQuoteStatus,
BusinessMessageReject,
CollateralAmountChange,
EventResendComplete,
Expand Down Expand Up @@ -102,9 +111,20 @@
OrderMassCancelReport,
OrderMassCancelRequest,
Party,
Quote,
QuoteCancel,
QuoteCancelStatus,
QuoteConfirm,
QuoteConfirmStatus,
QuoteRequest,
QuoteRequestAck,
QuoteRequestReject,
QuoteStatusReport,
Reject,
RelatedSymbol,
ResendRequest,
RFQCancel,
RFQCancelStatus,
SecurityStatus,
SecurityStatusRequest,
SequenceReset,
Expand All @@ -121,6 +141,9 @@
"APP_MESSAGE_MODELS",
"BEGIN_STRING_FIXT11",
"SOH",
"AcceptQuote",
"AcceptQuoteResult",
"AcceptQuoteStatus",
"ApplVerID",
"BookLevel",
"BusinessMessageReject",
Expand Down Expand Up @@ -183,6 +206,23 @@
"OrderMassCancelReport",
"OrderMassCancelRequest",
"Party",
"Quote",
"QuoteCancel",
"QuoteCancelResult",
"QuoteCancelStatus",
"QuoteConfirm",
"QuoteConfirmResult",
"QuoteConfirmStatus",
"QuoteRequest",
"QuoteRequestAck",
"QuoteRequestReject",
"QuoteRequestRejectReason",
"QuoteRequestType",
"QuoteStatus",
"QuoteStatusReport",
"RFQCancel",
"RFQCancelResult",
"RFQCancelStatus",
"RawMessage",
"Reject",
"RelatedSymbol",
Expand Down
64 changes: 64 additions & 0 deletions kalshi/fix/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,70 @@ class EventResendRejectReason(IntEnum):
END_EXECID_TOO_LARGE = 4


class QuoteRequestType(IntEnum):
"""Tag 303 — QuoteRequestAck (35=b) request type."""

MANUAL = 1
AUTOMATIC = 2


class QuoteStatus(IntEnum):
"""Tag 297 — QuoteStatusReport (35=AI) quote status."""

ACCEPTED = 0
REJECTED = 5
PENDING = 10
CANCELLED = 17


class QuoteRequestRejectReason(IntEnum):
"""Tag 658 — QuoteRequestReject (35=AG) reason."""

UNKNOWN_SYMBOL = 1
QUOTE_REQUEST_EXCEEDS_LIMIT = 3
INSUFFICIENT_CREDIT = 11
OTHER = 99


# The next four enums use a ``Result`` suffix to avoid colliding with the
# same-named status *messages* (the Kalshi dictionary names the status field and
# its carrying message identically, e.g. tag 21010 and 35=U8 are both
# "QuoteConfirmStatus"); the message keeps the spec name, the value-enum is suffixed.


class QuoteConfirmResult(IntEnum):
"""Tag 21010 — QuoteConfirmStatus (35=U8) outcome."""

ACCEPTED = 0
REJECTED = 1


class QuoteCancelResult(IntEnum):
"""Tag 298 — QuoteCancelStatus (35=U9) outcome."""

CANCELLED = 0
REJECTED = 1


class RFQCancelResult(IntEnum):
"""Tag 21013 — RFQCancelStatus (35=UB) outcome.

Spelled ``CANCELLED`` to match :class:`QuoteCancelResult` / :class:`QuoteStatus`
even though the dictionary describes tag 21013 value 0 as "CANCELED" — the
member name is SDK-chosen and not wire-significant (the wire value is ``0``).
"""

CANCELLED = 0
REJECTED = 1


class AcceptQuoteResult(IntEnum):
"""Tag 21025 — AcceptQuoteStatus (35=UC) outcome."""

ACCEPTED = 0
REJECTED = 1


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

Expand Down
28 changes: 28 additions & 0 deletions kalshi/fix/messages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@
OrderMassCancelRequest,
)
from kalshi.fix.messages.order_groups import OrderGroupRequest, OrderGroupResponse
from kalshi.fix.messages.rfq import (
AcceptQuote,
AcceptQuoteStatus,
Quote,
QuoteCancel,
QuoteCancelStatus,
QuoteConfirm,
QuoteConfirmStatus,
QuoteRequest,
QuoteRequestAck,
QuoteRequestReject,
QuoteStatusReport,
RFQCancel,
RFQCancelStatus,
)
from kalshi.fix.messages.session import (
Heartbeat,
Logon,
Expand All @@ -63,6 +78,8 @@

__all__ = [
"APP_MESSAGE_MODELS",
"AcceptQuote",
"AcceptQuoteStatus",
"BusinessMessageReject",
"CollateralAmountChange",
"EventResendComplete",
Expand Down Expand Up @@ -94,6 +111,17 @@
"OrderMassCancelReport",
"OrderMassCancelRequest",
"Party",
"Quote",
"QuoteCancel",
"QuoteCancelStatus",
"QuoteConfirm",
"QuoteConfirmStatus",
"QuoteRequest",
"QuoteRequestAck",
"QuoteRequestReject",
"QuoteStatusReport",
"RFQCancel",
"RFQCancelStatus",
"Reject",
"RelatedSymbol",
"ResendRequest",
Expand Down
22 changes: 22 additions & 0 deletions kalshi/fix/messages/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@
OrderMassCancelReport,
)
from kalshi.fix.messages.order_groups import OrderGroupResponse
from kalshi.fix.messages.rfq import (
AcceptQuoteStatus,
Quote,
QuoteCancelStatus,
QuoteConfirmStatus,
QuoteRequest,
QuoteRequestAck,
QuoteRequestReject,
QuoteStatusReport,
RFQCancelStatus,
)

logger = logging.getLogger("kalshi.fix")

Expand All @@ -48,6 +59,17 @@
MsgType.MARKET_DATA_REQUEST_REJECT.value: MarketDataRequestReject,
MsgType.SECURITY_STATUS.value: SecurityStatus,
MsgType.ORDER_GROUP_RESPONSE.value: OrderGroupResponse,
# RFQ / quoting. R and S are bidirectional — a client acting as market
# maker (or creator) receives them as notifications, so they decode too.
MsgType.QUOTE_REQUEST.value: QuoteRequest,
MsgType.QUOTE.value: Quote,
MsgType.QUOTE_REQUEST_ACK.value: QuoteRequestAck,
MsgType.QUOTE_STATUS_REPORT.value: QuoteStatusReport,
MsgType.QUOTE_REQUEST_REJECT.value: QuoteRequestReject,
MsgType.QUOTE_CONFIRM_STATUS.value: QuoteConfirmStatus,
MsgType.QUOTE_CANCEL_STATUS.value: QuoteCancelStatus,
MsgType.RFQ_CANCEL_STATUS.value: RFQCancelStatus,
MsgType.ACCEPT_QUOTE_STATUS.value: AcceptQuoteStatus,
}
)

Expand Down
Loading