feat: add stock screener
This commit is contained in:
@@ -34,6 +34,7 @@ import {
|
||||
InstrumentIdType,
|
||||
TbankAccountStatus,
|
||||
TbankCandleInterval,
|
||||
TbankInstrumentStatus,
|
||||
TbankInstrumentType,
|
||||
TbankOperationState,
|
||||
} from './tbank-protocol';
|
||||
@@ -325,6 +326,35 @@ export class TbankClient {
|
||||
).then((response) => response.instruments ?? []);
|
||||
}
|
||||
|
||||
async getAllShares(token: string): Promise<TbankShare[]> {
|
||||
const response = await this.call<{ instruments?: TbankShare[] }>(
|
||||
token,
|
||||
this.instruments,
|
||||
'shares',
|
||||
{ instrumentStatus: TbankInstrumentStatus.All },
|
||||
);
|
||||
const { instruments } = response;
|
||||
if (
|
||||
!Array.isArray(instruments) ||
|
||||
!instruments.length ||
|
||||
instruments.some((item) => !item?.uid)
|
||||
) {
|
||||
this.logger.event('error', 'tbank.shares.catalog.unusable', {
|
||||
code: TbankErrorCode.Unavailable,
|
||||
operation: 'shares',
|
||||
});
|
||||
throw new ServiceUnavailableException({
|
||||
code: TbankErrorCode.Unavailable,
|
||||
});
|
||||
}
|
||||
this.logger.event('info', 'tbank.shares.catalog.fetched', {
|
||||
asOf: new Date().toISOString(),
|
||||
count: instruments.length,
|
||||
operation: 'shares',
|
||||
});
|
||||
return instruments;
|
||||
}
|
||||
|
||||
findBonds(token: string, query: string): Promise<TbankBond[]> {
|
||||
return this.call<{ instruments?: TbankBond[] }>(
|
||||
token,
|
||||
|
||||
Reference in New Issue
Block a user