Browse Source

HAP fixes

master
Denis Tereshkin 4 years ago
parent
commit
81439ddf4e
  1. 2
      qhp-download-list.py
  2. 8
      qhp-hap-transfer.py

2
qhp-download-list.py

@ -41,7 +41,7 @@ def main():
s = rawdata.decode('utf-8') s = rawdata.decode('utf-8')
tickers = s.split(',') tickers = s.split(',')
for ticker in tickers: for ticker in tickers:
print(ticker) print(ticker.strip())
if __name__ == '__main__': if __name__ == '__main__':
main() main()

8
qhp-hap-transfer.py

@ -124,8 +124,10 @@ def upload_data(hap, data, ticker, period):
raw_data = serialized_bars.getvalue() raw_data = serialized_bars.getvalue()
print('Request: ', rq)
hap.send_multipart([bytes(json.dumps(rq), "utf-8"), raw_data]) hap.send_multipart([bytes(json.dumps(rq), "utf-8"), raw_data])
parts = hap.recv_multipart() parts = hap.recv_multipart()
print('Response: ', parts[0])
if parts[0] != b'OK': if parts[0] != b'OK':
return False return False
return True return True
@ -140,9 +142,9 @@ def convert_ticker(s, data):
current_mon = last_ts.date().month current_mon = last_ts.date().month
mon = get_month_by_code(s[-2]) mon = get_month_by_code(s[-2])
if year >= current_year_in_dec: if year >= current_year_in_dec:
return s[:-2] + ".{}-{}".format(mon, current_dec + year) return s[:-2] + "-{}.{}".format(mon, current_dec + year)
else: else:
return s[:-2] + ".{}-{}".format(mon, current_dec + 10 + year) return s[:-2] + "-{}.{}".format(mon, current_dec + 10 + year)
else: else:
return s return s
@ -205,6 +207,8 @@ def main():
max_retries = 3 max_retries = 3
for ticker in tickers: for ticker in tickers:
if ticker == "":
continue
for trynum in range(0, max_retries): for trynum in range(0, max_retries):
if allow_ticker(blacklist, ticker): if allow_ticker(blacklist, ticker):
print("Requesting ticker from QHP: {}".format(ticker)) print("Requesting ticker from QHP: {}".format(ticker))

Loading…
Cancel
Save