Announcement

Collapse
No announcement yet.

code review please...

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

  • code review please...

    The comments in the code should explain what I'm doing:
    PHP Code:
            var sym1 getSymbol();
            var 
    sym2 sym1.split(" ");
            
    // If today is a rollover day and we're using the continuous contract symbol
            // then warn the user to switch to the correct month.
            
    var bRolloverToday IsTodayRolloverDay();
            if(
    sym2.length && bRolloverToday && sym2[1] == "#F") {
                
    // popup warning that today is a rollover day but yesterday's
                // data is for a different contract
                
    msgBox("Warning: You are using a continuous contract (#F) which means that this " +
                    
    "indicator is using incorrect data from yesterday. Please switch to " +
                    
    "the next month's contract.""Warning - data problem");
            } 
    My questions:

    Is there already something built into eSignal or the EFS1 or 2 library that does what I'm trying to achieve above?

    Can you see any mistakes in the code or logic?

    How does one test this code before we hit a rollover date?

    Thanks
    Standing on the shoulders of giants.

  • #2
    Your code..

    Looks OK to me...

    The only real way to test it is to change (or alter) you IsTodayRolloverDay() to test specific dates. This way, you can test your code logic on any date you want, then assume it will work with rollover dates.

    B
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Also, you might need to take into account that traders rollover and start trading the next quarter a week before the actual expiry.

      Comment


      • #4
        Thanks for the ideas.

        Yes the IsTodayRolloverDay() checks to see if it is a Thursday 8 days before expiry Friday (which is the 3rd Friday of each quarter).

        If that's the day then I check for the #F.

        Are there other ways of expressing a continuous contract that would be missed by the #F check?
        Standing on the shoulders of giants.

        Comment


        • #5
          I believe that the American exchanges continuous contracts are only represented by the #F. Eurex, I know can not be done continuous. Unless I am mistaken. So I guess it depends on what symbols you might be using.

          Comment


          • #6
            Wild...

            If you find other contracts with different denotations for "continuous", then I suggest using an ARRAY to expand your search. Here is an example..

            ver ContinuousArray = new Array("#F","#S","#P"); // these are just examples..

            Now, you would use this function to check the array..

            function fIsContinuous(SymbolSuffex) {
            var x = 0;
            var vIsContinuous= false;

            while (x<ContinuousArray.length-1) {
            if ((SymbolSuffex == ContinuousArray [x])){
            vIsContinuous= true;
            }
            x=x+1;
            }
            return vIsContinuous;
            }

            You could also store this data to your web server and use the HTTP object to pull the array from your server.

            B
            Brad Matheny
            eSignal Solution Provider since 2000

            Comment


            • #7
              7.9 has user configurable rolls. The syntax is <ROOT> 1! for the front month, <ROOT> 2! for the next forward month, etc...

              However, since they're user configurable, the user can set them up to roll on any date, and not specific to what your EFS is expecting.

              (see Tools -> Continuous Contracts Settings).

              Comment


              • #8
                Thanks for all the info guys.

                Doji: Great idea: I already use the HTTP object to pull a lot of info from the web (like tick size etc.) so that would be easy to add.

                DionLoy: It looks like there's no way around a custom configured rollover date so I guess the user just has to have good documentation then. i.e. What I'm saying is that programatically there is no way that I can tell that yesterday's data is coming from a different contract than today's data in that scenario is there?

                Thanks again.
                Standing on the shoulders of giants.

                Comment

                Working...
                X