Comments (4)
Hey @bennycode, happy new year.
I'm ok pushing to candles
for now. I share your concern with the memory allocation so don't think it's something for you to implement in hindsight.
I'll close the ticket. Thanks for the feedback.
from coinbase-pro-node.
Hi @artdevgame, I am happy to hear that you like the project.
The current architecture allows only to get the latest candle. You can subscribe to ProductEvent.NEW_CANDLE
events and keep track of all emitted candles in your own application.
Would that be doable for you?
from coinbase-pro-node.
Hey @bennycode
I'm using the demo here:
https://github.com/bennycode/coinbase-pro-node/blob/main/src/demo/rest-watch-candles.ts
Here we retrieve all candles and assign to a variable called candles
:
https://github.com/bennycode/coinbase-pro-node/blob/main/src/demo/rest-watch-candles.ts#L17
At the moment, the body of the callback (https://github.com/bennycode/coinbase-pro-node/blob/main/src/demo/rest-watch-candles.ts#L13) in my version is pushing candle
to the candles
array because I need to keep track of the history (I'm looking for trends).
I don't like that my callback is now causing side effects, and would like to solve that somehow, like how array.map
has an optional 'array' param: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
Another way I could solve it is to have the ProductEvent.NEW_CANDLE
callback call client.rest.product.getCandles
again, but that seems a bit wasteful.
from coinbase-pro-node.
@artdevgame, I see your use case now. From my point of view, pushing incoming candles to the existing candles
array does not sound like a bad idea. The alternative would be to keep all fetched candles in the memory of the "coinbase-pro-node" library, or do you have another approach?
I wouldn't like to store all fetched candles in the memory of "coinbase-pro-node", because it would consume memory even in applications which don't have your use case and it would go beyond the concerns of a REST API.
In your case using an application state container, like Redux, could be a good idea to manage your candles and handle side effects. What do you think?
from coinbase-pro-node.
Related Issues (20)
- Can't figure out this 400 Error HOT 3
- Thanks! HOT 4
- Websocket example implementation needs to be updated? HOT 2
- Sorry newb here and at my wits end
- Should ws.subscribe() be marked async and await sendMessage()? HOT 2
- Having trouble accessing listCoinBaseAccounts() HOT 10
- Support conversion (USDC -> USD)
- wrong candlesticks data HOT 3
- Portfolio commission
- Maybe update docs for passing channels? HOT 1
- Add ability to generate wallet addresses HOT 2
- Q: onopen does not trigger for authenticated socket in container HOT 2
- Fix code scanning alert - Polynomial regular expression used on uncontrolled data HOT 1
- granularity for websockets HOT 1
- Unable to recreate order book with l2 data
- Coinbase Advanced Trade API support
- Wallet Endpoint - AvailableBalance interface HOT 2
- Is getPaymentMethods() typing broken? (PaymentMethod Interface) HOT 7
- Is TransferInformation Interface Incorrect? HOT 2
- Coinbase Pro doesn't exist (tutorial) HOT 2
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 coinbase-pro-node.