new ohlc; beta signin; elaborated order status (not working yet)
This commit is contained in:
@@ -90,7 +90,7 @@ const seriesStarts = {}
|
||||
async function getUrl(url) {
|
||||
try {
|
||||
const response = await fetch(url)
|
||||
console.log('got response', response)
|
||||
// console.log('got response', response)
|
||||
if (response.ok)
|
||||
return await response.text()
|
||||
else
|
||||
@@ -104,7 +104,7 @@ async function getUrl(url) {
|
||||
|
||||
|
||||
export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
||||
console.log('loadOHLC', tvRes, new Date(1000*from), new Date(1000*to), symbol, contract);
|
||||
// console.log('loadOHLC', tvRes, new Date(1000*from), new Date(1000*to), symbol, contract);
|
||||
let chainId
|
||||
let bars = [];
|
||||
let inverted = symbol.inverted;
|
||||
@@ -130,8 +130,6 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
||||
}
|
||||
baseURL += `${chainId}/${contract}/`
|
||||
|
||||
console.log('baseURL', baseURL)
|
||||
|
||||
const res = resMap[tvRes]
|
||||
const fetches = []
|
||||
let start = from
|
||||
@@ -140,7 +138,7 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
||||
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)}`)
|
||||
// console.log(`Series ${baseURL} starts at ${new Date(start*1000)}`)
|
||||
}
|
||||
else {
|
||||
console.error(`Bad response while fetching ${baseURL+'quote.csv'}`)
|
||||
@@ -155,7 +153,7 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
||||
|
||||
for(let now = start; now < to; now = res.nextStart(now)) {
|
||||
const url = baseURL + res.filename(contract, now);
|
||||
console.log('fetching', url)
|
||||
// console.log('fetching', url)
|
||||
const prom = getUrl(url)
|
||||
fetches.push(prom);
|
||||
}
|
||||
@@ -166,7 +164,7 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
||||
let lineNum = 0
|
||||
response.split('\n').forEach((line) => {
|
||||
lineNum++
|
||||
console.log(`processing line ${lineNum}`, line)
|
||||
// console.log(`processing line ${lineNum}`, line)
|
||||
const row = line.split(',')
|
||||
let time, open, high, low, close=null
|
||||
switch (row.length) {
|
||||
@@ -216,17 +214,17 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
||||
break
|
||||
}
|
||||
if (close!==null) {
|
||||
console.log(`filling up to ${time}`)
|
||||
// console.log(`filling up to ${time}`)
|
||||
fill(time, res.period)
|
||||
const bar = {time:time*1000, open, high, low, close};
|
||||
console.log('pushing bar', bar)
|
||||
// console.log('pushing bar', bar)
|
||||
bars.push(bar)
|
||||
latest = [time, close]
|
||||
}
|
||||
})
|
||||
console.log(`processed ${lineNum} lines`)
|
||||
// console.log(`processed ${lineNum} lines`)
|
||||
}
|
||||
else { console.log('response was empty') }
|
||||
// else { console.log('response was empty') }
|
||||
}
|
||||
|
||||
fill(to, res.period)
|
||||
@@ -241,7 +239,7 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
||||
// backward to find beginning of history. How far to search?
|
||||
|
||||
let noData = bars.length === 0;
|
||||
if (noData) console.log("noData == true!");
|
||||
console.log('bars', bars)
|
||||
// if (noData) console.log("noData == true!");
|
||||
// console.log('bars', bars)
|
||||
return [bars, {noData}];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user