Announcement

Collapse
No announcement yet.

Close() does not always return data

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

  • Close() does not always return data

    I'm accessing [or trying to] access the closing price for options but close() does not always return the price...any ideas?

  • #2
    dlee8989,

    I'm not sure of the answer, but if this is for stock options, esp. if it is on a short interval, there may not be a trade for any specific bar. I have seen days go by without a trade on some contracts.

    Some info on symbol/interval may help...

    Garth
    Garth

    Comment


    • #3
      Thanks for the reply. I'm not actually charting the option itself but rather displaying an option's last price (it'd be nice to be able to request either the 'buy' or the 'ask' instead of the 'close') based on the current stock symbol being charted. I store a list of options [in a file] I'm interested in and, based on the stock symbol I'm looking at, the options get read in. I call 'close()' for each option and display its price [along with the option]. Most of the time the close() returns a price; annoyingly, the price is NOT returned more times than it should. Interestingly, the options chain window displays pricing info for all options. I just did a test on a stock symbol that had problems earlier...all the options got priced. I believe it's more on the data stream side than the EFS side.

      Comment


      • #4
        I'm not sure I understand what you are trying to do but here are some comments:

        1) There is a getMostRecentAsk() and getMostRecentBid() command in EFS. This should get you the bid and ask values. I've never tried it with options, but it should work. For any symbol there should be a bid/ask for every bar.

        2) close() will only get the close for the current bar. If there was no trade during that interval, there will be no close() value. The option chain displays the last trade price, which as I have said can be days old on some option symbols. If you use a monthly interval and do a close() I bet there will be value for almost every option symbol (unless it is really out of the money, or very obscure stock).

        3) If #2 doesn't work, then post the option symbols showing the problems...it may help with debugging this.

        Garth
        Last edited by gspiker; 05-02-2008, 10:19 AM.
        Garth

        Comment


        • #5
          Hi Garth,

          In summary, I'm trying to display an option's price for the underlying security in the price pane. For example, while monitoring CISCO [CSCO], I'd like to see what the current price is for the $25, $26, and $27 call options...CYQ EE, CYQ EQ, and CYQ EN, respectively. My EFS script makes the following call:

          OptionPrice = close( "CYQ EE, D" );

          replacing the option symbol for each option. I then execute a drawTextAbsolute() for each option and price. However, sometimes the price is returned and sometimes not. When the price is not returned, I've 'reloaded' the script with some success (i.e., the price appears); other times, I've exited completely from eSignal (and close the data manager) and restarted...this, too, has had limited success...sometimes the price appears, other times not.

          I have the options chain window open and linked to the chart. This allows me to verify that I've got the option symbol correct and that I'm getting the correct price. The good news: I've got the option symbol correct and the option chain window displays all the pricing; the bad news...my close() call does not return the price.

          As to your most appreciated suggestions and/or comments:

          1. The getMostRecentBid() and getMostRecentAsk() functions would be great if you could optionally supply a symbol/interval parameter. They only work off the chart's symbol. This would be an even better function to call [instead of the close()] as the close() function doesn't discern whether the last was a bid or ask price and, as we all know, they're never the same!

          2. Yes, close(), by default, will retrieve the last price for the current bar UNLESS you supply it with an interval which I do. Since I'm only interested in the close() for the day, I explicityly define the 'D' interval when I make the close() call, as in the example above. The only time the close() would return 'null' is if there were no activity on the option for that day, i.e., no one as either bought or sold the option at all. This is another good reason to use the getMostRecentBid() and getMostRecentAsk()...they'll always be a Bid/Ask but not necessarily a Last price...a Last price will only exist once someone has bought or sold. Finally, as you pointed out, I'm only interested in highly liquid optons, i.e., [underlying] securities that trade with large volume...250,000 shares minimum and usually much, much more such as Cisco.

          I have a call into Tech Support and will post their response. Thanks for your interest.

          David

          Comment


          • #6
            Hi,

            There is also a getMostRecentTrade()...but like the other calls, it doesn't seem to allow a different symbol to be specified.

            I did chart the symbols you specified on a daily chart, and all do seem to have trades each day (not surprising).

            Sorry I couldn't help more.

            Garth
            Garth

            Comment


            • #7
              Hi David,

              If you are not referring to a bar Index when getting the close price, the issue could be that the format of your close command is returning a series object. In this case, the series object contains the data for every single value in the chart associated with the close price, in addition to several methods to retrieve them. Declaring a series once is efficient, doing so multiple times is not so efficient.

              See this link :

              http://kb.esignalcentral.com/article...ticle=2090&p=4


              The close() function is used to create a
              Series Object of the close prices or to retrieve individual close price values.

              close() returns a Series Object when nBarIndex is not specified.
              close(-1) returns a single price value when nBarIndex is specified.



              In your code, if your variable 'OptionPrice' were a global variable, you could create the series once with this line (inside a bInit conditional, for an example of this see the EFS 2 Custom folder in your Formula folder on your computer):

              OptionPrice = close( "CYQ EE, D" );



              Then to access the close price as you have defined the series, you would just call

              OptionPrice(0); - returns the close of the currently developing bar

              or

              OptionPrice(-1); - returns the close of last completed bar.


              See the links in my signature below for other references. The EFS Glossary is not as detailed as looking it up in the EFS Knowledgebase, so I usually check both.

              Hope this helps.

              Originally posted by dlee8989
              ...

              My EFS script makes the following call:

              OptionPrice = close( "CYQ EE, D" );
              ...
              the bad news...my close() call does not return the price...

              Comment


              • #8
                Hi Steve,

                Thanks for the input. I've tried all sorts of variations:

                (a) OptionPrice = close( 0, "CYQ EE,D" );
                (b) OptionPrice = close( 0, sym("CYQ EE,D") );
                (c) OptionPrice = close( sym("CYQ EE,D") );

                For (a) and (b) , I display OptionPrice as:

                debugPrintln( OptionPrice );

                which displays 'null'.

                For (c), I tried:

                debugPrintln( OptionPrice );

                and still get 'null' displayed. I tried:

                debugPrintln( OptionPrice(0) );

                [as you suggested] and I don't get anything displayed, not even 'null'.

                However, for (a), (b), and (c), when I change the option symbol to Oracle's and I write:

                debugPrintln( OptionPrice );

                I get a correct price value returned and displayed!

                As to your [appreciated] suggestions/ideas:

                * since I only need the most current closing price, creating a series is not necessary and, more importantly, could be a performance issue,

                * I've done something very similar to the 'bInit' routine you mentioned (I did take a look at it) but it isn't appropriate for my needs...the [closing] price of an option can change as the value of the underlying security changes...therefore, I want the option price each time the charted symbol's price changes.

                Since the close() function call returns a value for some option symbols and not others, it leads me to believe:

                * there is an issue with the close() call itself when it comes to option symbols, or

                * the data stream does not contain all the option prices or option pricing is on a different data stream than stock pricing, or

                * both!

                I spoke with tech support, who, by the way, was very professional. Unfortunately, they referred me to the forums. I've got a PM to Jason K, a product manager...I'll wait to see what he says...I'm hoping he'll be able to resolve my issue, one way or another. Thanks for the input...I'll enter a post as soon as I hear from Jason.

                Comment


                • #9
                  Hi David,

                  Your welcome, hopefully you are successful in your endeavor. Just a followup on a couple items.

                  The resources it takes to create a series are only significant when it is created. Once created, the series will automatically be updated every tick by the efs engine, regardless of whether you refer to it ever again. The creation of the series takes over 95% of the resources that are required over the life of the efs.

                  Once a series is created, the resources to maintain it are minimal. Again, the efs engine takes care of updating the series all by itself. You can ask for the most recent price at any time and it will be up-to-date.

                  If overwritten to a different series, the variable will represent the new series, not the original. If set to null, the variable would no longer represent a series and would no longer be automatically updated.


                  Originally posted by dlee8989


                  * since I only need the most current closing price, creating a series is not necessary and, more importantly, could be a performance issue,

                  * I've done something very similar to the 'bInit' routine you mentioned (I did take a look at it) but it isn't appropriate for my needs...the [closing] price of an option can change as the value of the underlying security changes...therefore, I want the option price each time the charted symbol's price changes.


                  With regards to the format to grab the series value, you should try a different format than what I previously posted.

                  Once a series object has been created, in order to access specific values, you must use the getValue() method of the series. Using the example I used before ...

                  Then to access the close price as you have defined the series, you would just call

                  OptionPrice.getValue(0); - returns the close of the currently developing bar

                  or

                  OptionPrice.getValue(-1); - returns the close of last completed bar.

                  I know there was a workaround put in place to ensure that efs1 code still worked once the efs2 methods were introduced. This explains why you will get a price returned when referring to a series, e.g. close()

                  Originally posted by dlee8989

                  However, for (a), (b), and (c), when I change the option symbol to Oracle's and I write:

                  debugPrintln( OptionPrice );

                  I get a correct price value returned and displayed!
                  Based on performance testing I have performed, using a barIndex parameter is more efficient than not using a barIndex inside the parenthesis.


                  There may be another issues that are affecting your efs, you may want to post working code if you continue to have problems.
                  Last edited by ; 05-06-2008, 05:28 PM.

                  Comment


                  • #10
                    Hello David,

                    If you try to load a daily chart for the option symbol(s), do you get data? As long as you see chart data for the symbol, close() should be returning a valid values and not nulls. That is the first thing we need to check.
                    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


                    • #11
                      Hi Jason,

                      Nice to hear from you. Yes, I can load an option in a chart and access the value(s) with the close() function. However, I'm still having the same problem as described below. I've tried various forms of the close() function to no avail. Based on the documentation description, I thought that if I specified only the 'symbol, interval', I would get a series back; likewise, if I specified a barIndex, "symbol, internval' I would get a single value back. I've tried both with no success. In fact, when I specify only the 'symbol, interval' (e.g., sObj = close( 0, "AW EV, D" ), the code seems to terminate on the function call. I have a debugPrintln() call before and after the function call; only the first debug statement prints...the second does not. I do get a value back for some options sometimes with just the "symbol, interval" defined. I'm kinda confused between what the doc says and what the functions return. Any additional comments on this would be greatly appreciated.

                      As a side note, I have no interest in charting an option...it really doesn't make any sense to do so. I'm interested in monitoring the underlying stock and displaying current prices on options [for the currently charted stock] that I'm interested in. That's why I'm trying to access an option's price by specifically naming it as a parameter to close().

                      Thanks for your help...it's greatly appreciated.

                      Comment


                      • #12
                        Hello David,

                        I was able to see the problem with the null using AW EV. There does seem to be a problem with EFS calls accessing the short form of the option symbol names. I'll report this to development. It appears to only return valid data while on the current bar, but not always as you've encountered.

                        In the mean time, there may be a solution for you. If you use the long form of the option symbol names, the calls seem to work properly. Try the following code example and let me know if this works for you.

                        PHP Code:
                        function preMain() {
                            
                        setPriceStudy(false);
                            
                        setStudyTitle("test");
                            
                        setCursorLabelName("AW MAY12C"0);
                            
                        setCursorLabelName("AW EV"1);
                            
                        setDefaultBarFgColor(Color.blue0);
                            
                        setDefaultBarFgColor(Color.red1);
                            
                        }

                        function 
                        main() {
                            var 
                        OptionPrice1 close(0sym("AW MAY12C, D") );
                            var 
                        OptionPrice2 close(0sym("AW EV, D") );
                            
                        //var OptionPrice = close(0);
                            
                        debugPrintln("index: " getCurrentBarIndex() + " AW EV: " OptionPrice2);
                            
                        debugPrintln("index: " getCurrentBarIndex() + " AW MAY12C: " OptionPrice1);
                            
                            return new Array(
                        OptionPrice1OptionPrice2);

                        Some additional notes on the syntax of close(). The way you're referencing the symbol (i.e. close(0, "AW MAY12C, D") ) is actually legacy syntax. The proper way to reference an external symbols and intervals with a call like this is to pass that string to the sym() function (i.e. close(0, sym("AW AW MAY12C, D")) ).

                        With any efs2 series function, if you specify a bar index parameter, you will get a single value returned. If you want a series object to be returned, do not specify the bar index parameter. Using the code example above, the following modification create the equivalent functionality using series objects of close().

                        PHP Code:
                        var xStudy1 null;
                        var 
                        xStudy2 null;
                        var 
                        bInit  false;  // initialization flag

                        function main() {
                            if (
                        bInit == false) {
                                
                        //var OptionPrice1 = close(0, sym("AW MAY12C, D") );
                                //var OptionPrice2 = close(0, sym("AW EV, D") );
                                
                        xStudy1 closesym("AW MAY12C, D") );
                                
                        xStudy2 closesym("AW EV, D") );
                                
                        bInit true;
                            }
                            
                            var 
                        OptionPrice1 xStudy1.getValue(0);
                            var 
                        OptionPrice2 xStudy2.getValue(0);
                            
                        debugPrintln("index: " getCurrentBarIndex() + " AW EV: " OptionPrice2);
                            
                        debugPrintln("index: " getCurrentBarIndex() + " AW MAY12C: " OptionPrice1);
                            
                            return new Array(
                        OptionPrice1OptionPrice2);

                        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


                        • #13
                          Hi Jason,

                          First, I didn't realize there was short and long name for options...are these forms specific to eSignal or are they recognized across various platforms?

                          I modified my script to use the long form of the option symbol and the current syntax of close(). I've noticed the following:

                          * I'm getting back pricing information! So far, I haven't run across any null value...will let you know if I do.

                          * When I modified my script last night (while the market was closed), the close() price returned matched up with the Last price in the options chain window. However, this morning, while the market is open, the prices no longer match up. As of 10:17 AM EST, I'm monitoring CMG JUN90P. The script is returning $4.50 while the options window is showing $5. Again, I've run a test script that only makes the close() call with the long option symbol hardcoded...it is, in fact, returning $4.50. I've checked several other options I'm monitoring and they all differ than what's in the options chain window.

                          *the close() call seems to take longer on an option than on a stock. I've also noticed this when I chart an option, too.

                          Comment


                          • #14
                            Hello David,

                            The differences in the price in the quote window (or options chain window) vs EFS may have to do with your time template settings in the advanced chart. The quote window will show the last price sent from the exchange. In order to show the same result from EFS you will need the chart to be using a 24-hr time template.
                            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


                            • #15
                              Hi Jason,

                              Understood. I'm currently using the default time template, "Dynamic, 0:00-24:00", for all my charts. It's currently 9:00 PM EST and some of the EFS prices matches up with the quote window and some do not. I'll keep checking through the weekend to see if they [eventually] sink up.

                              Comment

                              Working...
                              X