Announcement

Collapse
No announcement yet.

Help w/rounding Bid/Ask on e-russell

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

  • Help w/rounding Bid/Ask on e-russell

    Hi all,
    Can anyone help with the following???

    Enclosed is a script I use for a "trading Button" to retrieve MostRecent Bid/Ask pricing and trade when there is only a .10 spread between Bid/Ask on the e-russell. However; some the Ask/Bid prices retreved by getMostRecentAsk()/ Bid() function have extended decimals.(Bad esignal Data????).
    So I used a rounding logic to truncate to 2 dec. places.

    Simple enough... however when there is only a .10 spread after rounding values, my logic on line 170( ie: if(Ask - Bid == .10 ), is ignored and therefore lines 171 and 172 are ignored.

    I have enclosed my script and debug Output file to show the results of Both getMostRecentAsk/Bids and rounded values.


    This one has me stumped.

    Angelo
    ang.

  • #2
    Hello Angelo,

    Your EFS was not attached to your post. Please try again.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Hi Jason,

      Sorry, will try to post again.
      Attached Files
      ang.

      Comment


      • #4
        Hi Jason,

        Here is another version, using Stevehare's "round " routine version. Notice the long decimal on the getMostRecentBid().
        Also, why is the rounding difference after rounding both Ask & Bid coming up with the difference of a decimal???

        I see now why the logic of (Ask - Bid) is not true, since the difference is over .10. But why does (734.9 - 734.8) produce a difference of .10000000000002274 ?????

        Thanks for your help!!

        Angelo
        Attached Files
        ang.

        Comment


        • #5
          Angelo

          But why does (734.9 - 734.8) produce a difference of .10000000000002274 ?????
          That is due to how JavaScript (as well as some other languages) represents certain numbers (see this article in the EFS KnowledgeBase). The solution is to use the .toFixed() method as shown in the enclosed image
          Alex

          Comment


          • #6
            Hi Alex,

            Thanks for the solution to using the Fixed method to truncating decimal places.
            I see there is no need to apply rounding in this case. I also see the need to use this Fixed method in the logic as well.

            I was under the impression once a number was rounded it would retain its properties of fixed decimal places.

            As always, thanking you and the other moderators for your/their immersurable help in these threads!.

            Angelo
            ang.

            Comment


            • #7
              Angelo
              As always you are most welcome
              Alex

              Comment

              Working...
              X