Exemple #1
0
 def test_numerical_column_names_uniqueness(self):
     for model_name in ("BalanceSheet", "CashFlow", "IncomeStatement"):
         names = models.get_numerical_column_names(model_name)
         self.assertTrue(
             len(names) == len(set(names)),
             "two verbose column names in {0} are mapped to the same pythonic name!".format(model_name)
         )
Exemple #2
0
def load_fundamental_data(data_type, symbol, columns=None):
    """ Returns a DataFrame object containing <data_type> fundamental data of <symbol> with <columns>.

        data_type: name of *_updated_at fields in Symbol model without _updated_at
        symbol: e.g. 'C6L.SI'
        columns: a sequence of column names as defined in fa.database.*_numerical_columns modules.
            Default: None - include all.
    """
    if columns is None:
        model_name = data_type.replace("_", "")
        columns = get_numerical_column_names(model_name)

    columns = ["Date"] + list(columns)

    field_names = [to_pythonic_name(c) for c in columns]
    records = list(get_fundamentals(data_type, symbol, field_names))

    return pd.DataFrame.from_records(records, columns=columns, index="Date")
Exemple #3
0
 def test_get_numerical_column_names(self):
     with patch("fa.database.balancesheet_numerical_columns.verbose_names", ["abc", "def"]):
         names = models.get_numerical_column_names("BalanceSheet")
     self.assertEqual(names, ["abc", "def"])