code.vegaprotocol.io/vega@v0.79.0/core/integration/features/margin/767-margin-level-check.feature (about)

     1  Feature: Regression test for issue 767
     2  
     3    Background:
     4      Given the markets:
     5        | id        | quote name | asset | risk model                    | margin calculator         | auction duration | fees         | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | sla params      |
     6        | ETH/DEC19 | BTC        | BTC   | default-log-normal-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.25                   | 0                         | default-futures |
     7      And the following network parameters are set:
     8        | name                                    | value |
     9        | network.markPriceUpdateMaximumFrequency | 0s    |
    10        | limits.markets.maxPeggedOrders          | 2     |
    11  
    12    Scenario: Traders place orders meeting the maintenance margin, but not the initial margin requirements, and can close out
    13      Given the parties deposit on asset's general account the following amount:
    14        | party  | asset | amount  |
    15        | edd    | BTC   | 1026    |
    16        | barney | BTC   | 1000    |
    17        | party1 | BTC   | 1000000 |
    18        | party2 | BTC   | 1000000 |
    19        | aux    | BTC   | 100000  |
    20        | lpprov | BTC   | 1000000 |
    21  
    22      When the parties submit the following liquidity provision:
    23        | id  | party  | market id | commitment amount | fee | lp type    |
    24        | lp1 | lpprov | ETH/DEC19 | 900000            | 0.1 | submission |
    25        | lp1 | lpprov | ETH/DEC19 | 900000            | 0.1 | submission |
    26      And the parties place the following pegged iceberg orders:
    27        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    28        | lpprov | ETH/DEC19 | 2         | 1                    | buy  | BID              | 50         | 100    |
    29        | lpprov | ETH/DEC19 | 2         | 1                    | sell | ASK              | 50         | 100    |
    30  
    31      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
    32      When the parties place the following orders:
    33        | party | market id | side | volume | price | resulting trades | type       | tif     |
    34        | aux   | ETH/DEC19 | buy  | 1      | 1     | 0                | TYPE_LIMIT | TIF_GTC |
    35        | aux   | ETH/DEC19 | sell | 1      | 10001 | 0                | TYPE_LIMIT | TIF_GTC |
    36  
    37      # Trigger an auction to set the mark price
    38      When the parties place the following orders:
    39        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    40        | party1 | ETH/DEC19 | buy  | 1      | 10    | 0                | TYPE_LIMIT | TIF_GTC | party1-1  |
    41        | party2 | ETH/DEC19 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | party2-1  |
    42        | party1 | ETH/DEC19 | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GFA | party1-2  |
    43        | party2 | ETH/DEC19 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GFA | party2-2  |
    44      Then the opening auction period ends for market "ETH/DEC19"
    45      And the mark price should be "100" for the market "ETH/DEC19"
    46      Then the parties cancel the following orders:
    47        | party  | reference |
    48        | party1 | party1-1  |
    49        | party2 | party2-1  |
    50  
    51      When the parties place the following orders with ticks:
    52        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    53        | edd    | ETH/DEC19 | sell | 20     | 101   | 0                | TYPE_LIMIT | TIF_GTC |
    54        | edd    | ETH/DEC19 | sell | 20     | 102   | 0                | TYPE_LIMIT | TIF_GTC |
    55        | edd    | ETH/DEC19 | sell | 10     | 103   | 0                | TYPE_LIMIT | TIF_GTC |
    56        | edd    | ETH/DEC19 | sell | 15     | 104   | 0                | TYPE_LIMIT | TIF_GTC |
    57        | edd    | ETH/DEC19 | sell | 30     | 105   | 0                | TYPE_LIMIT | TIF_GTC |
    58        | barney | ETH/DEC19 | buy  | 20     | 99    | 0                | TYPE_LIMIT | TIF_GTC |
    59        | barney | ETH/DEC19 | buy  | 12     | 98    | 0                | TYPE_LIMIT | TIF_GTC |
    60        | barney | ETH/DEC19 | buy  | 14     | 97    | 0                | TYPE_LIMIT | TIF_GTC |
    61        | barney | ETH/DEC19 | buy  | 20     | 96    | 0                | TYPE_LIMIT | TIF_GTC |
    62        | barney | ETH/DEC19 | buy  | 5      | 95    | 0                | TYPE_LIMIT | TIF_GTC |
    63      Then the parties should have the following account balances:
    64        | party  | asset | market id | margin | general |
    65        | edd    | BTC   | ETH/DEC19 | 848    | 178     |
    66        | barney | BTC   | ETH/DEC19 | 594    | 406     |
    67      When the parties place the following orders with ticks:
    68        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
    69        | edd   | ETH/DEC19 | sell | 20     | 101   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    70      Then the parties should have the following account balances:
    71        | party  | asset | market id | margin | general |
    72        | edd    | BTC   | ETH/DEC19 | 1026   | 0       |
    73        | barney | BTC   | ETH/DEC19 | 594    | 406     |
    74      And the cumulated balance for all accounts should be worth "3102026"
    75      When the parties place the following orders with ticks:
    76        | party | market id | side | volume | price | resulting trades | type       | tif     |
    77        | edd   | ETH/DEC19 | buy  | 115    | 100   | 0                | TYPE_LIMIT | TIF_GTC |
    78      Then the parties should have the following account balances:
    79        | party  | asset | market id | margin | general |
    80        | edd    | BTC   | ETH/DEC19 | 1026   | 0       |
    81        | barney | BTC   | ETH/DEC19 | 594    | 406     |
    82      And the cumulated balance for all accounts should be worth "3102026"