UNPKG

parser-de-notas-de-corretagem

Version:
155 lines 5.55 kB
import { AssetCrawler, AssetVerbosity } from "./asset-crawler"; import { CashDividend, StockDividend } from './types/corporative-events'; export { AssetCrawler, CashDividend, StockDividend }; export type { AssetVerbosity }; /** Deal made in a `NegotiationNote` type */ export interface Deal { /** Deal type */ type: 'buy' | 'sell'; /** Stock/FII code */ code: string; /** Amount bought/sold */ quantity: number; /** Average value bought/sold with fees applied */ average: string; /** Total amount bought/sold with fees applied */ price: string; /** Deal date in format yyyy-MM-dd */ date: string; /** Asset's CNPJ */ cnpj: string; /** Whether the asset is a FII (real estate) */ isFII: boolean; } /** A parsed Negotiation Note type */ export declare class NegotiationNote { /** Negotiation note number */ number: string; /** The total amount bought with fees applied */ buyTotal: string; /** The total amount sold with fees applied */ sellTotal: string; /** The total amount of buy fees */ buyFees: string; /** The total amount of sell fees */ sellFees: string; /** The total amount of fees */ fees: string; /** Negotiation note date in format yyyy-MM-dd */ date: string; /** Negotiation note holder */ holder: string; /** Array of deals with buys and sells */ deals: Deal[]; } /** Possible date formats to be used */ export type DateFormat = "dd/MM/yyyy" | "yyyy-MM-dd"; /** Base custom error */ declare class BaseError extends Error { /** File that triggered the error */ file: string; /** * Create a custom error * @param message error message * @param file the file name that triggered the error */ constructor(message: string, file: string); } /** Wrong password error */ export declare class WrongPassword extends BaseError { /** Tested passwords */ passwords: string[]; /** * Create a custom error * @param message error message * @param file the file name that triggered the error * @param passwords tested passwords */ constructor(message: string, file: string, passwords: string[]); } /** Empty document error */ export declare class EmptyDocument extends BaseError { } /** Document that cannot be recognized */ export declare class UnknownDocumentFormat extends BaseError { } /** Document without note number error */ export declare class MissingNoteNumber extends BaseError { } /** Document without holder error */ export declare class MissingHolder extends BaseError { } /** Document without date error */ export declare class MissingDate extends BaseError { } /** Missing Buy or Sell sums */ export declare class MissingBuyOrSellSums extends BaseError { } /** Unknown Asset error error */ export declare class UnknownAsset extends BaseError { /** The unknown asset name in the note */ asset: string; /** * Create a custom error * @param message error message * @param file the file name that triggered the error * @param asset the unknown asset name in the note */ constructor(message: string, file: string, asset: string); } /** Brokerage notes parser */ export declare class NoteParser { /** Info about the assets */ assetCrawler: AssetCrawler; /** The date format used. Default is `dd/MM/yyyy` */ private dateFormat; /** Set the verbosity level. Actually it's the same as the crawler */ private _verbosity; /** Set the verbosity level */ set verbosity(v: AssetVerbosity); get verbosity(): AssetVerbosity; /** * Instantiate a new `NoteParser` * @param autoUpdateLookUpList whether the application should auto-update * the list of assets for new changes every week. Default is `false`. Require internet connection. * Updating this package to the latest version also gets the latest infos */ constructor(autoUpdateLookUpList?: boolean, verbosity?: AssetVerbosity); /** * Set the date format * @param format a `DateFormat` */ setDateFormat(format: DateFormat): void; /** * Read and parse a given PDF negotiation note by its full path * @param name PDF name * @param content PDF content * @param possiblePasswords all passwords that should be used to open the PDF * @param continueOnError whether should continue parsing even if encountering * unknown notes. In such cases, the `code` will be set to `UNDEF: <title>` whereas * `<title>` is the unknown asset. Default is `false` * @returns an `Array` of `NegotiationNote` */ parseNote(noteName: string, content: Uint8Array, possiblePasswords?: string[], continueOnError?: boolean): Promise<NegotiationNote[]>; /** * Add stock definition * @param code stock code * @param name stock name * @param cnpj stock CNPJ */ defineStock(code: string, name: string, cnpj?: string, isFII?: boolean): void; /** * 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[]]; /** * Convert a date according to `dateFormat` * @param date the date to be formatted * @returns the formatted date */ private formatDate; } //# sourceMappingURL=notes-parser.d.ts.map