This library is the official python SDK for algorithmic trading on Kalshi.
This SDK is powered by Kalshi's trading api.
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
Python 2.7 and 3.4+
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
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)
The documentation for the underlying web api used by the sdk can be found here.