Skip to content

BTC Historical Simulations#245

Draft
RZhang05 wants to merge 37 commits intomainfrom
raymond/time-series-sim-3
Draft

BTC Historical Simulations#245
RZhang05 wants to merge 37 commits intomainfrom
raymond/time-series-sim-3

Conversation

@RZhang05
Copy link
Copy Markdown
Contributor

@RZhang05 RZhang05 commented Apr 2, 2026

Closes: #221

Description

Verifies 0 liquidations under historical daily BTC data from 2021-2025. All simulations use 1.3/1.5/1.3/1.1 (initial/max/target/min) default health factors. Except 2022_noliquidations which uses 1.2/1.3/1.2/1.1.

Added a version of 2022_noliquidations, 2022_liquidation in which liquidations occur under the default strategy health factors. Manual liquidation is triggered in this case.

Note: uses default strategy health factors instead of the ones specified in the python simulations.

Test Outputs

2021
5:05PM INF LOG: "\n=== SIMULATION RESULTS ==="
5:05PM INF LOG: "Agents:              1"
5:05PM INF LOG: "Days simulated:      365"
5:05PM INF LOG: "Rebalance attempts:  365"
5:05PM INF LOG: "Vault rebalances:    0"
5:05PM INF LOG: "Position rebalances: 23"
5:05PM INF LOG: "Liquidation count:   0"
5:05PM INF LOG: ""
5:05PM INF LOG: "--- Price ---"
5:05PM INF LOG: "Initial BTC price:   $29374.15000000"
5:05PM INF LOG: "Lowest BTC price:    $29374.15000000"
5:05PM INF LOG: "Highest BTC price:   $67566.83000000"
5:05PM INF LOG: "Final BTC price:     $46306.45000000"
5:05PM INF LOG: "Price change:        +0.57643540"
5:05PM INF LOG: ""
5:05PM INF LOG: "--- Position (effective HF with collateralFactor=0.80000000) ---"
5:05PM INF LOG: "Lowest HF observed:  1.01783976"
5:05PM INF LOG: "Final HF (agent 0):  1.19670736"
5:05PM INF LOG: "Final collateral:    1.00000000 BTC ($46306.45000000)"
5:05PM INF LOG: "Final debt:          30955.90540801 MOET"
5:05PM INF LOG: "Final yield tokens:  32885.33010021 ($36164.85318749 @ yt=1.09972602)"
5:05PM INF LOG: ""
5:05PM INF LOG: "--- P&L ---"
5:05PM INF LOG: "Initial deposit:     1.00000000 BTC (~$29374.15000000)"
5:05PM INF LOG: "Net equity (USD):    $51515.39777948 (P&L: +$22141.24777948, +0.75376641)"
5:05PM INF LOG: "Net equity (BTC):    1.11248860 BTC (P&L: +0.11248860 BTC, +0.11248860)"
5:05PM INF LOG: "===========================\n"
5:05PM INF LOG: "=== TEST PASSED: 0 liquidations (expected 0) over 365 days of real BTC prices (1 agents) ==="
2022_noliquidations
5:13PM INF LOG: "\n=== SIMULATION RESULTS ==="
5:13PM INF LOG: "Agents:              1"
5:13PM INF LOG: "Days simulated:      365"
5:13PM INF LOG: "Rebalance attempts:  365"
5:13PM INF LOG: "Vault rebalances:    0"
5:13PM INF LOG: "Position rebalances: 32"
5:13PM INF LOG: "Liquidation count:   0"
5:13PM INF LOG: ""
5:13PM INF LOG: "--- Price ---"
5:13PM INF LOG: "Initial BTC price:   $47686.81000000"
5:13PM INF LOG: "Lowest BTC price:    $15787.28000000"
5:13PM INF LOG: "Highest BTC price:   $47686.81000000"
5:13PM INF LOG: "Final BTC price:     $16547.50000000"
5:13PM INF LOG: "Price change:        -0.65299628"
5:13PM INF LOG: ""
5:13PM INF LOG: "--- Position (effective HF with collateralFactor=0.80000000) ---"
5:13PM INF LOG: "Lowest HF observed:  1.00412642"
5:13PM INF LOG: "Final HF (agent 0):  1.11673374"
5:13PM INF LOG: "Final collateral:    1.00000000 BTC ($16547.50000000)"
5:13PM INF LOG: "Final debt:          11854.21333333 MOET"
5:13PM INF LOG: "Final yield tokens:  10670.47954001 ($11734.60399602 @ yt=1.09972602)"
5:13PM INF LOG: ""
5:13PM INF LOG: "--- P&L ---"
5:13PM INF LOG: "Initial deposit:     1.00000000 BTC (~$47686.81000000)"
5:13PM INF LOG: "Net equity (USD):    $16427.89066269 (P&L: -$31258.91933731, -0.65550451)"
5:13PM INF LOG: "Net equity (BTC):    0.99277175 BTC (P&L: -0.00722825 BTC, -0.00722825)"
5:13PM INF LOG: "===========================\n"
5:13PM INF LOG: "=== TEST PASSED: 0 liquidations (expected 0) over 365 days of real BTC prices (1 agents) ==="
2022_liquidation
5:24PM INF LOG: "\n=== SIMULATION RESULTS ==="
5:24PM INF LOG: "Agents:              1"
5:24PM INF LOG: "Days simulated:      365"
5:24PM INF LOG: "Rebalance attempts:  365"
5:24PM INF LOG: "Vault rebalances:    1"
5:24PM INF LOG: "Position rebalances: 10"
5:24PM INF LOG: "Liquidation count:   2"
5:24PM INF LOG: ""
5:24PM INF LOG: "--- Price ---"
5:24PM INF LOG: "Initial BTC price:   $47686.81000000"
5:24PM INF LOG: "Lowest BTC price:    $15787.28000000"
5:24PM INF LOG: "Highest BTC price:   $47686.81000000"
5:24PM INF LOG: "Final BTC price:     $16547.50000000"
5:24PM INF LOG: "Price change:        -0.65299628"
5:24PM INF LOG: ""
5:24PM INF LOG: "--- Position (effective HF with collateralFactor=0.80000000) ---"
5:24PM INF LOG: "Lowest HF observed:  0.95613251"
5:24PM INF LOG: "Final HF (agent 0):  1.22317799"
5:24PM INF LOG: "Final collateral:    0.86972082 BTC ($14391.70526895)"
5:24PM INF LOG: "Final debt:          9412.66463110 MOET"
5:24PM INF LOG: "Final yield tokens:  9666.38806922 ($10630.37847913 @ yt=1.09972602)"
5:24PM INF LOG: ""
5:24PM INF LOG: "--- P&L ---"
5:24PM INF LOG: "Initial deposit:     1.00000000 BTC (~$47686.81000000)"
5:24PM INF LOG: "Net equity (USD):    $15609.41911698 (P&L: -$32077.39088302, -0.67266799)"
5:24PM INF LOG: "Net equity (BTC):    0.94330981 BTC (P&L: -0.05669019 BTC, -0.05669019)"
5:24PM INF LOG: "===========================\n"
5:24PM INF LOG: "=== TEST PASSED: 2 liquidations (expected 2) over 365 days of real BTC prices (1 agents) ==="
2023
5:36PM INF LOG: "\n=== SIMULATION RESULTS ==="
5:36PM INF LOG: "Agents:              1"
5:36PM INF LOG: "Days simulated:      365"
5:36PM INF LOG: "Rebalance attempts:  365"
5:36PM INF LOG: "Vault rebalances:    1"
5:36PM INF LOG: "Position rebalances: 9"
5:36PM INF LOG: "Liquidation count:   0"
5:36PM INF LOG: ""
5:36PM INF LOG: "--- Price ---"
5:36PM INF LOG: "Initial BTC price:   $16625.08000000"
5:36PM INF LOG: "Lowest BTC price:    $16625.08000000"
5:36PM INF LOG: "Highest BTC price:   $44166.60000000"
5:36PM INF LOG: "Final BTC price:     $42265.19000000"
5:36PM INF LOG: "Price change:        +1.54225483"
5:36PM INF LOG: ""
5:36PM INF LOG: "--- Position (effective HF with collateralFactor=0.80000000) ---"
5:36PM INF LOG: "Lowest HF observed:  1.09873967"
5:36PM INF LOG: "Final HF (agent 0):  1.42017374"
5:36PM INF LOG: "Final collateral:    1.02448987 BTC ($43300.25900862)"
5:36PM INF LOG: "Final debt:          24391.52766643 MOET"
5:36PM INF LOG: "Final yield tokens:  23284.65657132 ($25606.74269824 @ yt=1.09972602)"
5:36PM INF LOG: ""
5:36PM INF LOG: "--- P&L ---"
5:36PM INF LOG: "Initial deposit:     1.00000000 BTC (~$16625.08000000)"
5:36PM INF LOG: "Net equity (USD):    $44515.47404043 (P&L: +$27890.39404043, +1.67760961)"
5:36PM INF LOG: "Net equity (BTC):    1.05324201 BTC (P&L: +0.05324201 BTC, +0.05324201)"
5:36PM INF LOG: "===========================\n"
5:36PM INF LOG: "=== TEST PASSED: 0 liquidations (expected 0) over 365 days of real BTC prices (1 agents) ==="
2024
6:09PM INF LOG: "\n=== SIMULATION RESULTS ==="
6:09PM INF LOG: "Agents:              1"
6:09PM INF LOG: "Days simulated:      366"
6:09PM INF LOG: "Rebalance attempts:  366"
6:09PM INF LOG: "Vault rebalances:    1"
6:09PM INF LOG: "Position rebalances: 11"
6:09PM INF LOG: "Liquidation count:   0"
6:09PM INF LOG: ""
6:09PM INF LOG: "--- Price ---"
6:09PM INF LOG: "Initial BTC price:   $44167.33000000"
6:09PM INF LOG: "Lowest BTC price:    $39507.37000000"
6:09PM INF LOG: "Highest BTC price:   $106140.60000000"
6:09PM INF LOG: "Final BTC price:     $93429.20000000"
6:09PM INF LOG: "Price change:        +1.11534634"
6:09PM INF LOG: ""
6:09PM INF LOG: "--- Position (effective HF with collateralFactor=0.80000000) ---"
6:09PM INF LOG: "Lowest HF observed:  1.09295140"
6:09PM INF LOG: "Final HF (agent 0):  1.28745604"
6:09PM INF LOG: "Final collateral:    1.02938540 BTC ($96174.65441368)"
6:09PM INF LOG: "Final debt:          59761.04858049 MOET"
6:09PM INF LOG: "Final yield tokens:  58522.99973129 ($64375.29970441 @ yt=1.10000000)"
6:09PM INF LOG: ""
6:09PM INF LOG: "--- P&L ---"
6:09PM INF LOG: "Initial deposit:     1.00000000 BTC (~$44167.33000000)"
6:09PM INF LOG: "Net equity (USD):    $100788.90553760 (P&L: +$56621.57553760, +1.28197868)"
6:09PM INF LOG: "Net equity (BTC):    1.07877307 BTC (P&L: +0.07877307 BTC, +0.07877307)"
6:09PM INF LOG: "===========================\n"
6:09PM INF LOG: "=== TEST PASSED: 0 liquidations (expected 0) over 366 days of real BTC prices (1 agents) ==="
2025
6:15PM INF LOG: "\n=== SIMULATION RESULTS ==="
6:15PM INF LOG: "Agents:              1"
6:15PM INF LOG: "Days simulated:      365"
6:15PM INF LOG: "Rebalance attempts:  365"
6:15PM INF LOG: "Vault rebalances:    2"
6:15PM INF LOG: "Position rebalances: 6"
6:15PM INF LOG: "Liquidation count:   0"
6:15PM INF LOG: ""
6:15PM INF LOG: "--- Price ---"
6:15PM INF LOG: "Initial BTC price:   $94419.76000000"
6:15PM INF LOG: "Lowest BTC price:    $76271.95000000"
6:15PM INF LOG: "Highest BTC price:   $124752.53000000"
6:15PM INF LOG: "Final BTC price:     $87508.83000000"
6:15PM INF LOG: "Price change:        -0.07319368"
6:15PM INF LOG: ""
6:15PM INF LOG: "--- Position (effective HF with collateralFactor=0.80000000) ---"
6:15PM INF LOG: "Lowest HF observed:  1.07072587"
6:15PM INF LOG: "Final HF (agent 0):  1.18353254"
6:15PM INF LOG: "Final collateral:    1.02547431 BTC ($89738.05706315)"
6:15PM INF LOG: "Final debt:          60657.77070591 MOET"
6:15PM INF LOG: "Final yield tokens:  57640.89076870 ($63389.18739431 @ yt=1.09972602)"
6:15PM INF LOG: ""
6:15PM INF LOG: "--- P&L ---"
6:15PM INF LOG: "Initial deposit:     1.00000000 BTC (~$94419.76000000)"
6:15PM INF LOG: "Net equity (USD):    $92469.47375155 (P&L: -$1950.28624845, -0.02065548)"
6:15PM INF LOG: "Net equity (BTC):    1.05668735 BTC (P&L: +0.05668735 BTC, +0.05668735)"
6:15PM INF LOG: "===========================\n"
6:15PM INF LOG: "=== TEST PASSED: 0 liquidations (expected 0) over 365 days of real BTC prices (1 agents) ==="

For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the standards mentioned here.
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

jribbink and others added 29 commits March 6, 2026 10:12
@RZhang05 RZhang05 changed the title Raymond/time series sim 3 BTC Historical Simulations Apr 2, 2026
Base automatically changed from raymond/time-series-sim-2 to main April 3, 2026 21:14
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BTC 2021-2024 Historical Simulations

3 participants