Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bug in Grids (orders, executions etc.)

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

    Bug in Grids (orders, executions etc.)

    Hi, I'm a C# developer and will be talking some programming.
    There is a known Microsoft bug in DataGrid (or DataGridView, don't remember in which one, or may be in both...) and looks like you did not take any action to prevent it. The problem shows when you try to sort a grid by clicking on a DateTime column header and there are records with the SAME DateTime values.

    Here is an example:
    Lets say we have executions grid like this:
    [GOOG] [Buy][100] [1/9/2009 9:00:00] [100L]
    [GOOG] [Sell][10] [1/9/2009 9:10:00] [90L]
    [GOOG] [Sell][20] [1/9/2009 9:10:00] [70L]
    [GOOG] [Sell][70] [1/9/2009 9:15:00] [-]

    Note that selling 10 and 20 happened at the same time.
    If you sort backwards the grid by clicking on Time column you will se something like this:
    [GOOG] [Sell][70] [1/9/2009 9:15:00] [-]
    [GOOG] [Sell][10] [1/9/2009 9:10:00] [90L] <- (!)
    [GOOG] [Sell][20] [1/9/2009 9:10:00] [70L] <- (!)
    [GOOG] [Buy][100] [1/9/2009 9:00:00] [100L]
    Note that data grid control sorted records with equal DateTime values incorrectly! And it creates lots of confusion.

    Correct result should look like this:
    [GOOG] [Sell][70] [1/9/2009 9:15:00] [-]
    [GOOG] [Sell][20] [1/9/2009 9:10:00] [70L]
    [GOOG] [Sell][10] [1/9/2009 9:10:00] [90L]
    [GOOG] [Buy][100] [1/9/2009 9:00:00] [100L]


    Here is a tip how to avoid it: When you add a record to the underneath data table, check last record's DateTime columns and if they are equal add 1 tick to the new record's DatTime column values. It wont affect how records are displayed but will guarantee that sorting back and forth will work correctly.


    Cheers!

    #2
    Not exactly sure what you are referring to. NT does not use the MS DataGrid/DataGridView.

    Also: If 2 records hold the same (!) timestamp, then their sorting is random since there is no "first" or "last" logic with them.

    Comment


      #3
      I'm referring to the .NET control called "DataGrid" (.NET 1.x) or "DataGridView" (.NET 2+) which I believe you use those controls to display tabular data. Or may be you use some kind of inherited controls and it also inherits the bug.

      If 2 records have the same time stamp their sorting should not be random. For those records sorting should consider which record came first to the data set. And you can see that sequence is important consideration when we look at the example of incrrect sorting here:

      [GOOG] [Sell][70] [1/9/2009 9:15:00] [-]
      [GOOG] [Sell][10] [1/9/2009 9:10:00] [90L]
      [GOOG] [Sell][20] [1/9/2009 9:10:00] [70L] <- (!) Why 70L?! should be 80L!
      [GOOG] [Buy][100] [1/9/2009 9:00:00] [100L]


      Note that selling of 10 shares has been recorder first and position was reduced to 90L. Then selling of 20 has been put to the data table and position was reduced to 70L. But if you resort the data incorrectly selling of 20 comes right after opening a position and shows Incorrect number of remaining shares of 70.
      By looking at that data anybody would ask: "How come, I bought 100 shares, then sold 20. Why my position is 70L instead of 80L?!"

      My point is that even if records have the same time stamp their sequence is important and they should be sorted considering the sequence. You can see in the example above that sequence IS important as if it's broken position values become sensless.

      Then if you think that sorting should be random, ok no problem, but agree that sorting backwards must produce exact oposite sequence of records.

      Comment


        #4
        >> I'm referring to the .NET control called "DataGrid" (.NET 1.x) or "DataGridView" (.NET 2+) which I believe you use those controls to display tabular data. Or may be you use some kind of inherited controls and it also inherits the bug.
        No, we don't.

        >> My point is that even if records have the same time stamp their sequence is important and they should be sorted considering the sequence.
        Thanks for your suggestion. We'll add it to the list of future considerations.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by giulyko00, Today, 12:03 PM
        0 responses
        2 views
        0 likes
        Last Post giulyko00  
        Started by AttiM, 02-14-2024, 05:20 PM
        12 responses
        213 views
        0 likes
        Last Post DrakeiJosh  
        Started by cre8able, 02-11-2023, 05:43 PM
        3 responses
        238 views
        0 likes
        Last Post rhubear
        by rhubear
         
        Started by frslvr, 04-11-2024, 07:26 AM
        8 responses
        117 views
        1 like
        Last Post NinjaTrader_BrandonH  
        Started by stafe, 04-15-2024, 08:34 PM
        10 responses
        47 views
        0 likes
        Last Post stafe
        by stafe
         
        Working...
        X