code.vegaprotocol.io/vega@v0.79.0/core/integration/features/price_monitoring/price-monitoring-bounds.feature (about)

     1  Feature: Price monitoring triggers test on or around monitoring bounds with decimals
     2  
     3    Background:
     4      Given time is updated to "2020-10-16T00:00:00Z"
     5      And the following assets are registered:
     6        | id  | decimal places |
     7        | ETH | 10             |
     8      And the price monitoring named "my-price-monitoring":
     9        | horizon | probability | auction extension |
    10        | 5       | 0.95        | 30                |
    11      And the price monitoring named "my-updated-price-monitoring":
    12        | horizon | probability | auction extension |
    13        | 5       | 0.8         | 30                |
    14      And the log normal risk model named "my-log-normal-risk-model":
    15        | risk aversion | tau                    | mu | r     | sigma |
    16        | 0.000001      | 0.00011407711613050422 | 0  | 0.016 | 2.0   |
    17      And the markets:
    18        | 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      |
    19        | ETH/DEC20 | ETH        | ETH   | default-log-normal-risk-model | default-margin-calculator | 1                | default-none | my-price-monitoring | default-eth-for-future | 5              | 0.001                  | 0                         | default-futures |
    20      And the following network parameters are set:
    21        | name                           | value |
    22        | market.auction.minimumDuration | 1     |
    23        | limits.markets.maxPeggedOrders | 2     |
    24      And the average block duration is "1"
    25  
    26    @PriceBounds
    27    Scenario: Trades below minimum price bound by 1 decimal trigger auction
    28      Given the parties deposit on asset's general account the following amount:
    29        | party  | asset | amount                     |
    30        | party1 | ETH   | 1000000000000000000000     |
    31        | party2 | ETH   | 1000000000000000000000     |
    32        | aux    | ETH   | 1000000000000000000000     |
    33        | aux2   | ETH   | 1000000000000000000000     |
    34        | lpprov | ETH   | 90000000000000000000000000 |
    35  
    36      When the parties submit the following liquidity provision:
    37        | id  | party  | market id | commitment amount  | fee | lp type    |
    38        | lp1 | lpprov | ETH/DEC20 | 9000000000000000   | 0.1 | submission |
    39        | lp1 | lpprov | ETH/DEC20 | 9000000000000000   | 0.1 | submission |
    40      And the parties place the following pegged iceberg orders:
    41        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    42        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
    43        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
    44  
    45      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
    46      When the parties place the following orders:
    47        | party | market id | side | volume | price        | resulting trades | type       | tif     |
    48        | aux   | ETH/DEC20 | buy  | 1      | 100000       | 0                | TYPE_LIMIT | TIF_GTC |
    49        | aux   | ETH/DEC20 | sell | 1      | 200000000000 | 0                | TYPE_LIMIT | TIF_GTC |
    50        | aux2  | ETH/DEC20 | buy  | 1      | 10000000000  | 0                | TYPE_LIMIT | TIF_GTC |
    51        | aux   | ETH/DEC20 | sell | 1      | 10000000000  | 0                | TYPE_LIMIT | TIF_GTC |
    52      Then the opening auction period ends for market "ETH/DEC20"
    53      And the market data for the market "ETH/DEC20" should be:
    54        | mark price  | trading mode            | horizon | min bound  | max bound   | target stake    | supplied stake   | open interest |
    55        | 10000000000 | TRADING_MODE_CONTINUOUS | 5       | 9984405895 | 10015612113 | 743400000000000 | 9000000000000000 | 1             |
    56      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
    57      And the mark price should be "10000000000" for the market "ETH/DEC20"
    58   
    59      #T0 + 10 min
    60      When the network moves ahead "1" blocks
    61  
    62      # Put in trade at min price bound -1 -> should trigger auction
    63      And the parties place the following orders:
    64        | party  | market id | side | volume | price      | resulting trades | type       | tif     |
    65        | party1 | ETH/DEC20 | sell | 1      | 9984405894 | 0                | TYPE_LIMIT | TIF_GTC |
    66        | party2 | ETH/DEC20 | buy  | 1      | 9984405894 | 0                | TYPE_LIMIT | TIF_GTC |
    67      Then the market data for the market "ETH/DEC20" should be:
    68        | mark price  | trading mode                    | auction trigger       | target stake     | supplied stake   | open interest |
    69        | 10000000000 | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | 1484481468319920 | 9000000000000000 | 1             |
    70  
    71      When the network moves ahead "1" blocks
    72      Then the mark price should be "10000000000" for the market "ETH/DEC20"
    73  
    74      # end of auction
    75      When the network moves ahead "30" blocks
    76      Then the market data for the market "ETH/DEC20" should be:
    77        | mark price | trading mode            | target stake     | supplied stake   | open interest |
    78        | 9984405894 | TRADING_MODE_CONTINUOUS | 1484481468319920 | 9000000000000000 | 2             |
    79  
    80    @PriceBounds
    81    Scenario: Trades above maximum price bound by 1 decimal trigger auction
    82      Given the parties deposit on asset's general account the following amount:
    83        | party  | asset | amount                     |
    84        | party1 | ETH   | 1000000000000000000000     |
    85        | party2 | ETH   | 1000000000000000000000     |
    86        | aux    | ETH   | 1000000000000000000000     |
    87        | aux2   | ETH   | 1000000000000000000000     |
    88        | lpprov | ETH   | 90000000000000000000000000 |
    89  
    90      When the parties submit the following liquidity provision:
    91        | id  | party  | market id | commitment amount  | fee | lp type    |
    92        | lp1 | lpprov | ETH/DEC20 | 9000000000000000   | 0.1 | submission |
    93        | lp1 | lpprov | ETH/DEC20 | 9000000000000000   | 0.1 | submission |
    94      And the parties place the following pegged iceberg orders:
    95        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    96        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
    97        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
    98      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
    99      When the parties place the following orders:
   100        | party | market id | side | volume | price        | resulting trades | type       | tif     |
   101        | aux   | ETH/DEC20 | buy  | 1      | 100000       | 0                | TYPE_LIMIT | TIF_GTC |
   102        | aux   | ETH/DEC20 | sell | 1      | 200000000000 | 0                | TYPE_LIMIT | TIF_GTC |
   103        | aux2  | ETH/DEC20 | buy  | 1      | 10000000000  | 0                | TYPE_LIMIT | TIF_GTC |
   104        | aux   | ETH/DEC20 | sell | 1      | 10000000000  | 0                | TYPE_LIMIT | TIF_GTC |
   105      Then the opening auction period ends for market "ETH/DEC20"
   106      And the market data for the market "ETH/DEC20" should be:
   107        | mark price  | trading mode            | horizon | min bound  | max bound   | target stake    | supplied stake   | open interest |
   108        | 10000000000 | TRADING_MODE_CONTINUOUS | 5       | 9984405895 | 10015612113 | 743400000000000 | 9000000000000000 | 1             |
   109   
   110      #T0 + 10 min
   111      When the network moves ahead "1" blocks
   112  
   113      # Put in trade at max price bound +1 -> should trigger auction
   114      And the parties place the following orders:
   115        | party  | market id | side | volume | price       | resulting trades | type       | tif     |
   116        | party1 | ETH/DEC20 | sell | 1      | 10015612114 | 0                | TYPE_LIMIT | TIF_GTC |
   117        | party2 | ETH/DEC20 | buy  | 1      | 10015612114 | 0                | TYPE_LIMIT | TIF_GTC |
   118      Then the market data for the market "ETH/DEC20" should be:
   119        | mark price  | trading mode                    | auction trigger       | target stake     | supplied stake   | open interest |
   120        | 10000000000 | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | 1489121209109520 | 9000000000000000 | 1             |
   121  
   122      When the network moves ahead "1" blocks
   123      Then the mark price should be "10000000000" for the market "ETH/DEC20"
   124  
   125      # end of auction
   126      When the network moves ahead "30" blocks
   127      Then the market data for the market "ETH/DEC20" should be:
   128        | mark price  | trading mode            | target stake     | supplied stake   | open interest |
   129        | 10015612114 | TRADING_MODE_CONTINUOUS | 1489121209109520 | 9000000000000000 | 2             |
   130  
   131    @PriceBounds
   132    Scenario: Trades below minimum price bound by 1 after an update to the price monitoring parameters
   133      Given the parties deposit on asset's general account the following amount:
   134        | party  | asset | amount                     |
   135        | party1 | ETH   | 1000000000000000000000     |
   136        | party2 | ETH   | 1000000000000000000000     |
   137        | aux    | ETH   | 1000000000000000000000     |
   138        | aux2   | ETH   | 1000000000000000000000     |
   139        | lpprov | ETH   | 90000000000000000000000000 |
   140  
   141      When the parties submit the following liquidity provision:
   142        | id  | party  | market id | commitment amount  | fee | lp type    |
   143        | lp1 | lpprov | ETH/DEC20 | 9000000000000000   | 0.1 | submission |
   144        | lp1 | lpprov | ETH/DEC20 | 9000000000000000   | 0.1 | submission |
   145      And the parties place the following pegged iceberg orders:
   146        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   147        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
   148        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
   149  
   150      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
   151      When the parties place the following orders:
   152        | party | market id | side | volume | price        | resulting trades | type       | tif     |
   153        | aux   | ETH/DEC20 | buy  | 1      | 100000       | 0                | TYPE_LIMIT | TIF_GTC |
   154        | aux   | ETH/DEC20 | sell | 1      | 200000000000 | 0                | TYPE_LIMIT | TIF_GTC |
   155        | aux2  | ETH/DEC20 | buy  | 1      | 10000000000  | 0                | TYPE_LIMIT | TIF_GTC |
   156        | aux   | ETH/DEC20 | sell | 1      | 10000000000  | 0                | TYPE_LIMIT | TIF_GTC |
   157      Then the opening auction period ends for market "ETH/DEC20"
   158      And the market data for the market "ETH/DEC20" should be:
   159        | mark price  | trading mode            | horizon | min bound  | max bound   | target stake    | supplied stake   | open interest |
   160        | 10000000000 | TRADING_MODE_CONTINUOUS | 5       | 9984405895 | 10015612113 | 743400000000000 | 9000000000000000 | 1             |
   161      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   162      And the mark price should be "10000000000" for the market "ETH/DEC20"
   163   
   164      # 9000000001   11000000000
   165      # Update price monitoring bounds
   166      When the markets are updated:
   167        | id        | price monitoring            | linear slippage factor | quadratic slippage factor |
   168        | ETH/DEC20 | my-updated-price-monitoring | 0.001                  | 0                         |
   169      Then the market data for the market "ETH/DEC20" should be:
   170        | mark price  | trading mode            | horizon | min bound  | max bound   | target stake    | supplied stake   | open interest |
   171        | 10000000000 | TRADING_MODE_CONTINUOUS | 5       | 9000000001 | 11000000000 | 743400000000000 | 9000000000000000 | 1             |
   172  
   173      When the network moves ahead "1" blocks
   174      # Put in trade at min price bound -1 -> should trigger auction
   175      And the parties place the following orders:
   176        | party  | market id | side | volume | price      | resulting trades | type       | tif     |
   177        | party1 | ETH/DEC20 | sell | 1      | 9000000000 | 0                | TYPE_LIMIT | TIF_GTC |
   178        | party2 | ETH/DEC20 | buy  | 1      | 9000000000 | 0                | TYPE_LIMIT | TIF_GTC |
   179      Then the market data for the market "ETH/DEC20" should be:
   180        | mark price  | trading mode                    | auction trigger       | target stake     | supplied stake   | open interest |
   181        | 10000000000 | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | 1338120000000000 | 9000000000000000 | 1             |
   182  
   183      When the network moves ahead "1" blocks
   184      Then the mark price should be "10000000000" for the market "ETH/DEC20"
   185  
   186      # end of auction
   187      When the network moves ahead "30" blocks
   188      Then the market data for the market "ETH/DEC20" should be:
   189        | mark price | trading mode            | target stake     | supplied stake   | open interest |
   190        | 9000000000 | TRADING_MODE_CONTINUOUS | 1338120000000000 | 9000000000000000 | 2             |
   191  
   192    @PriceBounds
   193    Scenario: Trades above maximum price bound by 1 decimal after market update
   194      Given the parties deposit on asset's general account the following amount:
   195        | party  | asset | amount                     |
   196        | party1 | ETH   | 1000000000000000000000     |
   197        | party2 | ETH   | 1000000000000000000000     |
   198        | aux    | ETH   | 1000000000000000000000     |
   199        | aux2   | ETH   | 1000000000000000000000     |
   200        | lpprov | ETH   | 90000000000000000000000000 |
   201  
   202      When the parties submit the following liquidity provision:
   203        | id  | party  | market id | commitment amount  | fee | lp type    |
   204        | lp1 | lpprov | ETH/DEC20 | 9000000000000000   | 0.1 | submission |
   205        | lp1 | lpprov | ETH/DEC20 | 9000000000000000   | 0.1 | submission |
   206      And the parties place the following pegged iceberg orders:
   207        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   208        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
   209        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
   210   
   211      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
   212      When the parties place the following orders:
   213        | party | market id | side | volume | price        | resulting trades | type       | tif     |
   214        | aux   | ETH/DEC20 | buy  | 1      | 100000       | 0                | TYPE_LIMIT | TIF_GTC |
   215        | aux   | ETH/DEC20 | sell | 1      | 200000000000 | 0                | TYPE_LIMIT | TIF_GTC |
   216        | aux2  | ETH/DEC20 | buy  | 1      | 10000000000  | 0                | TYPE_LIMIT | TIF_GTC |
   217        | aux   | ETH/DEC20 | sell | 1      | 10000000000  | 0                | TYPE_LIMIT | TIF_GTC |
   218      Then the opening auction period ends for market "ETH/DEC20"
   219      And the market data for the market "ETH/DEC20" should be:
   220        | mark price  | trading mode            | horizon | min bound  | max bound   | target stake    | supplied stake   | open interest |
   221        | 10000000000 | TRADING_MODE_CONTINUOUS | 5       | 9984405895 | 10015612113 | 743400000000000 | 9000000000000000 | 1             |
   222  
   223      # Update price monitoring bounds
   224      When the markets are updated:
   225        | id        | price monitoring            | linear slippage factor | quadratic slippage factor |
   226        | ETH/DEC20 | my-updated-price-monitoring | 0.001                  | 0                         |
   227      Then the market data for the market "ETH/DEC20" should be:
   228        | mark price  | trading mode            | horizon | min bound  | max bound   | target stake    | supplied stake   | open interest |
   229        | 10000000000 | TRADING_MODE_CONTINUOUS | 5       | 9000000001 | 11000000000 | 743400000000000 | 9000000000000000 | 1             |
   230   
   231      #T0 + 10 min
   232      When the network moves ahead "1" blocks
   233  
   234      # Put in trade at max price bound +1 -> should trigger auction
   235      And the parties place the following orders:
   236        | party  | market id | side | volume | price       | resulting trades | type       | tif     |
   237        | party1 | ETH/DEC20 | sell | 1      | 11000000001 | 0                | TYPE_LIMIT | TIF_GTC |
   238        | party2 | ETH/DEC20 | buy  | 1      | 11000000001 | 0                | TYPE_LIMIT | TIF_GTC |
   239      Then the market data for the market "ETH/DEC20" should be:
   240        | mark price  | trading mode                    | auction trigger       | target stake     | supplied stake   | open interest |
   241        | 10000000000 | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | 1635480000148680 | 9000000000000000 | 1             |
   242  
   243      When the network moves ahead "1" blocks
   244      Then the mark price should be "10000000000" for the market "ETH/DEC20"
   245  
   246      # end of auction
   247      When the network moves ahead "30" blocks
   248      Then the market data for the market "ETH/DEC20" should be:
   249        | mark price  | trading mode            | target stake     | supplied stake   | open interest |
   250        | 11000000001 | TRADING_MODE_CONTINUOUS | 1635480000148680 | 9000000000000000 | 2             |