-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
77 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* This App will print IBKR account open orders to console. | ||
*/ | ||
|
||
import { IBApiNextError } from ".."; | ||
import { IBApiNextApp } from "./common/ib-api-next-app"; | ||
|
||
///////////////////////////////////////////////////////////////////////////////// | ||
// The help text. // | ||
///////////////////////////////////////////////////////////////////////////////// | ||
|
||
const DESCRIPTION_TEXT = "Prints the account open orders."; | ||
const USAGE_TEXT = "Usage: open-orders.js <options>"; | ||
const OPTION_ARGUMENTS: [string, string][] = []; | ||
const EXAMPLE_TEXT = "open-orders.js"; | ||
|
||
////////////////////////////////////////////////////////////////////////////// | ||
// The App code // | ||
////////////////////////////////////////////////////////////////////////////// | ||
|
||
class OpenOrdersApp extends IBApiNextApp { | ||
constructor() { | ||
super(DESCRIPTION_TEXT, USAGE_TEXT, OPTION_ARGUMENTS, EXAMPLE_TEXT); | ||
} | ||
|
||
/** | ||
* Start the app. | ||
*/ | ||
start(): void { | ||
super.start(); | ||
|
||
this.api | ||
.getAllOpenOrders() | ||
.then((orders) => { | ||
this.printObject(orders); | ||
this.stop(); | ||
}) | ||
.catch((err: IBApiNextError) => { | ||
this.error(`getAllOpenOrders failed with '${err}'`); | ||
}); | ||
} | ||
|
||
/** | ||
* Stop the app with success code. | ||
*/ | ||
stop() { | ||
this.exit(); | ||
} | ||
} | ||
|
||
// run the app | ||
|
||
new OpenOrdersApp().start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters