code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/0019-MCAL-margin_calculator-verified_margins_case3.feature (about) 1 Feature: CASE-3: Trader submits long order that will trade - new formula & zero side of order book (0019-MCAL-001, 0019-MCAL-002) 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 And the markets: 11 | id | quote name | asset | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | 12 | ETH/DEC19 | ETH | ETH | default-simple-risk-model | default-overkill-margin-calculator | 1 | default-none | default-none | default-eth-for-future | 1e0 | 0 | default-futures | 13 And the parties deposit on asset's general account the following amount: 14 | party | asset | amount | 15 | party1 | ETH | 1000000000 | 16 | sellSideMM | ETH | 2000000000 | 17 | buySideMM | ETH | 2000000000 | 18 | aux | ETH | 1000000000 | 19 | aux2 | ETH | 1000000000 | 20 | lpprov | ETH | 1000000000 | 21 22 When the parties submit the following liquidity provision: 23 | id | party | market id | commitment amount | fee | lp type | 24 | lp1 | lpprov | ETH/DEC19 | 900000000 | 0.1 | submission | 25 | lp1 | lpprov | ETH/DEC19 | 900000000 | 0.1 | submission | 26 And the parties place the following pegged iceberg orders: 27 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 28 | lpprov | ETH/DEC19 | 600 | 1 | buy | BID | 600 | 10 | 29 | lpprov | ETH/DEC19 | 600 | 1 | sell | ASK | 600 | 10 | 30 31 # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction 32 Then the parties place the following orders: 33 | party | market id | side | volume | price | resulting trades | type | tif | reference | 34 | aux | ETH/DEC19 | buy | 1 | 7900000 | 0 | TYPE_LIMIT | TIF_GTC | cancel-me-buy | 35 | aux | ETH/DEC19 | sell | 1 | 25000000 | 0 | TYPE_LIMIT | TIF_GTC | cancel-me-sell | 36 | aux | ETH/DEC19 | buy | 1 | 10300000 | 0 | TYPE_LIMIT | TIF_GTC | aux-b-1 | 37 | aux2 | ETH/DEC19 | sell | 1 | 10300000 | 0 | TYPE_LIMIT | TIF_GTC | aux-s-1 | 38 Then the opening auction period ends for market "ETH/DEC19" 39 And the mark price should be "10300000" for the market "ETH/DEC19" 40 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" 41 42 # setting mark price 43 And the parties place the following orders: 44 | party | market id | side | volume | price | resulting trades | type | tif | reference | 45 | sellSideMM | ETH/DEC19 | sell | 1 | 10300000 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 46 | buySideMM | ETH/DEC19 | buy | 1 | 10300000 | 1 | TYPE_LIMIT | TIF_GTC | ref-2 | 47 48 # setting order book 49 And the parties place the following orders: 50 | party | market id | side | volume | price | resulting trades | type | tif | reference | 51 | sellSideMM | ETH/DEC19 | sell | 11 | 14000000 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 52 | sellSideMM | ETH/DEC19 | sell | 100 | 25000000 | 0 | TYPE_LIMIT | TIF_GTC | ref-2 | 53 | sellSideMM | ETH/DEC19 | sell | 2 | 11200000 | 0 | TYPE_LIMIT | TIF_GTC | ref-3 | 54 55 Then the parties cancel the following orders: 56 | party | reference | 57 | aux | cancel-me-sell | 58 59 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" 60 61 Scenario: 62 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" 63 64 # placing test order 65 When the parties place the following orders with ticks: 66 | party | market id | side | volume | price | resulting trades | type | tif | reference | 67 | party1 | ETH/DEC19 | buy | 13 | 15000000 | 2 | TYPE_LIMIT | TIF_GTC | ref-1 | 68 And "party1" should have general account balance of "114360000" for asset "ETH" 69 And the following trades should be executed: 70 | buyer | price | size | seller | 71 | party1 | 11200000 | 2 | sellSideMM | 72 | party1 | 14000000 | 11 | sellSideMM | 73 74 Then the following transfers should happen: 75 | from | to | from account | to account | market id | amount | asset | 76 | market | party1 | ACCOUNT_TYPE_SETTLEMENT | ACCOUNT_TYPE_MARGIN | ETH/DEC19 | 5600000 | ETH | 77 78 Then the parties should have the following account balances: 79 | party | asset | market id | margin | general | 80 | party1 | ETH | ETH/DEC19 | 873600000 | 114360000 | 81 And the parties should have the following margin levels: 82 | party | market id | maintenance | search | initial | release | 83 | party1 | ETH/DEC19 | 218400000 | 698880000 | 873600000 | 1092000000 | 84 And the parties should have the following profit and loss: 85 | party | volume | unrealised pnl | realised pnl | 86 | party1 | 13 | 5600000 | 0 | 87 88 # ANOTHER TRADE HAPPENING (BY A DIFFERENT PARTY) 89 # updating mark price to 160 90 When the parties place the following orders with ticks: 91 | party | market id | side | volume | price | resulting trades | type | tif | reference | 92 | sellSideMM | ETH/DEC19 | sell | 1 | 16000000 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 93 | buySideMM | ETH/DEC19 | buy | 1 | 16000000 | 1 | TYPE_LIMIT | TIF_GTC | ref-2 | 94 95 And the following transfers should happen: 96 | from | to | from account | to account | market id | amount | asset | 97 | market | party1 | ACCOUNT_TYPE_SETTLEMENT | ACCOUNT_TYPE_MARGIN | ETH/DEC19 | 26000000 | ETH | 98 99 Then the parties should have the following account balances: 100 | party | asset | market id | margin | general | 101 | party1 | ETH | ETH/DEC19 | 899600000 | 114360000 | 102 And the parties should have the following margin levels: 103 | party | market id | maintenance | search | initial | release | 104 | party1 | ETH/DEC19 | 249600000 | 798720000 | 998400000 | 1248000000 | 105 And the parties should have the following profit and loss: 106 | party | volume | unrealised pnl | realised pnl | 107 | party1 | 13 | 31600000 | 0 | 108 109 # CLOSEOUT ATTEMPT (FAILED, no buy-side in order book) BY TRADER 110 When the parties place the following orders with ticks: 111 | party | market id | side | volume | price | resulting trades | type | tif | 112 | party1 | ETH/DEC19 | sell | 13 | 8000000 | 0 | TYPE_LIMIT | TIF_GTC | 113 Then the parties should have the following account balances: 114 | party | asset | market id | margin | general | 115 | party1 | ETH | ETH/DEC19 | 899600000 | 114360000 | 116 And the parties should have the following margin levels: 117 | party | market id | maintenance | search | initial | release | 118 | party1 | ETH/DEC19 | 249600000 | 798720000 | 998400000 | 1248000000 | 119 And the parties should have the following profit and loss: 120 | party | volume | unrealised pnl | realised pnl | 121 | party1 | 13 | 31600000 | 0 | 122