tester1
-Interested User-
Posts: 2
Joined: Mar 28, 2018
|
Posted: Apr 3, 2018 12:29 PM
Msg. 1 of 3
Hi I am new to IQfeed and DTN. I am using the Developer license. I am generally interested getting historical data for testing purposes. I am using Python on Windows 8.1. I found a small script on the forum that I adapted to download 1 min data and it works just fine. I have just downloaded a stocks in the S&P500. However I am struggling with tick data downloads. I have tried HTT and HTX but no joy at all.
I have failed to get anything from the example scripts as well.
The edited script that I am using is below. I would appreciate any guidance on this as well as anything relate to python that I need or I may be missing. For Python 2.7 I am using Anaconda (64 bit)
*************************************************************************
import sys import socket import string
startdate= '20180101 093000' enddate = '20180326 160000'
def readHisSock(sock, recv_buffer = 4096): buffer = "" data = "" while 1: data = sock.recv(recv_buffer) buffer += data if "!ENDMSG!" in buffer: break return buffer[:-12] #removes endmsg line
host = "127.0.0.1" #localhost syms = ['GE', 'AAPL'] dir = "C:\Users\My Documents\LiClipse Workspace\IQfeed_data_download"
port = 9100 #history socket for sym in syms: f = open(sym + ".csv", "w") message = "HTT," + sym + "20180101 093000, 20180326 160000,,093000,160000,,,,1\n" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) s.sendall(message) d = readHisSock(s) #d is a string s.close
d = "".join(d.split("\r")) #server sends multiple endlines d = d.replace(",\n","\n")[:-1] #server has comma delimiter at end of each record
f.write(d) f.close()
Edited by tester1 on Apr 3, 2018 at 12:29 PM
|