kalshigo

package module
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

README

KalshiGo

KalshiGo is a Go package providing low-level bindings to the Kalshi API. Inspired by DiscordGo. Add kalshipulse on Discord for support or discussions.

Usage

c, err := NewFromKeyPath("./kalshi_private_key.pem", "7627b510-20db-4b17-8b8c-83f18c9344a1", "https://api.elections.kalshi.com")

if err != nil {
    panic(err)
}

s, err := c.GetSeries(&GetSeriesParams{
    SeriesTicker: "KXPAYROLLS",
})

if err != nil {
    panic(err)
}

fmt.Println(s)

In general, any GET endpoint (series, market, etc) will have a corresponding Get{type}Params struct that needs to be filled.

Status

Section Support Status
market
exchange
auth [1]
collection
portfolio
sockets

[1] The auth endpoint has been deprecated and replaced with API key-based authentication, which we support.

TODO:

  • Test with canonical jsons to check accuracy of structs

  • Add features (first priority)

  • Add context support

  • Add godoc comments

  • Add cleaner logging

  • Deduplicate code

Documentation

Index

Constants

View Source
const ANNOUNCEMENT_ENDPOINT = "/trade-api/v2/exchange/announcements"
View Source
const BALANCE_ENDPOINT = "/trade-api/v2/portfolio/balance"
View Source
const EVENT_PATH = "/trade-api/v2/events"
View Source
const FILLS_ENDPOINT = "/trade-api/v2/portfolio/fills"
View Source
const MARKET_PATH = "/trade-api/v2/markets"
View Source
const ORDERS_ENDPOINT = "/trade-api/v2/portfolio/orders"
View Source
const SCHEDULE_ENDPOINT = "/trade-api/v2/exchange/schedule"
View Source
const SERIES_PATH = "/trade-api/v2/series"
View Source
const STATUS_ENDPOINT = "/trade-api/v2/exchange/status"
View Source
const TRADE_PATH = "trade-api/v2/markets/trades"

Variables

View Source
var ErrPEMParse = errors.New("failed to parse PEM block containing the private key")

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(privateKey *rsa.PrivateKey, accessKey string, baseURL string) *Client

func NewFromKeyPath

func NewFromKeyPath(keyPath string, accessKey string, baseURL string) (*Client, error)

func (*Client) GetBalance

func (c *Client) GetBalance() (int, error)

func (*Client) GetEvent

func (c *Client) GetEvent(params *structs.GetEventParams) (*structs.Event, error)

func (*Client) GetEvents

func (c *Client) GetEvents(params *structs.GetEventsParams) (*structs.GetEventsResponse, error)

func (*Client) GetExchangeAnnouncements

func (c *Client) GetExchangeAnnouncements() ([]structs.Announcement, error)

func (*Client) GetExchangeSchedule

func (c *Client) GetExchangeSchedule() (*structs.GetExchangeScheduleResponse, error)

func (*Client) GetExchangeStatus

func (c *Client) GetExchangeStatus() (*structs.ExchangeStatus, error)

func (*Client) GetFills

func (c *Client) GetFills(params *structs.GetFillsParams) (*structs.GetFillsResponse, error)

func (*Client) GetMarket

func (c *Client) GetMarket(params *structs.GetMarketParams) (*structs.Market, error)

func (*Client) GetMarketCandlesticks

func (c *Client) GetMarketCandlesticks(params *structs.GetMarketCandlesticksParams) ([]structs.MarketCandlestick, error)

func (*Client) GetMarketOrderbook

func (c *Client) GetMarketOrderbook(params *structs.GetMarketOrderbookParams) (*structs.MarketOrderbook, error)

func (*Client) GetMarkets

func (c *Client) GetMarkets(params *structs.GetMarketsParams) (*structs.GetMarketsResponse, error)

func (*Client) GetOrders

func (c *Client) GetOrders(params *structs.GetOrdersParams) (*structs.GetOrdersResponse, error)

func (*Client) GetSeries

func (c *Client) GetSeries(params *structs.GetSeriesParams) (*structs.Series, error)

func (*Client) GetTrades

func (c *Client) GetTrades(params *structs.GetTradesParams) (*structs.GetTradesResponse, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL