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

     1  Feature: Test party accounts margins with fractional orders - the test is identical to margin.feature just with 2 position decimal places and all volumes are scaled by 10^2, to demonstrate that margins are calculated correctly (0019-MCAL-008)
     2  
     3    Background:
     4  
     5      Given the following network parameters are set:
     6        | name                                    | value |
     7        | market.auction.minimumDuration          | 1     |
     8        | network.markPriceUpdateMaximumFrequency | 0s    |
     9        | limits.markets.maxPeggedOrders          | 2     |
    10        | limits.markets.maxPeggedOrders          | 2     |
    11      And the markets:
    12        | id        | quote name | asset | risk model                  | margin calculator         | auction duration | fees         | price monitoring | data source config     | position decimal places | linear slippage factor | quadratic slippage factor | sla params      |
    13        | ETH/DEC19 | ETH        | ETH   | default-simple-risk-model-3 | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 2                       | 0.25                   | 0                         | default-futures |
    14  
    15    Scenario: a party place a new order in the system, margin are calculated
    16      Given the parties deposit on asset's general account the following amount:
    17        | party    | asset | amount       |
    18        | partyGuy | ETH   | 10000        |
    19        | party1   | ETH   | 1000000      |
    20        | party2   | ETH   | 1000000      |
    21        | aux      | ETH   | 100000000000 |
    22        | lpprov   | ETH   | 1000000000   |
    23  
    24      When the parties submit the following liquidity provision:
    25        | id  | party  | market id | commitment amount | fee | lp type    |
    26        | lp1 | lpprov | ETH/DEC19 | 900000000         | 0.1 | submission |
    27        | lp1 | lpprov | ETH/DEC19 | 900000000         | 0.1 | submission |
    28      And the parties place the following pegged iceberg orders:
    29        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    30        | lpprov | ETH/DEC19 | 2         | 1                    | buy  | BID              | 50         | 10     |
    31        | lpprov | ETH/DEC19 | 2         | 1                    | sell | ASK              | 50         | 10     |
    32  
    33      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
    34      Then the parties place the following orders:
    35        | party | market id | side | volume | price | resulting trades | type       | tif     |
    36        | aux   | ETH/DEC19 | buy  | 100    | 9     | 0                | TYPE_LIMIT | TIF_GTC |
    37        | aux   | ETH/DEC19 | sell | 100    | 10001 | 0                | TYPE_LIMIT | TIF_GTC |
    38  
    39      # Trigger an auction to set the mark price
    40      When the parties place the following orders:
    41        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    42        | party1 | ETH/DEC19 | buy  | 100    | 10    | 0                | TYPE_LIMIT | TIF_GTC | party1-1  |
    43        | party2 | ETH/DEC19 | sell | 100    | 10000 | 0                | TYPE_LIMIT | TIF_GTC | party2-1  |
    44        | party1 | ETH/DEC19 | buy  | 100    | 1000  | 0                | TYPE_LIMIT | TIF_GFA | party1-2  |
    45        | party2 | ETH/DEC19 | sell | 100    | 1000  | 0                | TYPE_LIMIT | TIF_GFA | party2-2  |
    46      Then the opening auction period ends for market "ETH/DEC19"
    47      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
    48      And the mark price should be "1000" for the market "ETH/DEC19"
    49      Then the parties cancel the following orders:
    50        | party  | reference |
    51        | party1 | party1-1  |
    52        | party2 | party2-1  |
    53  
    54      When the parties place the following orders with ticks:
    55        | party    | market id | side | volume | price | resulting trades | type       | tif     | reference |
    56        | partyGuy | ETH/DEC19 | sell | 100    | 1000  | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    57      Then the parties should have the following margin levels:
    58        | party    | market id | maintenance | search | initial | release |
    59        | partyGuy | ETH/DEC19 | 100         | 110    | 120     | 140     |
    60      Then the parties should have the following account balances:
    61        | party    | asset | market id | margin | general |
    62        | partyGuy | ETH   | ETH/DEC19 | 120    | 9880    |
    63  
    64    Scenario: an order is rejected if a party have insufficient margin
    65      Given the parties deposit on asset's general account the following amount:
    66        | party    | asset | amount     |
    67        | partyGuy | ETH   | 1          |
    68        | party1   | ETH   | 1000000    |
    69        | party2   | ETH   | 1000000    |
    70        | lpprov   | ETH   | 1000000000 |
    71  
    72      When the parties submit the following liquidity provision:
    73        | id  | party  | market id | commitment amount | fee | lp type    |
    74        | lp1 | lpprov | ETH/DEC19 | 900000000         | 0.1 | submission |
    75        | lp1 | lpprov | ETH/DEC19 | 900000000         | 0.1 | submission |
    76      And the parties place the following pegged iceberg orders:
    77        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    78        | lpprov | ETH/DEC19 | 2         | 1                    | buy  | BID              | 50         | 10     |
    79        | lpprov | ETH/DEC19 | 2         | 1                    | sell | ASK              | 50         | 10     |
    80   
    81      # Trigger an auction to set the mark price
    82      When the parties place the following orders:
    83        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    84        | party1 | ETH/DEC19 | buy  | 100    | 10    | 0                | TYPE_LIMIT | TIF_GTC | party1-1  |
    85        | party2 | ETH/DEC19 | sell | 100    | 10000 | 0                | TYPE_LIMIT | TIF_GTC | party2-1  |
    86        | party1 | ETH/DEC19 | buy  | 100    | 1000  | 0                | TYPE_LIMIT | TIF_GFA | party1-2  |
    87        | party2 | ETH/DEC19 | sell | 100    | 1000  | 0                | TYPE_LIMIT | TIF_GFA | party2-2  |
    88      Then the opening auction period ends for market "ETH/DEC19"
    89      And the mark price should be "1000" for the market "ETH/DEC19"
    90      Then the parties cancel the following orders:
    91        | party  | reference |
    92        | party1 | party1-1  |
    93        | party2 | party2-1  |
    94  
    95      When the parties place the following orders with ticks:
    96        | party    | market id | side | volume | price | type       | tif     | reference | error               |
    97        | partyGuy | ETH/DEC19 | sell | 100    | 1000  | TYPE_LIMIT | TIF_GTC | party1-1  | margin check failed |
    98      Then the following orders should be rejected:
    99        | party    | market id | reason                          |
   100        | partyGuy | ETH/DEC19 | ORDER_ERROR_MARGIN_CHECK_FAILED |