If you create an order with a name longer than 50 characters you will see error messages such as
"Error on executing DB command: System.Data.SqlServerCe.SqlCeException (0x80004005): A duplicate value cannot be inserted into a unique index. [ Table name = Executions,Constraint name = PK__Executions__0000000000000300"
in the logs and you'll see more detailed information in the trace file. Unfortunately none of this information makes it clear what exactly has gone wrong.
It would be great if the Account.CreateOrder function threw an exception if an order name is longer than 50 characters. I strongly suggest anyone using this API to use this extension method instead
public static class AccountExtensions { public static Order CreateOrderWithChecks(this Account account, Instrument instrument, OrderAction action, OrderType orderType, OrderEntry orderEntry, TimeInForce timeInForce, int quantity, double limitPrice, double stopPrice, string oco, string name, DateTime gtd, CustomOrder customOrder) { Debug.Assert(name.Length <= 50, "The name is not allowed to be longer than 50 characters."); if(name.Length > 50) { throw new ArgumentException(string.Format("'{0}' order name exceeds 50 characters. Found {1}", name, name.Length)); } return account.CreateOrder(instrument, action, orderType, orderEntry, timeInForce, quantity, limitPrice, stopPrice, oco, name, gtd, customOrder); } }
Comment