Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field names get capitalized implicitly.. #324

Open
goodboy opened this issue May 26, 2020 · 0 comments
Open

Field names get capitalized implicitly.. #324

goodboy opened this issue May 26, 2020 · 0 comments

Comments

@goodboy
Copy link
Contributor

goodboy commented May 26, 2020

I'm only writing this up so it hopefully doesn't bite any other user 馃樅.

This shamefully took me a while to figure out because of 2 problems:

  1. the pymarketstore.Client.write() method doesn't raise errors returned from the server by default which meant I didn't see the column mismatch error returned from the server (at least errors of a certain class).

  2. The server actually capitalizes all element names (numpy.dtype field names from the pymarketstore.Client perspective) when loading timebucket info. So, if you write non-capitalized field names in your numpy` structured array field names, you'll get an error when you try to append to that time bucket. So for example the following client code raises an error:

import pymarketstore as pymkts
client = pymkts.Client('http://localhost:5993/rpc')
symbol = 'SPY'

# Constants (notice not capitalized!)
DATA_TYPE_CANDLE = [
    ('Epoch', 'i8'), ('open', 'f8'), 
    ('high', 'f8'), ('low', 'f8'), 
    ('close', 'f8'), ('volume', 'f8')
]

data = [(timestamp('2019-01-01 00:00:00'), 1.0, 2.0, 3.0, 4.0, 5.0 ),  
          (timestamp('2019-01-01 00:00:01'), 1.0, 2.0, 3.0, 4.0, 5.0 ),
          (timestamp('2019-12-31 23:59:59'), 6.0, 7.0, 8.0, 9.0, 10.0)]

# works
client.write(np.array(data, dtype=DATA_TYPE_CANDLE), "{}/1Sec/OHLCV".format(symbol)))

# errors in the response as per 1. above.
client.write(np.array(data, dtype=DATA_TYPE_CANDLE), "{}/1Sec/OHLCV".format(symbol)))

I'll probably make an issue on pymarketstore to at least document that structarray fields must be caps.

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

No branches or pull requests

1 participant