Skip to content

fran0x/kinko

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kinkō

A simple Δ-neutral paper-trading simulator with a terminal UI.

It opens a long spot and a short perpetual position of equal notional to stay market-neutral, then tracks funding, basis drift, fees, and rebalances over time.

  • Fetches live spot and perp prices from exchange APIs
  • Simulates funding accrual and PnL in real time
  • Performs auto-rebalancing when delta drifts
  • Automatically flips side when funding changes sign
  • No real trades — fully paper-traded (safe to run anywhere)

Finite-State Machine (FSM)

This app runs as a small reactive state machine. Each state decides which actions to perform based on live data.

State Purpose Possible Actions
Init Cold start; fetches first prices and builds the initial position. FetchMarketData, InitFromEntry
CarryMode Normal running mode; harvests funding and rebalances when delta drifts beyond threshold. AccrueFunding, RebalancePerp, ReversePosition, UiPush
AutoReverse Short-term state right after a side flip; enforces cooldown to avoid immediate re-flipping. ReversePosition, Sleep, UiPush
VolatilityMode Market is choppy; widens thresholds and suppresses flips to reduce churn. AccrueFunding, RebalancePerp, UiPush
Paused Market is quiet (low vol, flat basis, near-zero funding); holds position and accrues funding only. AccrueFunding, UiPush
ErrorBackoff Temporary failure state (e.g., network/API error); sleeps and retries after a short delay. Sleep, FetchMarketData, UiPush
Stopped End condition (manual stop or time expiry); prints final PnL and exits. Stop, UiPush

Core Actions

Action Effect
FetchMarketData Pulls spot, perp, funding, and open-interest data.
AccrueFunding Accumulates carry PnL from signed notional × funding rate.
RebalancePerp Adjusts perpetual size to restore Δ-neutrality.
ReversePosition Flips hedge direction (short/long) when funding bias changes.
UiPush Sends tick updates to the terminal.
Sleep Waits between ticks or after transitions.
Stop Finalizes simulation and outputs summary.

Use just to build and run.

About

Simple Δ-neutral paper trading simulator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published