code.vegaprotocol.io/vega@v0.79.0/core/integration/features/price_monitoring/5206-price-bound-rounding.feature (about)

     1  Feature: Ensure price bounds are triggered as and when they should be, considering rounding and decimal places
     2  
     3    Background:
     4      Given the price monitoring named "st-price-monitoring":
     5        | horizon | probability | auction extension |
     6        | 5       | 0.95        | 10                |
     7      And the following assets are registered:
     8        | id  | decimal places |
     9        | ETH | 18             |
    10      And the log normal risk model named "st-log-normal-risk-model":
    11        | risk aversion | tau                    | mu | r     | sigma |
    12        | 0.001         | 0.00011407711613050422 | 0  | 0.016 | 1.5   |
    13      And the markets:
    14        | id        | quote name | asset | risk model               | margin calculator         | auction duration | fees         | price monitoring    | data source config     | decimal places | linear slippage factor | quadratic slippage factor | sla params      |
    15        | ETH/DEC20 | ETH        | ETH   | st-log-normal-risk-model | default-margin-calculator | 1                | default-none | st-price-monitoring | default-eth-for-future | 6              | 0.25                   | 0                         | default-futures |
    16      And the following network parameters are set:
    17        | name                           | value |
    18        | market.auction.minimumDuration | 1     |
    19        | limits.markets.maxPeggedOrders | 2     |
    20      And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC20"
    21  
    22    @STAuc
    23    Scenario: Replicate issue where price monitoring should be triggered at min bound - 1
    24      Given the parties deposit on asset's general account the following amount:
    25        | party   | asset | amount                        |
    26        | party1  | ETH   | 10000000000000000000000000000 |
    27        | party2  | ETH   | 10000000000000000000000000000 |
    28        | party3  | ETH   | 10000000000000000000000000000 |
    29        | party4  | ETH   | 10000000000000000000000000000 |
    30        | partyLP | ETH   | 10000000000000000000000000000 |
    31        | aux     | ETH   | 10000000000000000000000000000 |
    32  
    33      # 977142641
    34      When the parties place the following orders:
    35        | party  | market id | side | volume | price      | resulting trades | type       | tif     |
    36        | party3 | ETH/DEC20 | buy  | 1      | 977142640  | 0                | TYPE_LIMIT | TIF_GFA |
    37        | party2 | ETH/DEC20 | sell | 1      | 977142640  | 0                | TYPE_LIMIT | TIF_GFA |
    38        | party1 | ETH/DEC20 | buy  | 5      | 950000000  | 0                | TYPE_LIMIT | TIF_GTC |
    39        | party2 | ETH/DEC20 | sell | 5      | 1070000000 | 0                | TYPE_LIMIT | TIF_GTC |
    40        | party1 | ETH/DEC20 | buy  | 1      | 950000000  | 0                | TYPE_LIMIT | TIF_GTC |
    41        | party2 | ETH/DEC20 | sell | 1      | 1070000000 | 0                | TYPE_LIMIT | TIF_GTC |
    42      And the parties submit the following liquidity provision:
    43        | id  | party  | market id | commitment amount       | fee | lp type    |
    44        | lp1 | party1 | ETH/DEC20 | 39050000000000000000000 | 0.3 | submission |
    45        | lp1 | party1 | ETH/DEC20 | 39050000000000000000000 | 0.3 | submission |
    46      And the parties place the following pegged iceberg orders:
    47        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset  |
    48        | party1 | ETH/DEC20 | 2         | 1                    | buy  | BID              | 2          | 1000000 |
    49        | party1 | ETH/DEC20 | 2         | 1                    | sell | ASK              | 13         | 1000000 |
    50      Then the mark price should be "0" for the market "ETH/DEC20"
    51      And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC20"
    52  
    53      When the opening auction period ends for market "ETH/DEC20"
    54      Then the mark price should be "977142640" for the market "ETH/DEC20"
    55      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
    56  
    57      When the parties place the following orders:
    58        | party  | market id | side | volume | price     | resulting trades | type       | tif     |
    59        | aux    | ETH/DEC20 | buy  | 1      | 977142641 | 0                | TYPE_LIMIT | TIF_GTC |
    60        | party4 | ETH/DEC20 | sell | 1      | 977142641 | 1                | TYPE_LIMIT | TIF_GTC |
    61  
    62      Then the market data for the market "ETH/DEC20" should be:
    63        | mark price | last traded price | trading mode            |
    64        | 977142640  | 977142641         | TRADING_MODE_CONTINUOUS |
    65  
    66      And the market data for the market "ETH/DEC20" should be:
    67        | mark price | trading mode            | horizon | min bound | max bound | target stake           | supplied stake          | open interest |
    68        | 977142640  | TRADING_MODE_CONTINUOUS | 5       | 975999651 | 978286619 | 1080524331312000000000 | 39050000000000000000000 | 2             |
    69  
    70      When the parties place the following orders:
    71        | party  | market id | side | volume | price     | resulting trades | type       | tif     |
    72        | aux    | ETH/DEC20 | buy  | 1      | 975999650 | 0                | TYPE_LIMIT | TIF_GTC |
    73        | party4 | ETH/DEC20 | sell | 1      | 975999650 | 0                | TYPE_LIMIT | TIF_GTC |
    74      Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
    75      And the market data for the market "ETH/DEC20" should be:
    76        | mark price | last traded price | trading mode                    | auction trigger       | target stake           | supplied stake          | open interest |
    77        | 977142640  | 977142641         | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | 1618890619455000000000 | 39050000000000000000000 | 2             |
    78  
    79    @STAuc
    80    Scenario: Replicate  issue where price bounds are violated by 1 * 10^(market decimal places)
    81      Given the parties deposit on asset's general account the following amount:
    82        | party   | asset | amount                        |
    83        | party1  | ETH   | 10000000000000000000000000000 |
    84        | party2  | ETH   | 10000000000000000000000000000 |
    85        | party3  | ETH   | 10000000000000000000000000000 |
    86        | party4  | ETH   | 10000000000000000000000000000 |
    87        | partyLP | ETH   | 10000000000000000000000000000 |
    88        | aux     | ETH   | 10000000000000000000000000000 |
    89  
    90      # 977142641
    91      When the parties place the following orders:
    92        | party  | market id | side | volume | price      | resulting trades | type       | tif     |
    93        | party3 | ETH/DEC20 | buy  | 1      | 977142640  | 0                | TYPE_LIMIT | TIF_GFA |
    94        | party2 | ETH/DEC20 | sell | 1      | 977142640  | 0                | TYPE_LIMIT | TIF_GFA |
    95        | party1 | ETH/DEC20 | buy  | 5      | 950000000  | 0                | TYPE_LIMIT | TIF_GTC |
    96        | party2 | ETH/DEC20 | sell | 5      | 1070000000 | 0                | TYPE_LIMIT | TIF_GTC |
    97        | party1 | ETH/DEC20 | buy  | 1      | 950000000  | 0                | TYPE_LIMIT | TIF_GTC |
    98        | party2 | ETH/DEC20 | sell | 1      | 1070000000 | 0                | TYPE_LIMIT | TIF_GTC |
    99      And the parties submit the following liquidity provision:
   100        | id  | party  | market id | commitment amount       | fee | lp type    |
   101        | lp1 | party1 | ETH/DEC20 | 39050000000000000000000 | 0.3 | submission |
   102        | lp1 | party1 | ETH/DEC20 | 39050000000000000000000 | 0.3 | submission |
   103      And the parties place the following pegged iceberg orders:
   104        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset  |
   105        | party1 | ETH/DEC20 | 2         | 1                    | buy  | BID              | 2          | 1000000 |
   106        | party1 | ETH/DEC20 | 2         | 1                    | sell | ASK              | 13         | 1000000 |
   107      Then the mark price should be "0" for the market "ETH/DEC20"
   108      And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC20"
   109  
   110      When the opening auction period ends for market "ETH/DEC20"
   111      Then the mark price should be "977142640" for the market "ETH/DEC20"
   112      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   113  
   114      When the parties place the following orders:
   115        | party  | market id | side | volume | price     | resulting trades | type       | tif     |
   116        | aux    | ETH/DEC20 | buy  | 1      | 977142641 | 0                | TYPE_LIMIT | TIF_GTC |
   117        | party4 | ETH/DEC20 | sell | 1      | 977142641 | 1                | TYPE_LIMIT | TIF_GTC |
   118  
   119      And the market data for the market "ETH/DEC20" should be:
   120        | mark price | last traded price | trading mode            | horizon | min bound | max bound | target stake           | supplied stake          | open interest |
   121        | 977142640  | 977142641         | TRADING_MODE_CONTINUOUS | 5       | 975999651 | 978286619 | 1080524331312000000000 | 39050000000000000000000 | 2             |
   122  
   123      When the parties place the following orders:
   124        | party  | market id | side | volume | price     | resulting trades | type       | tif     |
   125        | aux    | ETH/DEC20 | buy  | 1      | 974999651 | 0                | TYPE_LIMIT | TIF_GTC |
   126        | party4 | ETH/DEC20 | sell | 1      | 974999651 | 0                | TYPE_LIMIT | TIF_GTC |
   127      Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   128      And the market data for the market "ETH/DEC20" should be:
   129        | mark price | last traded price | trading mode                    | auction trigger       | target stake           | supplied stake          | open interest |
   130        | 977142640  | 977142641         | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | 1617231921113700000000 | 39050000000000000000000 | 2             |