All time selectors work for OHLC

This commit is contained in:
7400
2024-02-11 11:34:09 -08:00
parent 16cce66fba
commit 00ac45dafc
3 changed files with 94 additions and 86 deletions

View File

@@ -1,12 +1,3 @@
// import {
// makeApiRequest,
// generateSymbol,
// parseFullSymbol,
// } from './helpers.js';
// import {
// subscribeOnStream,
// unsubscribeFromStream,
// } from './streaming.js';
import {jBars} from './jBars.js';
const lastBarsCache = new Map();
@@ -14,14 +5,14 @@ const lastBarsCache = new Map();
// DatafeedConfiguration implementation
const configurationData = {
// Represents the resolutions for bars supported by your datafeed
// supported_resolutions: ['1D', '1W', '1M'],
supported_resolutions: ['1D'],
supported_resolutions:
['1', '3', '5', '10', '15', '30', '60', '120', '240', '480', '720', '1D', '2D', '3D', '1W'],
// The `exchanges` arguments are used for the `searchSymbols` method if a user selects the exchange
exchanges: [{
value: 'Bitfinex',
name: 'Bitfinex',
desc: 'Bitfinex',
value: 'Uniswap',
name: 'Uniswap',
desc: 'Uniswap',
},
],
// The `symbols_types` arguments are used for the `searchSymbols` method if a user selects this symbol type
@@ -34,13 +25,11 @@ const configurationData = {
// Obtains all symbols for all exchanges supported by CryptoCompare API
async function getAllSymbols() {
// const data = await makeApiRequest('data/v3/all/exchanges');
// let allSymbols = [];
return [{
symbol: 'BTC/USD',
full_name: 'Bitfinex:BTC/USD',
description: 'BTC/USD',
exchange: 'Bitfinex',
symbol: 'WETH/USD',
full_name: 'Uniswap:WETH/USD',
description: 'WETH/USD 42161/0xC31E54c7a869B9Fc',
exchange: 'Uniswap',
type: 'crypto'}
];
}
@@ -96,9 +85,9 @@ export default {
exchange: symbolItem.exchange,
minmov: 1,
pricescale: 100,
has_intraday: false,
has_intraday: true, // Added to allow less than one day to work
has_no_volume: true,
has_weekly_and_monthly: false,
has_weekly_and_monthly: true, // Added to allow greater than one day to work
supported_resolutions: configurationData.supported_resolutions,
volume_precision: 2,
data_status: 'streaming',
@@ -112,17 +101,8 @@ export default {
const { from, to, firstDataRequest } = periodParams;
console.log('[getBars]: Method call', symbolInfo, resolution, from, to);
// const parsedSymbol = parseFullSymbol(symbolInfo.full_name);
// const urlParameters = {
// e: parsedSymbol.exchange,
// fsym: parsedSymbol.fromSymbol,
// tsym: parsedSymbol.toSymbol,
// toTs: to,
// limit: 2000,
// };
try {
var bars = await jBars(from, to, resolution);
var bars = await jBars(from, to, resolution); // This is the one that does all the work
if (firstDataRequest) {
lastBarsCache.set(symbolInfo.full_name, {
@@ -147,20 +127,9 @@ export default {
onResetCacheNeededCallback,
) => {
console.log('[subscribeBars]: Method call with subscriberUID:', subscriberUID);
// throw Error('subscribeBars unimplemented');
// subscribeOnStream(
// symbolInfo,
// resolution,
// onRealtimeCallback,
// subscriberUID,
// onResetCacheNeededCallback,
// lastBarsCache.get(symbolInfo.full_name),
// );
},
unsubscribeBars: (subscriberUID) => {
console.log('[unsubscribeBars]: Method call with subscriberUID:', subscriberUID);
// throw Error('unsubscribeBars unimplemented');
// unsubscribeFromStream(subscriberUID);
},
};