code.vegaprotocol.io/vega@v0.79.0/core/integration/features/target_stake/3135-target-stake-pdp.feature (about)

     1  Feature: Target stake
     2  
     3    # Market risk parameters and assets don't really matter.
     4    # We need to track open interest i.e. sum of all long positions across the parties and how they change over time
     5  
     6    Background:
     7      Given the following network parameters are set:
     8        | name                                    | value |
     9        | network.markPriceUpdateMaximumFrequency | 0s    |
    10        | limits.markets.maxPeggedOrders          | 2     |
    11      Given the liquidity monitoring parameters:
    12        | name               | triggering ratio | time window | scaling factor |
    13        | lqm-params         | 1.0              | 168h        | 1.5            |  
    14      
    15      And the simple risk model named "simple-risk-model-1":
    16        | long | short | max move up | min move down | probability of trading |
    17        | 0.1  | 0.1   | 10          | -10           | 0.1                    |
    18      And the log normal risk model named "log-normal-risk-model-1":
    19        | risk aversion | tau                    | mu | r  | sigma |
    20        | 0.000001      | 0.00011407711613050422 | -1 | -1 | -1    |
    21      And the fees configuration named "fees-config-1":
    22        | maker fee | infrastructure fee |
    23        | 0.00025   | 0.0005             |
    24      And the margin calculator named "margin-calculator-1":
    25        | search factor | initial factor | release factor |
    26        | 1.1           | 1.2            | 1.4            |
    27      And the markets:
    28        | id        | quote name | asset | liquidity monitoring | risk model          | margin calculator         | auction duration | fees          | price monitoring | data source config     | position decimal places | linear slippage factor | quadratic slippage factor | sla params      |
    29        | ETH/DEC21 | BTC        | BTC   | lqm-params           | simple-risk-model-1 | default-margin-calculator | 1                | fees-config-1 | default-none     | default-eth-for-future | 2                       | 0.25                   | 0                         | default-futures |
    30  
    31      # Above, it says mark price but really I don't mind if we start
    32      # with an opening auction as long as at start of the scenario
    33      # no-one has any open positions in the market.
    34      # So if we want to start with an auction, trade volume 1, then close out the position.
    35  
    36      # T0 + 8 days so whatever open interest was there after the auction
    37      # this is now out of the time window.
    38      And time is updated to "2021-03-08T00:00:00Z"
    39  
    40    Scenario: Max open interest changes over time
    41      # setup accounts
    42      Given the parties deposit on asset's general account the following amount:
    43        | party | asset | amount    |
    44        | tt_0  | BTC   | 100000000 |
    45        | tt_1  | BTC   | 100000000 |
    46        | tt_2  | BTC   | 100000000 |
    47        | tt_3  | BTC   | 100000000 |
    48  
    49      # put some volume on the book so that others can increase their
    50      # positions and close out if needed too
    51      When the parties place the following orders:
    52        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
    53        | tt_0  | ETH/DEC21 | buy  | 100000 | 90    | 0                | TYPE_LIMIT | TIF_GTC | tt_0_0    |
    54        | tt_0  | ETH/DEC21 | sell | 100000 | 110   | 0                | TYPE_LIMIT | TIF_GTC | tt_0_1    |
    55  
    56      Then the parties submit the following liquidity provision:
    57        | id  | party | market id | commitment amount | fee   | lp type    |
    58        | lp1 | tt_0  | ETH/DEC21 | 2000              | 0.001 | submission |
    59        | lp1 | tt_0  | ETH/DEC21 | 2000              | 0.001 | amendment  |
    60      And the parties place the following pegged iceberg orders:
    61        | party | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    62        | tt_0  | ETH/DEC21 | 2         | 1                    | buy  | BID              | 1          | 10     |
    63        | tt_0  | ETH/DEC21 | 2         | 1                    | sell | ASK              | 1          | 10     |
    64   
    65      # nothing should have traded, we have mark price set apriori or
    66      # due to auction closing.
    67      Then the mark price should be "0" for the market "ETH/DEC21"
    68  
    69      # Traders 1, 2, 3 go long
    70      When the parties place the following orders:
    71        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
    72        | tt_1  | ETH/DEC21 | buy  | 1000   | 110   | 0                | TYPE_LIMIT | TIF_GTC | tt_1_0    |
    73        | tt_2  | ETH/DEC21 | buy  | 2000   | 110   | 0                | TYPE_LIMIT | TIF_GTC | tt_2_0    |
    74        | tt_3  | ETH/DEC21 | buy  | 3000   | 110   | 0                | TYPE_LIMIT | TIF_GTC | tt_2_0    |
    75  
    76      Then the opening auction period ends for market "ETH/DEC21"
    77  
    78      Then the market data for the market "ETH/DEC21" should be:
    79        | trading mode            | auction trigger             | extension trigger           | target stake | supplied stake |
    80        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | AUCTION_TRIGGER_UNSPECIFIED | 990          | 2000           |
    81  
    82      # So now parties 1,2,3 are long 10+20+30 = 60.
    83      Then the mark price should be "110" for the market "ETH/DEC21"
    84  
    85      # Target stake is mark_price x max_oi x target_stake_scaling_factor x rf_short
    86      # rf_short should have been set above to 0.1
    87      # target_stake = 110 x 60 x 1.5 x 0.1
    88      And the target stake should be "990" for the market "ETH/DEC21"
    89  
    90      # T0 + 8 days + 1 hour
    91      When time is updated to "2021-03-08T01:00:00Z"
    92  
    93      # Trader 3 closes out 20
    94      When the parties place the following orders with ticks:
    95        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
    96        | tt_3  | ETH/DEC21 | sell | 2000   | 90    | 1                | TYPE_LIMIT | TIF_GTC | tt_2_1    |
    97  
    98      Then the mark price should be "90" for the market "ETH/DEC21"
    99  
   100      # the maximum oi over the last 7 days is still unchanged
   101      # target_stake = 90 x 60 x 1.5 x 0.1
   102      And the target stake should be "810" for the market "ETH/DEC21"
   103  
   104      # T0 + 15 days + 2 hour
   105      # so now the peak of 60 should have passed from window
   106      When time is updated to "2021-03-15T02:00:00Z"
   107  
   108      Then the mark price should be "90" for the market "ETH/DEC21"
   109  
   110      # target_stake = 90 x 40 x 1.5 x 0.1
   111      And the target stake should be "540" for the market "ETH/DEC21"