• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Account.CreateOrder with names longer then 50 characters results in strange errors.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Account.CreateOrder with names longer then 50 characters results in strange errors.

    The documentation clearly states that order names should not be longer than 50 characters. This important detail can easily be overlooked if the names for orders are generated at runtime.

    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

    Code:
    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);
        }
    }

    #2
    Hello ntbone,

    I will submit a feature request for Account.CreateOrder function to throw an exception if the order.Name is greater than 50 characters.

    Once I have a tracking ID for this request I will post in this thread for future reference.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you. Similarly I'd suggest the managed/unmanaged strategy functions that accept a name for the order also throw exceptions, if they don't already. I haven't worked directly with those yet so I am not sure if this issue also affects them.

      Comment


        #4
        Hello ntbone,

        I have received tracking ID# SFT-4094 for this request for Account.CreateOrder function to throw an exception if the order.Name is greater than 50 characters.

        Please note it is up to the NinjaTrader Development to decide if or when any request will be implemented.

        We appreciate you taking the time to provide feedback.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NinjaCustomer, Today, 12:29 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_ChrisSch  
        Started by smgrvd, Today, 12:08 AM
        0 responses
        4 views
        0 likes
        Last Post smgrvd
        by smgrvd
         
        Started by ronaldgreene828, Yesterday, 07:50 PM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_EricB  
        Started by nailz420, 07-17-2019, 08:38 AM
        2 responses
        13 views
        0 likes
        Last Post nailz420  
        Started by bouncetherubble, Yesterday, 06:56 PM
        0 responses
        6 views
        0 likes
        Last Post bouncetherubble  
        Working...
        X