Skip to content

no diagnostic found when clicking on "Open in new tab" #161

@bennycode

Description

@bennycode

Describe the bug

I clicked "Open in new tab" and received this:

Image

Expected behavior

A sidebar with error explanation.

Original error

Argument of type '{ intervalInMillis: number; }' is not assignable to parameter of type 'ExchangeCandleImportRequest'.
Type '{ intervalInMillis: number; }' is missing the following properties from type 'ExchangeCandleImportRequest': startTimeFirstCandle, startTimeLastCandle

Code

import {ms, CurrencyPair, getAlpacaClient} from '@typedtrader/exchange';

// Request: SHOP,USD 1h
export default async (request: string) => {
  if (!process.env.ALPACA_LIVE_API_KEY) {
    return;
  }

  if (!process.env.ALPACA_LIVE_API_SECRET) {
    return;
  }

  const spaceIndex = request.indexOf(' ');
  const pairPart = request.slice(0, spaceIndex);
  const commaIndex = pairPart.indexOf(',');
  const base = pairPart.slice(0, commaIndex);
  const counter = pairPart.slice(commaIndex + 1);
  const pair = new CurrencyPair(base, counter);
  const interval = request.slice(spaceIndex + 1);
  const intervalInMillis = ms(interval);

  const client = getAlpacaClient({
    apiKey: process.env.ALPACA_LIVE_API_KEY,
    apiSecret: process.env.ALPACA_LIVE_API_SECRET,
    usePaperTrading: false,
  });

  const candle = await client.getCandles(pair, {
    intervalInMillis,
  });

  return JSON.stringify({pair, interval, intervalInMillis});
};

Screenshots

Image

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions