code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/0006-POSI-AC009.feature (about)

     1  Feature: test AC 006-POSI-009, 006-POSI-027
     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 | 4                      | 0                         | default-futures |
     7      And the following network parameters are set:
     8        | name                                    | value |
     9        | market.auction.minimumDuration          | 1     |
    10        | network.markPriceUpdateMaximumFrequency | 0s    |
    11        | limits.markets.maxPeggedOrders          | 2     |
    12  
    13    Scenario:  Open long position, trades occur closing the long position and opening a short position (006-POSI-009; 006-POSI-027)
    14      Given the parties deposit on asset's general account the following amount:
    15        | party  | asset | amount   |
    16        | party1 | ETH   | 10000    |
    17        | party2 | ETH   | 10000    |
    18        | party3 | ETH   | 10000    |
    19        | aux    | ETH   | 100000   |
    20        | aux2   | ETH   | 100000   |
    21        | aux3   | ETH   | 100000   |
    22        | lpprov | ETH   | 10000000 |
    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 | 9000              | 0.1 | submission |
    27        | lp1 | lpprov | ETH/DEC19 | 9000              | 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      And the parties place the following orders:
    35        | party | market id | side | volume | price | resulting trades | type       | tif     |
    36        | aux   | ETH/DEC19 | buy  | 5      | 49    | 0                | TYPE_LIMIT | TIF_GTC |
    37        | aux   | ETH/DEC19 | sell | 5      | 5001  | 0                | TYPE_LIMIT | TIF_GTC |
    38        | aux2  | ETH/DEC19 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    39        | aux   | ETH/DEC19 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    40  
    41      Then the opening auction period ends for market "ETH/DEC19"
    42      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
    43      And the settlement account should have a balance of "0" for the market "ETH/DEC19"
    44  
    45      When the parties place the following orders with ticks:
    46        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    47        | party1 | ETH/DEC19 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    48        | party2 | ETH/DEC19 | buy  | 1      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
    49      Then the parties should have the following account balances:
    50        | party  | asset | market id | margin | general |
    51        | party1 | ETH   | ETH/DEC19 | 4920   | 5080    |
    52        | party2 | ETH   | ETH/DEC19 | 4932   | 4968    |
    53  
    54      # party3 does not have position record exist since party3 does not have either an open position nor active order
    55      Then the parties should have the following profit and loss:
    56        | party  | volume | unrealised pnl | realised pnl |
    57        | aux    | -1     | 0              | 0            |
    58        | aux2   | 1      | 0              | 0            |
    59        | party1 | -1     | 0              | 0            |
    60        | party2 | 1      | 0              | 0            |
    61  
    62      And the settlement account should have a balance of "0" for the market "ETH/DEC19"
    63      When the parties place the following orders with ticks:
    64        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    65        | party1 | ETH/DEC19 | sell | 1      | 2000  | 0                | TYPE_LIMIT | TIF_GTC |
    66      Then the parties should have the following account balances:
    67        | party  | asset | market id | margin | general |
    68        | party1 | ETH   | ETH/DEC19 | 5040   | 4960    |
    69    
    70      # update linear slippage factor more in line with what book-based slippage used to be
    71      And the markets are updated:
    72          | id          | linear slippage factor |
    73          | ETH/DEC19   | 1.5                    |
    74  
    75      When the parties place the following orders with ticks:
    76        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    77        | party3 | ETH/DEC19 | buy  | 1      | 2000  | 1                | TYPE_LIMIT | TIF_GTC |
    78      Then the parties should have the following account balances:
    79        | party  | asset | market id | margin | general |
    80        | party1 | ETH   | ETH/DEC19 | 7680   | 1320    |
    81        | party2 | ETH   | ETH/DEC19 | 3864   | 7036    |
    82        | party3 | ETH   | ETH/DEC19 | 3864   | 5936    |
    83  
    84      Then the following transfers should happen:
    85        | from   | to     | from account        | to account              | market id | amount | asset |
    86        | party1 | market | ACCOUNT_TYPE_MARGIN | ACCOUNT_TYPE_SETTLEMENT | ETH/DEC19 | 1000   | ETH   |
    87        | party1 | market | ACCOUNT_TYPE_MARGIN | ACCOUNT_TYPE_SETTLEMENT | ETH/DEC19 | 1000   | ETH   |
    88      And the cumulated balance for all accounts should be worth "10330000"
    89      And the settlement account should have a balance of "0" for the market "ETH/DEC19"
    90  
    91      Then the parties should have the following profit and loss:
    92        | party  | volume | unrealised pnl | realised pnl |
    93        | aux    | -1     | -1000          | 0            |
    94        | aux2   | 1      | 1000           | 0            |
    95        | party1 | -2     | -1000          | 0            |
    96        | party2 | 1      | 1000           | 0            |
    97        | party3 | 1      | 0              | 0            |
    98  
    99      When the parties place the following orders with ticks:
   100        | party | market id | side | volume | price | resulting trades | type       | tif     |
   101        | aux2  | ETH/DEC19 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   102        | aux3  | ETH/DEC19 | buy  | 2      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   103  
   104      Then the parties should have the following profit and loss:
   105        | party  | volume | unrealised pnl | realised pnl |
   106        | aux    | -1     | 0              | 0            |
   107        #aux2 closed long position: AC 0006-POSI-009
   108        | aux2   | 0      | 0              | 0            |
   109        #aux3 opened short position
   110        | aux3   | 1      | 0              | 0            |
   111        | party1 | -2     | 1000           | 0            |
   112        | party2 | 1      | 0              | 0            |
   113        | party3 | 1      | -1000          | 0            |
   114  
   115      And the market data for the market "ETH/DEC19" should be:
   116        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   117        | 1000       | TRADING_MODE_CONTINUOUS |         |           |           | 3300         | 9000           | 3             |
   118  
   119