axios
: make http requests to the exchangesdecimal.js
: convert string numbers into actual numbers, do math operations and do comparison operationsexpress
: server up the endpoint
Both of the commands below require that you are in the root directory
- To run locally on your machine do
npm run start
- To run with docker do
docker compose up
I haven't written JavaScript for some time and I'm sure my style or "way of doing things" is off base from how things should be done. You may notice how I opted to return things either as { ok: "success stuff goes here" } or as { error: "error stuff goes here" } and that is due to my time using Elixir.
I am more than willing and happy to dive into courses/books/training to sharpen my JavaScript skills.
When calling Binance one can set the limit
for how many items they want back. The more one wants the higher the request weight. I didn't want to get my IP banned so I opted to only ask for 100 items from their order book. The limit is 1,200 request weights per minute. I'm not sure if one can pay for a higher limit.
With Gemini one is able to get all the asks. This can be done by setting limit_asks
to 0.
Coinbase, by default, sends you everything.
I say all the above to say that if I had more time I would look into adding "retries" for Binance. Retires in the sense that I would start by calling Binance with the default limit of 100 and then experiment with retying with limits of maybe 100 or 300 all the way up to the max of 5000.
Since I am able to get the entire order book from coinbase and gemini it would be nice to get it from binance too - even if it takes three tries, for example (1 call at default 100, 1 call at 2500 and then the final one at 5000). Not getting Binance's full order book short changes it as an option to buy the desired BTC amount.
If I had more time I would also like to add more error handling if a request to an exchange times out, returns an error or something else. I would also like to add tests and bring in typescript to add types.
I'm most proud of how I opted to separate out the tasks into different modules. With how it's laid out it would be relatively easy to add another exchange.
Getting back up to speed with async/await and Promises.
Q) How did you find the test overall? Did you have any issues or have difficulties completing? If you have any suggestions on how we can improve the test, we'd love to hear them.
I enjoyed it 🤙 and think it did a good job resembling a real world challenge.