From 17c4d1094aa0a928ff4faa4d1f7b541d3e65cc3b Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 19 Mar 2024 15:53:52 -0400 Subject: [PATCH] symbol price precision fix --- src/charts/datafeed.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/charts/datafeed.js b/src/charts/datafeed.js index 1c00a26..0b01329 100644 --- a/src/charts/datafeed.js +++ b/src/charts/datafeed.js @@ -4,12 +4,14 @@ import {jBars, tvResolutionToPeriodString} from './jBars.js'; import {metadata} from "@/version.js"; import FlexSearch from "flexsearch"; import {useChartOrderStore} from "@/orderbuild.js"; -import {useOrderStore, useStore} from "@/store/store.js"; +import {useStore} from "@/store/store.js"; import {subOHLC, unsubOHLC} from "@/blockchain/ohlcs.js"; let feeDropdown = null let widget = null +const VARIABLE_TICK_SIZE = '0.00000000000000001 0.000000000001 0.0000000000000001 0.00000000001 0.000000000000001 0.0000000001 0.00000000000001 0.000000001 0.0000000000001 0.00000001 0.000000000001 0.0000001 0.00000000001 0.000001 0.0000000001 0.00001 0.000000001 0.0001 0.00000001 0.001 0.0000001 0.01 0.000001 0.1 0.00001 1 0.0001 10 0.001 100 0.01 1000 0.1 10000 1 100000 10 1000000 100 10000000 1000 100000000 10000 1000000000 100000 10000000000 1000000 100000000000 10000000 1000000000000 100000000' + export function initFeeDropdown(w) { widget = w widget.createDropdown( @@ -108,9 +110,10 @@ function addSymbol(p, base, quote, inverted) { const description = `${base.n} / ${quote.n}` const type = 'swap' const pools = [[p.a, p.f]] + const decimals = p.d _symbols[key] = { - full_name: key, symbol, description, - exchange, type, inverted, base, quote, pools, x:p.x + ticker: key, full_name, symbol, description, + exchange, type, inverted, base, quote, pools, decimals, x:p.x } if (defaultSymbol===null) defaultSymbol = _symbols[key] @@ -257,29 +260,32 @@ export const DataFeed = { return; } const co = useChartOrderStore(); - const os = useOrderStore() co.selectedSymbol = symbolItem const pool = symbolItem.pools[Math.trunc(symbolItem.pools.length/2)]; // noinspection JSValidateTypes co.selectedPool = pool updateFeeDropdown() - // Symbol information object + const priceScale = '100' + // LibrarySymbolInfo + // https://www.tradingview.com/charting-library-docs/latest/api/interfaces/Charting_Library.LibrarySymbolInfo const symbolInfo = { - ticker: symbolItem.full_name, + ticker: symbolItem.ticker, name: symbolItem.symbol, - description: symbolItem.description + ` ${(pool[1]/10000).toFixed(2)}%`, + pro_name: symbolItem.full_name, + // we add the fee to the description after the specific pool has been resolved + description: symbolItem.description + ` ${(pool[1] / 10000).toFixed(2)}%`, type: symbolItem.type, session: '24x7', timezone: 'Etc/UTC', exchange: symbolItem.exchange, - minmov: 1, - pricescale: 100, + minmov: 0.000000000000000001, + pricescale: 0.000000000000000001, + variable_tick_size: VARIABLE_TICK_SIZE, has_intraday: true, // Added to allow less than one day to work - // has_no_volume: true, // deprecated visible_plots_set: 'ohlc', has_weekly_and_monthly: true, // Added to allow greater than one day to work supported_resolutions: configurationData.supported_resolutions, - volume_precision: 2, + // volume_precision: 2, data_status: 'streaming', }; console.log('[resolveSymbol]: Symbol resolved', symbolName);