コード例 #1
0
ファイル: market.py プロジェクト: kris-kringle/stocks-repo
    def __init__(self, symbols=None, **kwargs):
        """ Initialize the class

        Parameters
        ----------
        symbols : string, array-like object (list, tuple, Series), or DataFrame
            Desired symbols for retrieval
        output_format: str, default 'json', optional
            Desired output format (json or pandas)
        kwargs:
            Additional request options (see base class)
        """
        if symbols:
            self.symbols = _handle_lists(symbols)
            if len(self.symbols) > self.symbol_limit:
                raise ValueError("At most " + str(self.symbol_limit) +
                                 "symbols may be entered at once.")
        else:
            if self.symbol_required:
                raise ValueError("Please input a symbol or list of symbols.")
            self.symbols = []
        super(Market, self).__init__(**kwargs)
コード例 #2
0
ファイル: test_utils.py プロジェクト: stan630/finance
 def test_handle_lists_err(self, mult):
     with pytest.raises(ValueError):
         _handle_lists(mult, mult=False)
コード例 #3
0
ファイル: test_utils.py プロジェクト: stan630/finance
 def test_handle_lists_mult(self, mult):
     assert _handle_lists(mult) == [1, 2, 3]
コード例 #4
0
ファイル: test_utils.py プロジェクト: stan630/finance
 def test_handle_lists_sing(self, single):
     assert _handle_lists(single, mult=False) == single
     assert _handle_lists(single) == [single]