react-crypto-chart-sosa
Advanced tools
Comparing version 0.0.9 to 0.0.15
@@ -1,31 +0,218 @@ | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
import { memo, useEffect, useState } from 'react'; | ||
import { fetchCandleStickData } from './utils/fetchService'; | ||
import TradeView from './TradeView'; | ||
import { getWebsocketUrl } from './utils/urls'; | ||
import { candleSocketAdaptor } from './utils/adaptor'; | ||
import { condleStickDefaultConfig, histogramDefaultConfig, defaultChartLayout, } from './utils/constants'; | ||
var __awaiter = | ||
(this && this.__awaiter) || | ||
function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { | ||
return value instanceof P | ||
? value | ||
: new P(function (resolve) { | ||
resolve(value); | ||
}); | ||
} | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { | ||
try { | ||
step(generator.next(value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
function rejected(value) { | ||
try { | ||
step(generator["throw"](value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
function step(result) { | ||
result.done | ||
? resolve(result.value) | ||
: adopt(result.value).then(fulfilled, rejected); | ||
} | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = | ||
(this && this.__generator) || | ||
function (thisArg, body) { | ||
var _ = { | ||
label: 0, | ||
sent: function () { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
}, | ||
trys: [], | ||
ops: [], | ||
}, | ||
f, | ||
y, | ||
t, | ||
g; | ||
return ( | ||
(g = { next: verb(0), throw: verb(1), return: verb(2) }), | ||
typeof Symbol === "function" && | ||
(g[Symbol.iterator] = function () { | ||
return this; | ||
}), | ||
g | ||
); | ||
function verb(n) { | ||
return function (v) { | ||
return step([n, v]); | ||
}; | ||
} | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) | ||
try { | ||
if ( | ||
((f = 1), | ||
y && | ||
(t = | ||
op[0] & 2 | ||
? y["return"] | ||
: op[0] | ||
? y["throw"] || ((t = y["return"]) && t.call(y), 0) | ||
: y.next) && | ||
!(t = t.call(y, op[1])).done) | ||
) | ||
return t; | ||
if (((y = 0), t)) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: | ||
case 1: | ||
t = op; | ||
break; | ||
case 4: | ||
_.label++; | ||
return { value: op[1], done: false }; | ||
case 5: | ||
_.label++; | ||
y = op[1]; | ||
op = [0]; | ||
continue; | ||
case 7: | ||
op = _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
default: | ||
if ( | ||
!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && | ||
(op[0] === 6 || op[0] === 2) | ||
) { | ||
_ = 0; | ||
continue; | ||
} | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { | ||
_.label = op[1]; | ||
break; | ||
} | ||
if (op[0] === 6 && _.label < t[1]) { | ||
_.label = t[1]; | ||
t = op; | ||
break; | ||
} | ||
if (t && _.label < t[2]) { | ||
_.label = t[2]; | ||
_.ops.push(op); | ||
break; | ||
} | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { | ||
op = [6, e]; | ||
y = 0; | ||
} finally { | ||
f = t = 0; | ||
} | ||
if (op[0] & 5) throw op[1]; | ||
return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
import React, { memo, useEffect, useCallback, useState } from "react"; | ||
import { fetchCandleStickData } from "./utils/fetchService"; | ||
import TradeView from "./TradeView"; | ||
import { WS_URL } from "./utils/constants"; | ||
import { candleSocketAdaptor } from "./utils/adaptor"; | ||
import { | ||
candleStickDefaultConfig, | ||
histogramDefaultConfig, | ||
defaultChartLayout, | ||
} from "./utils/constants"; | ||
var TradeViewChart = function (_a) { | ||
var _b = _a.pair, pair = _b === void 0 ? 'BTCBUSD' : _b, _c = _a.interval, interval = _c === void 0 ? '1m' : _c, _d = _a.useFuturesTestnet, useFuturesTestnet = _d === void 0 ? false : _d, _e = _a.useSpotTestnet, useSpotTestnet = _e === void 0 ? false : _e, _f = _a.candleStickConfig, candleStickConfig = _f === void 0 ? condleStickDefaultConfig : _f, _g = _a.histogramConfig, histogramConfig = _g === void 0 ? histogramDefaultConfig : _g, _h = _a.chartLayout, chartLayout = _h === void 0 ? defaultChartLayout : _h, containerStyle = _a.containerStyle; | ||
var _j = useState(null), candleStickData = _j[0], setCandleData = _j[1]; | ||
var _k = useState(null), updatedata = _k[0], setUpdateData = _k[1]; | ||
useEffect(function () { | ||
fetchCandleStickData(pair, interval, useFuturesTestnet, useSpotTestnet) | ||
.then(function (res) { return setCandleData(res); }) | ||
.catch(function (err) { return console.log(err); }); | ||
var ws = new WebSocket("".concat(getWebsocketUrl({ useFuturesTestnet: useFuturesTestnet, useSpotTestnet: useSpotTestnet }), "/").concat(pair.toLocaleLowerCase(), "@kline_").concat(interval)); | ||
ws.onmessage = function (e) { | ||
var message = JSON.parse(e.data); | ||
var parsedMessage = candleSocketAdaptor(message); | ||
setUpdateData(parsedMessage); | ||
}; | ||
return function () { | ||
ws.close(); | ||
}; | ||
}, [pair, interval, useFuturesTestnet, useSpotTestnet]); | ||
if (!candleStickData) { | ||
return _jsx("div", { className: "loader" }); | ||
} | ||
return (_jsx(TradeView, { updatedata: updatedata, initialChartData: candleStickData, candleStickConfig: candleStickConfig, histogramConfig: histogramConfig, chartLayout: chartLayout, containerStyle: containerStyle })); | ||
var _b = _a.pair, | ||
pair = _b === void 0 ? "BTCBUSD" : _b, | ||
_c = _a.interval, | ||
interval = _c === void 0 ? "1m" : _c, | ||
_d = _a.candleStickConfig, | ||
candleStickConfig = _d === void 0 ? candleStickDefaultConfig : _d, | ||
_e = _a.histogramConfig, | ||
histogramConfig = _e === void 0 ? histogramDefaultConfig : _e, | ||
_f = _a.chartLayout, | ||
chartLayout = _f === void 0 ? defaultChartLayout : _f, | ||
containerStyle = _a.containerStyle; | ||
var _g = useState(null), | ||
candleStickData = _g[0], | ||
setCandleData = _g[1]; | ||
var _h = useState(null), | ||
updatedata = _h[0], | ||
setUpdateData = _h[1]; | ||
var fetchCandleData = useCallback( | ||
function () { | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
var candleData; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
return [4 /*yield*/, fetchCandleStickData(pair)]; | ||
case 1: | ||
candleData = _a.sent(); | ||
setCandleData(candleData); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}, | ||
[pair] | ||
); | ||
useEffect( | ||
function () { | ||
fetchCandleData(); | ||
}, | ||
[fetchCandleData] | ||
); | ||
useEffect( | ||
function () { | ||
var ws = new WebSocket( | ||
"" | ||
.concat(WS_URL, "/") | ||
.concat(pair.toLocaleLowerCase(), "@kline_") | ||
.concat(interval) | ||
); | ||
// ws.onopen = () => console.log("open"); | ||
ws.onmessage = function (e) { | ||
var message = JSON.parse(e.data); | ||
var parsedMessage = candleSocketAdaptor(message); | ||
setUpdateData(parsedMessage); | ||
}; | ||
return function () { | ||
ws.close(); | ||
}; | ||
}, | ||
[pair, interval] | ||
); | ||
if (!candleStickData) { | ||
return React.createElement("div", { className: "loader" }); | ||
} | ||
return React.createElement(TradeView, { | ||
updatedata: updatedata, | ||
initialChartData: candleStickData, | ||
candleStickConfig: candleStickConfig, | ||
histogramConfig: histogramConfig, | ||
chartLayout: chartLayout, | ||
containerStyle: containerStyle, | ||
}); | ||
}; | ||
export default memo(TradeViewChart); |
@@ -1,72 +0,133 @@ | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
var __assign = | ||
(this && this.__assign) || | ||
function () { | ||
__assign = | ||
Object.assign || | ||
function (t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
s = arguments[i]; | ||
for (var p in s) | ||
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
import { memo, useRef, useEffect, useCallback } from 'react'; | ||
import { createChart } from 'lightweight-charts'; | ||
}; | ||
import React, { memo, useRef, useEffect, useCallback } from "react"; | ||
import { createChart } from "lightweight-charts"; | ||
var TradeView = function (_a) { | ||
var initialChartData = _a.initialChartData, _b = _a.updatedata, updatedata = _b === void 0 ? null : _b, _c = _a.candleStickConfig, candleStickConfig = _c === void 0 ? {} : _c, _d = _a.histogramConfig, histogramConfig = _d === void 0 ? {} : _d, _e = _a.chartLayout, chartLayout = _e === void 0 ? {} : _e, _f = _a.containerStyle, containerStyle = _f === void 0 ? { | ||
maxWidth: '100%', | ||
maxHeight: '100vh', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
} : _f; | ||
var resizeObserver = useRef(); | ||
var chartContainerRef = useRef(); | ||
var chart = useRef(); | ||
var candleSeries = useRef(); | ||
var volumeSeries = useRef(); | ||
var setInitialData = useCallback(function () { | ||
var _a, _b; | ||
candleSeries.current = (_a = chart === null || chart === void 0 ? void 0 : chart.current) === null || _a === void 0 ? void 0 : _a.addCandlestickSeries(candleStickConfig); | ||
candleSeries === null || candleSeries === void 0 ? void 0 : candleSeries.current.setData(initialChartData); | ||
volumeSeries.current = chart.current.addHistogramSeries(histogramConfig); | ||
(_b = volumeSeries === null || volumeSeries === void 0 ? void 0 : volumeSeries.current) === null || _b === void 0 ? void 0 : _b.setData(initialChartData); | ||
candleSeries.current.applyOptions({ | ||
priceFormat: { | ||
type: 'price', | ||
precision: 5, | ||
minMove: 0.001, | ||
}, | ||
}); | ||
}, [initialChartData, candleStickConfig, histogramConfig]); | ||
useEffect(function () { | ||
var _a, _b; | ||
if (updatedata) { | ||
(_a = candleSeries === null || candleSeries === void 0 ? void 0 : candleSeries.current) === null || _a === void 0 ? void 0 : _a.update(updatedata); | ||
(_b = volumeSeries === null || volumeSeries === void 0 ? void 0 : volumeSeries.current) === null || _b === void 0 ? void 0 : _b.update(updatedata); | ||
} | ||
}, [updatedata]); | ||
useEffect(function () { | ||
chart.current = createChart(chartContainerRef.current, __assign({ width: chartContainerRef.current.clientWidth, height: chartContainerRef.current.clientHeight }, chartLayout)); | ||
setInitialData(); | ||
}, [setInitialData, chartLayout]); | ||
// Resize chart on container resizes. | ||
useEffect(function () { | ||
resizeObserver.current = new ResizeObserver(function (entries) { | ||
var _a = entries[0].contentRect, width = _a.width, height = _a.height; | ||
chart.current.applyOptions({ | ||
width: width, | ||
height: height, | ||
priceFormat: { | ||
type: 'price', | ||
precision: 5, | ||
minMove: 0.001, | ||
}, | ||
}); | ||
}); | ||
resizeObserver.current.observe(chartContainerRef.current); | ||
return function () { return resizeObserver.current.disconnect(); }; | ||
}, []); | ||
return (_jsx("div", { ref: chartContainerRef, className: "chartContainer", style: containerStyle })); | ||
var initialChartData = _a.initialChartData, | ||
_b = _a.updatedata, | ||
updatedata = _b === void 0 ? null : _b, | ||
_c = _a.candleStickConfig, | ||
candleStickConfig = _c === void 0 ? {} : _c, | ||
_d = _a.histogramConfig, | ||
histogramConfig = _d === void 0 ? {} : _d, | ||
_e = _a.chartLayout, | ||
chartLayout = _e === void 0 ? {} : _e, | ||
_f = _a.containerStyle, | ||
containerStyle = | ||
_f === void 0 | ||
? { | ||
maxWidth: "100%", | ||
maxHeight: "100vh", | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
} | ||
: _f; | ||
var resizeObserver = useRef(); | ||
var chartContainerRef = useRef(); | ||
var chart = useRef(); | ||
var candleSeries = useRef(); | ||
var volumeSeries = useRef(); | ||
var setInitialData = useCallback( | ||
function () { | ||
var _a, _b; | ||
candleSeries.current = | ||
(_a = chart === null || chart === void 0 ? void 0 : chart.current) === | ||
null || _a === void 0 | ||
? void 0 | ||
: _a.addCandlestickSeries(candleStickConfig); | ||
candleSeries === null || candleSeries === void 0 | ||
? void 0 | ||
: candleSeries.current.setData(initialChartData); | ||
volumeSeries.current = chart.current.addHistogramSeries(histogramConfig); | ||
(_b = | ||
volumeSeries === null || volumeSeries === void 0 | ||
? void 0 | ||
: volumeSeries.current) === null || _b === void 0 | ||
? void 0 | ||
: _b.setData(initialChartData); | ||
candleSeries.current.applyOptions({ | ||
priceFormat: { | ||
type: "price", | ||
precision: 5, | ||
minMove: 0.001, | ||
}, | ||
}); | ||
}, | ||
[initialChartData, candleStickConfig, histogramConfig] | ||
); | ||
useEffect( | ||
function () { | ||
var _a, _b; | ||
if (updatedata) { | ||
(_a = | ||
candleSeries === null || candleSeries === void 0 | ||
? void 0 | ||
: candleSeries.current) === null || _a === void 0 | ||
? void 0 | ||
: _a.update(updatedata); | ||
(_b = | ||
volumeSeries === null || volumeSeries === void 0 | ||
? void 0 | ||
: volumeSeries.current) === null || _b === void 0 | ||
? void 0 | ||
: _b.update(updatedata); | ||
} | ||
}, | ||
[updatedata] | ||
); | ||
useEffect( | ||
function () { | ||
chart.current = createChart( | ||
chartContainerRef.current, | ||
__assign( | ||
{ | ||
width: chartContainerRef.current.clientWidth, | ||
height: chartContainerRef.current.clientHeight, | ||
}, | ||
chartLayout | ||
) | ||
); | ||
setInitialData(); | ||
}, | ||
[setInitialData, chartLayout] | ||
); | ||
// Resize chart on container resizes. | ||
useEffect(() => { | ||
resizeObserver.current = new ResizeObserver((entries) => { | ||
const { width, height } = entries[0].contentRect; | ||
chart.current.applyOptions({ | ||
width, | ||
height, | ||
priceFormat: { | ||
type: "price", | ||
precision: 5, | ||
minMove: 0.001, | ||
}, | ||
}); | ||
}); | ||
resizeObserver.current.observe(chartContainerRef.current); | ||
return () => resizeObserver.current.disconnect(); | ||
}, []); | ||
return React.createElement("div", { | ||
ref: chartContainerRef, | ||
className: "chartContainer", | ||
style: containerStyle, | ||
}); | ||
}; | ||
export default memo(TradeView); |
@@ -1,4 +0,3 @@ | ||
import { CandleStickAdaptorResult } from "./types"; | ||
export declare const candleStickAdaptor: (data: any) => CandleStickAdaptorResult; | ||
export declare const candleSocketAdaptor: (data: any) => { | ||
export function candleStickAdaptor(data: any): { | ||
time: number; | ||
open: number; | ||
@@ -8,2 +7,10 @@ high: number; | ||
close: number; | ||
value: number; | ||
color: string; | ||
}; | ||
export function candleSocketAdaptor(data: any): { | ||
open: number; | ||
high: number; | ||
low: number; | ||
close: number; | ||
time: number; | ||
@@ -10,0 +17,0 @@ value: number; |
export var candleStickAdaptor = function (data) { | ||
var openTime = data[0], open = data[1], high = data[2], low = data[3], close = data[4], volume = data[5]; | ||
return { | ||
time: openTime / 1000, | ||
open: parseFloat(open), | ||
high: parseFloat(high), | ||
low: parseFloat(low), | ||
close: parseFloat(close), | ||
value: parseFloat(volume), | ||
color: open < close ? "#005a40" : "#82112b", | ||
}; | ||
var openTime = data[0], | ||
open = data[1], | ||
high = data[2], | ||
low = data[3], | ||
close = data[4], | ||
volume = data[5], | ||
closeTime = data[6], | ||
quoteAssetVolume = data[7], | ||
numberOfTrades = data[8], | ||
takerBuyBaseAssetVolume = data[9], | ||
takerBuyQuotessetVolume = data[10], | ||
ignore = data[11]; | ||
return { | ||
time: openTime / 1000, | ||
open: parseFloat(open), | ||
high: parseFloat(high), | ||
low: parseFloat(low), | ||
close: parseFloat(close), | ||
value: parseFloat(volume), | ||
color: open < close ? "#0ecb81" : "#f6465d", | ||
// closeTime, | ||
// quoteAssetVolume, | ||
// numberOfTrades, | ||
// takerBuyBaseAssetVolume, | ||
// takerBuyQuotessetVolume, | ||
// ignore, | ||
}; | ||
}; | ||
export var candleSocketAdaptor = function (data) { | ||
var _a = data.k, T = _a.T, o = _a.o, c = _a.c, h = _a.h, l = _a.l, v = _a.v, V = _a.V; | ||
return { | ||
open: parseFloat(o), | ||
high: parseFloat(h), | ||
low: parseFloat(l), | ||
close: parseFloat(c), | ||
time: T / 1000, | ||
value: (parseFloat(v) + parseFloat(V)) / 2, | ||
color: o < c ? "#005a40" : "#82112b", | ||
}; | ||
var _a = data.k, | ||
T = _a.T, | ||
o = _a.o, | ||
c = _a.c, | ||
h = _a.h, | ||
l = _a.l, | ||
v = _a.v, | ||
V = _a.V; | ||
return { | ||
open: parseFloat(o), | ||
high: parseFloat(h), | ||
low: parseFloat(l), | ||
close: parseFloat(c), | ||
time: T / 1000, | ||
value: (parseFloat(v) + parseFloat(V)) / 2, | ||
color: o < c ? "#0ecb81" : "#f6465d", | ||
}; | ||
}; |
@@ -1,2 +0,1 @@ | ||
import { CandleStickAdaptorResult } from "./types"; | ||
export declare const parseCandleStickData: (candleArray?: never[]) => CandleStickAdaptorResult[]; | ||
export function parseCandleStickData(candleArray?: any[]): any; |
@@ -1,56 +0,54 @@ | ||
import { CrosshairMode, LineStyle } from "lightweight-charts"; | ||
export declare const BASE_URL = "https://api.binance.com/api/v3/klines?"; | ||
export declare const WS_URL = "wss://stream.binance.com:9443/ws"; | ||
export declare const condleStickDefaultConfig: { | ||
upColor: string; | ||
downColor: string; | ||
borderDownColor: string; | ||
borderUpColor: string; | ||
wickDownColor: string; | ||
wickUpColor: string; | ||
}; | ||
export declare const histogramDefaultConfig: { | ||
base: number; | ||
lineWidth: number; | ||
priceFormat: { | ||
type: string; | ||
}; | ||
overlay: boolean; | ||
scaleMargins: { | ||
top: number; | ||
bottom: number; | ||
}; | ||
}; | ||
export declare const defaultChartLayout: { | ||
layout: { | ||
backgroundColor: string; | ||
textColor: string; | ||
}; | ||
grid: { | ||
vertLines: { | ||
color: string; | ||
style: LineStyle; | ||
}; | ||
horzLines: { | ||
color: string; | ||
style: LineStyle; | ||
}; | ||
}; | ||
crosshair: { | ||
mode: CrosshairMode; | ||
}; | ||
leftPriceScale: { | ||
borderColor: string; | ||
}; | ||
rightPriceScale: { | ||
borderColor: string; | ||
}; | ||
overlayPriceScales: { | ||
borderColor: string; | ||
}; | ||
timeScale: { | ||
borderColor: string; | ||
timeVisible: boolean; | ||
secondsVisible: boolean; | ||
}; | ||
}; | ||
export const BASE_URL: "https://api.binance.com/api/v3/klines?"; | ||
export const WS_URL: "wss://stream.binance.com:9443/ws"; | ||
export namespace candleStickDefaultConfig { | ||
const upColor: string; | ||
const downColor: string; | ||
const borderDownColor: string; | ||
const borderUpColor: string; | ||
const wickDownColor: string; | ||
const wickUpColor: string; | ||
} | ||
export namespace histogramDefaultConfig { | ||
const base: number; | ||
const lineWidth: number; | ||
namespace priceFormat { | ||
const type: string; | ||
} | ||
const overlay: boolean; | ||
namespace scaleMargins { | ||
const top: number; | ||
const bottom: number; | ||
} | ||
} | ||
export namespace defaultChartLayout { | ||
namespace layout { | ||
const backgroundColor: string; | ||
const textColor: string; | ||
} | ||
namespace grid { | ||
namespace vertLines { | ||
const color: string; | ||
const style: LineStyle; | ||
} | ||
namespace horzLines { | ||
const color_1: string; | ||
export { color_1 as color }; | ||
const style_1: LineStyle; | ||
export { style_1 as style }; | ||
} | ||
} | ||
namespace crosshair { | ||
const mode: CrosshairMode; | ||
} | ||
namespace priceScale { | ||
const borderColor: string; | ||
} | ||
namespace timeScale { | ||
const borderColor_1: string; | ||
export { borderColor_1 as borderColor }; | ||
export const timeVisible: boolean; | ||
export const secondsVisible: boolean; | ||
} | ||
} | ||
import { LineStyle } from "lightweight-charts"; | ||
import { CrosshairMode } from "lightweight-charts"; |
import { CrosshairMode, LineStyle } from "lightweight-charts"; | ||
export var BASE_URL = "https://api.binance.com/api/v3/klines?"; | ||
export var WS_URL = "wss://stream.binance.com:9443/ws"; | ||
export var condleStickDefaultConfig = { | ||
upColor: "#00c176", | ||
downColor: "#cf304a", | ||
borderDownColor: "#cf304a", | ||
borderUpColor: "#00c176", | ||
wickDownColor: "#838ca1", | ||
wickUpColor: "#838ca1", | ||
export var candleStickDefaultConfig = { | ||
upColor: "#00c176", | ||
downColor: "#f6465d", | ||
borderDownColor: "#f6465d", | ||
borderUpColor: "#00c176", | ||
wickDownColor: "#838ca1", | ||
wickUpColor: "#838ca1", | ||
}; | ||
export var histogramDefaultConfig = { | ||
base: 0, | ||
lineWidth: 2, | ||
priceFormat: { | ||
type: "volume", | ||
}, | ||
overlay: true, | ||
scaleMargins: { | ||
top: 0.8, | ||
bottom: 0, | ||
}, | ||
base: 0, | ||
lineWidth: 2, | ||
priceFormat: { | ||
type: "volume", | ||
}, | ||
overlay: true, | ||
scaleMargins: { | ||
top: 0.8, | ||
bottom: 0, | ||
}, | ||
}; | ||
export var defaultChartLayout = { | ||
layout: { | ||
backgroundColor: "#ededed", | ||
textColor: "#253248", | ||
layout: { | ||
backgroundColor: "#ededed", | ||
textColor: "#253248", | ||
}, | ||
grid: { | ||
vertLines: { | ||
color: "#838fa3", | ||
style: LineStyle.SparseDotted, | ||
}, | ||
grid: { | ||
vertLines: { | ||
color: "#838fa3", | ||
style: LineStyle.SparseDotted, | ||
}, | ||
horzLines: { | ||
color: "#838fa3", | ||
style: LineStyle.SparseDotted, | ||
}, | ||
horzLines: { | ||
color: "#838fa3", | ||
style: LineStyle.SparseDotted, | ||
}, | ||
crosshair: { | ||
mode: CrosshairMode.Normal, | ||
}, | ||
leftPriceScale: { | ||
borderColor: "#485c7b", | ||
}, | ||
rightPriceScale: { | ||
borderColor: "#485c7b", | ||
}, | ||
overlayPriceScales: { | ||
borderColor: "#485c7b", | ||
}, | ||
timeScale: { | ||
borderColor: "#485c7b", | ||
timeVisible: true, | ||
secondsVisible: false, | ||
}, | ||
}, | ||
crosshair: { | ||
mode: CrosshairMode.Normal, | ||
}, | ||
priceScale: { | ||
borderColor: "#485c7b", | ||
}, | ||
timeScale: { | ||
borderColor: "#485c7b", | ||
timeVisible: true, | ||
secondsVisible: false, | ||
}, | ||
}; |
@@ -1,1 +0,1 @@ | ||
export declare const fetchCandleStickData: (symbol?: string, interval?: string, useFuturesTestnet?: boolean, useSpotTestnet?: boolean) => Promise<import("react-crypto-chart-sosa/src/utils/types").CandleStickAdaptorResult[]>; | ||
export function fetchCandleStickData(symbol?: string, interval?: string): Promise<any>; |
@@ -16,3 +16,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -38,9 +38,7 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
}; | ||
import { getBaseUrl } from "./urls"; | ||
import { BASE_URL } from "./constants"; | ||
import { parseCandleStickData } from "./candleStickService"; | ||
export var fetchCandleStickData = function (symbol, interval, useFuturesTestnet, useSpotTestnet) { | ||
export var fetchCandleStickData = function (symbol, interval) { | ||
if (symbol === void 0) { symbol = "BTCBUSD"; } | ||
if (interval === void 0) { interval = "1m"; } | ||
if (useFuturesTestnet === void 0) { useFuturesTestnet = false; } | ||
if (useSpotTestnet === void 0) { useSpotTestnet = false; } | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
@@ -51,3 +49,3 @@ var url, result, data; | ||
case 0: | ||
url = "".concat(getBaseUrl({ useFuturesTestnet: useFuturesTestnet, useSpotTestnet: useSpotTestnet }), "symbol=").concat(symbol, "&interval=").concat(interval); | ||
url = "".concat(BASE_URL, "symbol=").concat(symbol, "&interval=").concat(interval); | ||
return [4 /*yield*/, fetch(url)]; | ||
@@ -54,0 +52,0 @@ case 1: |
import { CrosshairMode, LineStyle } from 'lightweight-charts'; | ||
export interface CandleStickAdaptorResult { | ||
time: number; | ||
open: number; | ||
high: number; | ||
low: number; | ||
close: number; | ||
value: number; | ||
color: string; | ||
} | ||
export interface CandleStickSocketData { | ||
@@ -21,3 +12,3 @@ open: number; | ||
export interface TradeViewProps { | ||
initialChartData: CandleStickAdaptorResult[]; | ||
initialChartData: []; | ||
updatedata: CandleStickSocketData | null; | ||
@@ -62,8 +53,6 @@ candleStickConfig: CandleStickConfig; | ||
pair: string; | ||
interval?: string; | ||
candleStickConfig?: CandleStickConfig; | ||
histogramConfig?: HistogramConfig; | ||
chartLayout?: DeffaultChartLayout; | ||
useFuturesTestnet?: boolean; | ||
useSpotTestnet?: boolean; | ||
interval: string; | ||
candleStickConfig: CandleStickConfig; | ||
histogramConfig: HistogramConfig; | ||
chartLayout: DeffaultChartLayout; | ||
containerStyle?: { | ||
@@ -91,11 +80,5 @@ [x: string]: any; | ||
}; | ||
leftPriceScale?: { | ||
priceScale?: { | ||
borderColor: string; | ||
}; | ||
rightPriceScale?: { | ||
borderColor: string; | ||
}; | ||
overlayPriceScales?: { | ||
borderColor: string; | ||
}; | ||
timeScale?: { | ||
@@ -102,0 +85,0 @@ borderColor: string; |
{ | ||
"name": "react-crypto-chart-sosa", | ||
"version": "0.0.9", | ||
"version": "0.0.15", | ||
"description": "crypto chart widget for react using binance api", | ||
"main": "lib/cjs/index.js", | ||
"module": "lib/esm/index.js", | ||
"types": "lib/esm/index.d.ts", | ||
"main": "./lib/cjs/index.js", | ||
"module": "./lib/esm/index.js", | ||
"types": "./lib/esm/index.d.ts", | ||
"author": "Justin K Xavier", | ||
"contributors": [ | ||
{ | ||
"name": "Rakibul Yeasin", | ||
"email": "ryeasin03@gmail.com", | ||
"url": "https://dreygur.js.org/" | ||
} | ||
], | ||
"repository": { | ||
"url": "https://github.com/reverse-sosa/react-crypto-chart-sosa.git" | ||
"url": "https://github.com/reverseSosa/react-crypto-chart-sosa.git" | ||
}, | ||
@@ -26,16 +19,18 @@ "license": "MIT", | ||
"files": [ | ||
"lib" | ||
"/lib" | ||
], | ||
"devDependencies": { | ||
"@types/react": "^18.0.28", | ||
"@types/react-dom": "^18.0.11", | ||
"@types/react": "^18.2.0", | ||
"@types/react-dom": "^18.2.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"typescript": "^4.3.2" | ||
}, | ||
"dependencies": { | ||
"lightweight-charts": "^3.8.0" | ||
}, | ||
"peerDependencies": { | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"dependencies": { | ||
"lightweight-charts": "^4.0.0" | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
27063
684
1
172
5
+ Addedfancy-canvas@2.1.0(transitive)
+ Addedlightweight-charts@4.2.1(transitive)
- Removedfancy-canvas@0.2.2(transitive)
- Removedlightweight-charts@3.8.0(transitive)
Updatedlightweight-charts@^4.0.0