def _init_bql(self): """Loads self._bq from class-level shared BQL instance if no instance is available yet. Class-level shared BQL instance would be initialized if needed. """ if self._bq is None: if PortfolioMonitorModel.__shared_bq__ is None: _logger.info('Launching BQL service...') PortfolioMonitorModel.__shared_bq__ = bql.Service() self._bq = PortfolioMonitorModel.__shared_bq__
#Example A: Requesting a Single Data Item #============================================================================= ''' Request syntax: `get(data fields)for([security or universe])` BQL execute function: `bq.execute(request)` ''' # Import the BQL library import bql # Instantiate an object to interface with the BQL service bq = bql.Service() # Define the request string request = "get(PX_LAST)for(['AAPL US Equity'])" # Execute the request response = bq.execute(request) # Display the response in a DataFrame response[0].df() #Example B: Requesting Multiple Data Items #============================================================================= # Import the BQL library import bql # Instantiate an object to interface with the BQL service