wnz99 / tvcd Goto Github PK
View Code? Open in Web Editor NEWA JS module to fetch realtime candles data from various crypto exchanges. Created to feed TradingView chart.
A JS module to fetch realtime candles data from various crypto exchanges. Created to feed TradingView chart.
When trying to request the last candle to bitfinex i ended up doing the following request:
https://api-pub.bitfinex.com/v2/candles/trade:1D:tBTCUSD/hist?limit=5000&start=1671062400000&end=1671062400000
I can see bitfinex answers very quick in the browser with:
[
"error",
10020,
"time_interval: invalid"
]
But on my jest test it was timing out because it was taking more than 5000 ms to resolve the request.
I wonder if tvcd
will keep retrying to request and for that reason the timeout happens?
Vercel has a very nice library to convert string "timeframe" to number and vice-versa, we could potentially use it to do timeframe conversions where needed: https://github.com/vercel/ms
This article explain some interesting concepts on unin type VS enum
From some tests i did, string union type provide a better autocomplete experience on VSCode when filling function parameters ( as an end user ).
So when calling functions users can directly type the string value ( and see all options listed on VSCode ) instead of having to import the Enum and use the Enum.
Of course that's a minor detail in implementation, so low priority..
In case that would be implemented we would have an enum like that
export enum Exchanges {
'binance' = 'binance',
'binancefuturescoin' = 'binancefuturescoin',
'binancefuturesusd' = 'binancefuturesusd',
'bitfinex' = 'bitfinex',
'bitmex' = 'bitmex',
'bittrex' = 'bittrex',
'deversifi' = 'deversifi',
'gateio' = 'gateio',
'kucoin' = 'kucoin',
'poloniex' = 'poloniex',
'valr' = 'valr',
}
But function arguments that require exchange names as parameters would have type Exchanges
instead of ExchangesEnum
export type Exchanges =
'binance' |
'binancefuturescoin' |
'binancefuturesusd' |
...
Today i accidentally tried to ask for 3H
candle instead of 3h
candle for Bitfinex.
For some reason it triggered tons of requests for Bitfinex and screwed my rate limit.
Those are some expectations / suggestions
3H
or 3h
the library should be able to "translate" it to the right format, TLDR: allow users to use lowercase or uppercase for the letters perhaps looking at this issue could help standardize it3h
has lowercase h
but 1D
has uppercase D
undefined
on the URL ( see screenshot )Currently Bitfinex won't allow us to fetch 4H candles directly form their API.
It would be great to add this option and have tvcd
consolidate the last 4x1H candles into 1x4H candles by calculating the highest high, lowest low, open, close, and summed volume of those candles.
Snyk is reporting a vulnerability on request
package.
I can see you have all types under this file called exchanges
but some types could be moved into smaller files.
For instance types related to candles could be moved to types/candles.ts
Bitfinex tickers use the format INCH:UST
when the base or quote token is longer than 3 characters. Need to check if this line is correct:
https://github.com/wnz99/tvcd/blob/master/src/exchanges/bitfinex/utils/removeTradingPair.js#L8
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.