code.vegaprotocol.io/vega@v0.79.0/core/integration/features/mark-price/0009-MRKP-036.feature (about)

     1  Feature: Test It is possible to configure a cash settled futures and perps market to use median
     2    Background:
     3      Given the following network parameters are set:
     4        | name                                    | value |
     5        | network.markPriceUpdateMaximumFrequency | 4s    |
     6      And the perpetual oracles from "0xCAFECAFE1":
     7        | name        | asset | settlement property | settlement type | schedule property | schedule type  | margin funding factor | interest rate | clamp lower bound | clamp upper bound | quote name | settlement decimals |
     8        | perp-oracle | USD   | perp.ETH.value      | TYPE_INTEGER    | perp.funding.cue  | TYPE_TIMESTAMP | 0.5                   | 0.05          | 0.1               | 0.9               | ETH        | 18                  |
     9      And the liquidity monitoring parameters:
    10        | name       | triggering ratio | time window | scaling factor |
    11        | lqm-params | 0.00             | 24h         | 1e-9           |
    12      And the simple risk model named "simple-risk-model":
    13        | long | short | max move up | min move down | probability of trading |
    14        | 0.1  | 0.1   | 100         | -100          | 0.2                    |
    15      And the price monitoring named "my-price-monitoring":
    16        | horizon | probability | auction extension |
    17        | 36000   | 0.95        | 6                 |
    18  
    19      And the composite price oracles from "0xCAFECAFE1":
    20        | name    | price property   | price type   | price decimals |
    21        | oracle1 | price1.USD.value | TYPE_INTEGER | 0              |
    22  
    23      And the markets:
    24        | id        | quote name | asset | liquidity monitoring | risk model        | margin calculator         | auction duration | fees         | price monitoring    | data source config     | linear slippage factor | quadratic slippage factor | sla params      | price type | decay weight | decay power | cash amount | source weights | source staleness tolerance | oracle1 | market type |
    25        | ETH/FEB23 | ETH        | USD   | lqm-params           | simple-risk-model | default-margin-calculator | 1                | default-none | my-price-monitoring | default-eth-for-future | 0.25                   | 0                         | default-futures | median     | 0            | 1           | 20000       | 1,0,0,0        | 5s,20s,20s,1h25m0s         | oracle1 | future      |
    26        | ETH/FEB24 | ETH        | USD   | lqm-params           | simple-risk-model | default-margin-calculator | 1                | default-none | my-price-monitoring | perp-oracle            | 0.25                   | 0                         | default-futures | median     | 0            | 1           | 20000       | 1,0,0,0        | 5s,20s,20s,1h25m0s         | oracle1 | perp        |
    27  
    28    Scenario: 001 check mark price using median with traded mark price and book mark price, 0009-MRKP-036, 0009-MRKP-037
    29      Given the parties deposit on asset's general account the following amount:
    30        | party             | asset | amount       |
    31        | buySideProvider   | USD   | 100000000000 |
    32        | sellSideProvider  | USD   | 100000000000 |
    33        | party             | USD   | 48050        |
    34        | buySideProvider1  | USD   | 100000000000 |
    35        | sellSideProvider1 | USD   | 100000000000 |
    36        | party1            | USD   | 48050        |
    37      And the parties place the following orders:
    38        | party             | market id | side | volume | price | resulting trades | type       | tif     | reference |
    39        | buySideProvider   | ETH/FEB23 | buy  | 3      | 15900 | 0                | TYPE_LIMIT | TIF_GTC |           |
    40        | party             | ETH/FEB23 | sell | 3      | 15900 | 0                | TYPE_LIMIT | TIF_GTC |           |
    41        | sellSideProvider  | ETH/FEB23 | sell | 1      | 15920 | 0                | TYPE_LIMIT | TIF_GTC |           |
    42        | sellSideProvider  | ETH/FEB23 | sell | 1      | 15990 | 0                | TYPE_LIMIT | TIF_GTC |           |
    43        | sellSideProvider  | ETH/FEB23 | sell | 2      | 16008 | 0                | TYPE_LIMIT | TIF_GTC |           |
    44        | buySideProvider1  | ETH/FEB24 | buy  | 3      | 15900 | 0                | TYPE_LIMIT | TIF_GTC |           |
    45        | party1            | ETH/FEB24 | sell | 3      | 15900 | 0                | TYPE_LIMIT | TIF_GTC |           |
    46        | sellSideProvider1 | ETH/FEB24 | sell | 1      | 15920 | 0                | TYPE_LIMIT | TIF_GTC |           |
    47        | sellSideProvider1 | ETH/FEB24 | sell | 1      | 15990 | 0                | TYPE_LIMIT | TIF_GTC |           |
    48        | sellSideProvider1 | ETH/FEB24 | sell | 2      | 16008 | 0                | TYPE_LIMIT | TIF_GTC |           |
    49  
    50      When the network moves ahead "2" blocks
    51      # leaving opening auction
    52      Then the market data for the market "ETH/FEB23" should be:
    53        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
    54        | 15900      | TRADING_MODE_CONTINUOUS | 36000   | 15801     | 15999     | 0            | 0              | 3             |
    55      Then the market data for the market "ETH/FEB24" should be:
    56        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
    57        | 15900      | TRADING_MODE_CONTINUOUS | 36000   | 15801     | 15999     | 0            | 0              | 3             |
    58  
    59      And the parties place the following orders:
    60        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
    61        | buySideProvider  | ETH/FEB23 | buy  | 2      | 15920 | 1                | TYPE_LIMIT | TIF_GTC |           |
    62        | buySideProvider1 | ETH/FEB24 | buy  | 2      | 15920 | 1                | TYPE_LIMIT | TIF_GTC |           |
    63  
    64      When the network moves ahead "5" blocks
    65  
    66      # price from trades = 15920
    67      # price from book = 15900
    68      # markprice = median(15920,15900)=15910
    69      Then the mark price should be "15910" for the market "ETH/FEB23"
    70      Then the mark price should be "15910" for the market "ETH/FEB24"
    71      And the parties place the following orders:
    72        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
    73        | buySideProvider  | ETH/FEB23 | buy  | 1      | 15990 | 1                | TYPE_LIMIT | TIF_GTC |           |
    74        | buySideProvider1 | ETH/FEB24 | buy  | 1      | 15990 | 1                | TYPE_LIMIT | TIF_GTC |           |
    75  
    76      When the network moves ahead "1" blocks
    77      Then the mark price should be "15910" for the market "ETH/FEB23"
    78      Then the mark price should be "15910" for the market "ETH/FEB24"
    79  
    80      #0032-PRIM-039:For all available mark price calculation methodologies: the price history used by the price monitoring engine is in line with market's mark price history.
    81      Then the market data for the market "ETH/FEB23" should be:
    82        | mark price | trading mode            | horizon | ref price | min bound | max bound | target stake | supplied stake | open interest |
    83        | 15910      | TRADING_MODE_CONTINUOUS | 36000   | 15900     | 15801     | 15999     | 0            | 0              | 5             |
    84      Then the market data for the market "ETH/FEB24" should be:
    85        | mark price | trading mode            | horizon | ref price | min bound | max bound | target stake | supplied stake | open interest |
    86        | 15910      | TRADING_MODE_CONTINUOUS | 36000   | 15900     | 15801     | 15999     | 0            | 0              | 5             |
    87  
    88      And the parties place the following orders:
    89        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
    90        | buySideProvider  | ETH/FEB23 | buy  | 1      | 16008 | 0                | TYPE_LIMIT | TIF_GTC |           |
    91        | buySideProvider1 | ETH/FEB24 | buy  | 1      | 16008 | 0                | TYPE_LIMIT | TIF_GTC |           |
    92  
    93      Then the market data for the market "ETH/FEB23" should be:
    94        | mark price | trading mode                    |
    95        | 15910      | TRADING_MODE_MONITORING_AUCTION |
    96  
    97      When the network moves ahead "6" blocks
    98      Then the mark price should be "15910" for the market "ETH/FEB23"
    99      Then the mark price should be "15910" for the market "ETH/FEB24"
   100  
   101      Then the market data for the market "ETH/FEB23" should be:
   102        | mark price | trading mode                    |
   103        | 15910      | TRADING_MODE_MONITORING_AUCTION |
   104  
   105      Then the market data for the market "ETH/FEB24" should be:
   106        | mark price | trading mode                    |
   107        | 15910      | TRADING_MODE_MONITORING_AUCTION |
   108  
   109      # price from trades = (16008+15990)/2=15999
   110      # price from book = 16008
   111      # markprice = median(15999,16008)=16003
   112      When the network moves ahead "1" blocks
   113      Then the mark price should be "16003" for the market "ETH/FEB23"
   114      Then the mark price should be "16003" for the market "ETH/FEB24"
   115      #0009-MRKP-036:When a futures market is in a monitoring auction, book price is undefined with staleness increasing with time, the book price at auction uncrossing should be set to the price of the uncrossing trade, the mark price should only be recalculated when the auction exits, starting from only the last period indicated by `network.markPriceUpdateMaximumFrequency`
   116      #0032-PRIM-039
   117      Then the market data for the market "ETH/FEB23" should be:
   118        | mark price | trading mode            | horizon | ref price | min bound | max bound | target stake | supplied stake | open interest |
   119        | 16003      | TRADING_MODE_CONTINUOUS | 36000   | 0         | 15909     | 16107     | 0            | 0              | 6             |
   120      #0009-MRKP-037
   121      Then the market data for the market "ETH/FEB24" should be:
   122        | mark price | trading mode            | horizon | ref price | min bound | max bound | target stake | supplied stake | open interest |
   123        | 16003      | TRADING_MODE_CONTINUOUS | 36000   | 0         | 15909     | 16107     | 0            | 0              | 6             |
   124  
   125