import { Asset } from './asset'; /** * Resample unit. The minute, hour and day units are fixed durations; the * week and month units are calendar buckets. */ export type ResampleUnit = 'minute' | 'hour' | 'day' | 'week' | 'month'; /** * Optional configuration of resample parameters. */ export interface ResampleConfig { /** Bucket unit. */ unit: ResampleUnit; /** Number of units per bucket, a positive integer. */ size?: number; /** Drops the last bucket, which may cover only part of its interval. */ dropLast?: boolean; } /** * The default configuration of resample, used for the fields a configuration * leaves out. */ export declare const ResampleDefaultConfig: Required>; /** * Resample. Aggregates the bars of an asset into a coarser interval, such as * 1-minute bars into 1-hour bars, or daily bars into weekly bars. * * Each bar is assigned to the bucket that holds its date. Minute, hour and * day buckets are fixed durations counted from 1970-01-01 00:00 UTC, so a * 4-hour bucket starts at 00:00, 04:00, 08:00 and so on (UTC). Week buckets * start on Monday 00:00 UTC, and month buckets on the first day of the month * at 00:00 UTC; a 3-month bucket starts in January, April, July or October. * The date of each output bar is the start of its bucket. Buckets without any * bars, such as weekends or holidays, are left out. * * The last bucket may cover only part of its interval when the data ends * inside it. The dropLast option leaves it out. * * The dates must be in ascending order; an error is thrown otherwise. * * ``` * Open = First open of the bucket. * High = Max high of the bucket. * Low = Min low of the bucket. * Close = Last close of the bucket. * Volume = Sum of volumes of the bucket. * ``` * * @example * ```TypeScript * const weekly = resample(daily, { unit: 'week' }); * const hourly = resample(minutes, { unit: 'hour' }); * const quarterly = resample(daily, { unit: 'month', size: 3 }); * ``` * * @param asset asset with bars in ascending date order. * @param config configuration. * @return resampled asset. */ export declare function resample(asset: Asset, config: ResampleConfig): Asset; /** * Align resampled. Maps values computed on a resampled series, one per * bucket, back onto the original dates, so that results at two intervals can * be compared row by row. * * A bucket's value is assigned to the last original row of that bucket, the * first row at which all of the bucket's bars are known, and carried forward * until the next bucket's last row. Rows before the first bucket's last row * are NaN. When the configuration drops the last bucket, its rows carry the * previous bucket's value. * * ``` * Aligned[i] = Values[k], where k is the latest bucket whose last row is at * or before row i. * ``` * * @example * ```TypeScript * const weekly = resample(daily, { unit: 'week' }); * const weeklySma = sma(weekly.closings, { period: 4 }); * const aligned = alignResampled(daily.dates, weeklySma, { unit: 'week' }); * ``` * * @param dates original dates in ascending order. * @param values values, one per bucket of the resampled series. * @param config configuration used for resampling. * @return aligned values, one per original date. */ export declare function alignResampled(dates: Date[], values: number[], config: ResampleConfig): number[];