luketighe / IQFeed

Python - IQ DTN Feed Historical Data Download & Cache
28 stars 12 forks source link

cannot change the time to daily #4

Open pashute opened 6 years ago

pashute commented 6 years ago

Doesn't matter what I put in bars in seconds

It is saved in historic data as str(self.timeframe) and in the message: as '{0}' (enclosed in single quote).

I changed it to integer and it fails.

If I keep it as string, it gives me 1 minute info (60) whether I put in 86400 or 1440. If I put 1, it fails. If I put 'd' it gives me 1 minute info.

Where is the documentation for the "HIT" message?

(I'm using the modified version for version 3.6 with the two utf-8 fixes... could that be affecting the message) .

pashute commented 6 years ago

I asked also on the DTN forum

Perhaps its a sockets issue.

I erased the temporary files from their location before retrying.

I'll try sending it without the single quotes again. but leave the number as str(self.timestamp) so the %s can work correctly, and will debug. Tell you the results here.

pashute commented 6 years ago

Solved by a mix of codefix here, and overcoming a bug (or missing docs) in IQFeed DTN socket api.

I use direct timeframe without str() and without surrounding quotemark and works with hourly (3600) but not daily (86400). But if I pass: 36000 (10 hours) I get daily at 16:00 !

So it was two bugs. One here (or two if you count the sockets) and one which seems a bug of IQFeed socket DTN API. Let me join the project and I'll put up the fixed code with remarks.

I use:

buffer += data.decode("utf-8")

message = "HIT,{0},{1},{2},{3},,093000,160000,1\n".format(symbol, self.timeFrame, self.startDate, self.endDate)

sock.sendall(message.encode('utf-8'))  # see issue 2 on github

sock.shutdown(socket.SHUT_RDWR)  # see issue 1 on github
sock.close()  # added method parenthesis (as part of issue 1 fix)
pashute commented 6 years ago

Looking at anpur's iqfeed, there is HTT for periodic data (daily feed) instead of HIT.

So I will try it and add it in, in a pull request.