pull down to refresh
0 sats \ 0 replies \ @harrym 8h \ parent \ on: Stacker News Cowboy Credits Market Depth AGORA
I see the problem.
Its expected to be low volume, so minimal effort to get something working. But that means high ongoing maintenance to update trades, execute trades, confirm trades, allow partial trades, etc.
I'm not sure how you want to proceed.
For sure, you will prolly NOT want to be hard coding the orders like that forever. You likely want them out in a db-like file, even if its text, say csv? That would enable order updates more easily.
I'm no javascript guy, but surely there's a simple database module you can call in? With something like that, maybe you need more js that ensures standard format and allows user additions to the order file.
Some thoughts that apply whether you do manual or automatic handling...
Background on exchange order types:
1 spot orders, where a user just specifies the volume and the exchange fills the order starting at the best price (for the user) and then 'next' available (but worse) price etc. until the volume is reached.
2 limit orders, where a user specifies a volume and a limit price and the exchange handles all trades available until the price is reached or the trade is filled.
You're using something like limit orders, except you're not allowing for users to get the best price at the time of execution. For example, I might place an order to buy something at .9 sats and someone else places an order to sell that item at .89, then my order should get filled at .89. That makes your order book look weird, and you (or users) would need to notice then resubmit the trade.
Both types may result in partial order fulfillment. That would also need to be handled.
How would you actually know a trade had been resolved by any two users? They would likely just leave their trade offers in your list unless you hound them.