code.vegaprotocol.io/vega@v0.79.0/core/integration/features/margin/0019-MCAL-042.feature (about) 1 Feature: Test order margin during continuous 2 Background: 3 # Set liquidity parameters to allow "zero" target-stake which is needed to construct the order-book defined in the ACs 4 Given the following network parameters are set: 5 | name | value | 6 | network.markPriceUpdateMaximumFrequency | 0s | 7 And the liquidity monitoring parameters: 8 | name | triggering ratio | time window | scaling factor | 9 | lqm-params | 0.00 | 24h | 1e-9 | 10 And the simple risk model named "simple-risk-model": 11 | long | short | max move up | min move down | probability of trading | 12 | 0.1 | 0.2 | 100 | -100 | 0.2 | 13 And the markets: 14 | 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 | 15 | ETH/FEB23 | ETH | USD | lqm-params | simple-risk-model | default-margin-calculator | 1 | default-none | default-none | default-eth-for-future | 0.000125 | 0 | 1 | default-futures | 16 17 And the following network parameters are set: 18 | name | value | 19 | market.auction.minimumDuration | 2 | 20 Given the average block duration is "1" 21 22 Scenario: Check order margin during continuous 23 Given the parties deposit on asset's general account the following amount: 24 | party | asset | amount | 25 | buySideProvider | USD | 100000000000 | 26 | sellSideProvider | USD | 100000000000 | 27 | party1 | USD | 48050 | 28 And the parties place the following orders: 29 | party | market id | side | volume | price | resulting trades | type | tif | reference | 30 | buySideProvider | ETH/FEB23 | buy | 100 | 14900 | 0 | TYPE_LIMIT | TIF_GTC | | 31 | buySideProvider | ETH/FEB23 | buy | 10 | 15000 | 0 | TYPE_LIMIT | TIF_GTC | | 32 | party1 | ETH/FEB23 | buy | 20 | 15800 | 0 | TYPE_LIMIT | TIF_GFA | b-GFA-1 | 33 | buySideProvider | ETH/FEB23 | buy | 10 | 15900 | 0 | TYPE_LIMIT | TIF_GTC | | 34 | sellSideProvider | ETH/FEB23 | sell | 10 | 15900 | 0 | TYPE_LIMIT | TIF_GTC | | 35 | party1 | ETH/FEB23 | sell | 20 | 15910 | 0 | TYPE_LIMIT | TIF_GTC | s-GTC-2 | 36 | party1 | ETH/FEB23 | sell | 10 | 15920 | 0 | TYPE_LIMIT | TIF_GTC | s-GTC-1 | 37 | sellSideProvider | ETH/FEB23 | sell | 10 | 100000 | 0 | TYPE_LIMIT | TIF_GTC | | 38 | sellSideProvider | ETH/FEB23 | sell | 100 | 100100 | 0 | TYPE_LIMIT | TIF_GTC | | 39 40 When the network moves ahead "3" blocks 41 42 And the market data for the market "ETH/FEB23" should be: 43 | mark price | trading mode | 44 | 15900 | TRADING_MODE_CONTINUOUS | 45 46 And the parties should have the following margin levels: 47 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 48 | party1 | ETH/FEB23 | 9540 | 10494 | 11448 | 13356 | cross margin | 0 | 0 | 49 50 And the parties submit update margin mode: 51 | party | market | margin_mode | margin_factor | error | 52 | party1 | ETH/FEB23 | isolated margin | 0.3 | | 53 54 #AC: 0019-MCAL-220, GFA order added during auction should not be used to count order margin in continuous 55 #AC: 0019-MCAL-221, when party has no position, and place 2 short orders during auction, order margin should be updated 56 #order margin short: (2*15910+1*15920)*0.3=14322 57 And the parties should have the following margin levels: 58 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 59 | party1 | ETH/FEB23 | 0 | 0 | 0 | 0 | isolated margin | 0.3 | 14322 | 60 61 #AC: 0019-MCAL-222,When the party increases the order price during continunous, order margin should increase 62 #order margin short: (2*15912+1*15920)*0.3=14323 63 When the parties amend the following orders: 64 | party | reference | price | size delta | tif | error | 65 | party1 | s-GTC-2 | 15912 | 0 | TIF_GTC | | 66 67 And the parties should have the following margin levels: 68 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 69 | party1 | ETH/FEB23 | 0 | 0 | 0 | 0 | isolated margin | 0.3 | 14323 | 70 71 #AC: 0019-MCAL-223,When the party decreases the order price during continunous, order margin should decrease 72 #order margin short: (2*15902+1*15920)*0.3=14317 73 When the parties amend the following orders: 74 | party | reference | price | size delta | tif | error | 75 | party1 | s-GTC-2 | 15902 | 0 | TIF_GTC | | 76 77 And the parties should have the following margin levels: 78 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 79 | party1 | ETH/FEB23 | 0 | 0 | 0 | 0 | isolated margin | 0.3 | 14317 | 80 81 #AC: 0019-MCAL-224,When the party decreases the order volume during continunous, order margin should decrease 82 #AC: 0019-MCAL-090,A feature test that checks margin in case market PDP > 0 is created and passes. 83 #order margin short: (1*15902+1*15920)*0.3=9546 84 When the parties amend the following orders: 85 | party | reference | price | size delta | tif | error | 86 | party1 | s-GTC-2 | 15902 | -10 | TIF_GTC | | 87 88 And the parties should have the following margin levels: 89 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 90 | party1 | ETH/FEB23 | 0 | 0 | 0 | 0 | isolated margin | 0.3 | 9546 | 91 92 #AC: 0019-MCAL-225,When the party increases the order volume while decrease price during continunous, order margin should update accordingly 93 #order margin short: (4*15900+1*15920)*0.3=23856 94 When the parties amend the following orders: 95 | party | reference | price | size delta | tif | error | 96 | party1 | s-GTC-2 | 15900 | 30 | TIF_GTC | | 97 98 And the parties should have the following margin levels: 99 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 100 | party1 | ETH/FEB23 | 0 | 0 | 0 | 0 | isolated margin | 0.3 | 23856 | 101 102 #AC: 0019-MCAL-226,When the party's order is partially filled during continunous, order margin should update accordingly 103 #order margin short: (3*15900+1*15920)*0.3=19086 104 And the parties place the following orders: 105 | party | market id | side | volume | price | resulting trades | type | tif | reference | 106 | buySideProvider | ETH/FEB23 | buy | 10 | 15900 | 1 | TYPE_LIMIT | TIF_GTC | | 107 108 And the parties should have the following margin levels: 109 | party | market id | maintenance | margin mode | margin factor | order | 110 | party1 | ETH/FEB23 | 3182 | isolated margin | 0.3 | 19086 | 111 112 When the network moves ahead "1" blocks 113 114 #AC: 0019-MCAL-227,When the party cancel one of the two orders during continunous, order margin should be reduced 115 #order margin short: (3*15900+0*15920)*0.3=14310 116 When the parties amend the following orders: 117 | party | reference | size delta | tif | error | 118 | party1 | s-GTC-1 | -10 | TIF_GTC | | 119 120 And the parties should have the following margin levels: 121 | party | market id | maintenance | margin mode | margin factor | order | 122 | party1 | ETH/FEB23 | 3182 | isolated margin | 0.3 | 14310 | 123 124 #AC: 0019-MCAL-228, place a GFA order duing continuous, order should be rejected 125 And the parties place the following orders: 126 | party | market id | side | volume | price | resulting trades | type | tif | reference | error | 127 | party1 | ETH/FEB23 | buy | 10 | 15800 | 0 | TYPE_LIMIT | TIF_GFA | GFA-1 | gfa order received during continuous trading | 128 129 And the parties should have the following margin levels: 130 | party | market id | maintenance | margin mode | margin factor | order | 131 | party1 | ETH/FEB23 | 3182 | isolated margin | 0.3 | 14310 | 132 133 #AC: 0019-MCAL-229,When the party has position -1 and order -3, and new long order with size 1 will be offset 134 #order margin short: 3*15900*0.3=14310 135 And the parties place the following orders: 136 | party | market id | side | volume | price | resulting trades | type | tif | reference | 137 | party1 | ETH/FEB23 | buy | 10 | 15800 | 0 | TYPE_LIMIT | TIF_GTC | | 138 139 And the parties should have the following margin levels: 140 | party | market id | maintenance | margin mode | margin factor | order | 141 | party1 | ETH/FEB23 | 3182 | isolated margin | 0.3 | 14310 | 142 143 #AC: 0019-MCAL-230,When the party has position -1 and order -3, and new long orders with size 2 will be offset 144 #order margin short: 3*15900*0.3=14310 145 And the parties place the following orders: 146 | party | market id | side | volume | price | resulting trades | type | tif | reference | 147 | party1 | ETH/FEB23 | buy | 10 | 15800 | 0 | TYPE_LIMIT | TIF_GTC | | 148 149 And the parties should have the following margin levels: 150 | party | market id | maintenance | margin mode | margin factor | order | 151 | party1 | ETH/FEB23 | 3182 | isolated margin | 0.3 | 14310 | 152 153 #AC: 0019-MCAL-231,When the party has position -1 and order -3, and new long orders with size 3 will be offset 154 #order margin short: 3*15900*0.3=14310 155 #order margin short: 3*15800*0.3=14220 156 And the parties place the following orders: 157 | party | market id | side | volume | price | resulting trades | type | tif | reference | 158 | party1 | ETH/FEB23 | buy | 10 | 15800 | 0 | TYPE_LIMIT | TIF_GTC | | 159 160 And the parties should have the following margin levels: 161 | party | market id | maintenance | margin mode | margin factor | order | 162 | party1 | ETH/FEB23 | 3182 | isolated margin | 0.3 | 14310 | 163 164 And the market data for the market "ETH/FEB23" should be: 165 | mark price | trading mode | 166 | 15900 | TRADING_MODE_CONTINUOUS |