Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 algospoke, Yesterday, 06:40 PM
        2 responses
        19 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        45 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        20 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        181 views
        0 likes
        Last Post jeronymite  
        Working...
        X