def tweet_generic_graph(self, data_frame, adapter = default_adapter, type = 'line', gp = None, twitter_msg = None, twitter_on = None): self.plot_generic_graph(data_frame, type = type, adapter = adapter, gp = gp) twitter = TwitterPyThalesians() twitter.auto_set_key() if twitter_on: twitter.update_status(twitter_msg, picture = gp.file_output)
end = datetime.datetime.utcnow() start_date = end.replace(hour=0, minute=0, second=0, microsecond=0) # Returns a copy time_series_request = TimeSeriesRequest( start_date = start_date, # start date finish_date = datetime.datetime.utcnow(), # finish date freq = 'intraday', # intraday data data_source = 'bloomberg', # use Bloomberg as data source tickers = ['EURUSD'] , # ticker (Thalesians) fields = ['close'], # which fields to download vendor_tickers = ['EURUSD BGN Curncy'], # ticker (Bloomberg) vendor_fields = ['close'], # which Bloomberg fields to download cache_algo = 'internet_load_return') # how to return data ltsf = LightTimeSeriesFactory() df = ltsf.harvest_time_series(time_series_request) df.columns = [x.replace('.close', '') for x in df.columns.values] gp = GraphProperties() gp.title = 'EURUSD stuff!' gp.file_output = 'EURUSD.png' gp.source = 'Thalesians/BBG (created with PyThalesians Python library)' pf = PlotFactory() pf.plot_line_graph(df, adapter = 'pythalesians', gp = gp) pytwitter.update_status("check out my plot of EUR/USD!", picture = gp.file_output)
start_date = end.replace(hour=0, minute=0, second=0, microsecond=0) # Returns a copy time_series_request = TimeSeriesRequest( start_date=start_date, # start date finish_date=datetime.datetime.utcnow(), # finish date freq='intraday', # intraday data data_source='bloomberg', # use Bloomberg as data source tickers=['EURUSD'], # ticker (Thalesians) fields=['close'], # which fields to download vendor_tickers=['EURUSD BGN Curncy'], # ticker (Bloomberg) vendor_fields=['close'], # which Bloomberg fields to download cache_algo='internet_load_return') # how to return data ltsf = LightTimeSeriesFactory() df = ltsf.harvest_time_series(time_series_request) df.columns = [x.replace('.close', '') for x in df.columns.values] gp = GraphProperties() gp.title = 'EURUSD stuff!' gp.file_output = 'EURUSD.png' gp.source = 'Thalesians/BBG (created with PyThalesians Python library)' pf = PlotFactory() pf.plot_line_graph(df, adapter='pythalesians', gp=gp) pytwitter.update_status("check out my plot of EUR/USD!", picture=gp.file_output)