UNPKG

parser-de-notas-de-corretagem

Version:
81 lines 3.27 kB
import { Asset } from "./types/common"; import { StockInfos } from "./types/listed-stocks"; import { FiiInfos } from "./types/listed-real-estates"; import { CashDividend, StockDividend } from "./types/corporative-events"; /** Types of asset verbosity */ export type AssetVerbosity = 'off' | 'all' | 'minimal'; /** Assets crawler manager */ export declare class AssetCrawler { /** Assets cached */ protected assets: Array<StockInfos | FiiInfos>; /** Assets defined on runtime */ customAssets: Asset[]; /** Unprotected HTTPS agent for un-safe requests */ private unprotectedHttpsAgent; /** Auto-update flag */ private _autoUpdate; /** Auto-update flag */ set autoUpdate(v: boolean); get autoUpdate(): boolean; private autoUpdateTimer; /** Auto-update timeout */ private updaterTimeout; /** Auto-update timeout when any failure happens */ private updaterTimeoutIfFailed; /** Set the verbosity level */ verbosity: AssetVerbosity; /** Max number of retries when fetching data. Default is 20 */ maxRetries: number; /** Manage the keys being listened to */ private listenerKey; /** Keys generated on update */ private listeners; /** * Instantiate a new `AssetCrawler` * @param autoUpdate whether the application should auto-update * the list of assets for new changes. Default is `false`. Require internet connection * @param verbose set the verbosity level. Default is `off` */ constructor(autoUpdate?: boolean, verbose?: AssetVerbosity); /** * Update the listed assets after a timeout * @param timeout update after `timeout` milliseconds */ private updater; /** * Update the current listed assets. May take several minutes. * If `maxRetires` is reached, an Error is thrown and the fetch * process is interrupted */ fetchListedAssets(): Promise<void>; private fetchStocks; private fetchFIIs; /** * Parse the stock name and returns the stock code * @param name title of the stock in the brokerage note * @param kind asset kind (like ON, PN, DR2) * @returns the stock code */ getCodeFromTitle(name: string, kind?: string): Asset; /** * Get the stock dividends and the cash dividends of a given asset, if any * @param code the asset code (letter only) * @returns and `Array` where the first position is the list of stock dividends * and the second position is a list of the cash dividends */ getDividends(code: string): [StockDividend[], CashDividend[]]; /** * Subscribe to updates when `autoUpdate` is `on` or * when `fetchListedAssets` is manually called * @param callback function to be called when the data is updated * @returns the key number referring to the listener. Can be used to `unsubscribeToUpdates` */ subscribeToUpdates(callback: (assets: Array<StockInfos | FiiInfos>) => void): number; /** * Unsubscribe to updates when `autoUpdate` is `on` or * when `fetchListedAssets` is manually called * @param key the subscription key returned by `subscribeToUpdates` */ unsubscribeToUpdates(key: number): void; } //# sourceMappingURL=asset-crawler.d.ts.map