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

     1  Feature: test when isolated margin risk factor > 1
     2    Background:
     3      Given the average block duration is "1"
     4      And the following network parameters are set:
     5        | name                                    | value |
     6        | network.markPriceUpdateMaximumFrequency | 0s    |
     7        | limits.markets.maxPeggedOrders          | 6     |
     8        | market.auction.minimumDuration          | 1     |
     9      And the price monitoring named "my-price-monitoring-1":
    10        | horizon | probability | auction extension |
    11        | 5       | 0.99        | 6                 |
    12  
    13      And the liquidity monitoring parameters:
    14        | name       | triggering ratio | time window | scaling factor |
    15        | lqm-params | 0.00             | 24h         | 1e-9           |
    16      And the simple risk model named "simple-risk-model":
    17        | long | short | max move up | min move down | probability of trading |
    18        | 0.8  | 1     | 100         | -100          | 0.2                    |
    19      And the markets:
    20        | id        | quote name | asset | liquidity monitoring | risk model        | margin calculator         | auction duration | fees         | price monitoring      | data source config     | linear slippage factor | quadratic slippage factor | position decimal places | sla params      |
    21        | ETH/FEB23 | ETH        | USD   | lqm-params           | simple-risk-model | default-margin-calculator | 1                | default-none | my-price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | 2                       | default-futures |
    22  
    23    Scenario: 0019-MCAL-208
    24      Given the parties deposit on asset's general account the following amount:
    25        | party   | asset | amount       |
    26        | trader1 | USD   | 100000000000 |
    27        | trader2 | USD   | 100000000000 |
    28        | trader3 | USD   | 100000       |
    29        | trader4 | USD   | 100000000000 |
    30        | lprov1  | USD   | 100000000000 |
    31  
    32      And the parties submit the following liquidity provision:
    33        | id  | party  | market id | commitment amount | fee | lp type    |
    34        | lp1 | lprov1 | ETH/FEB23 | 1000              | 0.1 | submission |
    35  
    36      And the parties place the following orders with ticks:
    37        | party   | market id | side | volume | price  | resulting trades | type       | tif     | reference |
    38        | trader1 | ETH/FEB23 | buy  | 1000   | 14900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    39        | trader1 | ETH/FEB23 | buy  | 300    | 15600  | 0                | TYPE_LIMIT | TIF_GTC |           |
    40        | lprov1  | ETH/FEB23 | buy  | 100    | 15700  | 0                | TYPE_LIMIT | TIF_GTC | lp-buy-1  |
    41        | trader3 | ETH/FEB23 | buy  | 300    | 15800  | 0                | TYPE_LIMIT | TIF_GTC |           |
    42        | lprov1  | ETH/FEB23 | sell | 300    | 15800  | 0                | TYPE_LIMIT | TIF_GTC | lp-sell-1 |
    43        | trader2 | ETH/FEB23 | sell | 600    | 15820  | 0                | TYPE_LIMIT | TIF_GTC | t2-sell-1 |
    44        | trader2 | ETH/FEB23 | sell | 300    | 200000 | 0                | TYPE_LIMIT | TIF_GTC |           |
    45        | trader2 | ETH/FEB23 | sell | 1000   | 200100 | 0                | TYPE_LIMIT | TIF_GTC |           |
    46  
    47      When the network moves ahead "2" blocks
    48      Then the market data for the market "ETH/FEB23" should be:
    49        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
    50        | 15800      | TRADING_MODE_CONTINUOUS | 5       | 15701     | 15899     | 0            | 1000           | 300           |
    51  
    52      And the parties should have the following account balances:
    53        | party   | asset | market id | margin | general | bond |
    54        | trader3 | USD   | ETH/FEB23 | 59724  | 40276   |      |
    55  
    56      When the parties place the following pegged orders:
    57        | party  | market id | side | volume | pegged reference | offset | reference |
    58        | lprov1 | ETH/FEB23 | buy  | 100    | BID              | 10     | buy_peg_1 |
    59        | lprov1 | ETH/FEB23 | buy  | 200    | BID              | 20     | buy_peg_2 |
    60  
    61      Then the parties should have the following margin levels:
    62        | party   | market id | maintenance | search | initial | release | margin mode  | margin factor | order |
    63        | trader3 | ETH/FEB23 | 49770       | 54747  | 59724   | 69678   | cross margin | 0             | 0     |
    64      And the parties should have the following account balances:
    65        | party   | asset | market id | margin | general | bond |
    66        | trader3 | USD   | ETH/FEB23 | 59724  | 40276   |      |
    67  
    68      When the parties place the following orders with ticks:
    69        | party   | market id | side | volume | price | resulting trades | type       | tif     | reference |
    70        | trader3 | ETH/FEB23 | buy  | 10     | 15500 | 0                | TYPE_LIMIT | TIF_GTC | t3-buy    |
    71      Then the parties should have the following margin levels:
    72        | party   | market id | maintenance | search | initial | release | margin mode  | margin factor | order |
    73        | trader3 | ETH/FEB23 | 51034       | 56137  | 61240   | 71447   | cross margin | 0             | 0     |
    74      And the parties should have the following account balances:
    75        | party   | asset | market id | margin | general |
    76        | trader3 | USD   | ETH/FEB23 | 61240  | 38760   |
    77  
    78      When the parties submit update margin mode:
    79        | party   | market    | margin_mode     | margin_factor | error |
    80        | trader3 | ETH/FEB23 | isolated margin | 1.3           |       |
    81      Then the parties should have the following margin levels:
    82        | party   | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
    83        | trader3 | ETH/FEB23 | 49770       | 0      | 59724   | 0       | isolated margin | 1.3           | 2015  |
    84      And the parties should have the following account balances:
    85        | party   | asset | market id | margin | general | order margin |
    86        | trader3 | USD   | ETH/FEB23 | 61620  | 36365   | 2015         |
    87  
    88      # amend the order to increase the required margin, the order remains on the book without issue
    89      When the parties amend the following orders:
    90        | party   | reference | price | size delta | tif     | error |
    91        | trader3 | t3-buy    | 15500 | 20         | TIF_GTC |       |
    92      Then the orders should have the following status:
    93        | party   | reference | status        |
    94        | trader3 | t3-buy    | STATUS_ACTIVE |
    95      And the parties should have the following margin levels:
    96        | party   | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
    97        | trader3 | ETH/FEB23 | 49770       | 0      | 59724   | 0       | isolated margin | 1.3           | 6045  |
    98      And the parties should have the following account balances:
    99        | party   | asset | market id | margin | general | order margin |
   100        | trader3 | USD   | ETH/FEB23 | 61620  | 32335   | 6045         |
   101  
   102      When the parties place the following orders with ticks:
   103        | party   | market id | side | volume | price | resulting trades | type       | tif     | reference   |
   104        | trader1 | ETH/FEB23 | buy  | 10     | 15820 | 1                | TYPE_LIMIT | TIF_GTC | trader2-buy |
   105  
   106      #mark price changed triggers MTM win for trader3: 3*20=60
   107      And the network moves ahead "1" blocks
   108      Then the parties should have the following margin levels:
   109        | party   | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
   110        | trader3 | ETH/FEB23 | 49833       | 0      | 59799   | 0       | isolated margin | 1.3           | 6045  |
   111      And the parties should have the following account balances:
   112        | party   | asset | market id | margin | general | order margin |
   113        | trader3 | USD   | ETH/FEB23 | 61680  | 32335   | 6045         |
   114