Skip to content

Instantly share code, notes, and snippets.

@Fyzu
Last active September 3, 2024 14:50
Show Gist options
  • Save Fyzu/7ce934237abaed51bb640a72cd021e82 to your computer and use it in GitHub Desktop.
Save Fyzu/7ce934237abaed51bb640a72cd021e82 to your computer and use it in GitHub Desktop.
interface CandleData {
subscribeData(
symbol: string,
aggregation: AggregationPeriod,
/**
* `fromTime` and `toTime` options are candles timestamps which should be used when requesting more candles data (lazy loading)
* `fromTime` is an oldest candle's timestamp which should be data get from, `toTime` is the newest (usually toTime candle equals the oldest visible candle)
*/
options?: ChartDataOptions,
onSnapshot: (data: ChartCandleData[]) => void),
onUpdate: (data: ChartCandleData[]) => void),
onError: (error: Error) => void
): {
requestRange(fromTime: number, toTime: number): void
unsubscribe(): void
};
createDataModel(
symbol: string,
aggregation: AggregationPeriod,
/**
* `fromTime` and `toTime` options are candles timestamps which should be used when requesting more candles data (lazy loading)
* `fromTime` is an oldest candle's timestamp which should be data get from, `toTime` is the newest (usually toTime candle equals the oldest visible candle)
*/
options?: ChartDataOptions,
/**
* !!! Use with caution !!!
* This function updates the whole instrument series data
*/
// sub?: (data: ChartCandleData[]) => void
): {
subscribe(onUpdate: (sub: (type: 'snapshot' | 'update', data: ChartCandleData[]) => void)): Cancel
get(fromTime: number, toTime: number, onResult: ResultCallback, onError: ErrorCallback): Cancel;
close(): void
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment