symbol rework; fee % switching; symbol search improvements

This commit is contained in:
tim
2024-10-11 00:26:29 -04:00
parent 6d19adb130
commit 5b23864c2e
11 changed files with 233 additions and 178 deletions

View File

@@ -116,7 +116,7 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
let chainId
let bars = [];
let inverted = false;
let baseURL
let baseUrl
let latest = null // latest time, price
function fill(end, period) {
@@ -131,41 +131,41 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
}
if (symbol.x?.data) {
baseURL = symbol.x.data.uri
baseUrl = symbol.x.data.uri
contract = symbol.x.data.symbol
chainId = symbol.x.data.chain
inverted ^= symbol.x.data.inverted
}
else {
baseURL = `/ohlc/`
baseUrl = `/ohlc/`
chainId = useStore().chainId
}
baseURL += `${chainId}/${contract}/`
baseUrl += `${chainId}/${contract}/`
const res = tvResMap[tvRes]
const fetches = []
let start = from
if (!(baseURL in seriesStarts)) {
if (!(baseUrl in seriesStarts)) {
try {
const response = await getUrl(baseURL+'quote.csv')
// console.log('getting quote', baseUrl+'quote.csv')
const response = await getUrl(baseUrl+'quote.csv')
if (response.length) {
seriesStarts[baseURL] = parseInt(response.split(',')[0])
// console.log(`Series ${baseURL} starts at ${new Date(start*1000)}`)
seriesStarts[baseUrl] = parseInt(response.split(',')[0])
// console.log(`Series ${baseUrl} starts at ${new Date(start*1000)}`)
}
else {
console.error(`Bad response while fetching ${baseURL+'quote.csv'}`)
console.error(`Bad response while fetching ${baseUrl+'quote.csv'}`)
}
}
catch (e) {
console.error(e)
}
}
if (baseURL in seriesStarts)
start = Math.max(start, seriesStarts[baseURL])
if (baseUrl in seriesStarts)
start = Math.max(start, seriesStarts[baseUrl])
for(let now = start; now < to; now = res.nextStart(now)) {
const url = baseURL + res.filename(contract, now);
// console.log('fetching', url)
const url = baseUrl + res.filename(contract, now);
const prom = getUrl(url)
fetches.push(prom);
}