code.vegaprotocol.io/vega@v0.79.0/core/integration/features/closeouts/1847-closeout-long.feature (about) 1 Feature: Long close-out test (see ln 293 of system-tests/grpc/trading/tradesTests.py & https://github.com/vegaprotocol/scenario-runner/tree/develop/scenarios/QA/issues/86) 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-simple-risk-model-4 | 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 | market.auction.minimumDuration | 1 | 10 | network.markPriceUpdateMaximumFrequency | 0s | 11 | limits.markets.maxPeggedOrders | 2 | 12 13 Scenario: https://drive.google.com/file/d/1bYWbNJvG7E-tcqsK26JMu2uGwaqXqm0L/view 14 # setup accounts 15 Given the parties deposit on asset's general account the following amount: 16 | party | asset | amount | 17 | tt_4 | BTC | 500000 | 18 | tt_5 | BTC | 100 | 19 | tt_6 | BTC | 100000000 | 20 | tt_10 | BTC | 10000000 | 21 | tt_11 | BTC | 10000000 | 22 | tt_aux | BTC | 100000000 | 23 | t2_aux | BTC | 100000000 | 24 | lpprov | BTC | 100000000 | 25 26 # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction 27 Then the parties place the following orders: 28 | party | market id | side | volume | price | resulting trades | type | tif | reference | 29 | tt_aux | ETH/DEC19 | buy | 1 | 1 | 0 | TYPE_LIMIT | TIF_GTC | aux-b-1 | 30 | tt_aux | ETH/DEC19 | sell | 1 | 200 | 0 | TYPE_LIMIT | TIF_GTC | aux-s-1 | 31 | t2_aux | ETH/DEC19 | buy | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | aux-b-2 | 32 | tt_aux | ETH/DEC19 | sell | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | aux-s-2 | 33 And the parties submit the following liquidity provision: 34 | id | party | market id | commitment amount | fee | lp type | 35 | lp1 | lpprov | ETH/DEC19 | 90000 | 0.1 | submission | 36 | lp1 | lpprov | ETH/DEC19 | 90000 | 0.1 | submission | 37 And the parties place the following pegged iceberg orders: 38 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 39 | lpprov | ETH/DEC19 | 2 | 1 | buy | MID | 50 | 100 | 40 | lpprov | ETH/DEC19 | 2 | 1 | sell | MID | 50 | 100 | 41 Then the opening auction period ends for market "ETH/DEC19" 42 43 # place orders and generate trades 44 When the parties place the following orders "1" blocks apart: 45 | party | market id | side | volume | price | resulting trades | type | tif | reference | expires in | 46 | tt_10 | ETH/DEC19 | buy | 5 | 100 | 0 | TYPE_LIMIT | TIF_GTT | tt_10-1 | 3600 | 47 | tt_11 | ETH/DEC19 | sell | 5 | 100 | 1 | TYPE_LIMIT | TIF_GTT | tt_11-1 | 3600 | 48 | tt_4 | ETH/DEC19 | buy | 2 | 150 | 0 | TYPE_LIMIT | TIF_GTC | tt_4-1 | | 49 | tt_4 | ETH/DEC19 | buy | 2 | 150 | 0 | TYPE_LIMIT | TIF_GTC | tt_4-2 | | 50 | tt_5 | ETH/DEC19 | buy | 2 | 150 | 0 | TYPE_LIMIT | TIF_GTC | tt_5-1 | | 51 | tt_6 | ETH/DEC19 | sell | 2 | 150 | 1 | TYPE_LIMIT | TIF_GTC | tt_6-1 | | 52 | tt_5 | ETH/DEC19 | buy | 2 | 150 | 0 | TYPE_LIMIT | TIF_GTC | tt_5-2 | | 53 | tt_6 | ETH/DEC19 | sell | 2 | 150 | 1 | TYPE_LIMIT | TIF_GTC | tt_6-2 | | 54 | tt_10 | ETH/DEC19 | buy | 25 | 100 | 0 | TYPE_LIMIT | TIF_GTC | tt_10-2 | | 55 | tt_11 | ETH/DEC19 | sell | 25 | 0 | 3 | TYPE_MARKET | TIF_FOK | tt_11-2 | | 56 And the network moves ahead "1" blocks 57 58 And the mark price should be "100" for the market "ETH/DEC19" 59 60 # checking margins 61 Then the parties should have the following account balances: 62 | party | asset | market id | margin | general | 63 | tt_5 | BTC | ETH/DEC19 | 0 | 0 | 64 65 # then we make sure the insurance pool collected the funds 66 And the insurance pool balance should be "0" for the market "ETH/DEC19" 67 68 #check positions 69 Then the parties should have the following profit and loss: 70 | party | volume | unrealised pnl | realised pnl | 71 | tt_4 | 4 | -200 | 0 | 72 | tt_5 | 0 | 0 | -100 | 73 | tt_6 | -4 | 200 | -27 | 74 | tt_10 | 30 | 0 | 0 | 75 | tt_11 | -30 | 200 | -65 |