Display data in a html table in Console

cg142806cg142806 Posts: 2

I am trying to implement the Working Example for "Rate of Change", documented here:
https://app.cloudquant.com/#/glossary/281

When I run the working example, the data in the console does not show up as a table, but rather is is the raw html.

Here is my excerpt from my console output:

search
MSFT: 2018-06-29 09:30:00.000000

<

table class="talib" style="width:100%">


ROC: MSFT



Input
Output


date
close
real


2018-02-06
90.51
nan

Comments

  • ptunneyptunney Posts: 246
    edited July 2018

    I'll be honest, I have never used this function.

    If you run it for one symbol and save the text from the console window into a file and open the file in your browser you will have a table but I am sure that was not the intended process.

    I have reported it to our devs to see why it is broken.

    Are you just working through some of the demo code?

    As a new user, I would be much more interested in seeing exactly what data the TALIB function returned to me in its own format so I would know how I needed to manipulate it.

    In this case, I gave it 100 data points, what did it actually give me back?

    So my code would be...

    from cloudquant.interfaces import Strategy
    from collections import OrderedDict
    import talib
    class WE_ROC(Strategy):
        @classmethod
        def is_symbol_qualified(cls, symbol, md, service, account): 
            return symbol=="MSFT"
        def on_start(self, md, order, service, account):
            daily_bars = md.bar.daily(start=-100)
            close = daily_bars.close
            real = talib.ROC(close, timeperiod=10)
            print real

    Run on 5/1/2018 I get...

    [         nan          nan          nan          nan          nan
              nan          nan          nan          nan          nan
       5.1967459    3.30999411   3.64888968   1.60409777   0.19945977
       0.15191631   0.43354621   1.00374863  -1.03627638  -0.03466128
       1.49129554   3.12205703   3.2514683    3.16918983   2.83374017
       2.76510797   4.52641421   3.28493712   4.8750281    4.34271954
       3.31766262   3.87797725   4.10061535   4.08074303   5.13548793
       6.78923902   4.82143048   4.96890309   5.4026771    4.61714357
       1.97780063  -3.94059492  -0.62020011  -2.40691818  -7.92810869
      -6.25132273  -5.10008015  -3.13780294  -3.97163227  -1.23566703
       0.71055815   5.85852617   0.64574105   2.84670136  11.16560102
       8.71880881   6.18474814   4.87640398   2.2464497    0.42089291
       1.78260803   0.64710792   2.59045011   2.94341747   2.63661856
       1.41479616   0.22293707   0.08531709   1.43241987   1.66576612
      -0.80093977  -0.20360313  -1.47027194  -4.91369202  -9.69546356
      -3.08979846  -5.23249894  -4.75226335  -3.08983187  -6.42706335
      -3.42340438  -0.85900939  -0.10813808   0.49003501   4.11791274
      -0.95969454   2.67128575   4.68732797   1.98313274   6.38274033
       7.0895114    4.45142481   4.03767425   5.28648616   5.04572216
       0.25840385   0.48987257   0.72665131   2.94370199  -0.69024269]

    And what does that mean, well the oldest 10 data points return NAN. So without even looking at what ROC is I can say that the ROC function must need at least 10 data points to render a result. The final result in the list is the most recent return from the ROC.

    To print this out on its own we would use print real[-1].

    If you are interested in playing with the TALIB functions I would point you to the demo code under the SCRIPTS TAB, click PUBLIC SCRIPTS and click TALIB. There are a few simple demos there that should get you going quite quickly.

    Hope this helps.

  • cg142806cg142806 Posts: 2

    Thanks. I can work without the html table function no problem. Just wasn't sure if it was supposed to be working or not? or if there was some other trick to get it to present properly.

Sign In or Register to comment.