From e0a856724c23d51be95c9eb242ace634e35f0f30 Mon Sep 17 00:00:00 2001 From: Ronan-Yann Lorin Date: Wed, 6 Sep 2023 23:20:36 +0200 Subject: [PATCH] WIP --- src/tools/market-scanner.ts | 51 ++++++++----------------------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/src/tools/market-scanner.ts b/src/tools/market-scanner.ts index 01f593f7..7d460884 100644 --- a/src/tools/market-scanner.ts +++ b/src/tools/market-scanner.ts @@ -1,5 +1,5 @@ /** - * This App will print histogram data of a contract. + * This App will print Most active stocks. */ import path from "path"; import { Subscription } from "rxjs"; @@ -17,20 +17,9 @@ import { IBApiNextApp } from "./common/ib-api-next-app"; // The help text // ///////////////////////////////////////////////////////////////////////////////// -const DESCRIPTION_TEXT = "Print Most active stocks scan."; +const DESCRIPTION_TEXT = "Print most active stocks scan."; const USAGE_TEXT = "Usage: market-scanner.js "; -const OPTION_ARGUMENTS: [string, string][] = [ - [ - "conid=", - "(required) Contract ID (conId) of contract to receive histogram data for.", - ], - ["exchange=", "The destination exchange name."], - ["period=", "(required) Period of which data is being requested"], - [ - "periodUnit=", - "(required) Unit of the period argument", - ], -]; +const OPTION_ARGUMENTS: [string, string][] = []; const EXAMPLE_TEXT = "market-scanner.js -conid=3691937 -exchange=SMART -period=3 -periodUnit=DAY"; @@ -52,26 +41,10 @@ class PrintMarketScreenerApp extends IBApiNextApp { const scriptName = path.basename(__filename); logger.debug(`Starting ${scriptName} script`); - // if (!this.cmdLineArgs.conid) { - // this.error("-conid argument missing."); - // } - // if (!this.cmdLineArgs.exchange) { - // this.error("-exchange argument missing."); - // } - // if (!this.cmdLineArgs.period) { - // this.error("-period argument missing."); - // } - // if (!this.cmdLineArgs.periodUnit) { - // this.error("-periodUnit argument missing."); - // } - // if (!(this.cmdLineArgs.periodUnit in DurationUnit)) { - // this.error( - // "Invalid -periodUnit argument value: " + this.cmdLineArgs.periodUnit - // ); - // } - this.connect(this.cmdLineArgs.watch ? 10000 : 0); + // this.api.getScannerParameters().then((result) => console.log(result)); + this.subscription$ = this.api .getMarketScanner({ abovePrice: 1, @@ -79,19 +52,17 @@ class PrintMarketScreenerApp extends IBApiNextApp { locationCode: LocationCode.STK_US, instrument: Instrument.STK, }) - .subscribe( - (data) => { - logger.info(data); - }, - (error: IBApiNextError) => { + .subscribe({ + next: (data) => logger.info(data), + error: (error: IBApiNextError) => { logger.error("Error from the subscriber", error); this.stop(); }, - () => { + complete: () => { logger.info("Completed"); this.stop(); - } - ); + }, + }); } /** * Stop the app with success code.