|
|
|
|
@ -113,19 +113,28 @@ def main():
@@ -113,19 +113,28 @@ def main():
|
|
|
|
|
"timeframe" : period |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
print("Sending request:", rq) |
|
|
|
|
s.send_multipart([bytes(json.dumps(rq), "utf-8")]) |
|
|
|
|
parts = s.recv_multipart() |
|
|
|
|
print("Awaiting response") |
|
|
|
|
resp = s.recv() |
|
|
|
|
|
|
|
|
|
print(parts[0]) |
|
|
|
|
if parts[0] != b'OK': |
|
|
|
|
print("Error:", parts[1]) |
|
|
|
|
print(resp) |
|
|
|
|
if resp != b'OK': |
|
|
|
|
errmsg = s.recv_string() |
|
|
|
|
print("Error:", errmsg) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
line_count = 0 |
|
|
|
|
with open(args.output_file, 'w', newline='') as f: |
|
|
|
|
writer = csv.writer(f) |
|
|
|
|
writer.writerow(['<TICKER>', '<PER>', '<DATE>', '<TIME>', '<OPEN>', '<HIGH>', '<LOW>', '<CLOSE>', '<VOLUME>']) |
|
|
|
|
for line in struct.iter_unpack("<qddddQ", parts[1]): |
|
|
|
|
|
|
|
|
|
while True: |
|
|
|
|
if s.getsockopt(zmq.RCVMORE) == 0: |
|
|
|
|
break |
|
|
|
|
rawdata = s.recv() |
|
|
|
|
print("Got chunk: {} bytes".format(len(rawdata))) |
|
|
|
|
for line in struct.iter_unpack("<qddddQ", rawdata): |
|
|
|
|
|
|
|
|
|
timestamp = int(line[0]) |
|
|
|
|
open_ = float(line[1]) |
|
|
|
|
|