code.vegaprotocol.io/vega@v0.79.0/core/integration/features/orders/amend-order-decimal-places.feature (about)

     1  Feature: Amend orders
     2  
     3    Background:
     4      Given the following assets are registered:
     5        | id  | decimal places |
     6        | BTC | 5              |
     7      And the markets:
     8        | id        | quote name | asset | risk model                  | margin calculator                  | auction duration | fees         | price monitoring | data source config     | decimal places | linear slippage factor | quadratic slippage factor | sla params      |
     9        | ETH/DEC19 | BTC        | BTC   | default-simple-risk-model-2 | default-overkill-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 2              | 0.25                   | 0                         | default-futures |
    10      And the following network parameters are set:
    11        | name                                    | value |
    12        | network.markPriceUpdateMaximumFrequency | 0s    |
    13        | market.auction.minimumDuration          | 1     |
    14  
    15    Scenario: Amend rejected for non existing order
    16      # setup accounts
    17      Given the parties deposit on asset's general account the following amount:
    18        | party | asset | amount      |
    19        | myboi | BTC   | 1000000000  |
    20        | aux   | BTC   | 10000000000 |
    21        | aux2  | BTC   | 10000000000 |
    22  
    23      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
    24      When the parties place the following orders:
    25        | party | market id | side | volume | price | resulting trades | type       | tif     |
    26        | aux   | ETH/DEC19 | buy  | 1      | 1     | 0                | TYPE_LIMIT | TIF_GTC |
    27        | aux   | ETH/DEC19 | sell | 1      | 10001 | 0                | TYPE_LIMIT | TIF_GTC |
    28        | aux2  | ETH/DEC19 | buy  | 1      | 2     | 0                | TYPE_LIMIT | TIF_GTC |
    29        | aux   | ETH/DEC19 | sell | 1      | 2     | 0                | TYPE_LIMIT | TIF_GTC |
    30      Then the opening auction period ends for market "ETH/DEC19"
    31      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
    32  
    33      And the parties place the following orders with ticks:
    34        | party | market id | side | volume | price | resulting trades | type       | tif     | reference   |
    35        | myboi | ETH/DEC19 | sell | 1      | 2     | 0                | TYPE_LIMIT | TIF_GTC | myboi-ref-1 |
    36  
    37      # cancel the order, so we cannot edit it.
    38      And the parties cancel the following orders:
    39        | party | reference   |
    40        | myboi | myboi-ref-1 |
    41  
    42      Then the parties amend the following orders:
    43        | party | reference   | price | size delta | tif     | error                        |
    44        | myboi | myboi-ref-1 | 2     | 3          | TIF_GTC | OrderError: Invalid Order ID |
    45  
    46    Scenario: Reduce size success and not loosing position in order book
    47      # setup accounts
    48      Given the parties deposit on asset's general account the following amount:
    49        | party  | asset | amount      |
    50        | myboi  | BTC   | 1000000000  |
    51        | myboi2 | BTC   | 1000000000  |
    52        | myboi3 | BTC   | 1000000000  |
    53        | aux    | BTC   | 10000000000 |
    54        | aux2   | BTC   | 10000000000 |
    55  
    56      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
    57      When the parties place the following orders:
    58        | party | market id | side | volume | price | resulting trades | type       | tif     |
    59        | aux   | ETH/DEC19 | buy  | 1      | 1     | 0                | TYPE_LIMIT | TIF_GTC |
    60        | aux   | ETH/DEC19 | sell | 1      | 10001 | 0                | TYPE_LIMIT | TIF_GTC |
    61        | aux2  | ETH/DEC19 | buy  | 1      | 2     | 0                | TYPE_LIMIT | TIF_GTC |
    62        | aux   | ETH/DEC19 | sell | 1      | 2     | 0                | TYPE_LIMIT | TIF_GTC |
    63      Then the opening auction period ends for market "ETH/DEC19"
    64      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
    65  
    66      And the parties place the following orders with ticks:
    67        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference   |
    68        | myboi  | ETH/DEC19 | sell | 5      | 2     | 0                | TYPE_LIMIT | TIF_GTC | myboi-ref-1 |
    69        | myboi2 | ETH/DEC19 | sell | 5      | 2     | 0                | TYPE_LIMIT | TIF_GTC | myboi-ref-2 |
    70  
    71      # reducing size
    72      Then the parties amend the following orders:
    73        | party | reference   | price | size delta | tif     |
    74        | myboi | myboi-ref-1 | 0     | -2         | TIF_GTC |
    75  
    76      # matching the order now
    77      # this should match with the size 3 order of myboi
    78      Then the parties place the following orders with ticks:
    79        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference   |
    80        | myboi3 | ETH/DEC19 | buy  | 3      | 2     | 1                | TYPE_LIMIT | TIF_GTC | myboi-ref-3 |
    81  
    82      Then the following trades should be executed:
    83        | buyer  | seller | price | size |
    84        | myboi3 | myboi  | 2     | 3    |
    85  
    86    Scenario: Increase size success and loosing position in order book
    87      # setup accounts
    88      Given the parties deposit on asset's general account the following amount:
    89        | party  | asset | amount      |
    90        | myboi  | BTC   | 1000000000  |
    91        | myboi2 | BTC   | 1000000000  |
    92        | myboi3 | BTC   | 1000000000  |
    93        | aux    | BTC   | 10000000000 |
    94        | aux2   | BTC   | 10000000000 |
    95  
    96      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
    97      When the parties place the following orders:
    98        | party | market id | side | volume | price | resulting trades | type       | tif     |
    99        | aux   | ETH/DEC19 | buy  | 1      | 1     | 0                | TYPE_LIMIT | TIF_GTC |
   100        | aux   | ETH/DEC19 | sell | 1      | 10001 | 0                | TYPE_LIMIT | TIF_GTC |
   101        | aux2  | ETH/DEC19 | buy  | 1      | 2     | 0                | TYPE_LIMIT | TIF_GTC |
   102        | aux   | ETH/DEC19 | sell | 1      | 2     | 0                | TYPE_LIMIT | TIF_GTC |
   103      Then the opening auction period ends for market "ETH/DEC19"
   104      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
   105  
   106      Then the parties place the following orders:
   107        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference   |
   108        | myboi  | ETH/DEC19 | sell | 5      | 2     | 0                | TYPE_LIMIT | TIF_GTC | myboi-ref-1 |
   109        | myboi2 | ETH/DEC19 | sell | 5      | 2     | 0                | TYPE_LIMIT | TIF_GTC | myboi-ref-2 |
   110  
   111      # reducing size
   112      And the parties amend the following orders:
   113        | party | reference   | price | size delta | tif     |
   114        | myboi | myboi-ref-1 | 0     | 3          | TIF_GTC |
   115  
   116      # matching the order now
   117      # this should match with the size 3 order of myboi
   118      When the parties place the following orders:
   119        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference   |
   120        | myboi3 | ETH/DEC19 | buy  | 3      | 2     | 1                | TYPE_LIMIT | TIF_GTC | myboi-ref-3 |
   121      Then the following trades should be executed:
   122        | buyer  | seller | price | size |
   123        | myboi3 | myboi2 | 2     | 3    |
   124  
   125    Scenario: Reduce size success and order cancelled as  < to remaining
   126      # setup accounts
   127      Given the parties deposit on asset's general account the following amount:
   128        | party  | asset | amount      |
   129        | myboi  | BTC   | 1000000000  |
   130        | myboi2 | BTC   | 1000000000  |
   131        | myboi3 | BTC   | 1000000000  |
   132        | aux    | BTC   | 10000000000 |
   133        | aux2   | BTC   | 10000000000 |
   134  
   135      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
   136      When the parties place the following orders:
   137        | party | market id | side | volume | price | resulting trades | type       | tif     |
   138        | aux   | ETH/DEC19 | buy  | 1      | 1     | 0                | TYPE_LIMIT | TIF_GTC |
   139        | aux   | ETH/DEC19 | sell | 1      | 10001 | 0                | TYPE_LIMIT | TIF_GTC |
   140        | aux2  | ETH/DEC19 | buy  | 1      | 2     | 0                | TYPE_LIMIT | TIF_GTC |
   141        | aux   | ETH/DEC19 | sell | 1      | 2     | 0                | TYPE_LIMIT | TIF_GTC |
   142      Then the opening auction period ends for market "ETH/DEC19"
   143      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
   144  
   145      Then the parties place the following orders:
   146        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference   |
   147        | myboi  | ETH/DEC19 | sell | 5      | 2     | 0                | TYPE_LIMIT | TIF_GTC | myboi-ref-1 |
   148        | myboi2 | ETH/DEC19 | sell | 5      | 2     | 0                | TYPE_LIMIT | TIF_GTC | myboi-ref-2 |
   149  
   150      # matching the order now
   151      # this will reduce the remaining to 2 so it get cancelled later on
   152      When the parties place the following orders:
   153        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference   |
   154        | myboi3 | ETH/DEC19 | buy  | 3      | 2     | 1                | TYPE_LIMIT | TIF_GTC | myboi-ref-3 |
   155  
   156      # reducing size, remaining goes from 2 to -1, this will cancel
   157      Then the parties amend the following orders:
   158        | party | reference   | price | size delta | tif     |
   159        | myboi | myboi-ref-1 | 0     | -3         | TIF_GTC |
   160  
   161      # check the order status, it should be cancelled
   162      And the orders should have the following status:
   163        | party | reference   | status           |
   164        | myboi | myboi-ref-1 | STATUS_CANCELLED |
   165  
   166    Scenario: Amend to invalid tif is rejected
   167      # setup accounts
   168      Given the parties deposit on asset's general account the following amount:
   169        | party | asset | amount      |
   170        | myboi | BTC   | 1000000000  |
   171        | aux   | BTC   | 10000000000 |
   172        | aux2  | BTC   | 10000000000 |
   173  
   174      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
   175      When the parties place the following orders:
   176        | party | market id | side | volume | price | resulting trades | type       | tif     |
   177        | aux   | ETH/DEC19 | buy  | 1      | 1     | 0                | TYPE_LIMIT | TIF_GTC |
   178        | aux   | ETH/DEC19 | sell | 1      | 10001 | 0                | TYPE_LIMIT | TIF_GTC |
   179        | aux2  | ETH/DEC19 | buy  | 1      | 2     | 0                | TYPE_LIMIT | TIF_GTC |
   180        | aux   | ETH/DEC19 | sell | 1      | 2     | 0                | TYPE_LIMIT | TIF_GTC |
   181      Then the opening auction period ends for market "ETH/DEC19"
   182      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
   183  
   184      Then the parties place the following orders:
   185        | party | market id | side | volume | price | resulting trades | type       | tif     | reference   |
   186        | myboi | ETH/DEC19 | sell | 5      | 2     | 0                | TYPE_LIMIT | TIF_GTC | myboi-ref-1 |
   187  
   188  
   189      # cannot amend TIF to TIF_FOK so this will be rejected
   190      Then the parties amend the following orders:
   191        | party | reference   | price | size delta | tif     | error                                      |
   192        | myboi | myboi-ref-1 | 0     | 0          | TIF_FOK | OrderError: Cannot amend TIF to FOK or IOC |
   193  
   194    Scenario: TIF_GTC to TIF_GTT rejected without expiry
   195      # setup accounts
   196      Given the parties deposit on asset's general account the following amount:
   197        | party | asset | amount      |
   198        | myboi | BTC   | 1000000000  |
   199        | aux   | BTC   | 10000000000 |
   200  
   201      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
   202      When the parties place the following orders:
   203        | party | market id | side | volume | price | resulting trades | type       | tif     |
   204        | aux   | ETH/DEC19 | buy  | 1      | 1     | 0                | TYPE_LIMIT | TIF_GTC |
   205        | aux   | ETH/DEC19 | sell | 1      | 10001 | 0                | TYPE_LIMIT | TIF_GTC |
   206  
   207      Then the parties place the following orders:
   208        | party | market id | side | volume | price | resulting trades | type       | tif     | reference   |
   209        | myboi | ETH/DEC19 | sell | 5      | 2     | 0                | TYPE_LIMIT | TIF_GTC | myboi-ref-1 |
   210  
   211      # TIF_GTT rejected because of missing expiration date
   212      Then the parties amend the following orders:
   213        | party | reference   | price | size delta | tif     | error                                                           |
   214        | myboi | myboi-ref-1 | 0     | 0          | TIF_GTT | OrderError: Cannot amend order to GTT without an expiryAt field |
   215  
   216    Scenario: TIF_GTC to TIF_GTT with time in the past
   217      # setup accounts
   218      Given the parties deposit on asset's general account the following amount:
   219        | party | asset | amount      |
   220        | myboi | BTC   | 1000000000  |
   221        | aux   | BTC   | 10000000000 |
   222        | aux2  | BTC   | 10000000000 |
   223  
   224      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
   225      When the parties place the following orders:
   226        | party | market id | side | volume | price | resulting trades | type       | tif     |
   227        | aux   | ETH/DEC19 | buy  | 1      | 1     | 0                | TYPE_LIMIT | TIF_GTC |
   228        | aux   | ETH/DEC19 | sell | 1      | 10001 | 0                | TYPE_LIMIT | TIF_GTC |
   229        | aux2  | ETH/DEC19 | buy  | 1      | 2     | 0                | TYPE_LIMIT | TIF_GTC |
   230        | aux   | ETH/DEC19 | sell | 1      | 2     | 0                | TYPE_LIMIT | TIF_GTC |
   231      Then the opening auction period ends for market "ETH/DEC19"
   232      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
   233  
   234      Then the parties place the following orders:
   235        | party | market id | side | volume | price | resulting trades | type       | tif     | reference   |
   236        | myboi | ETH/DEC19 | sell | 5      | 2     | 0                | TYPE_LIMIT | TIF_GTC | myboi-ref-1 |
   237  
   238      # reducing size, remaining goes from 2 to -1, this will cancel
   239      Then the parties amend the following orders:
   240        | party | reference   | price | expiration date      | size delta | tif     |
   241        | myboi | myboi-ref-1 | 2     | 2030-11-30T00:00:00Z | 0          | TIF_GTT |