Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Data not being stored to database #36

Closed
rterbush opened this issue Dec 5, 2016 · 5 comments
Closed

Data not being stored to database #36

rterbush opened this issue Dec 5, 2016 · 5 comments

Comments

@rterbush
Copy link
Contributor

rterbush commented Dec 5, 2016

Really like the approach you are taking here and look forward to participating in the improvement.

But in the short term, I'm struggling to get data into the local mysql database. Hoping you can give some suggestions as to how to further debug this.

Currently connecting to a remote TWS instance. I've tried running TWS on a couple of different systems in case there is an API problem. As you can see below, Blotter starts up and indicates it is adding the contracts.

2016-12-05 21:49:30,797 [INFO] qtpylib.blotter: Connecting to Interactive Brokers...
Server Version: 76
TWS Time at connection:20161205 14:49:30 MST
2016-12-05 21:49:32,023 [INFO] qtpylib.blotter: Connection established...
2016-12-05 21:49:32,756 [INFO] qtpylib.blotter: Contract Added [AAPL]
2016-12-05 21:49:33,370 [INFO] qtpylib.blotter: Contract Added [ESZ2016]

But looking in the mysql database running on the same server, I have no data stored to the tables:

qtpy@localhost [qtpy]> show tables;
+----------------+
| Tables_in_qtpy |
+----------------+
| _version_      |
| bars           |
| greeks         |
| symbols        |
| ticks          |
| trades         |
+----------------+
6 rows in set (0.00 sec)

qtpy@localhost [qtpy]> select * from bars;
Empty set (0.00 sec)

qtpy@localhost [qtpy]> select * from symbols;
Empty set (0.00 sec)

qtpy@localhost [qtpy]> select * from ticks;
Empty set (0.00 sec)

I ran into some other errors when trying to add some ETFs like SPY, SSO, etc. but will see if first I can get this working with your example instruments. TWS is configured as you show in your screenshots.

@nwillemse
Copy link

nwillemse commented Dec 6, 2016

Hi,

It seems that the log2db in blotter.py has a bug. Might be because of latest version of mysql.

https://github.com/ranaroussi/qtpylib/blob/master/qtpylib/blotter.py#L641

After changing `expiry`=`%s` to `expiry`=%s it seems to store the ticks for stock symbols.

However, there's still another problem with futures data where the symbol is not being created. Problem was in the symbols.csv file for the futures specification which was incorrect for the expiry.

@rterbush
Copy link
Contributor Author

rterbush commented Dec 6, 2016

I can confirm that removal of the quotes fixes this issue when connecting to a TWS instance NOT using an FA account.

ranaroussi added a commit that referenced this issue Dec 6, 2016
* develop:
  updated docs and version #
  fixed multi symbol parsing (closing issues #37 + #38)
  Removed `` from log2db (closing issue #36)

# Conflicts:
#	docs/build/html.zip
@ranaroussi
Copy link
Owner

You're absolutely right, though personally I've never encountered this issue. Just out of curiosity - what version of MySQL are you using?

In any case, this should be fixed in version 1.5.41. To upgrade, run:

$ pip install qtpylib --upgrade --no-cache-dir

LMK if that fixed the issue.

@rterbush
Copy link
Contributor Author

rterbush commented Dec 6, 2016

I experienced the issue on MariaDB 10.1.19 and on MySQL 5.7

@ranaroussi
Copy link
Owner

Thanks! Everything seems to be working now?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants