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

     1  Feature:  switch to isolated margin with position and without orders during continuous
     2    Background:
     3      # switch between cross margin and isolated margin mode during auction
     4      Given the following network parameters are set:
     5        | name                                    | value |
     6        | network.markPriceUpdateMaximumFrequency | 0s    |
     7      And the price monitoring named "my-price-monitoring":
     8        | horizon | probability | auction extension |
     9        | 5       | 0.95        | 6                 |
    10        | 10      | 0.99        | 8                 |
    11      And the liquidity monitoring parameters:
    12        | name       | triggering ratio | time window | scaling factor |
    13        | lqm-params | 0.00             | 24h         | 1e-9           |
    14      And the simple risk model named "simple-risk-model":
    15        | long | short | max move up | min move down | probability of trading |
    16        | 0.1  | 0.1   | 100         | -100          | 0.2                    |
    17      And the markets:
    18        | 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      |
    19        | 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 |
    20  
    21      And the following network parameters are set:
    22        | name                           | value |
    23        | market.auction.minimumDuration | 1     |
    24      Given the average block duration is "1"
    25  
    26    Scenario: 001 switch to isolated margin during auction
    27      Given the parties deposit on asset's general account the following amount:
    28        | party            | asset | amount       |
    29        | buySideProvider  | USD   | 100000000000 |
    30        | sellSideProvider | USD   | 100000000000 |
    31        | party1           | USD   | 20908        |
    32        | party2           | USD   | 84110        |
    33  
    34      When the parties submit the following liquidity provision:
    35        | id  | party  | market id | commitment amount | fee | lp type    |
    36        | lp1 | party1 | ETH/FEB23 | 1000              | 0.1 | submission |
    37  
    38      And the parties place the following orders:
    39        | party            | market id | side | volume | price  | resulting trades | type       | tif     | reference |
    40        | buySideProvider  | ETH/FEB23 | buy  | 10     | 14900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    41        | buySideProvider  | ETH/FEB23 | buy  | 3      | 15600  | 0                | TYPE_LIMIT | TIF_GTC |           |
    42        | buySideProvider  | ETH/FEB23 | buy  | 3      | 15800  | 0                | TYPE_LIMIT | TIF_GTC |           |
    43        | party1           | ETH/FEB23 | sell | 3      | 15800  | 0                | TYPE_LIMIT | TIF_GTC | p1-sell   |
    44        | sellSideProvider | ETH/FEB23 | sell | 3      | 200000 | 0                | TYPE_LIMIT | TIF_GTC |           |
    45        | sellSideProvider | ETH/FEB23 | sell | 10     | 200100 | 0                | TYPE_LIMIT | TIF_GTC |           |
    46  
    47      When the network moves ahead "2" blocks
    48      And 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           | 3             |
    51  
    52      Then the parties should have the following account balances:
    53        | party  | asset | market id | margin | general | bond |
    54        | party1 | USD   | ETH/FEB23 | 19908  | 0       | 1000 |
    55  
    56      #maintenance margin: min((200000-15800),15800*0.25)+0.1*15800=5530
    57      And the parties should have the following margin levels:
    58        | party  | market id | maintenance | search | initial | release | margin mode  | margin factor | order |
    59        | party1 | ETH/FEB23 | 16590       | 18249  | 19908   | 23226   | cross margin | 0             | 0     |
    60  
    61      And the parties submit update margin mode:
    62        | party  | market    | margin_mode     | margin_factor | error                                                                                                                   |
    63        | party1 | ETH/FEB23 | isolated margin | 0.1           | margin factor (0.1) must be greater than max(riskFactorLong (0.1), riskFactorShort (0.1)) + linearSlippageFactor (0.25) |
    64  
    65      #AC0019-MCAL-108: switch to isolated margin with position and with orders with margin factor such that position margin is < initial should fail in continuous
    66      And the parties submit update margin mode:
    67        | party  | market    | margin_mode     | margin_factor | error                                                        |
    68        | party1 | ETH/FEB23 | isolated margin | 0.36          | required position margin must be greater than initial margin |
    69  
    70      #AC0019-MCAL-112: switch to isolated margin with position and no orders with margin factor such that there is insufficient balance in the general account in continuous mode
    71      And the parties submit update margin mode:
    72        | party  | market    | margin_mode     | margin_factor | error                                                                      |
    73        | party1 | ETH/FEB23 | isolated margin | 0.8           | insufficient balance in general account to cover for required order margin |
    74  
    75      And the parties place the following orders:
    76        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
    77        | party1           | ETH/FEB23 | buy  | 2      | 15800 | 0                | TYPE_LIMIT | TIF_GTC | p1-sell-1 |
    78        | sellSideProvider | ETH/FEB23 | sell | 2      | 15800 | 1                | TYPE_LIMIT | TIF_GTC |           |
    79  
    80      When the network moves ahead "1" blocks
    81      Then the parties should have the following account balances:
    82        | party  | asset | market id | margin | general | bond |
    83        | party1 | USD   | ETH/FEB23 | 6636   | 13272   | 1000 |
    84  
    85      #AC0019-MCAL-120: switch to isolated margin with position and no orders successful in continuous mode
    86      And the parties submit update margin mode:
    87        | party  | market    | margin_mode     | margin_factor | error |
    88        | party1 | ETH/FEB23 | isolated margin | 0.5           |       |
    89      And the parties should have the following margin levels:
    90        | party  | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
    91        | party1 | ETH/FEB23 | 5530        | 0      | 6636    | 0       | isolated margin | 0.5           | 0     |
    92  
    93      Then the parties should have the following account balances:
    94        | party  | asset | market id | margin | general | bond |
    95        | party1 | USD   | ETH/FEB23 | 7900   | 12008   | 1000 |
    96  
    97      #AC0019-MCAL-128: increase margin factor in isolated margin with position and no orders successful in continuous mode
    98      And the parties submit update margin mode:
    99        | party  | market    | margin_mode     | margin_factor | error |
   100        | party1 | ETH/FEB23 | isolated margin | 0.7           |       |
   101      And the parties should have the following margin levels:
   102        | party  | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
   103        | party1 | ETH/FEB23 | 5530        | 0      | 6636    | 0       | isolated margin | 0.7           | 0     |
   104  
   105      Then the parties should have the following account balances:
   106        | party  | asset | market id | margin | general | bond |
   107        | party1 | USD   | ETH/FEB23 | 11060  | 8848    | 1000 |
   108  
   109      #AC0019-MCAL-128: decrease margin factor in isolated margin with position and no orders successful in continuous mode
   110      And the parties submit update margin mode:
   111        | party  | market    | margin_mode     | margin_factor | error |
   112        | party1 | ETH/FEB23 | isolated margin | 0.6           |       |
   113      And the parties should have the following margin levels:
   114        | party  | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
   115        | party1 | ETH/FEB23 | 5530        | 0      | 6636    | 0       | isolated margin | 0.6           | 0     |
   116  
   117      Then the parties should have the following account balances:
   118        | party  | asset | market id | margin | general | bond |
   119        | party1 | USD   | ETH/FEB23 | 9480   | 10428   | 1000 |
   120  
   121      #AC0019-MCAL-136: switch to cross margin with position and no orders successful in continuous mode
   122      And the parties submit update margin mode:
   123        | party  | market    | margin_mode  | margin_factor | error |
   124        | party1 | ETH/FEB23 | cross margin |               |       |
   125      And the parties should have the following margin levels:
   126        | party  | market id | maintenance | search | initial | release | margin mode  | margin factor | order |
   127        | party1 | ETH/FEB23 | 5530        | 6083   | 6636    | 7742    | cross margin | 0             | 0     |
   128  
   129      When the network moves ahead "1" blocks
   130      Then the parties should have the following account balances:
   131        | party  | asset | market id | margin | general | bond |
   132        | party1 | USD   | ETH/FEB23 | 9480   | 10428   | 1000 |