diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/position.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/python/position.py b/python/position.py index da2fa4b8..5f2d3da0 100644 --- a/python/position.py +++ b/python/position.py @@ -22,6 +22,19 @@ def get_list(engine, workdate=None, asset_class=None, include_unsettled=True): positions.set_index('bbg_id', inplace=True) return positions +def get_list_range(engine, begin, end, asset_class=None): + begin = pd.Timestamp(begin).date() + end = pd.Timestamp(end).date() + positions = pd.read_sql_query("select identifier, bbg_type from list_positions_range(%s, %s, %s)", + engine, + params=(begin, end, asset_class)) + positions.loc[positions.identifier.str.len() <= 11, 'cusip'] = positions.identifier.str.slice(stop=9) + positions.loc[positions.identifier.str.len() == 12, 'isin'] = positions.identifier + positions['bbg_id'] = positions.cusip.where(positions.cusip.notnull(), positions['isin']) + \ + ' ' + positions.bbg_type + positions.set_index('bbg_id', inplace=True) + return positions + def backpopulate_marks(begin_str='2015-01-15', end_str='2015-07-15'): pattern = re.compile("\d{4}-\d{2}-\d{2}") list_of_daily_folder = (fullpath for (fullpath, _, _) in os.walk('/home/share/Daily') |
