syntax = "proto3";

package IBProto;

import "MiscData.proto";
import "OrderCondition.proto";
import "TagValue.proto";

message Order {

    // order ids
    optional int32 clientId = 1;
    optional int32 orderId = 2;
    optional int64 permId = 3;
    optional int32 parentId = 4;

    // primary attributes
    optional string action = 5;
    optional string totalQuantity = 6;
    optional int32 displaySize = 7;
    optional string orderType = 8;
    optional double lmtPrice = 9;
    optional double auxPrice = 10;
    optional string tif = 11;
    
    // clearing info
    optional string account = 12;
    optional string settlingFirm = 13;
    optional string clearingAccount = 14;
    optional string clearingIntent = 15;
    
    // secondary attributes
    optional bool allOrNone = 16;
    optional bool blockOrder = 17;
    optional bool hidden = 18;
    optional bool outsideRth = 19;
    optional bool sweepToFill = 20;
    optional double percentOffset = 21;
    optional double trailingPercent = 22;
    optional double trailStopPrice = 23;
    optional int32 minQty = 24;
    optional string goodAfterTime = 25;
    optional string goodTillDate = 26;
    optional string ocaGroup = 27;
    optional string orderRef = 28;
    optional string rule80A = 29;
    optional int32 ocaType = 30;
    optional int32 triggerMethod = 31;
    
    // extended order fields
    optional string activeStartTime = 32;
    optional string activeStopTime = 33;
    
    // advisor allocation orders
    optional string faGroup = 34;
    optional string faMethod = 35;
    optional string faPercentage = 36;

    // volatility orders
    optional double volatility = 37;
    optional int32 volatilityType = 38;
    optional bool continuousUpdate = 39;
    optional int32 referencePriceType = 40;
    optional string deltaNeutralOrderType = 41;
    optional double deltaNeutralAuxPrice = 42;
    optional int32 deltaNeutralConId = 43;
    optional string deltaNeutralOpenClose = 44;
    optional bool deltaNeutralShortSale = 45;
    optional int32 deltaNeutralShortSaleSlot = 46;
    optional string deltaNeutralDesignatedLocation = 47;

    // scale orders
    optional int32 scaleInitLevelSize = 48;
    optional int32 scaleSubsLevelSize = 49;
    optional double scalePriceIncrement = 50;
    optional double scalePriceAdjustValue = 51;
    optional int32 scalePriceAdjustInterval = 52;
    optional double scaleProfitOffset = 53;
    optional bool scaleAutoReset = 54;
    optional int32 scaleInitPosition = 55;
    optional int32 scaleInitFillQty = 56;
    optional bool scaleRandomPercent = 57;
    optional string scaleTable = 58;

    // hedge orders
    optional string hedgeType = 59;
    optional string hedgeParam = 60;

    // algo orders
    optional string algoStrategy = 61;
    repeated TagValue algoParams = 62;
    optional string algoId = 63;

    // combo orders
    repeated TagValue smartComboRoutingParams = 64;

    // processing control
    optional bool whatIf = 65;
    optional bool transmit = 66;
    optional bool overridePercentageConstraints = 67;

    // Institutional orders only
    optional string openClose = 68;
    optional int32 origin = 69;
    optional int32 shortSaleSlot = 70;
    optional string designatedLocation = 71;
    optional int32 exemptCode = 72;
    optional string deltaNeutralSettlingFirm = 73;
    optional string deltaNeutralClearingAccount = 74;
    optional string deltaNeutralClearingIntent = 75;

    // SMART routing only
    optional double discretionaryAmt = 76;
    optional bool optOutSmartRouting = 77;

    // BOX ORDERS ONLY
    optional double startingPrice = 78;
    optional double stockRefPrice = 79;
    optional double delta = 80;

    // pegged to stock or VOL orders
    optional double stockRangeLower = 81;
    optional double stockRangeUpper = 82;

    // Not Held
    optional bool notHeld = 83;

    // order misc options
    repeated TagValue orderMiscOptions = 84;

    //order algo id
    optional bool solicited = 85;

    optional bool randomizeSize = 86;
    optional bool randomizePrice = 87;

    // PEG2BENCH fields
    optional int32 referenceContractId = 88;
    optional double peggedChangeAmount = 89;
    optional bool isPeggedChangeAmountDecrease = 90;
    optional double referenceChangeAmount = 91;
    optional string referenceExchangeId = 92;
    optional string adjustedOrderType = 93;
    optional double triggerPrice = 94;
    optional double adjustedStopPrice = 95;
    optional double adjustedStopLimitPrice = 96;
    optional double adjustedTrailingAmount = 97;
    optional int32 adjustableTrailingUnit = 98;
    optional double lmtPriceOffset = 99;
    
    repeated OrderCondition conditions = 100;
    optional bool conditionsCancelOrder = 101;
    optional bool conditionsIgnoreRth = 102;

    // models
    optional string modelCode = 103;
    
    optional string extOperator = 104;
    
    optional SoftDollarTier softDollarTier = 105;
    
    // native cash quantity
    optional double cashQty = 106;

    optional string mifid2DecisionMaker = 107;
    optional string mifid2DecisionAlgo = 108;
    optional string mifid2ExecutionTrader = 109;
    optional string mifid2ExecutionAlgo = 110;

    // don't use auto price for hedge
    optional bool dontUseAutoPriceForHedge = 111;

    optional bool isOmsContainer = 112;
    optional bool discretionaryUpToLimitPrice = 113;

    optional string autoCancelDate = 114;
    optional string filledQuantity = 115;
    optional int32 refFuturesConId = 116;
    optional bool autoCancelParent = 117;
    optional string shareholder = 118;
    optional bool imbalanceOnly = 119;
    optional int32 routeMarketableToBbo = 120;
    optional int64 parentPermId = 121;

    optional int32 usePriceMgmtAlgo = 122;
    optional int32 duration = 123;
    optional int32 postToAts = 124;
    optional string advancedErrorOverride = 125;
    optional string manualOrderTime = 126;
    optional int32 minTradeQty = 127;
    optional int32 minCompeteSize = 128;
    optional double competeAgainstBestOffset = 129;
    optional double midOffsetAtWhole = 130;
    optional double midOffsetAtHalf = 131;
    optional string customerAccount = 132;
    optional bool professionalCustomer = 133;
    optional string bondAccruedInterest = 134;
    optional bool includeOvernight = 135;
    optional int32 manualOrderIndicator = 136;
    optional string submitter = 137;
    optional bool deactivate = 138;
    optional bool postOnly = 139;
    optional bool allowPreOpen = 140;
    optional bool ignoreOpenAuction = 141;
    optional int32 seekPriceImprovement = 142;
    optional int32 whatIfType = 143;
}
