Comments (5)
I think you need JSON.parse()
each order in the bids and asks arrays.
from nodejs-order-book.
sry, err is not gone(
from nodejs-order-book.
i think we need "fromJSON" function
from nodejs-order-book.
Hi thanks for reporting. I wasn't able to reproduce your error. What I noticed is that each object in the orders
array is actually a string. If you remove the double quotes before and after the opening and closing braces of each object, you can initialize the order book without any problems.
const snapshot = {
snapshot: {
bids: [
{
price: 30,
orders: [
{
id: '14:22:1720293920736',
side: 'buy',
origSize: 1,
size: 1,
price: 30,
time: 1720293920736,
isMaker: true
},
{
id: '14:22:1720293921301',
side: 'buy',
origSize: 1,
size: 1,
price: 30,
time: 1720293921301,
isMaker: true
}
]
}
],
asks: [
{
price: 33,
orders: [
{
id: '14:22:1720293904645',
side: 'sell',
origSize: 1,
size: 1,
price: 33,
time: 1720293904646,
isMaker: true
},
{
id: '14:22:1720293912873',
side: 'sell',
origSize: 1,
size: 1,
price: 33,
time: 1720293912873,
isMaker: true
},
{
id: '14:22:1720293913076',
side: 'sell',
origSize: 1,
size: 1,
price: 33,
time: 1720293913076,
isMaker: true
}
]
}
],
ts: 1720293921302,
lastOp: 5
}
}
const book = new OrderBook({ snapshot: snapshot.snapshot, enableJournaling: true })
console.log(book.toString())
33 -> 3
------------------------------------
30 -> 2
from nodejs-order-book.
I think you need
JSON.parse()
each order in the bids and asks arrays.
yes, i think about it. Thx.
from nodejs-order-book.
Related Issues (19)
- add benchmark img
- Order: traderID HOT 2
- Simple test reveal bug HOT 1
- Stop-limit, stop-market and OCO orders HOT 8
- time in force parameter: GTC, FOK, IOC HOT 2
- Taker/Maker flag for each order in response HOT 1
- buyOrderCanBeFilled/sellOrderCanBeFilled optimization HOT 1
- Discussion: canceled orders
- Question: market buy quantity HOT 4
- How to use this library with DB HOT 3
- How I create orderbook UI with your lib data HOT 1
- stop self buy sell orders match HOT 3
- How to lock user balance on market order HOT 4
- Modifying the order price should run the matching process HOT 9
- Recover order book data when application restarts HOT 10
- How to get the latest price and trades from OrderBook HOT 6
- v6 Conditional Orders (Help Wanted)
- v6 Conditional Orders - Stop Limit, Stop Market and OCO orders HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodejs-order-book.