def load_data(self, dataset, transpose=False): #dataset = 'Shareholding' data = Load.FinData(dataset=dataset, select=self.stock_id, date=self.date) if len(data) == 0: return data if transpose: data = Load.transpose(data) data['stock_id'] = data['stock_id'].astype(str) data['date'] = data['date'].astype(str) return data
def load_data(self, dataset, transpose=False): #dataset = 'Shareholding' form_data = { 'dataset': dataset, 'stock_id': self.stock_id, 'date': self.date } res = requests.post(self.url, verify=True, data=form_data) temp = res.json() data = pd.DataFrame(temp['data']) if len(data) == 0: return data if transpose: data = Load.transpose(data) data['stock_id'] = data['stock_id'].astype(str) data['date'] = data['date'].astype(str) return data
res = requests.post(url, verify=True, data=form_data) temp = res.json() data = pd.DataFrame(temp['data']) data.head() '''----------------FinancialStatements----------------''' form_data = { 'dataset': 'FinancialStatements', 'stock_id': '2317', 'date': '2019-01-01' } res = requests.post(url, verify=True, data=form_data) temp = res.json() data = pd.DataFrame(temp['data']) data = Load.transpose(data) data.head() '''----------------TaiwanCashFlowsStatement----------------''' form_data = { 'dataset': 'TaiwanCashFlowsStatement', 'stock_id': '2330', 'date': '2019-06-01' } res = requests.post(url, verify=True, data=form_data) temp = res.json() data = pd.DataFrame(temp['data']) data.head() '''----------------TaiwanStockStockDividend----------------''' form_data = { 'dataset': 'TaiwanStockStockDividend',
"stock_id"])) StockDividendResult = Load.FinData(dataset="StockDividendResult", select="2330", date="2010-01-01") print(StockDividendResult[:5]) print("load 財報 FinancialStatements {} ".format( TaiwanStockInfo.loc[_index, "stock_id"])) TaiwanStockFinancialStatements = Load.FinData( dataset="FinancialStatements", select=2330, date='2019-01-01', ) print(TaiwanStockFinancialStatements[:5]) # transpose data = Load.transpose(TaiwanStockFinancialStatements) print("load 借卷融資 TaiwanStockMarginPurchaseShortSale {} ".format( TaiwanStockInfo.loc[_index, "stock_id"])) TaiwanStockMarginPurchaseShortSale = Load.FinData( dataset="TaiwanStockMarginPurchaseShortSale", select=TaiwanStockInfo.loc[_index, "stock_id"], date=date3, ) print(TaiwanStockMarginPurchaseShortSale[:5]) print("load total 借卷融資 TotalMarginPurchaseShortSale ") TotalMarginPurchaseShortSale = Load.FinData( dataset="TotalMarginPurchaseShortSale", date=date3) print(TotalMarginPurchaseShortSale[:5])