Skip to main content

Kalshi Trade API

Project description

kalshi_python

This library is the official python SDK for algorithmic trading on Kalshi.

This SDK is powered by Kalshi's trading rest api v2. The documentation for the underlying api can be found here.

By using this SDK, you agree to Kalshi's Developer Agreement (https://kalshi.com/developer-agreement).

This Python package is automatically generated by the Swagger Codegen project:

  • API version: 2.0.0
  • Package version: 1.0.0
  • Build package: io.swagger.codegen.v3.generators.python.PythonClientCodegen

Requirements.

Python 2.7 and 3.4+

Installation & Usage

pip install

If the python package is hosted on Github, you can install directly from Github

pip install kalshi-python

Then import the package:

import kalshi_python 

Quick start

Please follow the installation procedure and then run the following:

import uuid
import kalshi_python
from kalshi_python.models import CreateOrderRequest
from pprint import pprint

config = kalshi_python.Configuration()
# Comment the line below to use production
config.host = 'https://demo-api.kalshi.co/trade-api/v2'

# Create an API configuration passing your credentials.
# Use this if you want the kalshi_python sdk to manage the authentication for your.
kalshi_api = kalshi_python.ApiInstance(
    email='YOUR_EMAIL_HERE',
    password='YOUR_PASSWORD_HERE',
    configuration=config,
)

# Optionally you can use the
exchangeStatus = kalshi_api.get_exchange_status()
print('Exchange status response: ')
pprint(exchangeStatus)

# Replace the series ticker with the market ticker you want.
marketTicker = 'FED-23DEC-T3.00'
marketResponse = kalshi_api.get_market(marketTicker)
print('\nMarket: ' + marketTicker)
pprint(marketResponse)

balanceResponse = kalshi_api.get_balance()
print('\nUser balance: ')
pprint(balanceResponse)

# Submit an order for 10 yes contracts at 50cents on 'FED-23DEC-T3.00'
orderUuid = str(uuid.uuid4())
orderResponse = kalshi_api.create_order(CreateOrderRequest(
    ticker=marketTicker,
    action='buy',
    type='limit',
    yes_price=50,
    count=10,
    client_order_id=orderUuid,
    side='yes',
))
print('\nOrder submitted: ')
pprint(orderResponse)

Documentation for API Endpoints

All URIs are relative to https://trading-api.kalshi.com/trade-api/v2

Class Method HTTP request Description
AuthApi login POST /login Login
AuthApi logout POST /logout Logout
ExchangeApi get_exchange_status GET /exchange/status Endpoint for getting the exchange status.
MarketApi get_event GET /events/{event_ticker} GetEvent
MarketApi get_market GET /markets/{ticker} GetMarket
MarketApi get_market_history GET /markets/{ticker}/history GetMarketHistory
MarketApi get_market_orderbook GET /markets/{ticker}/orderbook GetMarketOrderbook
MarketApi get_markets GET /markets GetMarkets
MarketApi get_series GET /series/{series_ticker} GetSeries
MarketApi get_trades GET /markets/trades GetTrades
PortfolioApi batch_cancel_orders DELETE /portfolio/orders/batched BatchCancelOrders
PortfolioApi batch_create_orders POST /portfolio/orders/batched BatchCreateOrders
PortfolioApi cancel_order DELETE /portfolio/orders/{order_id} CancelOrder
PortfolioApi create_order POST /portfolio/orders CreateOrder
PortfolioApi decrease_order POST /portfolio/orders/{order_id}/decrease DecreaseOrder
PortfolioApi get_balance GET /portfolio/balance GetBalance
PortfolioApi get_fills GET /portfolio/fills GetFills
PortfolioApi get_order GET /portfolio/orders/{order_id} GetOrder
PortfolioApi get_orders GET /portfolio/orders GetOrders
PortfolioApi get_portfolio_settlements GET /portfolio/settlements GetPortfolioSettlements
PortfolioApi get_positions GET /portfolio/positions GetPositions

Documentation For Models

Documentation For Authorization

bearer_token

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header
  • Example: "Authorization: Bearer f73f541a-fa99-42ca-87e3-bc593289d58d:P0hRpKR8lKkeVYsVYN13h382xsLThe1HbCb3BdGm2fgtoQVJwVLQF7JiiiRNfmQS"

Author

support@kalshi.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kalshi_python-1.1.0.tar.gz (53.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kalshi_python-1.1.0-py3-none-any.whl (142.1 kB view details)

Uploaded Python 3

File details

Details for the file kalshi_python-1.1.0.tar.gz.

File metadata

  • Download URL: kalshi_python-1.1.0.tar.gz
  • Upload date:
  • Size: 53.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for kalshi_python-1.1.0.tar.gz
Algorithm Hash digest
SHA256 72de1f4a6897ffc41e247112530fc3b94c0a5c6541eb0d6fe8bc03a4e4854eb7
MD5 24c442028053c3f4c5ad428d22865262
BLAKE2b-256 e225e6acefc61c509d0a55544eb1fcc652bf06b153ba509f67af189821ec2c74

See more details on using hashes here.

File details

Details for the file kalshi_python-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: kalshi_python-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 142.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for kalshi_python-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f49fc93496d0b05bdde258367452963b36a4806cb3e06599a722d7c9a0d7731
MD5 abb14b43fc0ef09aad735d464198d7be
BLAKE2b-256 63a646127713e7274ead3b219d04f97d16f9666423577b88b56c8e66364905e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page