Page tree
Skip to end of metadata
Go to start of metadata

Introduction

Order validation is configurable via *.config files and database.

Configuration file (Oms.OrderProcessor.config with orderProcessorConfig configuration element) stores components performing order validation depending on order manipulation goal. 

Config example

 

the list of validators used by default:

Etna.Trading.Oms.Processing.Validation.ValidationRulesManagerValidator, Etna.Trading.Oms

uses a ValidationRulesManager (Etna.Trading.Oms.Condition.ValidationRulesManager, Etna.Trading.Oms) which downloads validation rules by ValidationRulesDataProvider (Etna.Trading.Oms.Data.ValidationRulesDataProvider, Etna.Trading.Oms.Data)

in a nutshell, a single validation rule is a set of database entities called Conditions and condition is a function(ParamName, ParamValue,Operation,Argument) - validation rules are set via Backoffice

Etna.Trading.Oms.Processing.Validation.Syntax.MultiLegsSyntaxValidator, Etna.Trading.Oms

validates multileg order underlying legs values:

"StrikePriceUndefined" when a strike price wasn't defined for an option leg

"OptionTypeUndefined" when an option type wasn't defined for an option leg

"ExpirationDateUndefined" when expiration date wasn't set for an option leg

"SecurityUndefined" when security is not set for a common stock leg

"IncorrectOrderQuantity" when leg quantity < 0 or > 10000000

"IncorrectTimeInForce" when a not supported time in force is set for a leg

"LimitPriceUndefined" when limit price not set for a limit order leg

"StopPriceUndefined" when stop price not set for a stop order leg

Etna.Trading.Oms.Processing.Validation.Syntax.SecurityTypeValidator, Etna.Trading.Oms

UnsupportedSecurityType” when security type is not allowed in configuration file

Etna.Trading.Oms.Processing.Validation.AccountOwnerShipValidator, Etna.Trading.Oms

UserDisabled” when user is disabled

"AccountDisabled" when account is disabled

"AccountIsNotApproved" when account status is not Approved

AccountDoesNotBelongToUser” when account doesn’t belong to user / user is not in Administrators group

Etna.Trading.Oms.Processing.Validation.FatFingersValidator, Etna.Trading.Oms

prevents from filling in random/occasional/extremely big values

uses database settings:

LargeTradeSizeShares - if stock order qty exceeds this setting  returns "FatFingersStockSizeExceedsMaximum

LargeTradeSizeContracts - if option order qty exceeds this setting  returns "FatFingersOptionsSizeExceedsMaximum

MaxTradeValue - the maximum trade value; when (orderQty*secContractSize*price) > MaxTradeValue, returns "FatFingersValueExceedsMaximum"

TradeBandMin - for limit orders: when limit price is too far from market price (value in percent), returns "FatFingersTradeBands"

TradeBandMax -  for limit orders: when limit price is too far from market price (value in percent), returns "FatFingersTradeBands"

Etna.Trading.Oms.Processing.Validation.PermissionValidator, Etna.Trading.Oms

uses MarginManager to validate an order

TradingDeniedForAccount” when account is not permitted to open position or any of option legs can’t be placed

"TradingDeniedForSecurity" when security is not tradable

"ShortTradingDeniedForSecurity" when short trade is disabled for security

"AccountMarginRuleViolation" when account doesn’t pass margin rules

Etna.Trading.Oms.Processing.Validation.WashTradesValidator, Etna.Trading.Oms

WashTradeAttempt” when user tries to place limit orders on the same security with same limit prices in different directions

Etna.Trading.Oms.Processing.Validation.StopPriceValidator, Etna.Trading.Oms

checks if the stop price is set correctly for a stop order. Compares stop price against bid and ask. 

BuyStopOrderStopPriceLessAsk” when user tries to place stop Buy/BuyToCover/BuyToOpen order with stop price less than ask

SellStopOrderStopPriceGreaterBid” when user tries to place stop Sell/SellShort/SellToClose order with stop price greater than bid

Etna.Trading.Oms.Processing.Validation.Syntax.CrossZeroPositionValidator, Etna.Trading.Oms

PositionLocked” when order position is locked and order is closing order

UnexpectedBuyOrder” when account tries to place Buy order on symbol for which account contains short position or pending Sell Short orders.

LongPositionCrossZero” when account tries to place Sell order on symbol for which account contains long position with (positionQty-pendingSellOrdersQty) < orderQty

UnexpectedBuyToCoverOrder” when account tries to place BuyToCover order on symbol for which account contains long or zero position.

ShortPositionCrossZero” when account tries to place BuyToCover order on symbol for which account contains short position with (positionQty-pendingBuyToCoverOrdersQty) < orderQty

UnexpectedSellShortOrder” when account tries to place SellShort order on symbol for which account contains long position or pending Buy orders.

UnsupportedOrderSide” when order side is not supported or not set

OcoOrderWithOppositeLegs” when one of the legs of OCO order has the opposite order direction.

Etna.Trading.Oms.Processing.Validation.Syntax.SellNotExistingPositionValidator, Etna.Trading.Oms

UnexpectedSellOrder” when account tries to place Sell order on symbol for which account contains short or zero position.

Etna.Trading.Oms.Processing.Validation.InitialMarginValidator, Etna.Trading.Oms

InitialMargin” when sum of order’s initial margin and cost exceeds account excess

Etna.Trading.Oms.Processing.Validation.OptionLevelValidator, Etna.Trading.Oms

OptionLevelRestriction” when trading this order is prohibited for account due to it’s option level

Etna.Trading.Oms.Processing.Validation.DayTraderPatternValidator, Etna.Trading.Oms

works for DayTrader and Margin accounts

"DayTraderPatternRestriction" when day trades count > 3

"DayTraderPatternEquityBalanceShortage" when dayTrade qty > 3 and Excess < 25 000

http://www.finra.org/investors/day-trading-margin-requirements-know-rules

Etna.Trading.Oms.Processing.Validation.OrderConsistencyValidator, Etna.Trading.Oms

MarketOrderIsGtc” when user tries to set Market order with GTC duration

ShortOrderIsGtc” when user tries to SellShort stock-like security with GTC duration

AonOrderQuantity” when order is AllOrNone and its quantity is <2

OrderQuantity” when order has 0 legs and its quantity <1

For using this validator include this section in section <validators>.   

Etna.Trading.Oms.Processing.Validation.TradeOptionAtExpirationDayValidator, Etna.Trading.Oms

This validator reject option orders of increasing position, if today is the day of expiration of this option and time after 1 p.m. But you can send order "Sell-to Close" or "Buy-to-Close" after 1 p.m.

In such case it returns "TradeOptionAfter1pmAtExpirationDay".

For using this validator include this section in section <validators>.

and include this section in <<eventManagerConfig >, section <events>. Usually it is in Oms.EventManager.config.

Key 'event' (TradeExpiredOption) - it is schedule for trade options at they expiration day.Time in config set in UTC.

Key 'state' (openedTradeExpiredOption) - after rise this state you can trade option at the day of expiration. After rise any other state option trade impossible.

Etna.Trading.Oms.Processing.Validation.NonStandartOptionsValidator, Etna.Trading.Oms

This validator reject non-standart option. You can not trade non-standart options. In this case validator returns "TradeNonStandartOptions".

You can send orders only for sell-to-close or buy-to-close position. Position for non-standart options can be opened in back office.

Validator define what is non-standart option with help of INonStandartOptionsCriterion. You can implement this interface or NonStandartsByNumbersInSymbol.

NonStandartsByNumbersInSymbol determine that option is non-standart if it contains numbers in first 6 characters in the name.

 For using this validator include this section in section <validators>.

Key 'criterion' determine what type of screening will be using for define non-standart options. 

 Etna.Trading.Oms.Processing.Validation.OtcTradeValidator, Etna.Trading.Oms 

This validator reject orders with Over-the-Counter securities. You can't trade with OTCBB and Pink securities. 

It returns “TradeOTC” when security’s exchange isn’t in list of OTC exchanges. 

For using this validator include this section in section <validators>. 

Key 'exchanges' determine at what borders trading OTC order. Usually it is name of channels, from which this securities was taken. About OTC on Quotemedia look Security exchanges 

Can be also managed through BackOffice / ORM validation rules

Etna.Trading.Oms.Processing.Validation.PriceOutOfMarketValidator, Etna.Trading.Oms 

Validate order, that price isn't out of the market. 

PriceOutOfMarket” when order price is more than ask for increasing position or less than bid for decreasing position 

For using this validator include this section in section <validators>. 

Etna.Trading.Oms.Processing.Validation.BuyingPowerValidator, Etna.Trading.Oms

InitialMargin” when account’s buying power is less than order initial margin 

Etna.Trading.Oms.Processing.Validation.ComplexOrderValidator, Etna.Trading.Oms

Complex orders is not allowed for IRA accounts.” when user is placing multileg order for Cash/MarginIRA account and any of legs’ securities isn’t an option

Etna.Trading.Oms.Processing.Validation.DayTradingExcessValidator, Etna.Trading.Oms

DayTradingBuyingPowerExceeded” when DayTradingBuyingPower - Order.Cost - PendingCash < 0

"TooSmallEquityForDayTrading" when account Margin Equity < $25000 and order is not closing

Etna.Trading.Oms.Processing.Validation.EventStateValidator, Etna.Trading.Oms

Invalid event state. Expected '{0}' but was '{1}'.” for different states missmatches

Etna.Trading.Oms.Processing.Validation.ExpirationDateValidator, Etna.Trading.Oms

InvalidOrderExpiration” when order TimeInForce is GTD and ExpireDate is less than current moment


Etna.Trading.Oms.Processing.Validation.ExtendedHoursValidator, Etna.Trading.Oms

ExtendedHoursOnlyLimitOrders” when order type is not limit (in extended hours)

ExtendedHoursNotOptions” when underlying security is an option (in extended hours)

ExtendedHoursWrongTimeForGTX” when order extended hours is “PRE” (for post-market) or “POST” (for pre-market) or any for opened market/extended hours closed

ExtendedHoursCanNotModify” when order is modification attempt and order modification in closed market is disabled (for post-market and extended hours closed)

Etna.Trading.Oms.Processing.Validation.IndexOptionsMultiOrderValidator, Etna.Trading.Oms

IndexOptionsOneExparyDate” when index option has incorrect expiration date

Etna.Trading.Oms.Processing.Validation.MaintenanceMarginValidator, Etna.Trading.Oms

MaintenanceMargin” when equity is more or equal than maintenance margin

Etna.Trading.Oms.Processing.Validation.NonStockStopLimitPriceConsistencyValidator, Etna.Trading.Oms

Validator, Etna.Trading.Oms for non-stocks:

PricePrecisionIsOutOfRange” when precision of stop/limit price is out of range

Etna.Trading.Oms.Processing.Validation.OptionSettlementValidator, Etna.Trading.Oms

Not enough settled cash.” when account is cash or marginIRA type, security is option, side is Buy and (available - unsettledDelta) is greater or equal than order cost

Etna.Trading.Oms.Processing.Validation.OrderPriceValidator, Etna.Trading.Oms

OrderPriceIsInvalid” when stop or limit price is incorrect (many cases for different sides)

Etna.Trading.Oms.Processing.Validation.OtoOcoValidator, Etna.Trading.Oms

OTO/OCO market orders are not allowed.” when OTO/OCO order is market

OTO/OCO trailing orders are not allowed.” when OTO/OCO order is trailing stop or trailing stop limit

OCO expiration type must be same.” when second order has other expiration than first one for OCO

OCO price difference shold be at least {0}$.” when OCO orders price difference is lesser than 0.1 for options or 0.2 for other types

Etna.Trading.Oms.Processing.Validation.PartiallyFilledOrderValidator, Etna.Trading.Oms

Can't modify partially filled order.” when user tries to modify partially filled order

Etna.Trading.Oms.Processing.Validation.PositionBalanceValidator, Etna.Trading.Oms

INAPPROPRIATE_POSITION_VALUE” when position exceeds threshold value for positions

Etna.Trading.Oms.Processing.Validation.PricePrecisionValidator, Etna.Trading.Oms

PricePrecisionIsOutOfRange” when order price precision exceeds 2 decimals for >=$1 price or 4 decimals for <$1 price

Etna.Trading.Oms.Processing.Validation.StockStopLimitPriceConsistencyValidator, Etna.Trading.Oms

Validator, Etna.Trading.Oms for stocks-like types:

PricePrecisionIsOutOfRange” when precision of stop/limit price is out of range

Etna.Trading.Oms.Processing.Validation.TimeInForceValidator, Etna.Trading.Oms

IncorrectTimeInForce” when time in force is not GTC or Day

Etna.Trading.Oms.Processing.Validation.TotalInitialMarginValidator, Etna.Trading.Oms

TotalInitialMargin” when equity is less than total initial margin + commissions value

Etna.Trading.Oms.Processing.Validation.UnsettledFundsUsageValidator, Etna.Trading.Oms

Too much unsettled cash will be released with this order.” when available cash is less than order cost - position available value

Etna.Trading.Oms.Processing.Validation.Syntax.OrderPriceValidator, Etna.Trading.Oms

LimitPriceUndefined” when limit price is not set for limit orders

StopPriceUndefined” when stop price is not set for stop orders

 StrikePriceUndefined” when order price is >0 and stop price is <0 for stop limit orders 

Validators priority

 

  1. ValidationRulesManagerValidator 1
  2. MultiLegsSyntaxValidator 1
  3. SecurityTypeValidator 1
  4. AccountOwnerShipValidator 1
  5. PriceOutOfMarketValidator 1, warning
  6. FatFingersValidator 1, warning
  7. PermissionValidator 2
  8. TradeOptionAtExpirationDayValidator 2
  9. OtcTradeValidator 2
  10. NonStandartOptionsValidator 2
  11. OrderConsistencyValidator 2
  12. StopPriceValidator 2
  13. CrossZeroPositionValidator 3
  14. SellNotExistingPositionValidator 3
  15. InitialMarginValidator 3
  16. OptionLevelValidator 3
  17. DayTraderPatternValidator 4
  18. UnsettledFundsUsageValidator 4

 

The numbers at the end of lines indicate the priority of the validator. The lower the number, the higher the priority. If multiple validators at the same time reject the order, you will see a message from the validator with the highest priority. f multiple validators at the same time reject the order and they have same priority, you will see a message from the first validator in the list with the that priority.



  • No labels