code.vegaprotocol.io/vega@v0.79.0/core/integration/features/margin/0019-MCAL-102.feature (about)

     1  Feature: Switch mode during auction
     2    Background:
     3      # switch to isolated margin with no position and no order (before the first order ever has been sent) in auction
     4      Given the following network parameters are set:
     5        | name                                    | value |
     6        | network.markPriceUpdateMaximumFrequency | 0s    |
     7      And the liquidity monitoring parameters:
     8        | name       | triggering ratio | time window | scaling factor |
     9        | lqm-params | 0.00             | 24h         | 1e-9           |
    10      And the simple risk model named "simple-risk-model":
    11        | long | short | max move up | min move down | probability of trading |
    12        | 0.1  | 0.1   | 100         | -100          | 0.2                    |
    13      And the markets:
    14        | 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      |
    15        | ETH/FEB23 | ETH        | USD   | lqm-params           | simple-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.25                   | 0                         | default-futures |
    16  
    17      And the following network parameters are set:
    18        | name                           | value |
    19        | market.auction.minimumDuration | 2     |
    20  
    21    Scenario: 001 switch to isolated margin with no position and no order (before the first order ever has been sent) in auction (0019-MCAL-102)
    22      Given the parties deposit on asset's general account the following amount:
    23        | party            | asset | amount       |
    24        | buySideProvider  | USD   | 100000000000 |
    25        | sellSideProvider | USD   | 100000000000 |
    26        | party1           | USD   | 273500       |
    27  
    28      When the parties submit the following liquidity provision:
    29        | id  | party  | market id | commitment amount | fee | lp type    |
    30        | lp1 | party1 | ETH/FEB23 | 1000              | 0.1 | submission |
    31  
    32      And the parties place the following orders:
    33        | party            | market id | side | volume | price  | resulting trades | type       | tif     | reference |
    34        | buySideProvider  | ETH/FEB23 | buy  | 10     | 14900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    35        | buySideProvider  | ETH/FEB23 | buy  | 6      | 15800  | 0                | TYPE_LIMIT | TIF_GTC |           |
    36        | sellSideProvider | ETH/FEB23 | sell | 1      | 200000 | 0                | TYPE_LIMIT | TIF_GTC |           |
    37        | sellSideProvider | ETH/FEB23 | sell | 10     | 200100 | 0                | TYPE_LIMIT | TIF_GTC |           |
    38  
    39      When the network moves ahead "2" blocks
    40      And the order book should have the following volumes for market "ETH/FEB23":
    41        | side | price  | volume |
    42        | buy  | 14900  | 10     |
    43        | buy  | 15800  | 6      |
    44        | sell | 15900  | 0      |
    45        | sell | 200000 | 1      |
    46      And the parties should have the following margin levels:
    47        | party           | market id | maintenance |
    48        | buySideProvider | ETH/FEB23 | 24380       |
    49  
    50      Then the parties should have the following account balances:
    51        | party  | asset | market id | margin | general | bond |
    52        | party1 | USD   | ETH/FEB23 | 0      | 272500  | 1000 |
    53  
    54      And the market data for the market "ETH/FEB23" should be:
    55        | mark price | trading mode                 |
    56        | 0          | TRADING_MODE_OPENING_AUCTION |
    57  
    58      #switch to isolated margin, failed because party has no order
    59      And the parties submit update margin mode:
    60        | party  | market    | margin_mode     | margin_factor | error                      |
    61        | party1 | ETH/FEB23 | isolated margin | 0.6           | no market observable price |
    62  
    63      And the parties place the following orders:
    64        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference   |
    65        | party1 | ETH/FEB23 | sell | 8      | 15900 | 0                | TYPE_LIMIT | TIF_GTC | party1-sell |
    66  
    67      And the orders should have the following status:
    68        | party  | reference   | status        |
    69        | party1 | party1-sell | STATUS_ACTIVE |
    70  
    71      And the market data for the market "ETH/FEB23" should be:
    72        | mark price | trading mode                 |
    73        | 0          | TRADING_MODE_OPENING_AUCTION |
    74      When the network moves ahead "1" blocks
    75  
    76      #switch to isolated margin, failed because of no market observable price
    77      And the parties submit update margin mode:
    78        | party  | market    | margin_mode     | margin_factor | error                      |
    79        | party1 | ETH/FEB23 | isolated margin | 0.6           | no market observable price |
    80  
    81      When the network moves ahead "1" blocks
    82      And the parties should have the following margin levels:
    83        | party  | market id | maintenance | initial | margin mode  | margin factor | order |
    84        | party1 | ETH/FEB23 | 12720       | 15264   | cross margin | 0             | 0     |
    85      Then the parties should have the following account balances:
    86        | party  | asset | market id | margin | general | bond |
    87        | party1 | USD   | ETH/FEB23 | 15264  | 257236  | 1000 |
    88  
    89      And the market data for the market "ETH/FEB23" should be:
    90        | mark price | trading mode                 |
    91        | 0          | TRADING_MODE_OPENING_AUCTION |
    92  
    93      And the parties place the following orders:
    94        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
    95        | sellSideProvider | ETH/FEB23 | sell | 1      | 15800 | 0                | TYPE_LIMIT | TIF_GTC | sellP-2   |
    96  
    97      When the network moves ahead "2" blocks
    98  
    99      And the market data for the market "ETH/FEB23" should be:
   100        | mark price | trading mode            |
   101        | 15800      | TRADING_MODE_CONTINUOUS |
   102      #MTM from price change
   103      And the parties should have the following margin levels:
   104        | party  | market id | maintenance | initial | search | release | margin mode  | margin factor | order |
   105        | party1 | ETH/FEB23 | 12640       | 15168   | 13904  | 17696   | cross margin | 0             | 0     |
   106      Then the parties should have the following account balances:
   107        | party  | asset | market id | margin | general | bond |
   108        | party1 | USD   | ETH/FEB23 | 15264  | 257236  | 1000 |
   109  
   110      #switch to isolated margin, when there is market observable price
   111      And the parties submit update margin mode:
   112        | party  | market    | margin_mode     | margin_factor |
   113        | party1 | ETH/FEB23 | isolated margin | 0.6           |
   114      When the network moves ahead "1" blocks
   115      And the parties should have the following margin levels:
   116        | party  | market id | maintenance | release | search | initial | margin mode     | margin factor | order |
   117        | party1 | ETH/FEB23 | 0           | 0       | 0      | 0       | isolated margin | 0.6           | 76320 |
   118      Then the parties should have the following account balances:
   119        | party  | asset | market id | margin | general | bond |
   120        | party1 | USD   | ETH/FEB23 | 0      | 196180  | 1000 |
   121  
   122