Documentation
¶
Overview ¶
Package kalshi implements a Go client for the Kalshi API.
Index ¶
- Constants
- type Cents
- type Client
- func (c *Client) Balance(ctx context.Context) (Cents, error)
- func (c *Client) CancelOrder(ctx context.Context, orderID string) (*Order, error)
- func (c *Client) CreateOrder(ctx context.Context, req CreateOrderRequest) (*Order, error)
- func (c *Client) DecreaseOrder(ctx context.Context, orderID string, req DecreaseOrderRequest) (*Order, error)
- func (c *Client) Event(ctx context.Context, event string) (*EventResponse, error)
- func (c *Client) Events(ctx context.Context, req EventsRequest) (*EventsResponse, error)
- func (c *Client) ExchangeSchedule(ctx context.Context) (*ExchangeScheduleResponse, error)
- func (c *Client) ExchangeStatus(ctx context.Context) (*ExchangeStatusResponse, error)
- func (c *Client) Fills(ctx context.Context, req FillsRequest) (*FillsResponse, error)
- func (c *Client) Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
- func (c *Client) Logout(ctx context.Context) error
- func (c *Client) Market(ctx context.Context, ticker string) (*Market, error)
- func (c *Client) MarketHistory(ctx context.Context, ticker string, req MarketHistoryRequest) (*MarketHistoryResponse, error)
- func (c *Client) MarketOrderBook(ctx context.Context, ticker string) (*OrderBook, error)
- func (c *Client) Markets(ctx context.Context, req MarketsRequest) (*MarketsResponse, error)
- func (c *Client) OpenFeed(ctx context.Context) (*Feed, error)
- func (c *Client) Order(ctx context.Context, orderID string) (*Order, error)
- func (c *Client) Orders(ctx context.Context, req OrdersRequest) (*OrdersResponse, error)
- func (c *Client) Positions(ctx context.Context, req PositionsRequest) (*PositionsResponse, error)
- func (c *Client) Series(ctx context.Context, seriesTicker string) (*Series, error)
- func (c *Client) Settlements(ctx context.Context, req SettlementsRequest) (*SettlementsResponse, error)
- func (c *Client) Trades(ctx context.Context, req TradesRequest) (*TradesResponse, error)
- type CreateOrderRequest
- type CursorRequest
- type CursorResponse
- type DecreaseOrderRequest
- type Event
- type EventPosition
- type EventResponse
- type EventsRequest
- type EventsResponse
- type ExchangeScheduleResponse
- type ExchangeStatusResponse
- type Feed
- type Fill
- type FillsRequest
- type FillsResponse
- type LoginRequest
- type LoginResponse
- type Market
- type MarketHistory
- type MarketHistoryRequest
- type MarketHistoryResponse
- type MarketPosition
- type MarketsRequest
- type MarketsResponse
- type Order
- type OrderAction
- type OrderBook
- func (b OrderBook) BestNoOffer(quantity int) (Cents, bool)
- func (b OrderBook) BestYesOffer(quantity int) (Cents, bool)
- func (b OrderBook) NoLiquidity() Cents
- func (b OrderBook) NoOffersUnderLimit(limit Cents) int
- func (b OrderBook) NoTotalOffers() int
- func (b OrderBook) YesLiquidity() Cents
- func (b OrderBook) YesOffersUnderLimit(limit Cents) int
- func (b OrderBook) YesTotalOffers() int
- type OrderBookBid
- type OrderBookBids
- type OrderStatus
- type OrderType
- type OrdersRequest
- type OrdersResponse
- type PositionsRequest
- type PositionsResponse
- type Series
- type Settlement
- type SettlementStatus
- type SettlementsRequest
- type SettlementsResponse
- type Side
- type StreamOrderBook
- type Time
- type Timestamp
- type Trade
- type TradesRequest
- type TradesResponse
Constants ¶
const ( APIDemoURL = "https://demo-api.kalshi.co/trade-api/v2/" APIProdURL = "https://trading-api.kalshi.com/trade-api/v2/" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// BaseURL is one of APIDemoURL or APIProdURL.
BaseURL string
// See https://trading-api.readme.io/reference/tiers-and-rate-limits.
WriteRatelimit *rate.Limiter
ReadRateLimit *rate.Limiter
// contains filtered or unexported fields
}
Client must be instantiated via New.
func New ¶
New creates a new Kalshi client. Login must be called to authenticate the the client before any other request.
func (*Client) Balance ¶
Balance is described here: https://trading-api.readme.io/reference/getbalance.
func (*Client) CancelOrder ¶
CancelOrder is described here: https://trading-api.readme.io/reference/cancelorder.
func (*Client) CreateOrder ¶
CreateOrder is described here: https://trading-api.readme.io/reference/createorder.
func (*Client) DecreaseOrder ¶
func (c *Client) DecreaseOrder(ctx context.Context, orderID string, req DecreaseOrderRequest) (*Order, error)
DecreaseOrder is described here: https://trading-api.readme.io/reference/decreaseorder.
func (*Client) Event ¶
Event is described here: https://trading-api.readme.io/reference/getevent.
func (*Client) Events ¶
func (c *Client) Events(ctx context.Context, req EventsRequest) (*EventsResponse, error)
Events is described here: https://trading-api.readme.io/reference/getevents.
func (*Client) ExchangeSchedule ¶
func (c *Client) ExchangeSchedule(ctx context.Context) (*ExchangeScheduleResponse, error)
ExchangeSchedule is described here: https://trading-api.readme.io/reference/getexchangeschedule.
func (*Client) ExchangeStatus ¶
func (c *Client) ExchangeStatus(ctx context.Context) (*ExchangeStatusResponse, error)
ExchangeStatus is described here: https://trading-api.readme.io/reference/getexchangestatus.
func (*Client) Fills ¶
func (c *Client) Fills(ctx context.Context, req FillsRequest) (*FillsResponse, error)
Fills is described here: https://trading-api.readme.io/reference/getfills.
func (*Client) Login ¶
func (c *Client) Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
Login is described here: https://trading-api.readme.io/reference/login.
The Client will stay authenticated after Login is called since it stores the token in the cookie state.
func (*Client) Logout ¶
Logout is described here: https://trading-api.readme.io/reference/logout.
func (*Client) Market ¶
Market is described here: https://trading-api.readme.io/reference/getmarket.
func (*Client) MarketHistory ¶
func (c *Client) MarketHistory( ctx context.Context, ticker string, req MarketHistoryRequest, ) (*MarketHistoryResponse, error)
func (*Client) MarketOrderBook ¶
MarketOrderBook is described here: https://trading-api.readme.io/reference/getmarketorderbook.
func (*Client) Markets ¶
func (c *Client) Markets( ctx context.Context, req MarketsRequest, ) (*MarketsResponse, error)
Markets is described here: https://trading-api.readme.io/reference/getmarkets.
func (*Client) OpenFeed ¶
OpenFeed creates a new market data streaming connection. OpenFeed is described in more detail here: https://trading-api.readme.io/reference/introduction. WARNING: OpenFeed has not been thoroughly tested.
func (*Client) Order ¶
Order is described here: https://trading-api.readme.io/reference/getorder.
func (*Client) Orders ¶
func (c *Client) Orders(ctx context.Context, req OrdersRequest) (*OrdersResponse, error)
Orders is described here: https://trading-api.readme.io/reference/getorders
func (*Client) Positions ¶
func (c *Client) Positions(ctx context.Context, req PositionsRequest) (*PositionsResponse, error)
Positions is described here: https://trading-api.readme.io/reference/getpositions.
func (*Client) Series ¶
Series is described here: https://trading-api.readme.io/reference/getseries.
func (*Client) Settlements ¶
func (c *Client) Settlements(ctx context.Context, req SettlementsRequest) (*SettlementsResponse, error)
Settlements is described here: https://trading-api.readme.io/reference/getportfoliosettlements.
func (*Client) Trades ¶
func (c *Client) Trades( ctx context.Context, req TradesRequest, ) (*TradesResponse, error)
Trades is described here: https://trading-api.readme.io/reference/gettrades.
type CreateOrderRequest ¶
type CreateOrderRequest struct {
Action OrderAction `json:"action,omitempty"`
BuyMaxCost Cents `json:"buy_max_cost,omitempty"`
Count int `json:"count,omitempty"`
Expiration *Timestamp `json:"expiration_ts,omitempty"`
NoPrice Cents `json:"no_price,omitempty"`
YesPrice Cents `json:"yes_price,omitempty"`
Ticker string `json:"ticker,omitempty"`
ClientOrderID string `json:"client_order_id,omitempty"`
Type OrderType `json:"type"`
Side Side `json:"side"`
}
CreateOrderRequest is described here: https://trading-api.readme.io/reference/createorder.
func (*CreateOrderRequest) Price ¶
func (o *CreateOrderRequest) Price() Cents
func (*CreateOrderRequest) SetPrice ¶
func (c *CreateOrderRequest) SetPrice(p Cents)
SetPrice sets the price of the order based on its side.
func (*CreateOrderRequest) String ¶
func (c *CreateOrderRequest) String() string
String returns a human-readable representation of the order.
type CursorRequest ¶
type CursorResponse ¶
type CursorResponse struct {
Cursor string `json:"cursor"`
}
type DecreaseOrderRequest ¶
type DecreaseOrderRequest struct {
ReduceBy int `json:"reduce_by,omitempty"`
ReduceTo int `json:"reduce_to,omitempty"`
}
DecreaseOrder is described here: https://trading-api.readme.io/reference/decreaseorder.
type Event ¶
type Event struct {
Category string `json:"category"`
EventTicker string `json:"event_ticker"`
MutuallyExclusive bool `json:"mutually_exclusive"`
SeriesTicker string `json:"series_ticker"`
StrikeDate time.Time `json:"strike_date"`
StrikePeriod string `json:"strike_period"`
SubTitle string `json:"sub_title"`
Title string `json:"title"`
}
Event is described here: https://trading-api.readme.io/reference/getevents.
type EventPosition ¶
type EventPosition struct {
EventExposure Cents `json:"event_exposure"`
EventTicker string `json:"event_ticker"`
FeesPaid Cents `json:"fees_paid"`
RealizedPnl Cents `json:"realized_pnl"`
RestingOrderCount int `json:"resting_order_count"`
TotalCost Cents `json:"total_cost"`
}
EventPosition is described here: https://trading-api.readme.io/reference/getpositions.
type EventResponse ¶
EventResponse is described here: https://trading-api.readme.io/reference/getevent.
type EventsRequest ¶
type EventsRequest struct {
CursorRequest
// Status is one of "open", "closed", or "settled".
Status string `url:"status,omitempty"`
SeriesTicker string `url:"series_ticker,omitempty"`
}
EventsRequest is described here: https://trading-api.readme.io/reference/getevents.
type EventsResponse ¶
type EventsResponse struct {
CursorResponse
Events []Event `json:"events"`
}
EventsResponse is described here: https://trading-api.readme.io/reference/getevents.
type ExchangeScheduleResponse ¶
type ExchangeScheduleResponse struct {
Schedule struct {
StandardHours struct {
Monday struct {
OpenTime string `json:"open_time"`
CloseTime string `json:"close_time"`
} `json:"monday"`
Tuesday struct {
OpenTime string `json:"open_time"`
CloseTime string `json:"close_time"`
} `json:"tuesday"`
Wednesday struct {
OpenTime string `json:"open_time"`
CloseTime string `json:"close_time"`
} `json:"wednesday"`
Thursday struct {
OpenTime string `json:"open_time"`
CloseTime string `json:"close_time"`
} `json:"thursday"`
Friday struct {
OpenTime string `json:"open_time"`
CloseTime string `json:"close_time"`
} `json:"friday"`
Saturday struct {
OpenTime string `json:"open_time"`
CloseTime string `json:"close_time"`
} `json:"saturday"`
Sunday struct {
OpenTime string `json:"open_time"`
CloseTime string `json:"close_time"`
} `json:"sunday"`
} `json:"standard_hours"`
MaintenanceWindows []struct {
EndDatetime string `json:"end_datetime"`
StartDatetime string `json:"start_datetime"`
} `json:"maintenance_windows,omitempty"`
} `json:"schedule"`
}
ExchangeScheduleResponse is described here: https://trading-api.readme.io/reference/getexchangeschedule.
type ExchangeStatusResponse ¶
type ExchangeStatusResponse struct {
ExchangeActive bool `json:"exchange_active,omitempty"`
TradingActive bool `json:"trading_active,omitempty"`
}
ExchangeStatusResponse is described here: https://trading-api.readme.io/reference/getexchangestatus.
type Feed ¶
type Feed struct {
// contains filtered or unexported fields
}
Feed is a websocket connection to the Kalshi streaming API. Feed is described in more detail here: https://trading-api.readme.io/reference/introduction. WARNING: Feed has not been thoroughly tested.
type Fill ¶
type Fill struct {
Action OrderAction `json:"action"`
Count int `json:"count"`
CreatedTime time.Time `json:"created_time"`
IsTaker bool `json:"is_taker"`
NoPrice Cents `json:"no_price"`
OrderID string `json:"order_id"`
Side Side `json:"side"`
Ticker string `json:"ticker"`
TradeID string `json:"trade_id"`
YesPrice Cents `json:"yes_price"`
}
Fill is described here: https://trading-api.readme.io/reference/getfills.
type FillsRequest ¶
type FillsRequest struct {
CursorRequest
Ticker string `url:"ticker,omitempty"`
OrderID string `url:"order_id,omitempty"`
MinTS Timestamp `url:"min_ts,omitempty"`
MaxTS Timestamp `url:"max_ts,omitempty"`
}
FillsRequest is described here: https://trading-api.readme.io/reference/getfills.
type FillsResponse ¶
type FillsResponse struct {
CursorResponse
Fills []Fill `json:"fills"`
}
FillsResponse is described here: https://trading-api.readme.io/reference/getfills.
type LoginRequest ¶
type LoginRequest struct {
Email string `json:"email,omitempty"`
Password string `json:"password,omitempty"`
}
LoginRequest is described here: https://trading-api.readme.io/reference/login.
type LoginResponse ¶
type LoginResponse struct {
Token string `json:"token,omitempty"`
UserID string `json:"user_id,omitempty"`
}
LoginResponse is described here: https://trading-api.readme.io/reference/login.
type Market ¶
type Market struct {
Ticker string `json:"ticker"`
EventTicker string `json:"event_ticker"`
Subtitle string `json:"subtitle"`
OpenTime time.Time `json:"open_time"`
CloseTime time.Time `json:"close_time"`
ExpirationTime time.Time `json:"expiration_time"`
Status string `json:"status"`
YesBid Cents `json:"yes_bid"`
YesAsk Cents `json:"yes_ask"`
NoBid Cents `json:"no_bid"`
NoAsk Cents `json:"no_ask"`
LastPrice Cents `json:"last_price"`
PreviousYesBid Cents `json:"previous_yes_bid"`
PreviousYesAsk Cents `json:"previous_yes_ask"`
PreviousPrice Cents `json:"previous_price"`
Volume int `json:"volume"`
Volume24H int `json:"volume_24h"`
Liquidity Cents `json:"liquidity"`
OpenInterest int `json:"open_interest"`
Result string `json:"result"`
CanCloseEarly bool `json:"can_close_early"`
ExpirationValue string `json:"expiration_value"`
Category string `json:"category"`
RiskLimit Cents `json:"risk_limit_cents"`
StrikeType string `json:"strike_type"`
FloorStrike float64 `json:"floor_strike,omitempty"`
CapStrike float64 `json:"cap_strike,omitempty"`
}
Market is described here: https://trading-api.readme.io/reference/getmarkets.
func (*Market) EstimateReturn ¶
func (m *Market) EstimateReturn(p *MarketPosition) Cents
EstimateReturn shows the estimated return for an open position.
func (*Market) NoMidPrice ¶
func (*Market) YesMidPrice ¶
type MarketHistory ¶
type MarketHistory struct {
NoAsk Cents `json:"no_ask"`
NoBid Cents `json:"no_bid"`
OpenInterest int `json:"open_interest"`
Ts Timestamp `json:"ts"`
Volume int `json:"volume"`
YesAsk Cents `json:"yes_ask"`
YesBid Cents `json:"yes_bid"`
YesPrice Cents `json:"yes_price"`
}
MarketHistory is described here: https://trading-api.readme.io/reference/getmarkethistory.
type MarketHistoryRequest ¶
type MarketHistoryRequest struct {
CursorRequest
MinTS Timestamp `json:"min_ts,omitempty"`
MaxTS Timestamp `json:"max_ts,omitempty"`
}
MarketHistoryRequest is described here: https://trading-api.readme.io/reference/getmarkethistory.
type MarketHistoryResponse ¶
type MarketHistoryResponse struct {
CursorResponse
History []MarketHistory `json:"history"`
Ticker string `json:"ticker"`
}
MarketHistoryResponse is described here: https://trading-api.readme.io/reference/getmarkethistory.
type MarketPosition ¶
type MarketPosition struct {
// Fees paid on fill orders, in cents.
FeesPaid Cents `json:"fees_paid"`
// Number of contracts bought in this market. Negative means NO contracts and positive means YES contracts.
Position int `json:"position"`
// Locked in profit and loss, in cents.
RealizedPnl Cents `json:"realized_pnl"`
// Aggregate size of resting orders in contract units.
RestingOrdersCount int `json:"resting_orders_count"`
// Unique identifier for the market.
Ticker string `json:"ticker"`
// Total spent on this market in cents.
TotalTraded Cents `json:"total_traded"`
// Cost of the aggregate market position in cents.
MarketExposure Cents `json:"market_exposure"`
}
MarketPosition is described here: https://trading-api.readme.io/reference/getpositions.
func (*MarketPosition) AvgPrice ¶
func (p *MarketPosition) AvgPrice() Cents
func (*MarketPosition) String ¶
func (p *MarketPosition) String() string
type MarketsRequest ¶
type MarketsRequest struct {
CursorRequest
EventTicker string `url:"event_ticker,omitempty"`
SeriesTicker string `url:"series_ticker,omitempty"`
MaxCloseTs int `url:"max_close_ts,omitempty"`
MinCloseTs int `url:"min_close_ts,omitempty"`
// Status is one of "open", "closed", and "settled"
Status string `url:"status,omitempty"`
Tickers []string `url:"status,omitempty"`
}
MarketsRequest is described here: https://trading-api.readme.io/reference/getmarkets.
type MarketsResponse ¶
type MarketsResponse struct {
Markets []Market `json:"markets,omitempty"`
CursorResponse
}
MarketsResponse is described here: https://trading-api.readme.io/reference/getmarkets.
type Order ¶
type Order struct {
Action OrderAction `json:"action"`
ClientOrderID string `json:"client_order_id"`
CloseCancelCount int `json:"close_cancel_count"`
CreatedTime *Time `json:"created_time"`
DecreaseCount int `json:"decrease_count"`
ExpirationTime *Time `json:"expiration_time"`
FccCancelCount int `json:"fcc_cancel_count"`
LastUpdateTime *Time `json:"last_update_time"`
MakerFillCost int `json:"maker_fill_cost"`
MakerFillCount int `json:"maker_fill_count"`
MakerFees Cents `json:"maker_fees"`
NoPrice Cents `json:"no_price"`
OrderID string `json:"order_id"`
PlaceCount int `json:"place_count"`
QueuePosition int `json:"queue_position"`
RemainingCount int `json:"remaining_count"`
Side Side `json:"side"`
Status OrderStatus `json:"status"`
TakerFees Cents `json:"taker_fees"`
TakerFillCost Cents `json:"taker_fill_cost"`
TakerFillCount int `json:"taker_fill_count"`
Ticker string `json:"ticker"`
Type OrderType `json:"type"`
UserID string `json:"user_id"`
YesPrice Cents `json:"yes_price"`
}
Order is described here: https://trading-api.readme.io/reference/getorders.
type OrderAction ¶
type OrderAction string
const ( Buy OrderAction = "buy" Sell OrderAction = "sell" )
type OrderBook ¶
type OrderBook struct {
YesBids OrderBookBids `json:"yes"`
NoBids OrderBookBids `json:"no"`
}
OrderBook is a snapshot of the order book.
Make sure you understand the market structure before using this struct. A central feature of the Kalshi contract model is that a No bid corresponds to a Yes ask of the complementary price and vice versa. That is, a No bid at 40 cents is equivalent to a Yes ask at 60 cents. This OrderBook type is a a list of bids on either side.
Detailed documentation can be found here: https://trading-api.readme.io/reference/getmarketorderbook.
func (OrderBook) BestNoOffer ¶
BestNoOffer returns the best average asking price for No contracts given a desired quantity.
func (OrderBook) BestYesOffer ¶
BestYesOffer returns the best average asking price for Yes contracts given a desired quantity.
func (OrderBook) NoLiquidity ¶
NoLiquidity returns the total sum required to buy all available No contracts on the market.
func (OrderBook) NoOffersUnderLimit ¶
NoOffersUnderLimit is the quantity of No contracts available to be taken at a price less than or equal to the given limit.
func (OrderBook) NoTotalOffers ¶
NoTotalOffers is the quantity of total No contracts available to be taken.
func (OrderBook) YesLiquidity ¶
YesLiquidity returns the total sum required to buy all available Yes contracts on the market.
func (OrderBook) YesOffersUnderLimit ¶
YesOffersUnderLimit is the quantity of Yes contracts available to be taken at a price less than or equal to the given limit.
func (OrderBook) YesTotalOffers ¶
YesTotalOffers is the quantity of total Yes contracts available to be taken.
type OrderBookBid ¶
OrderBookBid represents the aggregate quantity of all resting Bids at a given price.
func (OrderBookBid) MarshalJSON ¶
func (o OrderBookBid) MarshalJSON() ([]byte, error)
func (*OrderBookBid) UnmarshalJSON ¶
func (o *OrderBookBid) UnmarshalJSON(b []byte) error
type OrderBookBids ¶
type OrderBookBids []OrderBookBid
type OrderStatus ¶
type OrderStatus string
const ( Resting OrderStatus = "resting" Canceled OrderStatus = "canceled" Executed OrderStatus = "executed" Pending OrderStatus = "pending" )
type OrdersRequest ¶
type OrdersRequest struct {
Ticker string `url:"ticker,omitempty"`
Status OrderStatus `url:"status,omitempty"`
}
OrdersRequest is described here: https://trading-api.readme.io/reference/getorders
type OrdersResponse ¶
type OrdersResponse struct {
CursorResponse
Orders []Order `json:"orders"`
}
Orders is described here: https://trading-api.readme.io/reference/getorders.
type PositionsRequest ¶
type PositionsRequest struct {
CursorRequest
Limit int `url:"limit,omitempty"`
SettlementStatus SettlementStatus `url:"settlement_status,omitempty"`
Ticker string `url:"ticker,omitempty"`
EventTicker string `url:"event_ticker,omitempty"`
}
Position is described here: https://trading-api.readme.io/reference/getpositions.
type PositionsResponse ¶
type PositionsResponse struct {
CursorResponse
EventPositions []EventPosition `json:"event_positions"`
MarketPositions []MarketPosition `json:"market_positions"`
}
PositionsResponse is described here: https://trading-api.readme.io/reference/getpositions.
type Series ¶
type Series struct {
Frequency string `json:"frequency"`
Ticker string `json:"ticker"`
Title string `json:"title"`
}
Series is described here: https://trading-api.readme.io/reference/getseries.
type Settlement ¶
type Settlement struct {
MarketResult string `json:"market_result"`
NoCount int `json:"no_count"`
NoTotalCost int `json:"no_total_cost"`
Revenue int `json:"revenue"`
SettledTime time.Time `json:"settled_time"`
Ticker string `json:"ticker"`
YesCount int `json:"yes_count"`
YesTotalCost int `json:"yes_total_cost"`
}
Settlement is described here: https://trading-api.readme.io/reference/getportfoliosettlements.
type SettlementStatus ¶
type SettlementStatus string
const ( StatusAll SettlementStatus = "all" StatusSettled SettlementStatus = "settled" StatusUnsettled SettlementStatus = "unsettled" )
type SettlementsRequest ¶
type SettlementsRequest struct {
CursorRequest
}
PortfolioSettlements is described here: https://trading-api.readme.io/reference/getportfoliosettlements.
type SettlementsResponse ¶
type SettlementsResponse struct {
CursorResponse
Settlements []Settlement `json:"settlements"`
}
SettlementsResponse is described here: https://trading-api.readme.io/reference/getportfoliosettlements.
type StreamOrderBook ¶
type StreamOrderBook struct {
OrderBook
LoadedAt time.Time
// MarketID is included so multiple streaming order books can be multiplexed
// onto one channel.
MarketID string
}
StreamOrderBook is sent by the streaming connection.
type Time ¶
Time is a time.Time that tolerates additional '"' characters. Kalshi API endpoints use both RFC3339 and POSIX timestamps.
func (*Time) UnmarshalJSON ¶
type Timestamp ¶
Timestamp represents a POSIX Timestamp in seconds.
func ExpireAfter ¶
ExpireAfter is a helper function for creating an expiration timestamp some duration after the current time.
func OrderExecuteImmediateOrCancel ¶
func OrderExecuteImmediateOrCancel() *Timestamp
When passed to `CreateOrder`, the order will attempt to partially or completely fill and the remaining unfilled quantity will be cancelled. This is also known as Immediate-or-Cancel (IOC).
func OrderGoodTillCanceled ¶
func OrderGoodTillCanceled() *Timestamp
When passed to `CreateOrder`, the order won't expire until explicitly cancelled. This is also known as Good 'Till Cancelled (GTC). This function just returns `nil`.
func (Timestamp) MarshalJSON ¶
func (*Timestamp) UnmarshalJSON ¶
type Trade ¶
type Trade struct {
Count int `json:"count"`
CreatedTime time.Time `json:"created_time"`
NoPrice Cents `json:"no_price"`
TakerSide Side `json:"taker_side"`
Ticker string `json:"ticker"`
TradeID string `json:"trade_id"`
YesPrice Cents `json:"yes_price"`
}
Trade is described here: https://trading-api.readme.io/reference/gettrades.
type TradesRequest ¶
type TradesRequest struct {
CursorRequest
Ticker string `url:"ticker,omitempty"`
MinTS int `url:"min_ts,omitempty"`
MaxTS int `url:"max_ts,omitempty"`
}
TradesRequest is described here: https://trading-api.readme.io/reference/gettrades.
type TradesResponse ¶
type TradesResponse struct {
CursorResponse
Trades []Trade `json:"trades,omitempty"`
}
TradesResponse is described here: https://trading-api.readme.io/reference/gettrades.