Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added .DS_Store
Binary file not shown.
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# .env.example
# For Kalshi Demo Environment
DEMO_KEYID=3627ae7b-ca77-4eb4-ad64-36e654a4e02e
DEMO_KEYFILE=test1.txt

# For NOAA Historical Data
NOAA_API_TOKEN="PZgbYnOwDvdWXAkXBNfJjnbjHfeROsyM"
37 changes: 32 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
# kalshi-starter-code-python
Example python code for accessing api-authenticated endpoints on [Kalshi](https://kalshi.com). This is not an SDK.
# Kalshi Weather Trading Bot

## Installation
Install requirements.txt in a virtual environment of your choice and execute main.py from within the repo.
This is a modular, robust trading bot for Kalshi weather markets focused exclusively on Philadelphia markets. The bot uses XGBoost-based predictive modeling integrated into a CLI for training, backtesting, and live trading.

## Project Structure

```
pip install -r requirements.txt
kalshi_weather_bot/
├── data/ # Data storage directory
│ └── (holds downloaded csv files)
├── models/ # Model storage directory
│ └── (holds saved model files)
├── backtests/ # Backtesting results
│ └── (holds backtest results and metrics)
├── src/ # Source code modules
│ ├── data_collection/
│ ├── feature_engineering/
│ ├── modeling/
│ ├── backtesting/
│ └── trading/
├── .env.example # Example environment file
├── .env # Your API credentials (not in repo)
├── clients.py # Kalshi API client
├── config.py # Configuration parameters
├── main.py # Main controller with CLI interface
├── requirements.txt # Python dependencies
├── deploy.sh # Deployment script
└── README.md # This file
├── __init__.py
└── trader.py
python main.py
```
7 changes: 7 additions & 0 deletions backtests/backtest_metrics_20250731_075424.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"total_return_pct": 1416.6288476730167,
"num_trades": 197,
"max_drawdown_pct": 32.721988615457896,
"sharpe_ratio": 2.7577769447030587,
"win_rate_pct": 44.67005076142132
}
7 changes: 7 additions & 0 deletions backtests/backtest_metrics_20250804_012311.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"total_return_pct": 70617.12251110707,
"num_trades": 588,
"max_drawdown_pct": 53.59977347946383,
"sharpe_ratio": 0.6543218665388222,
"win_rate_pct": 34.01360544217687
}
3 changes: 3 additions & 0 deletions backtests/backtest_metrics_20250804_012815.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"message": "No trades were made during backtesting."
}
7 changes: 7 additions & 0 deletions backtests/backtest_metrics_20250804_012929.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"total_return_pct": 2410442576.629363,
"num_trades": 671,
"max_drawdown_pct": 47.972670414296765,
"sharpe_ratio": 1.7344546286105804,
"win_rate_pct": 82.11624441132638
}
7 changes: 7 additions & 0 deletions backtests/backtest_metrics_20250804_013132.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"total_return_pct": -94.20570082682177,
"num_trades": 675,
"max_drawdown_pct": 94.22134297153437,
"sharpe_ratio": -6.438670781671149,
"win_rate_pct": 80.5925925925926
}
7 changes: 7 additions & 0 deletions backtests/backtest_metrics_20250804_013157.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"total_return_pct": -92.59875276874347,
"num_trades": 689,
"max_drawdown_pct": 92.61548659546241,
"sharpe_ratio": -5.973289931105801,
"win_rate_pct": 82.29317851959361
}
3 changes: 3 additions & 0 deletions backtests/backtest_metrics_20250804_022058.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"message": "No trades were made during backtesting."
}
7 changes: 7 additions & 0 deletions backtests/backtest_metrics_20250804_095641.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"total_return_pct": -99.71683624112629,
"num_trades": 2254,
"max_drawdown_pct": 99.7177619489648,
"sharpe_ratio": -4.761328941663111,
"win_rate_pct": 87.35581188997338
}
7 changes: 7 additions & 0 deletions backtests/backtest_metrics_20250804_102141.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"total_return_pct": -99.84735237447275,
"num_trades": 2255,
"max_drawdown_pct": 99.84949675316788,
"sharpe_ratio": -5.0753910830145825,
"win_rate_pct": 86.25277161862527
}
7 changes: 7 additions & 0 deletions backtests/backtest_metrics_20250804_110508.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"total_return_pct": -99.94626924983766,
"num_trades": 2276,
"max_drawdown_pct": 99.94689488297486,
"sharpe_ratio": -5.54734559947591,
"win_rate_pct": 84.49033391915641
}
7 changes: 7 additions & 0 deletions backtests/backtest_metrics_20250804_110607.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"total_return_pct": -99.99999999981728,
"num_trades": 2492,
"max_drawdown_pct": 99.9999999998222,
"sharpe_ratio": -9.384662478797791,
"win_rate_pct": 39.72712680577849
}
7 changes: 7 additions & 0 deletions backtests/backtest_metrics_20250804_110839.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"total_return_pct": -99.99999999943691,
"num_trades": 2492,
"max_drawdown_pct": 99.99999999943692,
"sharpe_ratio": -8.936473025994527,
"win_rate_pct": 40.93097913322632
}
7 changes: 7 additions & 0 deletions backtests/backtest_metrics_20250804_110946.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"total_return_pct": -99.99999999957674,
"num_trades": 2492,
"max_drawdown_pct": 99.99999999960471,
"sharpe_ratio": -8.986360268878498,
"win_rate_pct": 40.32905296950241
}
198 changes: 198 additions & 0 deletions backtests/trade_log_20250731_075424.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
date,capital,pnl
2023-08-06,10311.401153334227,311.4011533342266
2023-08-07,9795.831095667516,-515.5700576667114
2023-08-10,10503.791065357653,707.9599696901373
2023-08-13,10832.155167210809,328.3641018531554
2023-08-14,10290.547408850269,-541.6077583605405
2023-08-16,9776.020038407756,-514.5273704425134
2023-08-17,9287.219036487368,-488.8010019203878
2023-08-20,8822.858084663,-464.3609518243683
2023-08-23,8936.305709145094,113.44762448209379
2023-08-24,9585.422763155693,649.1170540105993
2023-08-28,9106.151624997909,-479.2711381577846
2023-08-29,8650.844043748013,-455.3075812498955
2023-09-20,8218.301841560613,-432.5422021874007
2023-09-23,7807.386749482583,-410.9150920780307
2023-09-26,11027.474323713277,3220.087574230694
2023-09-27,10476.100607527613,-551.3737161856639
2023-09-28,9952.295577151232,-523.8050303763806
2023-10-04,11742.361253120544,1790.0656759693122
2023-10-08,11155.243190464516,-587.1180626560272
2023-10-12,12670.682186428578,1515.4389959640603
2023-10-13,15376.342364016531,2705.6601775879544
2023-10-21,14607.525245815705,-768.8171182008267
2023-10-22,18390.29150175166,3782.766255935956
2023-10-27,17470.77692666408,-919.5145750875831
2023-10-30,17743.20274153213,272.4258148680544
2023-11-06,16856.042604455524,-887.1601370766066
2023-11-09,17554.03006354237,697.9874590868455
2023-11-18,17935.712569948468,381.68250640609807
2023-11-19,17038.926941451045,-896.7856284974235
2023-11-20,17301.113011719433,262.18607026838635
2023-11-30,16436.057361133462,-865.0556505859718
2023-12-04,16708.202015789768,272.14465465630633
2023-12-05,17002.563763131522,294.36174734175387
2023-12-07,16152.435574974947,-850.1281881565762
2023-12-14,16349.608796010254,197.17322103530827
2023-12-15,15532.128356209741,-817.4804398005127
2023-12-19,14755.521938399255,-776.6064178104871
2023-12-22,14017.745841479293,-737.7760969199628
2023-12-23,13316.858549405328,-700.8872920739647
2024-01-24,13880.229376938993,563.3708275336649
2024-01-27,13186.217908092043,-694.0114688469496
2024-02-06,16036.451139366007,2850.2332312739645
2024-02-14,16839.286649639802,802.8355102737962
2024-02-23,15997.322317157812,-841.9643324819901
2024-02-26,15197.456201299921,-799.8661158578907
2024-02-27,15290.787566355579,93.33136505565747
2024-02-28,14526.2481880378,-764.5393783177791
2024-03-01,16176.298732261022,1650.0505442232222
2024-03-17,15367.483795647971,-808.8149366130511
2024-03-21,20206.20744834587,4838.7236526978995
2024-03-22,20393.441467507357,187.2340191614855
2024-03-30,20691.658914670017,298.21744716266113
2024-04-03,19657.075968936515,-1034.582945733501
2024-04-06,20229.806872701625,572.7309037651086
2024-04-09,19218.316529066542,-1011.4903436350814
2024-04-11,21472.640086421794,2254.323557355253
2024-04-17,20399.008082100703,-1073.6320043210897
2024-04-24,29133.31220051961,8734.304118418906
2024-04-26,27676.646590493627,-1456.6656100259806
2024-04-27,26292.814260968946,-1383.8323295246814
2024-05-02,27883.731333651827,1590.9170726828809
2024-05-05,26489.544766969237,-1394.1865666825915
2024-05-07,29786.130328106665,3296.5855611374272
2024-05-08,28296.82381170133,-1489.3065164053332
2024-05-10,34352.8519527404,6056.0281410390635
2024-05-12,38111.58129162526,3758.729338884866
2024-05-13,36206.002227043995,-1905.579064581263
2024-05-14,36651.292551919716,445.2903248757235
2024-05-19,34818.72792432373,-1832.564627595986
2024-05-22,42602.210381594174,7783.482457270444
2024-05-31,40472.099862514464,-2130.110519079709
2024-06-03,38448.49486938874,-2023.6049931257232
2024-06-05,36526.0701259193,-1922.424743469437
2024-06-10,34699.76661962333,-1826.3035062959655
2024-06-11,32964.77828864216,-1734.9883309811667
2024-06-17,33575.473861331775,610.6955726896155
2024-06-18,40137.44228119909,6561.968419867313
2024-06-19,46187.54313114673,6050.100849947643
2024-06-21,43878.1659745894,-2309.3771565573365
2024-06-24,41684.25767585993,-2193.90829872947
2024-06-25,39600.04479206693,-2084.2128837929968
2024-06-27,37620.04255246359,-1980.0022396033467
2024-06-28,35739.04042484041,-1881.0021276231794
2024-07-03,46939.78143101558,11200.741006175169
2024-07-04,47117.37459661227,177.5931655966943
2024-07-05,55744.47628105919,8627.101684446921
2024-07-09,68662.68723245841,12918.21095139921
2024-07-11,69368.7628563642,706.0756239057915
2024-07-20,65900.324713546,-3468.4381428182105
2024-07-26,66745.73097193283,845.4062583868383
2024-07-30,63408.444423336194,-3337.2865485966418
2024-08-07,60238.022202169384,-3170.42222116681
2024-08-08,61118.974870794875,880.9526686254918
2024-08-10,62177.20607098484,1058.2312001899597
2024-08-13,69358.00806141197,7180.801990427135
2024-08-22,80142.8520137263,10784.843952314335
2024-08-23,76135.70941303998,-4007.142600686315
2024-08-27,78164.86309946192,2029.1536864219404
2024-08-31,74256.61994448882,-3908.243154973096
2024-09-08,70543.78894726437,-3712.830997224441
2024-09-10,67016.59949990116,-3527.1894473632187
2024-09-11,70049.75576460685,3033.156264705686
2024-09-20,73669.7402480767,3619.984483469855
2024-09-24,69986.25323567286,-3683.4870124038357
2024-09-29,66486.94057388922,-3499.3126617836433
2024-10-09,66978.5015917082,491.56101781898496
2024-10-14,63629.576512122796,-3348.9250795854105
2024-10-16,60448.09768651666,-3181.47882560614
2024-10-18,57425.692802190824,-3022.4048843258333
2024-10-21,57661.10311742153,235.41031523070603
2024-10-22,80328.2160738129,22667.11295639137
2024-10-25,76311.80527012226,-4016.4108036906455
2024-10-26,77504.32342090186,1192.518150779591
2024-11-04,73629.10724985677,-3875.216171045093
2024-11-05,69947.65188736393,-3681.4553624928385
2024-11-06,88549.92184905167,18602.269961687736
2024-11-08,89307.18168372732,757.2598346756596
2024-11-10,84841.82259954096,-4465.359084186366
2024-11-14,80599.7314695639,-4242.091129977048
2024-11-16,76569.74489608571,-4029.9865734781956
2024-11-17,77160.08507127914,590.3401751934233
2024-11-20,73302.08081771519,-3858.0042535639573
2024-11-22,69636.97677682943,-3665.1040408857602
2024-11-24,66155.12793798796,-3481.8488388414717
2024-11-30,78842.6859463248,12687.558008336837
2024-12-01,82352.67466349358,3509.9887171687933
2024-12-05,83074.06688782902,721.3922243354306
2024-12-07,78920.36354343756,-4153.703344391451
2024-12-17,74974.34536626568,-3946.018177171878
2024-12-18,71225.6280979524,-3748.717268313285
2024-12-20,67664.34669305479,-3561.28140489762
2024-12-25,64281.129358402046,-3383.2173346527397
2024-12-26,61067.07289048194,-3214.0564679201025
2024-12-29,61443.27509766847,376.20220718652797
2025-01-01,78906.66879486902,17463.393697200554
2025-01-07,74961.33535512557,-3945.3334397434514
2025-01-08,75425.53367865174,464.1983235261661
2025-01-11,86598.16396639452,11172.63028774278
2025-01-20,82268.2557680748,-4329.908198319727
2025-01-25,78154.84297967106,-4113.41278840374
2025-01-27,80536.73872199154,2381.895742320487
2025-01-28,81505.32313431408,968.5844123225356
2025-01-29,88218.71295927343,6713.389824959351
2025-02-04,83807.77731130975,-4410.935647963672
2025-02-08,123304.0095691639,39496.23225785414
2025-02-11,123908.1637128208,604.1541436568893
2025-02-21,117712.75552717976,-6195.40818564104
2025-02-23,111827.11775082078,-5885.637776358988
2025-02-26,131787.69653663662,19960.578785815844
2025-03-01,125198.3117098048,-6589.384826831832
2025-03-03,128388.87808906438,3190.566379259583
2025-03-09,129664.6618769773,1275.783787912929
2025-03-15,123181.42878312845,-6483.233093848866
2025-03-16,117022.35734397202,-6159.0714391564225
2025-03-22,111171.23947677342,-5851.117867198602
2025-03-25,105612.67750293475,-5558.561973838671
2025-03-27,119869.01346663579,14256.335963701044
2025-04-01,113875.56279330401,-5993.45067333179
2025-04-04,108181.78465363881,-5693.778139665201
2025-04-06,108856.30586547886,674.5212118400581
2025-04-08,103413.49057220492,-5442.815293273942
2025-04-11,98242.81604359466,-5170.674528610246
2025-04-12,93330.67524141492,-4912.140802179733
2025-04-15,88664.14147934418,-4666.533762070746
2025-04-19,124688.67446029394,36024.53298094976
2025-04-20,118454.24073727925,-6234.4337230146975
2025-04-21,112531.52870041529,-5922.712036863963
2025-04-22,106904.95226539453,-5626.576435020764
2025-04-24,101559.70465212481,-5345.247613269727
2025-04-25,117933.18051351554,16373.475861390727
2025-05-07,112036.52148783977,-5896.659025675777
2025-05-14,113246.94854996407,1210.4270621243086
2025-05-15,107584.60112246587,-5662.347427498203
2025-05-16,109536.68298451994,1952.0818620540601
2025-05-18,131137.43087112476,21600.747886604808
2025-05-22,159165.93901627307,28028.50814514832
2025-05-24,151207.64206545943,-7958.296950813654
2025-05-25,143647.25996218645,-7560.382103272972
2025-05-27,178003.643107308,34356.383145121545
2025-06-01,169103.4609519426,-8900.182155365399
2025-06-04,160648.28790434546,-8455.17304759713
2025-06-05,152615.8735091282,-8032.4143952172735
2025-06-06,154642.49885868316,2026.6253495549568
2025-06-07,146910.373915749,-7732.124942934159
2025-06-09,151449.27479644318,4538.900880694191
2025-06-13,154512.5446248401,3063.2698283969344
2025-06-20,146786.9173935981,-7725.627231242006
2025-06-21,148116.82764932187,1329.9102557237807
2025-06-23,140710.9862668558,-7405.841382466093
2025-06-26,177070.8500928756,36359.8638260198
2025-06-27,168217.3075882318,-8853.54250464378
2025-06-28,159806.44220882023,-8410.86537941159
2025-07-02,151816.1200983792,-7990.322110441011
2025-07-09,157120.78827530117,5304.668176921971
2025-07-13,168047.5177477027,10926.72947240152
2025-07-14,159645.14186031756,-8402.375887385135
2025-07-19,151662.88476730167,-7982.257093015878
Loading