Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reqHistoricalData tests added #192

Merged
merged 9 commits into from
Oct 26, 2023
Merged

reqHistoricalData tests added #192

merged 9 commits into from
Oct 26, 2023

Conversation

rylorin
Copy link
Member

@rylorin rylorin commented Oct 7, 2023

No description provided.

let ib: IBApi;
const clientId = Math.floor(Math.random() * 32766) + 1; // ensure unique client

beforeEach(() => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 4 locations. Consider refactoring.

// logger.info("IBApi disconnected");
});

it("Stock market data", (done) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 3 locations. Consider refactoring.

ib.connect();
});

it("Monthly market data", (done) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 3 locations. Consider refactoring.

ib.connect();
});

it("Weekly market data", (done) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 3 locations. Consider refactoring.

@@ -0,0 +1,318 @@
/**
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File historical-data.test.ts has 253 lines of code (exceeds 250 allowed). Consider refactoring.

const refId = 4;
let count = 0;

ib.once(EventName.nextValidId, (_reqId) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

@@ -0,0 +1,335 @@
/**
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File historical-data.test.ts has 266 lines of code (exceeds 250 allowed). Consider refactoring.

.catch((err: IBApiNextError) => {
this.error(`getAllOpenOrders failed with '${err}'`);
});
this.subscription$ = this.api.getOpenOrders().subscribe({
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

if (error.reqId === -1) {
console.warn(`${error.error.message} (Error #${error.code})`);
} else {
console.error(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 2 locations. Consider refactoring.

import { Subscription } from "rxjs";
import { IBApiNext, IBApiNextError } from "../../..";

const _awaitTimeout = (delay: number): Promise<unknown> =>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

ib.connect().reqMarketDataType(MarketDataType.DELAYED_FROZEN);
});

it("SPY market data", (done) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 3 locations. Consider refactoring.

ib.connect().reqMarketDataType(MarketDataType.DELAYED_FROZEN);
});

it("Index market data", (done) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 3 locations. Consider refactoring.

@@ -1093,7 +1096,7 @@ export class IBApi extends EventEmitter {
* - 3 (delayed) enables delayed and disables delayed-frozen market data.
* - 4 (delayed-frozen) enables delayed and delayed-frozen market data.
*/
reqMarketDataType(marketDataType: number): IBApi {
reqMarketDataType(marketDataType: MarketDataType): IBApi {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

@rylorin rylorin linked an issue Oct 26, 2023 that may be closed by this pull request
@codeclimate
Copy link

codeclimate bot commented Oct 26, 2023

Code Climate has analyzed commit b4426b2 and detected 22 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 2
Duplication 20

View more on Code Climate.

@rylorin rylorin merged commit fbefa9b into master Oct 26, 2023
2 checks passed
@rylorin rylorin deleted the historical-data-test branch October 26, 2023 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Re-connect after TWS restart not working properly
1 participant