예제 #1
0
 def create_adjustment_reader(cls, tempdir):
     dbpath = tempdir.getpath('adjustments.sqlite')
     writer = SQLiteAdjustmentWriter(dbpath, cls.env.trading_days,
                                     MockDailyBarSpotReader())
     splits = DataFrame.from_records([
         {
             'effective_date': str_to_seconds('2014-06-09'),
             'ratio': (1 / 7.0),
             'sid': cls.AAPL,
         }
     ])
     mergers = DataFrame(
         {
             # Hackery to make the dtypes correct on an empty frame.
             'effective_date': array([], dtype=int),
             'ratio': array([], dtype=float),
             'sid': array([], dtype=int),
         },
         index=DatetimeIndex([], tz='UTC'),
         columns=['effective_date', 'ratio', 'sid'],
     )
     dividends = DataFrame({
         'sid': array([], dtype=uint32),
         'amount': array([], dtype=float64),
         'record_date': array([], dtype='datetime64[ns]'),
         'ex_date': array([], dtype='datetime64[ns]'),
         'declared_date': array([], dtype='datetime64[ns]'),
         'pay_date': array([], dtype='datetime64[ns]'),
     })
     writer.write(splits, mergers, dividends)
     return SQLiteAdjustmentReader(dbpath)
예제 #2
0
 def create_adjustment_reader(cls, tempdir):
     dbpath = tempdir.getpath("adjustments.sqlite")
     writer = SQLiteAdjustmentWriter(dbpath)
     splits = DataFrame.from_records(
         [{"effective_date": str_to_seconds("2014-06-09"), "ratio": (1 / 7.0), "sid": cls.AAPL}]
     )
     mergers = dividends = DataFrame(
         {
             # Hackery to make the dtypes correct on an empty frame.
             "effective_date": array([], dtype=int),
             "ratio": array([], dtype=float),
             "sid": array([], dtype=int),
         },
         index=DatetimeIndex([], tz="UTC"),
         columns=["effective_date", "ratio", "sid"],
     )
     writer.write(splits, mergers, dividends)
     return SQLiteAdjustmentReader(dbpath)
예제 #3
0
 def create_adjustment_reader(cls, tempdir):
     dbpath = tempdir.getpath('adjustments.sqlite')
     writer = SQLiteAdjustmentWriter(dbpath)
     splits = DataFrame.from_records([{
         'effective_date':
         str_to_seconds('2014-06-09'),
         'ratio': (1 / 7.0),
         'sid':
         cls.AAPL,
     }])
     mergers = dividends = DataFrame(
         {
             # Hackery to make the dtypes correct on an empty frame.
             'effective_date': array([], dtype=int),
             'ratio': array([], dtype=float),
             'sid': array([], dtype=int),
         },
         index=DatetimeIndex([], tz='UTC'),
         columns=['effective_date', 'ratio', 'sid'],
     )
     writer.write(splits, mergers, dividends)
     return SQLiteAdjustmentReader(dbpath)
 def create_adjustment_reader(cls, tempdir):
     dbpath = tempdir.getpath('adjustments.sqlite')
     writer = SQLiteAdjustmentWriter(dbpath)
     splits = DataFrame.from_records([
         {
             'effective_date': str_to_seconds('2014-06-09'),
             'ratio': (1 / 7.0),
             'sid': cls.AAPL,
         }
     ])
     mergers = dividends = DataFrame(
         {
             # Hackery to make the dtypes correct on an empty frame.
             'effective_date': array([], dtype=int),
             'ratio': array([], dtype=float),
             'sid': array([], dtype=int),
         },
         index=DatetimeIndex([], tz='UTC'),
         columns=['effective_date', 'ratio', 'sid'],
     )
     writer.write(splits, mergers, dividends)
     return SQLiteAdjustmentReader(dbpath)
예제 #5
0
# ADJUSTMENTS use the following scheme to indicate information about the value
# upon inspection.
#
# 1s place is the equity
#
# 0.1s place is the action type, with:
#
# splits, 1
# mergers, 2
# dividends, 3
#
# 0.001s is the date
SPLITS = DataFrame(
    [
        # Before query range, should be excluded.
        {'effective_date': str_to_seconds('2015-06-03'),
         'ratio': 1.103,
         'sid': 1},
        # First day of query range, should be excluded.
        {'effective_date': str_to_seconds('2015-06-10'),
         'ratio': 3.110,
         'sid': 3},
        # Third day of query range, should have last_row of 2
        {'effective_date': str_to_seconds('2015-06-12'),
         'ratio': 3.112,
         'sid': 3},
        # After query range, should be excluded.
        {'effective_date': str_to_seconds('2015-06-21'),
         'ratio': 6.121,
         'sid': 6},
        # Another action in query range, should have last_row of 1
# ADJUSTMENTS use the following scheme to indicate information about the value
# upon inspection.
#
# 1s place is the equity
#
# 0.1s place is the action type, with:
#
# splits, 1
# mergers, 2
# dividends, 3
#
# 0.001s is the date
SPLITS = DataFrame(
    [
        # Before query range, should be excluded.
        {"effective_date": str_to_seconds("2015-06-03"), "ratio": 1.103, "sid": 1},
        # First day of query range, should be excluded.
        {"effective_date": str_to_seconds("2015-06-10"), "ratio": 3.110, "sid": 3},
        # Third day of query range, should have last_row of 2
        {"effective_date": str_to_seconds("2015-06-12"), "ratio": 3.112, "sid": 3},
        # After query range, should be excluded.
        {"effective_date": str_to_seconds("2015-06-21"), "ratio": 6.121, "sid": 6},
        # Another action in query range, should have last_row of 1
        {"effective_date": str_to_seconds("2015-06-11"), "ratio": 3.111, "sid": 3},
        # Last day of range.  Should have last_row of 7
        {"effective_date": str_to_seconds("2015-06-19"), "ratio": 3.119, "sid": 3},
    ],
    columns=["effective_date", "ratio", "sid"],
)