or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

account.mdcore.mdindex.mdinstruments.mdorders.mdpositions.mdpricing.mdtrades.mdtransactions.mdusers.md
tile.json

instruments.mddocs/

Instrument Data

Candlestick data, prices, order books, position books for market analysis.

API Methods

candles

Get candlestick data for an instrument.

candles(
  instrument: string,
  queryParams: {
    price?: 'M' | 'B' | 'A' | 'BA' | 'MBA';
    granularity?: string;
    count?: number;  // max 5000
    from?: string;
    to?: string;
    smooth?: boolean;
    includeFirst?: boolean;
    dailyAlignment?: number;
    alignmentTimezone?: string;
    weeklyAlignment?: string;
  },
  responseHandler: (response: Response) => void
): void;

Response: { instrument: string, granularity: string, candles: Candlestick[] }

Example:

ctx.instrument.candles('EUR_USD', {
  price: 'M',
  granularity: 'H1',
  count: 100
}, (response) => {
  if (response.isSuccess()) {
    response.body.candles.forEach(candle => {
      if (candle.complete) {
        console.log(candle.time, candle.mid.c);
      }
    });
  }
});

price

Get current price snapshot.

price(
  instrument: string,
  queryParams: { time?: string },
  responseHandler: (response: Response) => void
): void;

Response: { price: Price }

prices

Get historical price range.

prices(
  instrument: string,
  queryParams: { from: string; to: string },
  responseHandler: (response: Response) => void
): void;

Response: { prices: Price[] }

orderBook

Get order book snapshot.

orderBook(
  instrument: string,
  queryParams: { time?: string },
  responseHandler: (response: Response) => void
): void;

Response: { orderBook: OrderBook }

Example:

ctx.instrument.orderBook('EUR_USD', {}, (response) => {
  if (response.isSuccess()) {
    const book = response.body.orderBook;
    book.buckets.forEach(bucket => {
      console.log(bucket.price, bucket.longCountPercent, bucket.shortCountPercent);
    });
  }
});

positionBook

Get position book snapshot.

positionBook(
  instrument: string,
  queryParams: { time?: string },
  responseHandler: (response: Response) => void
): void;

Response: { positionBook: PositionBook }

Data Classes

Candlestick

interface Candlestick {
  time: string;
  bid?: CandlestickData;
  ask?: CandlestickData;
  mid?: CandlestickData;
  volume: number;
  complete: boolean;
}

interface CandlestickData {
  o: string;
  h: string;
  l: string;
  c: string;
}

OrderBook

interface OrderBook {
  instrument: string;
  time: string;
  price: string;
  bucketWidth: string;
  buckets: OrderBookBucket[];
}

interface OrderBookBucket {
  price: string;
  longCountPercent: string;
  shortCountPercent: string;
}

PositionBook

interface PositionBook {
  instrument: string;
  time: string;
  price: string;
  bucketWidth: string;
  buckets: PositionBookBucket[];
}

interface PositionBookBucket {
  price: string;
  longCountPercent: string;
  shortCountPercent: string;
}

Instrument

Complete instrument specification.

interface Instrument {
  name: string;
  type: string;
  displayName: string;
  pipLocation: number;
  displayPrecision: number;
  tradeUnitsPrecision: number;
  minimumTradeSize: string;
  maximumTrailingStopDistance: string;
  minimumTrailingStopDistance: string;
  maximumPositionSize: string;
  maximumOrderUnits: string;
  marginRate: string;
  commission: InstrumentCommission;
  guaranteedStopLossOrderMode?: string;
  guaranteedStopLossOrderExecutionPremium?: string;
  guaranteedStopLossOrderLevelRestriction?: GuaranteedStopLossOrderLevelRestriction;
}

InstrumentCommission

interface InstrumentCommission {
  commission: string;
  unitsTraded: string;
  minimumCommission: string;
}

GuaranteedStopLossOrderLevelRestriction

interface GuaranteedStopLossOrderLevelRestriction {
  volume: string;
  priceRange: string;
}

Error Handling

ctx.instrument.candles('EUR_USD', { granularity: 'H1', count: 100 }, (response) => {
  if (response.isSuccess()) {
    console.log('Candles:', response.body.candles.length);
  } else if (response.isClientError()) {
    console.error('Client error:', response.body.errorCode, response.body.errorMessage);
  }
});