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 TraderBCL, Today, 04:38 AM
              2 responses
              16 views
              0 likes
              Last Post TraderBCL  
              Started by martin70, 03-24-2023, 04:58 AM
              14 responses
              106 views
              0 likes
              Last Post martin70  
              Started by Radano, 06-10-2021, 01:40 AM
              19 responses
              609 views
              0 likes
              Last Post Radano
              by Radano
               
              Started by KenneGaray, Today, 03:48 AM
              0 responses
              5 views
              0 likes
              Last Post KenneGaray  
              Started by thanajo, 05-04-2021, 02:11 AM
              4 responses
              471 views
              0 likes
              Last Post tradingnasdaqprueba  
              Working...
              X