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

     1  Feature: Amending order partially trades, plenty of balance to cover the order amendment + trades + fees
     2    Background:
     3      Given the average block duration is "1"
     4      And the following network parameters are set:
     5        | name                                    | value |
     6        | network.markPriceUpdateMaximumFrequency | 0s    |
     7        | limits.markets.maxPeggedOrders          | 6     |
     8        | market.auction.minimumDuration          | 1     |
     9      And the price monitoring named "my-price-monitoring-1":
    10        | horizon | probability | auction extension |
    11        | 5       | 0.99        | 6                 |
    12  
    13      And the liquidity monitoring parameters:
    14        | name       | triggering ratio | time window | scaling factor |
    15        | lqm-params | 0.00             | 24h         | 1e-9           |
    16      And the simple risk model named "simple-risk-model":
    17        | long | short | max move up | min move down | probability of trading |
    18        | 0.1  | 0.2   | 100         | -100          | 0.2                    |
    19      And the markets:
    20        | id        | quote name | asset | liquidity monitoring | risk model        | margin calculator         | auction duration | fees         | price monitoring      | data source config     | linear slippage factor | quadratic slippage factor | position decimal places | sla params      |
    21        | ETH/FEB23 | ETH        | USD   | lqm-params           | simple-risk-model | default-margin-calculator | 1                | default-none | my-price-monitoring-1 | default-eth-for-future | 0.000125               | 0                         | 2                       | default-futures |
    22  
    23    @MCAL202
    24    Scenario:
    25      Given the parties deposit on asset's general account the following amount:
    26        | party   | asset | amount       |
    27        | trader1 | USD   | 100000000000 |
    28        | trader2 | USD   | 100000000000 |
    29        | trader3 | USD   | 100000000000 |
    30        | trader4 | USD   | 100000000000 |
    31        | lprov1  | USD   | 100000000000 |
    32  
    33      And the parties submit the following liquidity provision:
    34        | id  | party  | market id | commitment amount | fee | lp type    |
    35        | lp1 | lprov1 | ETH/FEB23 | 1000              | 0.1 | submission |
    36  
    37      And the parties place the following orders with ticks:
    38        | party   | market id | side | volume | price  | resulting trades | type       | tif     | reference |
    39        | trader1 | ETH/FEB23 | buy  | 1000   | 14900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    40        | trader1 | ETH/FEB23 | buy  | 300    | 15600  | 0                | TYPE_LIMIT | TIF_GTC |           |
    41        | lprov1  | ETH/FEB23 | buy  | 100    | 15700  | 0                | TYPE_LIMIT | TIF_GTC | lp-buy-1  |
    42        | trader3 | ETH/FEB23 | buy  | 300    | 15800  | 0                | TYPE_LIMIT | TIF_GTC |           |
    43        | lprov1  | ETH/FEB23 | sell | 300    | 15800  | 0                | TYPE_LIMIT | TIF_GTC | lp-sell-1 |
    44        | trader2 | ETH/FEB23 | sell | 600    | 15802  | 0                | TYPE_LIMIT | TIF_GTC | t2-sell-1 |
    45        | trader2 | ETH/FEB23 | sell | 300    | 200000 | 0                | TYPE_LIMIT | TIF_GTC |           |
    46        | trader2 | ETH/FEB23 | sell | 1000   | 200100 | 0                | TYPE_LIMIT | TIF_GTC |           |
    47  
    48      When the network moves ahead "2" blocks
    49      Then the market data for the market "ETH/FEB23" should be:
    50        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
    51        | 15800      | TRADING_MODE_CONTINUOUS | 5       | 15701     | 15899     | 0            | 1000           | 300           |
    52  
    53      When the parties place the following pegged orders:
    54        | party  | market id | side | volume | pegged reference | offset | reference |
    55        | lprov1 | ETH/FEB23 | buy  | 100    | BID              | 10     | buy_peg_1 |
    56        | lprov1 | ETH/FEB23 | buy  | 200    | BID              | 20     | buy_peg_2 |
    57  
    58      Then the parties should have the following margin levels:
    59        | party   | market id | maintenance | margin mode  | margin factor | order |
    60        | lprov1  | ETH/FEB23 | 9486        | cross margin | 0             | 0     |
    61        | trader1 | ETH/FEB23 | 20540       | cross margin | 0             | 0     |
    62        | trader3 | ETH/FEB23 | 4746        | cross margin | 0             | 0     |
    63  
    64      When the parties place the following orders with ticks:
    65        | party   | market id | side | volume | price | resulting trades | type       | tif     | reference    |
    66        | trader3 | ETH/FEB23 | buy  | 100    | 15500 | 0                | TYPE_LIMIT | TIF_GTC | t3-to-amend  |
    67        | trader4 | ETH/FEB23 | sell | 5      | 15801 | 0                | TYPE_LIMIT | TIF_GTC | t4-for-amend |
    68      Then the parties should have the following margin levels:
    69        | party   | market id | maintenance | margin mode  | margin factor | order |
    70        | trader3 | ETH/FEB23 | 6326        | cross margin | 0             | 0     |
    71  
    72      When the parties submit update margin mode:
    73        | party   | market    | margin_mode     | margin_factor | error |
    74        | trader3 | ETH/FEB23 | isolated margin | 0.3           |       |
    75      Then the parties should have the following margin levels:
    76        | party   | market id | maintenance | search | release | margin mode     | margin factor | order |
    77        | trader3 | ETH/FEB23 | 4746        | 0      | 0       | isolated margin | 0.3           | 4650  |
    78      And the parties should have the following account balances:
    79        | party   | asset | market id | margin | general     | order margin |
    80        | trader3 | USD   | ETH/FEB23 | 14220  | 99999981130 | 4650         |
    81  
    82      # amend the order to increase the required margin, and the order partially trades (trader4 has a buy position for 5 @ 15801)
    83      When the parties amend the following orders:
    84        | party   | reference   | price | size delta | tif     | error |
    85        | trader3 | t3-to-amend | 15801 | -90        | TIF_GTC |       |
    86      Then the orders should have the following status:
    87        | party   | reference   | status        |
    88        | trader3 | t3-to-amend | STATUS_ACTIVE |
    89      And the parties should have the following margin levels:
    90        | party   | market id | maintenance | search | release | margin mode     | margin factor | order |
    91        | trader3 | ETH/FEB23 | 4826        | 0      | 0       | isolated margin | 0.3           | 237   |
    92      And the parties should have the following account balances:
    93        | party   | asset | market id | margin | general     | order margin |
    94        | trader3 | USD   | ETH/FEB23 | 14457  | 99999985226 | 237          |
    95