Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Import to SQL

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

    Import to SQL

    Hello, i have a problem with the format which NinjaTrader saves the datetime.
    SQL Server does not parse the time without the ":" between the hours, minutes and seconds.

    I've been looking for a solution, but I have no luck so far.
    Please i seek assistance on this issue.

    Thank you.

    #2
    What version of NinjaTrader 8 are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.0.?.?)

    Can you elaborate on how you're running into this issue exactly? Is there any associated error message?

    Comment


      #3
      8.0.20.1 64-bit

      I don't know if i made myself clear. Just in case i will clarify.

      I exported Historical Data, now i want to import it to my SQL server. And the "yyyyMMdd HHmmss" is not valid due to the absense of the colons in the time.

      Thank you.

      Comment


        #4
        Thank you for the clarification.

        I would not expect the time stamps of exported historical data to include semicolons separating the date from the time. Here is a help guide link with more information on what to expect with NinjaTrader historical data formatting:I am not aware of any tool that would automatically populate the semicolons necessary to make importing into an SQL. This would be possible to automate via NinjaScript. Would you like more information on how to program this yourself? Otherwise, you would have to perform this edit manually.

        I also encourage other forum users who may know of an existing tool that accomplishes this export format to provide that information.

        Comment


          #5
          I didn't say semicolons. I meant the colons of the time. NT exports it as "HHmmss" instead of "HH:mm:ss", that is the problem.
          Thank you.

          Comment


            #6
            I apologize for misreading your message. In any case, NinjaTrader exports the data in the format defined in the help guide and the same answer I provided applies to any desired change from that format.

            Comment


              #7
              Code:
              List<string> readFiles = new List<string>();
                          readFiles.Add(@"C:\file.csv");
              
                          List<string> writeFiles = new List<string>();
                          writeFiles.Add(@"C:\file.2.csv");
              
                          for (int i = 0; i < readFiles.Count; ++i)
                          {
                              StreamReader reader = new StreamReader(readFiles[i]);
                              StreamWriter writer = new StreamWriter(writeFiles[i]);
                              string line;
                              while ((line = reader.ReadLine()) != null)
                              {
                                  var split = line.Split(';');
                                  if (split[0].Length > 15)
                                  {
                                      var date = DateTime.ParseExact(split[0], "yyyyMMdd HHmmss fffffff", null);
                                      split[0] = date.ToString("yyyy-MM-dd HH:mm:ss.fffffff");
                                  } else
                                  {
                                      var date = DateTime.ParseExact(split[0], "yyyyMMdd HHmmss", null);
                                      split[0] = date.ToString("yyyy-MM-dd HH:mm:ss");
                                  }
                                  writer.WriteLine(string.Join(";", split));
                              }
                              reader.Close();
                              writer.Close();
                          }

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by traderqz, Today, 12:06 AM
              10 responses
              18 views
              0 likes
              Last Post traderqz  
              Started by algospoke, 04-17-2024, 06:40 PM
              5 responses
              46 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by arvidvanstaey, Today, 02:19 PM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Zachary  
              Started by mmckinnm, Today, 01:34 PM
              3 responses
              5 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by f.saeidi, Today, 01:32 PM
              2 responses
              9 views
              0 likes
              Last Post f.saeidi  
              Working...
              X