INNER CODE UNIT · Python
_df_DAILY_AVG_EXG_RATE
adminho/trading-stock-thailand · BOT_API_example.py:148
def _df_DAILY_AVG_EXG_RATE(data_detail):
date_list, rate_list, currencyname_list = [], [], []
for value in data_detail:
date_list.append(value["period"])
rate_list.append(value["mid_rate"])
currencyname_list.append(value["currency_name_eng"])
templist = []
# remove duplicated currency_name_eng (and remove whitespace on the right and left side)
[templist.append(name.strip()) for name in currencyname_list if name.strip() not in templist]
currencyname_list = templist
num_column = len(currencyname_list)
num_row = int(len(date_list)/num_column)
assert num_row == int(len(rate_list)/num_column)
# reshape
date_list = np.reshape(date_list, (num_row, num_column) )