Esempio n. 1
0
def test_tables():
    ibm = Stock("GM")
    assert ibm.chart_table().empty == False
    assert ibm.dividends_table().empty == False
    assert ibm.effective_spread_table().empty == False
    assert ibm.financials_table().empty == False
    assert ibm.volume_by_venue_table().empty == False
Esempio n. 2
0
    def get_dividends(self, ref_symbol, ref_range='1m'):
        """
        Get dividends from IEX
        @params:
            ref_symbol  - Required  : symbol (Str)
            ref_range   - Optional  : date range (Str)
        """

        stock = Stock(ref_symbol)
        dividends = stock.dividends_table(ref_range, token=IEX_TOKEN)
        #print( ref_symbol )
        #print( dividends )
        #Remove unnecesary data
        dividends.drop(["recordDate", "declaredDate", "flag"],
                       axis=1,
                       errors='ignore',
                       inplace=True)
        #Add symbol name column
        if not dividends.empty:
            dividends_len = len(dividends.index)
            dividends_arr = [ref_symbol] * dividends_len
            dividends.insert(loc=0, column='symbol', value=dividends_arr)
            #Reorder dataframe
            dividends = self.set_column_sequence(
                dividends, ["symbol", "exDate", "paymentDate", "amount"])

        return dividends