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

orderbook not sorted properly #83

Closed
TestniTester opened this issue Aug 3, 2017 · 3 comments
Closed

orderbook not sorted properly #83

TestniTester opened this issue Aug 3, 2017 · 3 comments

Comments

@TestniTester
Copy link

example:
'2734.4': { PRICE: 2734.4, COUNT: 2, AMOUNT: -10,5990971},
'2734.8': { PRICE: 2734.8, COUNT: 1, AMOUNT: -0,11},
'2734.3': { PRICE: 2734.3, COUNT: 1, AMOUNT: -4.260452},
'2736.9': { PRICE: 2736.9, COUNT: 1, AMOUNT: -0,01068},

same sort error on bids/asks

@robertkowalski
Copy link
Contributor

Hello and thanks for reporting!

I'm not sure if I can follow, can you elaborate please what the error is and how it happens for you?

Thank you in advance!

@TestniTester
Copy link
Author

if you open orderbook.js (examples)
the orders in orderbook array are not properly sorted...
if you look up my example, all orders in ALL orderbooks should be sorted by price....
BIDS descending, ASKS ascending...
right?
her...they are mot properly sorted
2734,4
2734,8
2734,3
2736,9
should acualy be
2734,3
2734,4
2734,8
2736,9
right?

@robertkowalski
Copy link
Contributor

robertkowalski commented Aug 3, 2017

You raise a good point.

In JavaScript just plain Arrays guarantee sorting order, the example does not provide a sorted orderbook and uses a hashmap like structure for fast inserts and deletes.

It's easy to get the prices with Object.keys as an array and use .sort to make it sorted ascending or descending.

I'm busy with some other fixes right now, but I opened #84

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

2 participants