LispTick Wiki

Tick Time Series dedicated functions

backward

Shift all values to previous time. Last time and first value are lost.

parameter

  • ts: input timeserie

clockref

Define the timeserie as a clock reference, or metronome. For any operation between several timeseries there will be one update for output if there is one update for the clockref serie. This synchronization mode ensure that length of output timeserie is <= to clockref timeserie. Adding a ref-value ensure length of output timeserie is = to clockref timeserie, uncomputed values due to missing data from other series will be replaced by ref-value.

parameter

  • ts: timeserie than will become the reference for time
  • ref-value: a value used when reference timeserie has value before other series

delta

Returns timeserie where each point is the current value minus previous value of the input timeserie. So result length is input length-1, and first output point time is time of second input point time.

parameter

  • ts: input timeserie

forward

Shift all values to next time. First time and last value are lost.

parameter

  • ts: input timeserie

graphsample

Subsample timeserie in order to minimize number of points but to keep same result on screen. This is useful to get a smaller timeserie that will be drawn like the full timeserie if your output screen is nbr pixel width. As graphsample process on a stream it can't know the future so sends lots of points at the beginning then less and less.

parameters

  • nbr: should be the number of pixels of the graph you will create with timeserie.
  • ts: input timeserie

example

  • graph show all S&P E-Mini future bid prices not null on a Full HD screen (more than 2 million points)

history

Return all available dates for a given source and code.

As history can be huge depending on source better call through a LispTick client with streaming (Walk method).

parameter

  • source: data provider source name
  • code: a code related to source (e.g. a RIC like "BNPP.PA")

keep

Only keep points in timeserie that fulfill the given condition

parameters

  • ts: input timeserie
  • func: can be <, >, <=, >=, =, not= or any function returning a boolean, each timeserie point will be used as 1st argument
  • args: argument of func after timeserie point

examples

Change timeserie ts to keep only positif values

Limit perimeter to code ending with ".PA"

label

Give a name to the timeserie that can be used in a graph for example.

parameters

  • name: a string
  • ts: input timeserie

localize

Set time location, useful to ensure time precision when created manually.

parameters

  • time: input time
  • location: timezone, can be any tz data name like "US/Eastern" see TZ Wiki

examples

Tests ensuring daylight saving is well handled

max

Max returns maximum of several values. If an argument is a timeserie latest value is used for comparaison. If the only argument is a timeserie result is the point with maximum value.

parameters

  • a: first input timeserie or value
  • b: second input timeserie or value
  • ...: as many timeseries or values as you want

example

  • graph Use maximum of current and previous bid price to filter spikes.
  • graph Get higer trade price over a period.

merge

Merge several timeseries into one, synchronize points from all timeseries.

parameters

  • ts1: first input timeserie
  • ts2: second input timeserie
  • ...: as many timeseries as you want

min

Min returns minimum of several values. If an argument is a timeserie latest value is used for comparaison. If the only argument is a timeserie result is the point with minimum value.

parameters

  • a: first input timeserie or value
  • b: second input timeserie or value
  • ...: as many timeseries or values as you want

See max for some examples

now

Retrieve current time

example

  • graph trade prices since 00h00 UTC until now for Bitcoin from Bitstamp

one

Replace value of every update by 1.0 .

parameter

  • ts: input timeserie

parallel-sample

Apply undrelying function for all given arguments combination using all available ressources.

parameter

  • func: function name called with each argument tuples (args1[0] args2[0]...) (args1[0] args2[1] ...) ...
  • samplemode: how to choose point to keep, can be open, high, low, close, sum, count, all
  • args1: a value, an array of values, a timeserie or a range used as an iterator
  • args2: a value, an array of values, a timeserie or a range used as an iterator ...

example

  • graphCompute number of trades for Bitcoin, Ether, Ripple from source bitstamp in February 2018. Show only the result value of timeserie, not the time (which is time of last trade).

parallel-sample-grid

As parallel-sample but result is a grid with used arguments for kept result instead of a simple timeserie

parameter

  • func: function name called with each argument tuples (args1[0] args2[0]...) (args1[0] args2[1] ...) ...
  • samplemode: how to choose point to keep, can be open, high, low, close, sum, count, all
  • args1: a value, an array of values, a timeserie or a range used as an iterator
  • args2: a value, an array of values, a timeserie or a range used as an iterator ...

perimeter

Return all available codes for a given source and date.

As perimeter can be huge depending on source better call through a LispTick client with streaming (Walk method).

parameter

  • source: data provider source name
  • code: a code related to source (e.g. a RIC like "BNPP.PA")
  • date: a LispTick Date without time

prune

Filter points in timeserie where value doesn't change.

parameter

  • ts: input timeserie

range

Create an interator on an range of values. Should be used as an argument to parallel-sample.

parameter

  • start: Starting value, included
  • stop: Ending value, included
  • step: Value to add at each step

example

Every day from 19 January 2018 until 1st May 2018, included

restrict

Only keep timeserie points in [start, stop[. If no timezone is given with start or stop it will be "local" to timeserie timezone.

parameters

  • ts: input timeserie
  • start: a time with or without date
  • stop: a time with or without date

sigma

Returns a timeserie where each point is the summation of all previous points in the input timeserie.

parameter

  • ts: input timeserie

example

  • graphCompute full volume traded during the day at any time.

sign

Replace value of every update by its sign:

  • value < 0 → -1
  • value == 0 → 0
  • value > 0 → 1

parameter

  • ts: input timeserie

sliding

Replace each update by the specified value from the sliding window. Typical usage is a moving average.

parameters

  • period|int: a duration or an int, defines the window size in time or in number of updates
  • samplemode: how to choose point to keep, can be open, high, low, close, sum, count, all
  • ts: input timeserie

examples

Average weighted by number of updates, like Bollinger Band base. Here the average is done on 1000 updates or on a 2h window. Using a period instead of a number of updates allows to extend Bollinger bands to high frequency data.

Use graphsample to get same graph but with less data transmission.

  • graph Average

subsample

Keep only one point per period from input timeserie, samplemode defines which point to keep. Each value is taken in the range [i * period, (i+1) * period[, each time value is the time of original point.

parameters

  • period: a duration, defines the period size
  • samplemode: how to choose point to keep, can be open, high, low, close, sum, count, all
  • ts: input timeserie

examples

Request 5 minutes timebar for a stock.

  • graph Open High Low Close
  • graph Volume
  • graph Number of 1st limit bid update per hour for S&P E-Mini future

tget

Get time at a precise index in a timeserie. If index is a time return same time if an update exists or return time of update just before.

parameters

  • ts: input timeserie
  • i: index or time of the data to retrieve, 0 is first -1 is last

example

  • graph Use the first and last timeserie times to compute the day quotation duration

time-as-array

Return times of timeserie as an array of datetime.

parameter

  • ts: input timeserie

time-as-value

Return times of timeserie as a timeserie of Epoch times, number of seconds since 1 January 1970.

parameter

  • ts: input timeserie

timeserie

Create timeserie by hand or retrieve data from a source

parameters

  • origin: which tick data you want to look at, can be, depending on source:
    • @trade-price
    • @trade-volume
    • @bid-price
    • @bid-volume
    • @ask-price
    • @ask-volume
    • @[ask|bid]-[price|volume]-n retrieve nth limit (i.e. ask-price-1 should be equal to ask-price depending on source)
  • source: data provider source name
  • code: a code related to source (e.g. a RIC like "BNPP.PA")
  • date: a LispTick Date without time
  • stop: optional LispTick Date, several days timeserie from [date to stop]
  • filter: optional string argument, used by source to filter output

examples

  • graph bid prices for Bitcoin from Bitstamp source, spikes come from lack of liquidity
  • graph Hard coded time serie

value-as-array

Return values of timeserie as an array of floats.

parameter

  • ts: input timeserie

version

Return LispTick version as a string.

example

  • graph Current version

vget

Get value at a precise index in a timeserie. If index is a time return value at time if an update exists or just before.

parameters

  • ts: input timeserie
  • i: index or time of the data to retrieve, 0 is first -1 is last

example

  • graph Use first timeserie value to compute the serie return