code.vegaprotocol.io/vega@v0.79.0/core/integration/features/spot/orders/0014-ORDT-163.feature (about) 1 Feature: stop order in spot market 2 3 Background: 4 Given time is updated to "2024-01-01T00:00:00Z" 5 6 Given the following network parameters are set: 7 | name | value | 8 | network.markPriceUpdateMaximumFrequency | 1s | 9 | market.value.windowLength | 1h | 10 | spam.protection.max.stopOrdersPerMarket | 5 | 11 12 Given the following assets are registered: 13 | id | decimal places | 14 | ETH | 2 | 15 | BTC | 2 | 16 17 Given the fees configuration named "fees-config-1": 18 | maker fee | infrastructure fee | 19 | 0 | 0 | 20 Given the log normal risk model named "lognormal-risk-model-1": 21 | risk aversion | tau | mu | r | sigma | 22 | 0.001 | 0.01 | 0 | 0.0 | 1.2 | 23 And the price monitoring named "price-monitoring-1": 24 | horizon | probability | auction extension | 25 | 360000 | 0.999 | 1 | 26 27 And the spot markets: 28 | id | name | base asset | quote asset | risk model | auction duration | fees | price monitoring | decimal places | position decimal places | sla params | 29 | BTC/ETH | BTC/ETH | BTC | ETH | lognormal-risk-model-1 | 1 | fees-config-1 | price-monitoring-1 | 2 | 2 | default-basic | 30 31 # setup accounts 32 Given the parties deposit on asset's general account the following amount: 33 | party | asset | amount | 34 | party1 | ETH | 100 | 35 | party1 | BTC | 11 | 36 | party2 | ETH | 10000 | 37 | party2 | BTC | 10 | 38 | party3 | ETH | 10000 | 39 | party3 | BTC | 1000 | 40 | party4 | BTC | 1000 | 41 | party5 | BTC | 1000 | 42 And the average block duration is "1" 43 44 # Place some orders to get out of auction 45 And the parties place the following orders: 46 | party | market id | side | volume | price | resulting trades | type | tif | 47 | party3 | BTC/ETH | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GFA | 48 | party4 | BTC/ETH | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 49 50 And the opening auction period ends for market "BTC/ETH" 51 When the network moves ahead "1" blocks 52 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH" 53 And the mark price should be "1000" for the market "BTC/ETH" 54 55 Scenario:0014-ORDT-163, 0014-ORDT-164: A wrapped buy/sell order will be rejected when triggered if the party doesn't have enough of the required quote asset to cover the order. 56 57 # place an order to match with the limit order then check the stop is filled 58 And the parties place the following orders: 59 | party | market id | side | volume | price | resulting trades | type | tif | reference | 60 | party4 | BTC/ETH | sell | 50 | 1010 | 0 | TYPE_LIMIT | TIF_GTC | p4-sell | 61 62 # create party1 stop order 63 And the parties place the following orders: 64 | party | market id | side | volume | price | resulting trades | type | tif | only | ra price trigger | error | reference | 65 | party1 | BTC/ETH | buy | 50 | 1010 | 0 | TYPE_LIMIT | TIF_GTC | | 1005 | | stop1 | 66 67 # now we trade at 1005, this will breach the trigger 68 When the parties place the following orders: 69 | party | market id | side | volume | price | resulting trades | type | tif | 70 | party3 | BTC/ETH | buy | 1 | 1005 | 0 | TYPE_LIMIT | TIF_GTC | 71 | party4 | BTC/ETH | sell | 1 | 1005 | 1 | TYPE_LIMIT | TIF_GTC | 72 73 # check that the order was triggered 74 Then the stop orders should have the following states 75 | party | market id | status | reference | 76 | party1 | BTC/ETH | STATUS_TRIGGERED | stop1 | 77 78 Then "party1" should have general account balance of "100" for asset "ETH" 79 Then "party1" should have general account balance of "11" for asset "BTC" 80 81 And the parties cancel the following orders: 82 | party | reference | 83 | party4 | p4-sell | 84 85 # place an order to match with the limit order then check the stop is filled 86 And the parties place the following orders: 87 | party | market id | side | volume | price | resulting trades | type | tif | reference | 88 | party3 | BTC/ETH | buy | 50 | 1015 | 0 | TYPE_LIMIT | TIF_GTC | p4-sell | 89 90 # create party2 stop order 91 And the parties place the following orders: 92 | party | market id | side | volume | price | resulting trades | type | tif | only | ra price trigger | error | reference | 93 | party2 | BTC/ETH | sell | 50 | 1015 | 0 | TYPE_LIMIT | TIF_GTC | | 1020 | | stop2 | 94 95 # now we trade at 1005, this will breach the trigger 96 When the parties place the following orders: 97 | party | market id | side | volume | price | resulting trades | type | tif | 98 | party3 | BTC/ETH | buy | 1 | 1020 | 0 | TYPE_LIMIT | TIF_GTC | 99 | party4 | BTC/ETH | sell | 1 | 1020 | 1 | TYPE_LIMIT | TIF_GTC | 100 101 # check that the order was triggered 102 Then the stop orders should have the following states 103 | party | market id | status | reference | 104 | party2 | BTC/ETH | STATUS_TRIGGERED | stop2 | 105 106 Then "party2" should have general account balance of "10000" for asset "ETH" 107 Then "party2" should have general account balance of "10" for asset "BTC" 108 109