syntax = "proto3";

package dbag.energy.m7t.management.request.v7;

import "dbag/energy/m7t/common/v7/order_common.proto";
import "dbag/energy/m7t/validation/v7/validation.proto";

option java_multiple_files = true;
option java_package = "com.deutscheboerse.energy.m7.api.management.request.v7";

/*
 * This message is used to modify one or several orders. If the order modification has an impact on the order execution priority,
 * the old order is removed by the system and a new order with a new order id is entered instead.
 */
message OrderModify {
  // Type of order modification
  optional ModificationType modification_type = 1 [
    (energy.m7t.validation.v7.mandatory) = true
  ];

  // List of all orders contained in the basket.
  repeated OrderModifyPayload order_list = 2 [
    (energy.m7t.validation.v7.min_occurrence) = 1,
    (energy.m7t.validation.v7.max_occurrence) = 100
  ];
}

/*
 *  Represents order structure for Order Modify.
 */
message OrderModifyPayload {
  // Order Id as returned by the backend system.
  optional int64 order_id = 1 [
    (energy.m7t.validation.v7.mandatory) = true,
    (energy.m7t.validation.v7.min_value) = 0
  ];

  // Type of the order. "REGULAR" is the default value.
  dbag.energy.m7t.common.v7.OrderType type = 2 [
    (energy.m7t.validation.v7.mandatory) = true
  ];

  // Limit price of the order.
  optional int64 price = 3 [
    (energy.m7t.validation.v7.mandatory) = true
  ];

  // Total quantity of the order.
  optional int32 quantity = 4 [
    (energy.m7t.validation.v7.mandatory) = true
  ];

  // Order revision number.
  optional int64 revision = 5 [
    (energy.m7t.validation.v7.mandatory) = true,
    (energy.m7t.validation.v7.min_value) = 0
  ];

  // Details for stop limit orders.
  optional dbag.energy.m7t.common.v7.StopOrderDetails stop_order_details = 6 [
    (energy.m7t.validation.v7.mandatory_if) = {
      field_name: "type",
      field_value: "ORDER_TYPE_STOP"
    }
  ];

  // Details for Iceberg orders.
  optional dbag.energy.m7t.common.v7.IcebergOrderDetails iceberg_order_details = 7 [
    (energy.m7t.validation.v7.mandatory_if) = {
      field_name: "type",
      field_value: "ORDER_TYPE_ICEBERG"
    }
  ];

  // Execution restriction of the order. "NOT_RESTRICTED" is the default value.
  optional dbag.energy.m7t.common.v7.OrderExecutionRestriction execution_restriction = 8;

  // Details for validity restriction of the order.
  optional dbag.energy.m7t.common.v7.ValidityRestrictionDetails validity_restriction_details = 9;

  // Open Close Indicator, mandatory for futures & cross-product spreads.
  optional dbag.energy.m7t.common.v7.OrderOpenCloseIndicator open_close_indicator = 10;

  // The indicator whether the order shall be automatically transferred to the corresponding linked contract after the trading in the specific delivery area ends in XBID. "False" is default value.
  optional bool aot = 11;

  // Location data for the order. Available only for products with Locations enabled.
  optional dbag.energy.m7t.common.v7.LocationDetails location_details = 12;

  // Metadata which can be used by the client.
  optional dbag.energy.m7t.common.v7.ClientMetadata client_metadata = 13;
}
;
/*
 * Types of order modification. Offers the possibility to activate, deactivate, modify or delete orders
 */
enum ModificationType {
  MODIFICATION_TYPE_UNSPECIFIED = 0; // Modification type is unknown.
  MODIFICATION_TYPE_ACTIVATE = 1; // Activate all orders.
  MODIFICATION_TYPE_DEACTIVATE = 2; // Deactivates (hibernates) all orders.
  MODIFICATION_TYPE_MODIFY = 3; // Modifies all orders
  MODIFICATION_TYPE_DELETE = 4; // Deletes all orders.
}
