code.vegaprotocol.io/vega@v0.79.0/core/integration/features/orders/stoporders-auctions.feature (about)

     1  Feature: stop orders
     2    Background:
     3      Given time is updated to "2020-10-16T00:00:00Z"
     4      And the price monitoring named "my-price-monitoring":
     5        | horizon | probability | auction extension |
     6        | 60      | 0.95        | 240               |
     7        | 600     | 0.99        | 360               |
     8      And the simple risk model named "my-simple-risk-model":
     9        | long | short | max move up | min move down | probability of trading |
    10        | 0.11 | 0.1   | 10          | 11            | 0.1                    |
    11      And the markets:
    12        | id        | quote name | asset | auction duration | risk model           | margin calculator         | fees         | price monitoring    | data source config     | linear slippage factor | quadratic slippage factor | sla params      |
    13        | ETH/DEC20 | ETH        | ETH   | 240              | my-simple-risk-model | default-margin-calculator | default-none | my-price-monitoring | default-eth-for-future | 0.01                   | 0                         | default-futures |
    14      And the following network parameters are set:
    15        | name                                    | value |
    16        | market.auction.minimumDuration          | 240   |
    17        | network.markPriceUpdateMaximumFrequency | 0s    |
    18        | limits.markets.maxPeggedOrders          | 2     |
    19        | spam.protection.max.stopOrdersPerMarket | 5     |
    20  
    21    Scenario: A stop order placed either prior to or during an auction will not execute during an auction, nor will it participate in the uncrossing. (0014-ORDT-065)
    22      Given the parties deposit on asset's general account the following amount:
    23        | party  | asset | amount       |
    24        | party1 | ETH   | 10000        |
    25        | party2 | ETH   | 10000        |
    26        | aux    | ETH   | 100000000000 |
    27        | aux2   | ETH   | 100000000000 |
    28        | lpprov | ETH   | 100000000000 |
    29  
    30      When the parties submit the following liquidity provision:
    31        | id  | party  | market id | commitment amount | fee | lp type    |
    32        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
    33        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
    34  
    35      And the parties place the following pegged iceberg orders:
    36        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    37        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
    38        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
    39  
    40      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
    41      Then the parties place the following orders:
    42        | party | market id | side | volume | price | resulting trades | type       | tif     |
    43        | aux   | ETH/DEC20 | buy  | 1      | 25    | 0                | TYPE_LIMIT | TIF_GTC |
    44        | aux   | ETH/DEC20 | sell | 1      | 134   | 0                | TYPE_LIMIT | TIF_GTC |
    45        | aux2  | ETH/DEC20 | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |
    46        | aux   | ETH/DEC20 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |
    47      Then the opening auction period ends for market "ETH/DEC20"
    48      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
    49      And the mark price should be "100" for the market "ETH/DEC20"
    50      And time is updated to "2020-10-16T00:10:00Z"
    51  
    52      When the parties place the following orders:
    53        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    54        | party1 | ETH/DEC20 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    55        | party2 | ETH/DEC20 | buy  | 1      | 100   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
    56  
    57      And the mark price should be "100" for the market "ETH/DEC20"
    58  
    59      When the parties place the following orders:
    60        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    61        | party1 | ETH/DEC20 | sell | 1      | 111   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    62        | party2 | ETH/DEC20 | buy  | 1      | 111   | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
    63  
    64      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
    65      And the mark price should be "100" for the market "ETH/DEC20"
    66  
    67      When the parties place the following orders:
    68        | party  | market id | side | volume | price | resulting trades | type        | tif     | only   | fb trailing | reference |
    69        | party1 | ETH/DEC20 | buy  | 1      | 0     | 0                | TYPE_MARKET | TIF_GTC | reduce | 0.05        | tstop     |
    70  
    71      # Now we make sure the trailing stop is working correctly
    72      Then the stop orders should have the following states
    73        | party  | market id | status           | reference |
    74        | party1 | ETH/DEC20 | STATUS_PENDING   | tstop     |
    75  
    76      # Now let's move back out of auction
    77      When the parties place the following orders:
    78        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    79        | party1 | ETH/DEC20 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    80        | party2 | ETH/DEC20 | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
    81  
    82      And time is updated to "2020-10-16T00:15:00Z"
    83      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
    84      And the mark price should be "105" for the market "ETH/DEC20"
    85  
    86      # The stop should still be waiting and has not been triggered
    87      Then the stop orders should have the following states
    88        | party  | market id | status           | reference |
    89        | party1 | ETH/DEC20 | STATUS_PENDING   | tstop     |
    90  
    91      # Move the mark price down by <10% to not trigger the stop orders
    92      When the parties place the following orders:
    93        | party | market id | side | volume | price | resulting trades | type       | tif     |
    94        | aux2  | ETH/DEC20 | buy  | 1      | 102    | 0                | TYPE_LIMIT | TIF_GTC |
    95        | aux   | ETH/DEC20 | sell | 1      | 102    | 1                | TYPE_LIMIT | TIF_GTC |
    96      And then the network moves ahead "5" blocks
    97      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
    98      And the mark price should be "102" for the market "ETH/DEC20"
    99  
   100      Then the stop orders should have the following states
   101        | party  | market id | status         | reference |
   102        | party1 | ETH/DEC20 | STATUS_PENDING | tstop     |
   103  
   104      # Move the mark price down by 10% to trigger the orders
   105      When the parties place the following orders:
   106        | party | market id | side | volume | price | resulting trades | type       | tif     |
   107        | aux   | ETH/DEC20 | buy  | 2      | 95    | 0                | TYPE_LIMIT | TIF_GTC |
   108        | aux2  | ETH/DEC20 | sell | 2      | 95    | 2                | TYPE_LIMIT | TIF_GTC |
   109      And then the network moves ahead "10" blocks
   110      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   111      And the mark price should be "95" for the market "ETH/DEC20"
   112  
   113      Then the stop orders should have the following states
   114        | party  | market id | status           | reference |
   115        | party1 | ETH/DEC20 | STATUS_TRIGGERED | tstop     |
   116  
   117  
   118    Scenario: A stop order placed either prior to or during an auction, where the uncrossing price is within the triggering range, will immediately execute following uncrossing. (0014-ORDT-066)
   119      Given the parties deposit on asset's general account the following amount:
   120        | party  | asset | amount       |
   121        | party1 | ETH   | 10000        |
   122        | party2 | ETH   | 10000        |
   123        | aux    | ETH   | 100000000000 |
   124        | aux2   | ETH   | 100000000000 |
   125        | lpprov | ETH   | 100000000000 |
   126  
   127      When the parties submit the following liquidity provision:
   128        | id  | party  | market id | commitment amount | fee | lp type    |
   129        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   130        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   131  
   132      And the parties place the following pegged iceberg orders:
   133        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   134        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
   135        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
   136  
   137      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
   138      Then the parties place the following orders:
   139        | party | market id | side | volume | price | resulting trades | type       | tif     |
   140        | aux   | ETH/DEC20 | buy  | 1      | 25    | 0                | TYPE_LIMIT | TIF_GTC |
   141        | aux   | ETH/DEC20 | sell | 1      | 134   | 0                | TYPE_LIMIT | TIF_GTC |
   142        | aux2  | ETH/DEC20 | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |
   143        | aux   | ETH/DEC20 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |
   144      Then the opening auction period ends for market "ETH/DEC20"
   145      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   146      And the mark price should be "100" for the market "ETH/DEC20"
   147      And time is updated to "2020-10-16T00:10:00Z"
   148  
   149      When the parties place the following orders:
   150        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   151        | party1 | ETH/DEC20 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   152        | party2 | ETH/DEC20 | buy  | 1      | 100   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   153  
   154      And the mark price should be "100" for the market "ETH/DEC20"
   155  
   156      When the parties place the following orders:
   157        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
   158        | aux   | ETH/DEC20 | sell | 1      | 85    | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   159        | aux2  | ETH/DEC20 | buy  | 1      | 85    | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
   160  
   161      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   162      And the mark price should be "100" for the market "ETH/DEC20"
   163  
   164      When the parties place the following orders:
   165        | party  | market id | side | volume | price | resulting trades | type        | tif     | only   | fb trailing | reference |
   166        | party1 | ETH/DEC20 | buy  | 1      | 0     | 0                | TYPE_MARKET | TIF_IOC | reduce | 0.01        | tstop     |
   167  
   168      # Now we make sure the trailing stop is working correctly
   169      Then the stop orders should have the following states
   170        | party  | market id | status           | reference |
   171        | party1 | ETH/DEC20 | STATUS_PENDING   | tstop     |
   172  
   173      # Now let's move back out of auction
   174      When the parties place the following orders:
   175        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   176        | party1 | ETH/DEC20 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   177        | party2 | ETH/DEC20 | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
   178  
   179      And time is updated to "2020-10-16T00:15:00Z"
   180      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   181      And the mark price should be "92" for the market "ETH/DEC20"
   182  
   183      # The stop should still be waiting and has not been triggered
   184      Then the stop orders should have the following states
   185        | party  | market id | status           | reference |
   186        | party1 | ETH/DEC20 | STATUS_TRIGGERED | tstop     |
   187  
   188      # check that the order got submitted (it will be stopped due to self trading)
   189      Then the orders should have the following states:
   190        | party  | market id | side | volume | remaining | price | status         | reference |
   191        | party1 | ETH/DEC20 | buy  | 1      | 1         | 0     | STATUS_STOPPED | tstop     |
   192  
   193