def get_data_blp_intraday(self, daylag, minutes):
        '''imports intraday data from bbg api, converts to dataframe '''
        formattedPair = self.pair  # +str(' Curncy')##removed this as what if you want a Comdty or Index?

        event = 'TRADE'
        #starting point, if BDay(-10), starts 10days ago for instance
        #dt = pd.datetools.BDay(-dayLag).apply(pd.datetime.now())
        delta = pd.datetools.BDay(-daylag).apply(self.endDate)

        start = pd.datetime.combine(delta,
                                    datetime.time(0, 0))  #time(hour, minute)

        #endDay = datetime.date(2017,12,3)
        #end = pd.datetime.combine(endDay, datetime.time(23, 30))
        end = self.endDate
        print(end)

        intraDayDf = LocalTerminal.get_intraday_bar(
            formattedPair, event, start, end, interval=minutes).as_frame()

        #f.set_index('time')  wrong
        intraDayDf = intraDayDf.set_index('time')
        return intraDayDf
Beispiel #2
0
from tia.bbg import LocalTerminal
import tia.bbg.datamgr as dm
import datetime
import pandas as pd

sid = 'IBM US EQUITY'
event = 'TRADE'
dt = pd.datetools.BDay(-1).apply(pd.datetime.now())
start = pd.datetime.combine(dt, datetime.time(13, 30))
end = pd.datetime.combine(dt, datetime.time(21, 30))
f = LocalTerminal.get_intraday_bar(sid, event, start, end,
                                   interval=60).as_frame()
f.head(1)
pxs = LocalTerminal.get_historical(members, 'PX_LAST')
f = pxs.as_frame()
f.columns = f.columns.get_level_values(0)
# Show first 5 rows for last 5 days
f.iloc[:5, -5:]

#########################
##Intraday Tick Request##
#########################
import datetime
sid = 'VOD LN EQUITY'
events = ['TRADE', 'AT_TRADE']
dt = pd.datetools.BDay(-1).apply(pd.datetime.now())
start = pd.datetime.combine(dt, datetime.time(13, 30))
end = pd.datetime.combine(dt, datetime.time(13, 35))
f = LocalTerminal.get_intraday_tick(sid, events, start, end, include_condition_codes=True).as_frame()
f.head()

########################
##Intraday Bar Request##
########################
import datetime
sid = 'IBM US EQUITY'
event = 'TRADE'
dt = pd.datetools.BDay(-1).apply(pd.datetime.now())
start = pd.datetime.combine(dt, datetime.time(13, 30))
end = pd.datetime.combine(dt, datetime.time(21, 30))
f = LocalTerminal.get_intraday_bar(sid, event, start, end, interval=60).as_frame()
f.head()