1

I would like to ask a completely new question regarding this code.

The code in the link above returns a numpy array for open and close:

open = np.array([q.open for q in quotes]).astype(np.float)
close = np.array([q.close for q in quotes]).astype(np.float)

As per Dan's help, quotes returns:

In your case you are using asobject=True so the format you get is date, year, month, day, d, open, close, high, low, volume, adjusted_close.

Therefore, open and close must be elements [5] and [6] of quotes.

>>> open
array([[ 28.12235692,  28.32908451,  28.482779  , ...,  84.8198783 ,
         84.1401    ,  84.64308037],
       [ 22.49848073,  22.66286426,  22.91112016, ...,  63.66703704,
         64.57105722,  64.12120097]])

and:

>>> close
array([[ 28.5 ,  28.53,  29.23, ...,  83.8 ,  84.99,  83.82],
       [ 22.91,  22.71,  23.53, ...,  63.52,  64.78,  63.92]])
>>> 

I do not understand exacty what open and close represent.

Is each element of open and close all the prices for that specific stock?

Can you please help me to understand exactly what do open and close contain? Are they just lists of lists of prices per symbol per day?

1 Answer 1

1

quotes is a list which contains stock information per symbol:

In [43]: len(quotes)
Out[43]: 61

In [44]: len(symbols)
Out[44]: 61

In [45]: symbols
Out[45]: 
array(['COP', 'AXP', 'RTN', 'BA', 'AAPL', 'PEP', 'NAV', 'GSK', 'MSFT',
       'KMB', 'R', 'SAP', 'GS', 'CL', 'WAG', 'WMT', 'GE', 'SNE', 'PFE',
       'AMZN', 'MAR', 'NVS', 'KO', 'MMM', 'CMCSA', 'SNY', 'IBM', 'CVX',
       'WFC', 'DD', 'CVS', 'TOT', 'CAT', 'CAJ', 'BAC', 'AIG', 'TWX', 'HD',
       'TXN', 'KFT', 'VLO', 'NWS', 'F', 'CVC', 'TM', 'PG', 'LMT', 'K',
       'HMC', 'GD', 'HPQ', 'DELL', 'MTU', 'XRX', 'YHOO', 'XOM', 'JPM',
       'MCD', 'CSCO', 'NOC', 'UN'], 
      dtype='|S17')

For example the first element in quotes is for the 'COP' symbol and contains an array of values by date:

In [49]: symbols[0]
Out[49]: 'COP'

In [50]: quotes[0].open
Out[50]: 
array([ 13.81001419,  14.01678947,  14.01500099, ...,  56.77238579,
        56.82699428,  56.89080408])

In [51]: quotes[0].date
Out[51]: 
array([2003-01-02, 2003-01-03, 2003-01-06, ..., 2007-12-27, 2007-12-28,
       2007-12-31], dtype=object)
5
  • thank you daniel! i got it to work. do you have a few moments to describe exactly what is affinity propogation? scikit-learn.org/stable/auto_examples/applications/… Commented Oct 5, 2012 at 18:39
  • here's the additional q i asked, thanks again! stackoverflow.com/questions/12752480/… Commented Oct 5, 2012 at 19:55
  • ask your question on some of the machine learning q&a sites Commented Oct 5, 2012 at 20:45
  • thanks! can you recommend one? Commented Oct 5, 2012 at 20:47
  • can you please recommend a machine learning q and a site? Commented Oct 5, 2012 at 22:04

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.