Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calling Python and R functions from NinjaTrader/C#

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

    Calling Python and R functions from NinjaTrader/C#

    I'm looking to write a function in Python and using Python for .NET call it into a NinjaTrader strategy. I know that this can be done in C#/.NET but has this been tried in NinjaTrader? Also, is there anything about NinjaTrader that would not allow a Python function to be called into it? I'd be willing to consider IronPython which is Python built for the .NET platform,

    Similarly, I'd be interested in calling functions into Ninja strategies that are written in R. Has this been tried? Is there anything about Ninja that would not permit this?

    Thx,
    Lou
    Last edited by bluelou; 06-05-2010, 11:01 PM.

    #2
    Hi bluelou,

    I don't believe integration with Python is supported, however here is more information on integration though our ATI



    Perhaps others on this forum can speak to your specific requests.
    TimNinjaTrader Customer Service

    Comment


      #3
      Tim,
      Thx for this. There is a .NET version of Python called IronPython and there are other ways of calling traditional CPython into .NET as well (e.g., Python for .NET). R has R D COM for use with .NET. But, I'd prefer not to be the 1st Ninja user to try this. If anyone has any experience with any of the above please chime in.

      What about the Meta.Numerics C#/.NET open-source statistical library? Has this been tried w/Ninja? This sounds like the cleanest way to go for my purposes since the libraries are written in C#.

      Thx,
      Lou

      Comment


        #4
        Use R or python in NT

        Hi,

        Has anyone succeded using R or Python from NT ?

        I think it would open very nive perspective for NT users....

        I unfortunately have to use other platforms like quantopian in order to use machine learning/statistical capabilities of python or R !! such a pity..

        regards,

        Mayouf.k

        Comment


          #5
          Originally posted by mayouf.k View Post
          Hi,

          Has anyone succeded using R or Python from NT ?

          I think it would open very nive perspective for NT users....

          I unfortunately have to use other platforms like quantopian in order to use machine learning/statistical capabilities of python or R !! such a pity..

          regards,

          Mayouf.k
          I've used statconn for R. But, it's no longer free. It's easier for me to go R >> MySQL >> C#/NT for periodic parameter updates. And, data in R via C#/NT >> .csv >> R

          Comment


            #6
            Use R or python in NT

            Hi bluelou,

            Thanks for your reply. It would be great if we can see an script example of how you used statconn.

            About SQL, if I get it right, you have you data in CSV or SQL like below:

            Open | High | Low | Close
            10 | 12 | 8 | 11

            And you compute a long or short signal in R (even python I guess) by using any model.
            Then you add an "output" column in your data in order to have this:

            Open | High | Low | Close | Signal
            10 | 12 | 8 | 11 | 1 (or 0)

            When you get this data with this added column, then you import the csv is NT and use the signal column to activate your trading orders ?

            Im not sure if it is the way you did,,,,but the idea looks great.

            Is that possible to have a very simple script of the way you use this trick ?

            cheers,

            Mick

            Comment


              #7
              Originally posted by mayouf.k View Post
              Hi bluelou,

              Thanks for your reply. It would be great if we can see an script example of how you used statconn.

              About SQL, if I get it right, you have you data in CSV or SQL like below:

              Open | High | Low | Close
              10 | 12 | 8 | 11

              And you compute a long or short signal in R (even python I guess) by using any model.
              Then you add an "output" column in your data in order to have this:

              Open | High | Low | Close | Signal
              10 | 12 | 8 | 11 | 1 (or 0)

              When you get this data with this added column, then you import the csv is NT and use the signal column to activate your trading orders ?

              Im not sure if it is the way you did,,,,but the idea looks great.

              Is that possible to have a very simple script of the way you use this trick ?

              cheers,

              Mick
              Mick,
              Anything I've done with statconn and MySQL and NT isn't specific to NT, just C#. I haven't used statconn in a few years. I don't even have any of the code I used. But, I can give you an idea of my use case with MySQL.

              For MySQL, I'm not doing what you've described. Think of it as 2 csv files. The 1st file is indicator-type output from NT. This file is used as input to a model in R. An R script is run and the parameter output is added to a MySQL database. In NT, strategy parameters are called from the MySQL database.

              I use the MySQL database with NT in 2 different ways: For backtesting, I can query the database for a matrix of parameters that evolve over time. For live trading, the most recent parameter set is called into NT when the strategy is initialized. This solution makes sense for me since my parameters evolve relatively slowly. I only need to update the database every couple of weeks.

              There's nothing here unique to NT. This is just C# and MySQL. I don't have examples b/c they're non-trivial. Also, I don't know a lot about MySQL. I needed it as a bridge b/t R and C# and hired someone to write a MySQL script.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by fx.practic, 10-15-2013, 12:53 AM
              5 responses
              5,403 views
              0 likes
              Last Post Bidder
              by Bidder
               
              Started by Shai Samuel, 07-02-2022, 02:46 PM
              4 responses
              94 views
              0 likes
              Last Post Bidder
              by Bidder
               
              Started by DJ888, Yesterday, 10:57 PM
              0 responses
              6 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by MacDad, 02-25-2024, 11:48 PM
              7 responses
              158 views
              0 likes
              Last Post loganjarosz123  
              Started by Belfortbucks, Yesterday, 09:29 PM
              0 responses
              8 views
              0 likes
              Last Post Belfortbucks  
              Working...
              X