Skip to content

Commit

Permalink
Some tests improved
Browse files Browse the repository at this point in the history
  • Loading branch information
rylorin committed Nov 8, 2024
1 parent 00edad1 commit 54df66f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/api/order/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,9 @@ export interface Order {
professionalCustomer?: boolean;

bondAccruedInterest?: string;

includeOvernight?: boolean;

manualOrderIndicator?: number;
}

Expand Down
14 changes: 7 additions & 7 deletions src/tests/unit/api/historical-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe("IBApi Historical data Tests", () => {
ib.reqHistoricalData(
refId,
contract,
"20241110-17:00:00",
"20241107-17:00:00",
"30 S",
BarSizeSetting.SECONDS_FIFTEEN,
WhatToShow.BID_ASK,
Expand All @@ -134,17 +134,17 @@ describe("IBApi Historical data Tests", () => {
count: number | undefined,
WAP: number,
) => {
console.log(counter, time, open, high, low, close, volume, count, WAP);
// console.log(counter, time, open, high, low, close, volume, count, WAP);
expect(reqId).toEqual(refId);
if (time.startsWith("finished")) {
expect(counter).toEqual(2);
done();
} else if (counter++ == 1) {
expect(time).toEqual("1721408385");
expect(open).toEqual(11.95);
expect(high).toEqual(11.95);
expect(low).toEqual(11.9);
expect(close).toEqual(11.95);
expect(time).toEqual("1730998785");
expect(open).toEqual(8.77);
expect(high).toEqual(8.77);
expect(low).toEqual(8.75);
expect(close).toEqual(8.77);
expect(volume).toEqual(-1);
expect(count).toEqual(-1);
expect(WAP).toEqual(-1);
Expand Down
27 changes: 25 additions & 2 deletions src/tests/unit/api/order/placeConditionalOrder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const sample_percent_condition: OrderCondition = new PercentChangeCondition(
ConjunctionConnection.OR,
);
const sample_time_condition: OrderCondition = new TimeCondition(
"20250102-17:00:00",
"20260102-18:00:00",
true,
ConjunctionConnection.OR,
);
Expand Down Expand Up @@ -342,8 +342,31 @@ describe("Place Conditional Orders", () => {
})
.on(EventName.openOrderEnd, () => {
if (isDone) done();
else done("failed");
})
.on(
EventName.orderStatus,
(
orderId,
status,
filled,
remaining,
_avgFillPrice,
_permId,
_parentId,
_lastFillPrice,
_clientId,
_whyHeld,
_mktCapPrice,
) => {
if (!isDone && orderId == refId) {
isDone = true;
expect(status).toMatch(/Pending/);
expect(filled).toEqual(0);
expect(remaining).toEqual(refOrder.totalQuantity);
done();
}
},
)
.on(
EventName.error,
(
Expand Down

0 comments on commit 54df66f

Please sign in to comment.