kalshi-cpp 0.6.2
C++23 client for Kalshi's Predictions API
Loading...
Searching...
No Matches
kalshi::RateLimitedTransport Class Referencefinal

Transport decorator that paces requests to Kalshi's Read and Write budgets so they are not rejected with 429. More...

#include <kalshi/rate_limit.hpp>

Inheritance diagram for kalshi::RateLimitedTransport:
kalshi::HttpTransport

Public Member Functions

 RateLimitedTransport (std::shared_ptr< const HttpTransport > inner, RateLimitConfig config)
 
Result< HttpResponse > request (HttpMethod method, std::string_view path, std::string_view body={}) const override
 path is relative to the base URL and may carry a query string.
 
double cost (HttpMethod method, std::string_view path, std::string_view body) const
 Token cost this transport charges for a request.
 
- Public Member Functions inherited from kalshi::HttpTransport
virtual ~HttpTransport ()=default
 
Result< HttpResponse > get (std::string_view path) const
 
Result< HttpResponse > post (std::string_view path, std::string_view body={}) const
 
Result< HttpResponse > put (std::string_view path, std::string_view body={}) const
 
Result< HttpResponse > del (std::string_view path, std::string_view body={}) const
 

Static Public Member Functions

static bool is_write (HttpMethod method, std::string_view path) noexcept
 Whether a request draws from the Write budget.
 

Detailed Description

Transport decorator that paces requests to Kalshi's Read and Write budgets so they are not rejected with 429.

Writes are order, order-group, RFQ, quote, and block-trade mutations; every other request uses the Read budget. Batch requests cost their per-item cost times the number of items. Per-shard Write buckets are not modeled separately, so pacing is conservative when orders target several shards.

Build a config from the account's limits with rate_limit_config() in kalshi/api.hpp.

Constructor & Destructor Documentation

◆ RateLimitedTransport()

kalshi::RateLimitedTransport::RateLimitedTransport ( std::shared_ptr< const HttpTransport >  inner,
RateLimitConfig  config 
)

Member Function Documentation

◆ request()

Result< HttpResponse > kalshi::RateLimitedTransport::request ( HttpMethod  method,
std::string_view  path,
std::string_view  body = {} 
) const
overridevirtual

path is relative to the base URL and may carry a query string.

Implements kalshi::HttpTransport.

◆ is_write()

static bool kalshi::RateLimitedTransport::is_write ( HttpMethod  method,
std::string_view  path 
)
staticnoexcept

Whether a request draws from the Write budget.

◆ cost()

double kalshi::RateLimitedTransport::cost ( HttpMethod  method,
std::string_view  path,
std::string_view  body 
) const

Token cost this transport charges for a request.


The documentation for this class was generated from the following file: