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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Level2 Subscription doesnt work correctly #6

Open
ghost opened this issue Jun 8, 2021 · 1 comment
Open

Level2 Subscription doesnt work correctly #6

ghost opened this issue Jun 8, 2021 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 8, 2021

Going from the documentation the following should return a Level2 Event
apex.Level2.subscribe(console.log);

Instead you get this garbled mess

ActionType:(10) [15, 1, 1623181164534, 0, 43916.83, 1, 37467.84, 2, 0.0047, 0]
LastTradePrice:undefined
NumberOfAccounts:(10) [13, 1, 1623181164534, 0, 43916.83, 1, 38340.63, 2, 0.6923, 1]
NumberOfOrders:undefined
Price:undefined
ProductPairCode:undefined
Quantity:undefined
Side:undefined
UpdateDateTime:(10) [14, 0, 1623181160956, 2, 43916.83, 0, 37437.09, 2, 0, 0]
UpdateId:(10) [12, 0, 1623181159643, 2, 43916.83, 0, 38305.21, 2, 0, 1]
@ghost
Copy link
Author

ghost commented Jun 10, 2021

apex.Trade.subscribe(console.log);

Doesn't work either, related to this.

The error comes from the fact that the subscriptions both return arrays of arrays and you guys pass it into their respective constructors Level2 and Trade which decodes them only as a single array.

Change this

new Trade(JSON.parse(o)));

To this

JSON.parse(o).map((t) => new Trade(t));

Understandable mistake to make when Level2UpdateEvent and TradeDataUpdateEvent imply singularity.

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

0 participants