code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/0011-MARA-change_in_margin_figures.feature (about)

     1  Feature: Test party accounts
     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 | ETH        | ETH   | default-simple-risk-model-3 | 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: 001: A party place a new order in the system, margin are calculated (0011-MARA-001, 0011-MARA-002)
    13      Given the parties deposit on asset's general account the following amount:
    14        | party    | asset | amount       |
    15        | partyGuy | ETH   | 1000         |
    16        | party1   | ETH   | 1000000      |
    17        | party2   | ETH   | 1000000      |
    18        | aux      | ETH   | 100000000000 |
    19        | lpprov   | ETH   | 100000000000 |
    20  
    21      When the parties submit the following liquidity provision:
    22        | id  | party  | market id | commitment amount | fee | lp type    |
    23        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
    24        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
    25      And the parties place the following pegged iceberg orders:
    26        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    27        | lpprov | ETH/DEC19 | 2         | 1                    | buy  | BID              | 50         | 10     |
    28        | lpprov | ETH/DEC19 | 2         | 1                    | sell | ASK              | 50         | 10     |
    29  
    30      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
    31      Then the parties place the following orders:
    32        | party | market id | side | volume | price | resulting trades | type       | tif     |
    33        | aux   | ETH/DEC19 | buy  | 1      | 9     | 0                | TYPE_LIMIT | TIF_GTC |
    34        | aux   | ETH/DEC19 | sell | 1      | 10001 | 0                | TYPE_LIMIT | TIF_GTC |
    35  
    36      # Trigger an auction to set the mark price
    37      When the parties place the following orders:
    38        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    39        | party1 | ETH/DEC19 | buy  | 1      | 10    | 0                | TYPE_LIMIT | TIF_GTC | party1-1  |
    40        | party2 | ETH/DEC19 | sell | 1      | 10000 | 0                | TYPE_LIMIT | TIF_GTC | party2-1  |
    41        | party1 | ETH/DEC19 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GFA | party1-2  |
    42        | party2 | ETH/DEC19 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GFA | party2-2  |
    43      Then the opening auction period ends for market "ETH/DEC19"
    44      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
    45      And the mark price should be "1000" 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     | reference |
    53        | partyGuy | ETH/DEC19 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    54      Then the parties should have the following margin levels:
    55        | party    | market id | maintenance | search | initial | release |
    56        | partyGuy | ETH/DEC19 | 100         | 110    | 120     | 140     |
    57      Then the parties should have the following account balances:
    58        | party    | asset | market id | margin | general |
    59        | partyGuy | ETH   | ETH/DEC19 | 120    | 880     |
    60  
    61      # Amending order such that margin check goes through and margin account is topped up successfully
    62      When the parties amend the following orders:
    63        | party    | reference | price | size delta | tif     |
    64        | partyGuy | ref-1     | 1000  | 2          | TIF_GTC |
    65  
    66      Then the parties should have the following margin levels:
    67        | party    | market id | maintenance | search | initial | release |
    68        | partyGuy | ETH/DEC19 | 300         | 330    | 360     | 420     |
    69  
    70      Then the parties should have the following account balances:
    71        | party    | asset | market id | margin | general |
    72        | partyGuy | ETH   | ETH/DEC19 | 360    | 640     |
    73  
    74      # Amending order such that margin check fails and amend order gets rejected
    75      When the parties amend the following orders:
    76        | party    | reference | price | size delta | tif     | error               |
    77        | partyGuy | ref-1     | 1000  | 8          | TIF_GTC | margin check failed |
    78  
    79      And the order book should have the following volumes for market "ETH/DEC19":
    80        | side | price | volume |
    81        | sell | 1000  | 3      |
    82  
    83    Scenario: 002: An order is rejected if a party have insufficient margin (0011-MARA-002)
    84      Given the parties deposit on asset's general account the following amount:
    85        | party    | asset | amount  |
    86        | partyGuy | ETH   | 1       |
    87        | party1   | ETH   | 1000000 |
    88        | party2   | ETH   | 1000000 |
    89        | lpprov   | ETH   | 1000000 |
    90  
    91      When the parties submit the following liquidity provision:
    92        | id  | party  | market id | commitment amount | fee | lp type    |
    93        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
    94        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
    95      And the parties place the following pegged iceberg orders:
    96        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    97        | lpprov | ETH/DEC19 | 2         | 1                    | buy  | BID              | 50         | 10     |
    98        | lpprov | ETH/DEC19 | 2         | 1                    | sell | ASK              | 50         | 10     |
    99   
   100      # Trigger an auction to set the mark price
   101      When the parties place the following orders:
   102        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   103        | party1 | ETH/DEC19 | buy  | 1      | 10    | 0                | TYPE_LIMIT | TIF_GTC | party1-1  |
   104        | party2 | ETH/DEC19 | sell | 1      | 10000 | 0                | TYPE_LIMIT | TIF_GTC | party2-1  |
   105        | party1 | ETH/DEC19 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GFA | party1-2  |
   106        | party2 | ETH/DEC19 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GFA | party2-2  |
   107      Then the opening auction period ends for market "ETH/DEC19"
   108      And the mark price should be "1000" for the market "ETH/DEC19"
   109      Then the parties cancel the following orders:
   110        | party  | reference |
   111        | party1 | party1-1  |
   112        | party2 | party2-1  |
   113  
   114      When the parties place the following orders with ticks:
   115        | party    | market id | side | volume | price | type       | tif     | reference | error               |
   116        | partyGuy | ETH/DEC19 | sell | 1      | 1000  | TYPE_LIMIT | TIF_GTC | party1-1  | margin check failed |
   117      Then the following orders should be rejected:
   118        | party    | market id | reason                          |
   119        | partyGuy | ETH/DEC19 | ORDER_ERROR_MARGIN_CHECK_FAILED |