code.vegaprotocol.io/vega@v0.79.0/core/integration/features/margin/598-open-position-with-zero-margin.feature (about)

     1  Feature: Regression test for issue 598
     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.02                   | 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: Open position but ZERO in margin account
    13      Given the parties deposit on asset's general account the following amount:
    14        | party  | asset | amount  |
    15        | edd    | BTC   | 1000    |
    16        | barney | BTC   | 1000    |
    17        | chris  | BTC   | 1000    |
    18        | party1 | BTC   | 1000000 |
    19        | party2 | BTC   | 1000000 |
    20        | aux    | BTC   | 1000    |
    21        | lpprov | BTC   | 1000000 |
    22  
    23      When the parties submit the following liquidity provision:
    24        | id  | party  | market id | commitment amount | fee | lp type    |
    25        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
    26        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
    27      And the parties place the following pegged iceberg orders:
    28        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    29        | lpprov | ETH/DEC19 | 2         | 1                    | buy  | BID              | 50         | 100    |
    30        | lpprov | ETH/DEC19 | 2         | 1                    | sell | ASK              | 50         | 100    |
    31   
    32      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
    33      Then the parties place the following orders:
    34        | party | market id | side | volume | price | resulting trades | type       | tif     |
    35        | aux   | ETH/DEC19 | buy  | 1      | 95    | 0                | TYPE_LIMIT | TIF_GTC |
    36        | aux   | ETH/DEC19 | sell | 1      | 105   | 0                | TYPE_LIMIT | TIF_GTC |
    37  
    38      # Trigger an auction to set the mark price
    39      When the parties place the following orders:
    40        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    41        | party1 | ETH/DEC19 | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GFA | party1-2  |
    42        | party2 | ETH/DEC19 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GFA | party2-2  |
    43      Then the opening auction period ends for market "ETH/DEC19"
    44      And the mark price should be "100" for the market "ETH/DEC19"
    45      When the parties place the following orders with ticks:
    46        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    47        | edd    | ETH/DEC19 | sell | 10     | 101   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    48        | edd    | ETH/DEC19 | sell | 12     | 102   | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
    49        | edd    | ETH/DEC19 | sell | 13     | 103   | 0                | TYPE_LIMIT | TIF_GTC | ref-3     |
    50        | edd    | ETH/DEC19 | sell | 14     | 104   | 0                | TYPE_LIMIT | TIF_GTC | ref-4     |
    51        | edd    | ETH/DEC19 | sell | 15     | 105   | 0                | TYPE_LIMIT | TIF_GTC | ref-5     |
    52        | barney | ETH/DEC19 | buy  | 10     | 99    | 0                | TYPE_LIMIT | TIF_GTC | ref-6     |
    53        | barney | ETH/DEC19 | buy  | 12     | 98    | 0                | TYPE_LIMIT | TIF_GTC | ref-7     |
    54        | barney | ETH/DEC19 | buy  | 13     | 97    | 0                | TYPE_LIMIT | TIF_GTC | ref-8     |
    55        | barney | ETH/DEC19 | buy  | 14     | 96    | 0                | TYPE_LIMIT | TIF_GTC | ref-9     |
    56        | barney | ETH/DEC19 | buy  | 15     | 95    | 0                | TYPE_LIMIT | TIF_GTC | ref-10    |
    57      Then the parties should have the following account balances:
    58        | party  | asset | market id | margin | general |
    59        | edd    | BTC   | ETH/DEC19 | 571    | 429     |
    60        | barney | BTC   | ETH/DEC19 | 535    | 465     |
    61      # next instruction will trade with edd
    62      When the parties place the following orders with ticks:
    63        | party | market id | side | volume | price | resulting trades | type        | tif     | reference |
    64        | chris | ETH/DEC19 | buy  | 10     | 0     | 1                | TYPE_MARKET | TIF_IOC | ref-1     |
    65      And the average fill price is:
    66        | market     | volume | side | ref price | equivalent linear slippage factor |
    67        | ETH/DEC19  | 10     | sell | 100       | 0.02                              |
    68      # update linear slippage factor in line with what book-based slippage used to be
    69      And the markets are updated:
    70        | id          | linear slippage factor |
    71        | ETH/DEC19   | 0.0303030303030303     |
    72      Then the parties should have the following account balances:
    73        | party | asset | market id | margin | general |
    74        | edd   | BTC   | ETH/DEC19 | 571    | 429     |
    75        | chris | BTC   | ETH/DEC19 | 108    | 791     |
    76      
    77      # next instruction will trade with barney
    78      When the parties place the following orders with ticks:
    79        | party | market id | side | volume | price | resulting trades | type        | tif     | reference |
    80        | chris | ETH/DEC19 | sell | 10     | 0     | 1                | TYPE_MARKET | TIF_IOC | ref-1     |
    81      Then the parties should have the following account balances:
    82        | party  | asset | market id | margin | general |
    83        | chris  | BTC   | ETH/DEC19 | 0      | 780     |
    84        | barney | BTC   | ETH/DEC19 | 535    | 465     |
    85        | edd    | BTC   | ETH/DEC19 | 591    | 429     |
    86  
    87      Then the parties should have the following margin levels:
    88        | party  | market id | maintenance |
    89        | edd    | ETH/DEC19 | 502         |
    90        | barney | ETH/DEC19 | 471         |
    91        | chris  | ETH/DEC19 | 0           |