Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Test Driven Development (TDD)

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

    Test Driven Development (TDD)

    NT Forum,

    Some years have passed since (Test Driven Development (TDD)) was posted (happy to have the thread moved into NT8/Platform Technical Support).

    Is there any functionality or guidance towards implementing Test Driven Development (TDD). Any guidance or examples from NT or third party developers would be greatly appreciated.

    Shannon

    #2
    Hello Shannon,

    Thank you for your post.

    We would not have any items specific to TDD or a similar process. I can point you towards our Best Practices in the Help Guide but this would not be a process like TDD: https://ninjatrader.com/support/help..._practices.htm

    Please let me know if you have any questions.

    Comment


      #3
      Shannon, you need to clearly define what exactly you want to test. If you for example have specific routines in your code that require testing then I would recommend that you extract them into an external project and run tests against them. That's usually what I do with more complex modules which I either copy/paste into my strategy or implement them as an external DLL.

      For testing the actual order flow etc. - this would be more difficult as you would have to simulate the live data. Which is something you could do by using the custom data connector and feeding it simulation data. With a bit of creativity it can be done.

      In general TDD usually allows you to maintain your core business logic and NT functionality is outside of your own domain. What you want to test is what you are adding, i.e. particular calls which may break based on faulty/changed parameters, null values, data series problems, etc.

      So in summary: extract your core logic into external testing modules and do your TDD there. Executing for example asserts in the context of NinjaTrader running live or in simulation mode would be very difficult and quite frankly is far outside the needs of most strategy/indicator developers.

      Comment


        #4
        Thank your for your respective responses.

        I am currently refactoring several complex Indicators originally designed to operate under Calculation.OnBarClose to operate under .OnBarClose AND .OnEachTick.

        Ideally, I would like to develop unit tests for each Indicator which would operate under .OnBarClose OR .OnEachTick. I believe this would require mocking (or similar) a specified sequence of OnBarUpdate events. Ideally, a sequence of tick data could be recorded (or extracted) and used to develop a mock series. Unit Tests could then consume the mock series (under .OnBarClose OR .OnEachTick) to test and validate Indicator behavior.

        On reflection, my question should have asked for guidance towards automated unit testing in NT8. Any guidance would be greatly appreciated.

        Comment


          #5
          Hello Shansen,

          Thank you for your response.

          I could see this as a custom instrument that you exported data from another instrument or created your own historical data using a formatting (linked below). Then in the Playback Connection you could play back the historical data for the custom instrument with the tailored data as you need.


          Please let me know if you have any questions.

          Comment


            #6
            Patrick,

            Thank you for the excellent suggestion. Though this approach is far from and automated approach.
            Is it possible to mock tick events and feed through the NT8 process to form bars and be processed as normal by Indicators?

            It appears this topic (or similar) has been broached previously:
            - Making NinjaScript Development Unit Testable
            - Unit Testing in NT8

            Again thanks
            Shannon

            Comment


              #7
              Hello Shannon,

              Thank you for your response.

              I would not have any additional solutions for this item.

              Comment


                #8
                Hi Shannon,

                This is a pretty old thread, but if you are still looking - here is a guide on how to approach TDD with NT8:
                A step-by-step guide to implementing TDD Best Practice in NinjaTrader 8 with NUnit and Visual Studio Community Edition.


                Hope this helps,
                Frank

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by bortz, 11-06-2023, 08:04 AM
                47 responses
                1,607 views
                0 likes
                Last Post aligator  
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                9 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                19 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Jon17, Today, 04:33 PM
                0 responses
                6 views
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                15 views
                0 likes
                Last Post Javierw.ok  
                Working...
                X