def test_compile_resquest_param(self): rb = RequestBuilder(api_key='demo') rb.set_category('balance-sheet-statement') rb.add_sub_category('AAPL') rb.set_query_params({'period': 'quarter'}) self.assertEqual( rb.compile_request(), BASE_URL + "/balance-sheet-statement/AAPL?period=quarter&apikey=demo")
def get_historical_chart(self, interval, symbol): if FMPValidator.is_valid_interval(interval): rb = RequestBuilder() rb.set_category('historical-chart') rb.add_sub_category(interval) rb.add_sub_category(symbol) hc = self.__do_request__(rb.compile_request()) return hc else: raise FMPException('Interval value is not valid',FMP.get_historical_chart.__name__)
def test_compile_request_subcategories(self): rb = RequestBuilder(api_key='demo') rb.set_category('historical-chart') rb.add_sub_category('1hour') rb.add_sub_category('^GSPC') self.assertEqual( rb.compile_request(), BASE_URL + "/historical-chart/1hour/^GSPC?apikey=demo")
async def get_dividends_and_stock_splits(self, symbol, reportType): rb = RequestBuilder() rb.set_category(reportType) rb.add_sub_category(symbol) quote = await self.__do_request__(rb.compile_request()) response_text = await quote.text() starter_char = response_text.find(" [ ") end_char = response_text.find(" ]") formatted_text = response_text[(starter_char):(end_char + 2)].strip() formatted_text.rstrip('\r\n') formatted_text.lstrip('\r\n') # print (formatted_text) formatted_json = json.loads(formatted_text) df = pd.DataFrame(formatted_json) return df
def get_historical_price(self,symbol): rb = RequestBuilder() rb.set_category('historical-price-full') rb.add_sub_category(symbol) hp = self.__do_request__(rb.compile_request()) return hp
def get_quote(self,symbol): rb = RequestBuilder() rb.set_category('quote') rb.add_sub_category(symbol) quote = self.__do_request__(rb.compile_request()) return quote
def get_quote_short(self, symbol): rb = RequestBuilder(self.api_key) rb.set_category('quote-short') rb.add_sub_category(symbol) quote = self.__do_request__(rb.compile_request()) return quote
def get_cash_flow_statement(self, symbol): rb = RequestBuilder() rb.set_category('cash-flow-statement') rb.add_sub_category(symbol) quote = self.__do_request__(rb.compile_request()) return quote
def get_data_from_api(self, symbol, reportType): rb = RequestBuilder() rb.set_category(reportType) rb.add_sub_category(symbol) quote = self.__do_request__(rb.compile_request()) return quote
def test_compile_resquest_category(self): rb = RequestBuilder(api_key='demo') rb.set_category('quote') self.assertEqual(rb.compile_request(), BASE_URL + "/quote?apikey=demo")
def test_compile_request_subcategory(self): rb = RequestBuilder(api_key='demo') rb.set_category('quote') rb.add_sub_category('^DJI,^GSPC') self.assertEqual(rb.compile_request(), BASE_URL + "/quote/^DJI,^GSPC?apikey=demo")