symbol price precision fix

This commit is contained in:
Tim
2024-03-19 15:53:52 -04:00
parent c9685c51e1
commit 17c4d1094a

View File

@@ -4,12 +4,14 @@ import {jBars, tvResolutionToPeriodString} from './jBars.js';
import {metadata} from "@/version.js"; import {metadata} from "@/version.js";
import FlexSearch from "flexsearch"; import FlexSearch from "flexsearch";
import {useChartOrderStore} from "@/orderbuild.js"; 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"; import {subOHLC, unsubOHLC} from "@/blockchain/ohlcs.js";
let feeDropdown = null let feeDropdown = null
let widget = 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) { export function initFeeDropdown(w) {
widget = w widget = w
widget.createDropdown( widget.createDropdown(
@@ -108,9 +110,10 @@ function addSymbol(p, base, quote, inverted) {
const description = `${base.n} / ${quote.n}` const description = `${base.n} / ${quote.n}`
const type = 'swap' const type = 'swap'
const pools = [[p.a, p.f]] const pools = [[p.a, p.f]]
const decimals = p.d
_symbols[key] = { _symbols[key] = {
full_name: key, symbol, description, ticker: key, full_name, symbol, description,
exchange, type, inverted, base, quote, pools, x:p.x exchange, type, inverted, base, quote, pools, decimals, x:p.x
} }
if (defaultSymbol===null) if (defaultSymbol===null)
defaultSymbol = _symbols[key] defaultSymbol = _symbols[key]
@@ -257,29 +260,32 @@ export const DataFeed = {
return; return;
} }
const co = useChartOrderStore(); const co = useChartOrderStore();
const os = useOrderStore()
co.selectedSymbol = symbolItem co.selectedSymbol = symbolItem
const pool = symbolItem.pools[Math.trunc(symbolItem.pools.length/2)]; const pool = symbolItem.pools[Math.trunc(symbolItem.pools.length/2)];
// noinspection JSValidateTypes // noinspection JSValidateTypes
co.selectedPool = pool co.selectedPool = pool
updateFeeDropdown() updateFeeDropdown()
// Symbol information object const priceScale = '100'
// LibrarySymbolInfo
// https://www.tradingview.com/charting-library-docs/latest/api/interfaces/Charting_Library.LibrarySymbolInfo
const symbolInfo = { const symbolInfo = {
ticker: symbolItem.full_name, ticker: symbolItem.ticker,
name: symbolItem.symbol, 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, type: symbolItem.type,
session: '24x7', session: '24x7',
timezone: 'Etc/UTC', timezone: 'Etc/UTC',
exchange: symbolItem.exchange, exchange: symbolItem.exchange,
minmov: 1, minmov: 0.000000000000000001,
pricescale: 100, pricescale: 0.000000000000000001,
variable_tick_size: VARIABLE_TICK_SIZE,
has_intraday: true, // Added to allow less than one day to work has_intraday: true, // Added to allow less than one day to work
// has_no_volume: true, // deprecated
visible_plots_set: 'ohlc', visible_plots_set: 'ohlc',
has_weekly_and_monthly: true, // Added to allow greater than one day to work has_weekly_and_monthly: true, // Added to allow greater than one day to work
supported_resolutions: configurationData.supported_resolutions, supported_resolutions: configurationData.supported_resolutions,
volume_precision: 2, // volume_precision: 2,
data_status: 'streaming', data_status: 'streaming',
}; };
console.log('[resolveSymbol]: Symbol resolved', symbolName); console.log('[resolveSymbol]: Symbol resolved', symbolName);