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

     1  Feature: Test order margin during auction
     2    Background:
     3      # Set liquidity parameters to allow "zero" target-stake which is needed to construct the order-book defined in the ACs
     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.19                   | 0                         | default-futures |
    16  
    17      And the following network parameters are set:
    18        | name                           | value |
    19        | market.auction.minimumDuration | 2     |
    20      Given the average block duration is "1"
    21  
    22    Scenario: Check order margin during openning auction
    23      Given the parties deposit on asset's general account the following amount:
    24        | party            | asset | amount       |
    25        | buySideProvider  | USD   | 100000000000 |
    26        | sellSideProvider | USD   | 100000000000 |
    27        | party1           | USD   | 48050        |
    28      And the parties place the following orders:
    29        | party            | market id | side | volume | price  | resulting trades | type       | tif     | reference |
    30        | buySideProvider  | ETH/FEB23 | buy  | 10     | 14900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    31        | buySideProvider  | ETH/FEB23 | buy  | 1      | 15000  | 0                | TYPE_LIMIT | TIF_GTC |           |
    32        | buySideProvider  | ETH/FEB23 | buy  | 1      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    33        | sellSideProvider | ETH/FEB23 | sell | 1      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    34        | party1           | ETH/FEB23 | sell | 2      | 15910  | 0                | TYPE_LIMIT | TIF_GTC | s-GTC-2   |
    35        | party1           | ETH/FEB23 | sell | 1      | 15920  | 0                | TYPE_LIMIT | TIF_GTC | s-GTC-1   |
    36        | sellSideProvider | ETH/FEB23 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC |           |
    37        | sellSideProvider | ETH/FEB23 | sell | 10     | 100100 | 0                | TYPE_LIMIT | TIF_GTC |           |
    38  
    39      And the market data for the market "ETH/FEB23" should be:
    40        | mark price | trading mode                 |
    41        | 0          | TRADING_MODE_OPENING_AUCTION |
    42  
    43      And the parties should have the following margin levels:
    44        | party  | market id | maintenance | search | initial | release | margin mode  | margin factor | order |
    45        | party1 | ETH/FEB23 | 4774        | 5251   | 5728    | 6683    | cross margin | 0             | 0     |
    46  
    47      And the parties submit update margin mode:
    48        | party  | market    | margin_mode     | margin_factor | error |
    49        | party1 | ETH/FEB23 | isolated margin | 0.3           |       |
    50  
    51      #AC: 0019-MCAL-200, when party has no position, and place 2 short orders during auction, order margin should be updated
    52      #order margin short: (2*15910+1*15920)*0.3=14322
    53      And the parties should have the following margin levels:
    54        | party  | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
    55        | party1 | ETH/FEB23 | 0           | 0      | 0       | 0       | isolated margin | 0.3           | 14322 |
    56  
    57      # #AC: 0019-MCAL-201, when party has no position, and place short orders size -3 during auction, and long order size 1 which can offset, order margin should be updated using max(price, markPrice, indicativePrice)
    58      And the parties place the following orders:
    59        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    60        | party1 | ETH/FEB23 | buy  | 1      | 15800 | 0                | TYPE_LIMIT | TIF_GTC | b-GTC-1   |
    61  
    62      #order margin short: (2*15910+1*15920)*0.3=14322
    63      #order margin long: 1*15800*0.3=5750
    64      And the parties should have the following margin levels:
    65        | party  | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
    66        | party1 | ETH/FEB23 | 0           | 0      | 0       | 0       | isolated margin | 0.3           | 14322 |
    67  
    68      #AC: 0019-MCAL-202, when party has no position, and place short orders size -3 during auction, and long orders size 2 which can offset, order margin should be updated using max(price, markPrice, indicativePrice)
    69      And the parties place the following orders:
    70        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    71        | party1 | ETH/FEB23 | buy  | 1      | 15800 | 0                | TYPE_LIMIT | TIF_GTC | b-GTC-2   |
    72  
    73      #order margin short: (2*15910+1*15920)*0.3=14322
    74      #order margin long: 2*15800*0.3=9480
    75      And the parties should have the following margin levels:
    76        | party  | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
    77        | party1 | ETH/FEB23 | 0           | 0      | 0       | 0       | isolated margin | 0.3           | 14322 |
    78  
    79      #AC: 0019-MCAL-203, when party has no position, and place short orders size -3 during auction, and long orders size 3 which can offset, order margin should be updated using max(price, markPrice, indicativePrice)
    80      And the parties place the following orders:
    81        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    82        | party1 | ETH/FEB23 | buy  | 1      | 15800 | 0                | TYPE_LIMIT | TIF_GTC | b-GTC-3   |
    83  
    84      #order margin short: (2*15910+1*15920)*0.3=14322
    85      #order margin long: 3*15800*0.3=14220
    86      And the parties should have the following margin levels:
    87        | party  | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
    88        | party1 | ETH/FEB23 | 0           | 0      | 0       | 0       | isolated margin | 0.3           | 14322 |
    89  
    90      #AC: 0019-MCAL-204, when party has no position, and place short orders size -3 during auction, and long orders size 4, which is over the offset size, order margin should be updated using max(price, markPrice, indicativePrice)
    91      #order margin short: (2*15910+1*15920)*0.3=14322
    92      #order margin long: 4*15900*0.3=19080
    93      And the parties place the following orders:
    94        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    95        | party1 | ETH/FEB23 | buy  | 1      | 15800 | 0                | TYPE_LIMIT | TIF_GTC | b-GTC-4   |
    96  
    97      And the parties should have the following margin levels:
    98        | party  | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
    99        | party1 | ETH/FEB23 | 0           | 0      | 0       | 0       | isolated margin | 0.3           | 19080 |
   100  
   101      #AC: 0019-MCAL-205,When the party changes the order price during auction, order margin should be updated using max(price, markPrice, indicativePrice)
   102      When the parties amend the following orders:
   103        | party  | reference | price | size delta | tif     | error |
   104        | party1 | b-GTC-3   | 15750 | 0          | TIF_GTC |       |
   105      When the network moves ahead "1" blocks
   106      And the parties should have the following margin levels:
   107        | party  | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
   108        | party1 | ETH/FEB23 | 0           | 0      | 0       | 0       | isolated margin | 0.3           | 19080 |
   109  
   110      #AC: 0019-MCAL-206,When the party reduces the order size only during auction, the order margin should be reduced 
   111      When the parties amend the following orders:
   112        | party  | reference | price | size delta | tif     | error |
   113        | party1 | b-GTC-4   | 15800 | -1         | TIF_GTC |       |
   114  
   115      And the orders should have the following status:
   116        | party  | reference | status           |
   117        | party1 | b-GTC-4   | STATUS_CANCELLED |
   118  
   119      And the parties should have the following margin levels:
   120        | party  | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
   121        | party1 | ETH/FEB23 | 0           | 0      | 0       | 0       | isolated margin | 0.3           | 14322 |
   122      When the network moves ahead "2" blocks
   123  
   124      And the market data for the market "ETH/FEB23" should be:
   125        | mark price | trading mode            |
   126        | 15900      | TRADING_MODE_CONTINUOUS |
   127  
   128      #order margin long: 3*15800*0.3=14220
   129      #order margin short: (2*15910+1*15920)*0.3=14322
   130      And the parties should have the following margin levels:
   131        | party  | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
   132        | party1 | ETH/FEB23 | 0           | 0      | 0       | 0       | isolated margin | 0.3           | 14322 |
   133  
   134      #AC: 0019-MCAL-207, when party has no position, and place 2 short orders size 3 and 4 long orders of size 4, which is over the offset size, order margin should be updated using max(price, markPrice, indicativePrice)
   135      #order margin long: (3*15800+15750)*0.3=18945
   136      #order margin short: (2*15910+1*15920)*0.3=14322
   137      And the parties place the following orders:
   138        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   139        | party1 | ETH/FEB23 | buy  | 1      | 15800 | 0                | TYPE_LIMIT | TIF_GTC | b-GTC-4   |
   140  
   141      And the parties should have the following margin levels:
   142        | party  | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
   143        | party1 | ETH/FEB23 | 0           | 0      | 0       | 0       | isolated margin | 0.3           | 18945 |
   144