It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center
                            
                        
                    
                
                                7年前关闭。
            
                    
我想问一个关于this code的全新问题。

上面链接中的代码为openclose返回一个numpy数组:

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


按照Dan's helpquotes返回:


  在您的情况下,您使用的是asobject = True,因此获得的格式为
  日期,年,月,日,d,打开,关闭,高,低,音量,
  Adjusted_close。


因此,打开和关闭必须是[5]的元素[6]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]])


和:

>>> 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]])
>>>


我不完全理解openclose代表什么。

是否打开和关闭该特定股票的所有价格的每个元素?

您能帮我确切地了解打开和关闭包含什么吗?他们只是每天每个符号的价格清单吗?

最佳答案

quotes是包含每个交易品种的库存信息的列表:

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')


例如,quotes中的第一个元素用于'COP'符号,并包含按日期排列的值数组:

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)

关于python - python numpy数组的结构,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12751152/

10-12 18:10