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
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@
"rxjs": "^7.8.1"
},
"devDependencies": {
"@types/jest": "^29.5.4",
"@types/jest": "^29.5.5",
"@types/node": "^18.17.15",
"@types/source-map-support": "^0.5.7",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"@types/source-map-support": "^0.5.8",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"ajv": "^8.12.0",
"eslint": "^8.49.0",
"eslint-plugin-jest": "^27.2.3",
"eslint": "^8.51.0",
"eslint-plugin-jest": "^27.4.2",
"eslint-plugin-rxjs": "^5.0.3",
"jest": "^29.7.0",
"jest-environment-node": "^29.7.0",
Expand Down
4 changes: 2 additions & 2 deletions src/api-next/api-next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,7 @@ export class IBApiNext {
* - [n] M (months)
* - [n] Y (years)
* @param barSizeSetting the size of the bar:
* - 1 sec
* - 1 secs
* - 5 secs
* - 15 secs
* - 30 secs
Expand Down Expand Up @@ -1832,7 +1832,7 @@ export class IBApiNext {
*
* @param contract The contract for which we want to retrieve the data.
* @param barSizeSetting the size of the bar:
* - 1 sec
* - 1 secs
* - 5 secs
* - 15 secs
* - 30 secs
Expand Down
32 changes: 19 additions & 13 deletions src/api-next/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@

export {
AccountSummaries,
AccountSummariesUpdate,
AccountSummaryTagName,
AccountSummaryTagValues,
AccountSummaryValue,
AccountSummaryValues,
AccountSummariesUpdate,
} from "./account/account-summary";

export {
AccountUpdate,
AccountUpdatesUpdate,
} from "./account/account-update";
export { AccountUpdate, AccountUpdatesUpdate } from "./account/account-update";

// common

export { AccountId, ConId, CurrencyCode } from "./common/common-types";
export { ConnectionState } from "./common/connection-state";
export { IBApiNextError } from "./common/error";
export { Logger } from "./common/logger";
export { ItemListUpdate } from "./common/item-list-update";
export { ConnectionState } from "./common/connection-state";
export { Logger } from "./common/logger";

// contract

Expand All @@ -29,14 +26,14 @@ export { SecurityDefinitionOptionParameterType } from "./contract/sec-def-opt-pa

// market

export { MarketDataType } from "./market/market-data-type";
export {
MarketDataTick,
MarketDataTicks,
MarketDataUpdate,
} from "./market/market-data";
import { TickType as IBApiTickType } from "../api/market/tickType";
export { MarketDataType } from "./market/market-data-type";
export { IBApiTickType };
import { TickType as IBApiTickType } from "../api/market/tickType";
import { TickType as IBApiNextTickType } from "./market/tick-type";
export { IBApiNextTickType };

Expand All @@ -48,26 +45,35 @@ export { PnLSingle } from "./pnl/pnl-single";
// position

export {
Position,
AccountPositions,
AccountPositionsUpdate,
Position,
} from "./position/position";

// market depth
// Market depth

export {
OrderBook,
OrderBookRow,
OrderBookRowPosition,
OrderBookRows,
OrderBook,
OrderBookUpdate,
} from "./market-depth/order-book";

// Order

export { ExecutionDetail } from "./order/execution-detail";
export { OpenOrder } from "./order/open-order";
export { OpenOrdersUpdate } from "./order/open-order-update";
export { ExecutionDetail } from "./order/execution-detail";

// Market scanner

export {
MarketScannerItem,
MarketScannerItemRank,
MarketScannerRows,
MarketScannerUpdate,
} from "./market-scanner/market-scanner";

// IBApiNext

Expand Down
219 changes: 6 additions & 213 deletions src/api-next/market-scanner/market-scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,216 +16,9 @@ export type MarketScannerRows = Map<MarketScannerItemRank, MarketScannerItem>;

export type MarketScannerUpdate = ItemListUpdate<MarketScannerRows>;

export enum LocationCode {
BOND_US = "BOND.US",
EFP = "EFP",
// FUT_ECBOT = "FUT.ECBOT",
FUT_EU_BELFOX = "FUT.EU.BELFOX",
// FUT_EU_DTB = "FUT.EU.DTB",
FUT_EU_FTA = "FUT.EU.FTA",
FUT_EU_IDEM = "FUT.EU.IDEM",
FUT_EU_LIFFE = "FUT.EU.LIFFE",
FUT_EU_MEFFRV = "FUT.EU.MEFFRV",
FUT_EU_MONEP = "FUT.EU.MONEP",
FUT_EU = "FUT.EU",
// FUT_GLOBEX = "FUT.GLOBEX",
FUT_HK_HKFE = "FUT.HK.HKFE",
FUT_HK_JAPAN = "FUT.HK.JAPAN",
FUT_HK_KSE = "FUT.HK.KSE",
FUT_HK_NSE = "FUT.HK.NSE",
FUT_HK_OSE_JPN = "FUT.HK.OSE.JPN",
FUT_HK_SGX = "FUT.HK.SGX",
FUT_HK_SNFE = "FUT.HK.SNFE",
FUT_HK_TSE_JPN = "FUT.HK.TSE.JPN",
FUT_HK = "FUT.HK",
FUT_IPE = "FUT.IPE",
FUT_NA_CDE = "FUT.NA.CDE",
FUT_NA = "FUT.NA",
FUT_NYBOT = "FUT.NYBOT",
// FUT_NYMEX = "FUT.NYMEX",
FUT_NYSELIFFE = "FUT.NYSELIFFE",
FUT_US = "FUT.US",
IND_EU_BELFOX = "IND.EU.BELFOX",
// IND_EU_DTB = "IND.EU.DTB",
IND_EU_FTA = "IND.EU.FTA",
IND_EU_LIFFE = "IND.EU.LIFFE",
IND_EU_MONEP = "IND.EU.MONEP",
IND_EU = "IND.EU",
IND_HK_HKFE = "IND.HK.HKFE",
IND_HK_JAPAN = "IND.HK.JAPAN",
IND_HK_KSE = "IND.HK.KSE",
IND_HK_NSE = "IND.HK.NSE",
IND_HK_OSE_JPN = "IND.HK.OSE.JPN",
IND_HK_SGX = "IND.HK.SGX",
IND_HK_SNFE = "IND.HK.SNFE",
IND_HK_TSE_JPN = "IND.HK.TSE.JPN",
IND_HK = "IND.HK",
IND_US = "IND.US",
SLB_AQS = "SLB.AQS",
STK_AMEX = "STK.AMEX",
STK_ARCA = "STK.ARCA",
STK_EU_AEB = "STK.EU.AEB",
STK_EU_BM = "STK.EU.BM",
STK_EU_BVME = "STK.EU.BVME",
STK_EU_EBS = "STK.EU.EBS",
STK_EU_IBIS = "STK.EU.IBIS",
STK_EU_IBIS_ETF = "STK.EU.IBIS-ETF",
STK_EU_IBIS_EUSTARS = "STK.EU.IBIS-EUSTARS",
STK_EU_IBIS_NEWX = "STK.EU.IBIS-NEWX",
STK_EU_IBIS_USSTARS = "STK.EU.IBIS-USSTARS",
STK_EU_IBIS_XETRA = "STK.EU.IBIS-XETRA",
STK_EU_LSE = "STK.EU.LSE",
STK_EU_SBF = "STK.EU.SBF",
STK_EU_SBVM = "STK.EU.SBVM",
STK_EU_SFB = "STK.EU.SFB",
STK_EU_SWISS = "STK.EU.SWISS",
STK_EU_VIRTX = "STK.EU.VIRTX",
STK_EU = "STK.EU",
STK_HK_ASX = "STK.HK.ASX",
STK_HK_NSE = "STK.HK.NSE",
STK_HK_SEHK = "STK.HK.SEHK",
STK_HK_SGX = "STK.HK.SGX",
STK_HK_TSE_JPN = "STK.HK.TSE.JPN",
STK_HK = "STK.HK",
STK_NA_CANADA = "STK.NA.CANADA",
STK_NA_TSE = "STK.NA.TSE",
STK_NA_VENTURE = "STK.NA.VENTURE",
STK_NA = "STK.NA",
STK_NASDAQ_NMS = "STK.NASDAQ.NMS",
STK_NASDAQ_SCM = "STK.NASDAQ.SCM",
STK_NASDAQ = "STK.NASDAQ",
STK_NYSE = "STK.NYSE",
STK_OTCBB = "STK.OTCBB",
STK_PINK = "STK.PINK",
STK_US_MAJOR = "STK.US.MAJOR",
STK_US_MINOR = "STK.US.MINOR",
STK_US = "STK.US",
WAR_EU_ALL = "WAR.EU.ALL",
}

export enum Instrument {
STK = "STK",
BOND = "BOND",
EFP = "EFP",
FUT_EU = "FUT.EU",
FUT_HK = "FUT.HK",
FUT_NA = "FUT.NA",
FUT_US = "FUT.US",
IND_EU = "IND.EU",
IND_HK = "IND.HK",
IND_US = "IND.US",
PMONITOR = "PMONITOR",
PMONITORM = "PMONITORM",
SLB_US = "SLB.US",
STOCK_EU = "STOCK.EU",
STOCK_HK = "STOCK.HK",
STOCK_NA = "STOCK.NA",
WAR_EU = "WAR.EU",
}

export enum ScanCode {
TOP_PERC_GAIN,
TOP_PERC_LOSE,
MOST_ACTIVE,
ALL_SYMBOLS_ASC,
ALL_SYMBOLS_DESC,
BOND_CUSIP_AZ,
BOND_CUSIP_ZA,
FAR_MATURITY_DATE,
HALTED,
HIGH_BOND_ASK_CURRENT_YIELD_ALL,
HIGH_BOND_ASK_YIELD_ALL,
HIGH_BOND_DEBT_2_BOOK_RATIO,
HIGH_BOND_DEBT_2_EQUITY_RATIO,
HIGH_BOND_DEBT_2_TAN_BOOK_RATIO,
HIGH_BOND_EQUITY_2_BOOK_RATIO,
HIGH_BOND_EQUITY_2_TAN_BOOK_RATIO,
HIGH_BOND_NET_ASK_CURRENT_YIELD_ALL,
HIGH_BOND_NET_ASK_YIELD_ALL,
HIGH_BOND_NET_SPREAD_ALL,
HIGH_BOND_SPREAD_ALL,
HIGH_COUPON_RATE,
HIGH_DIVIDEND_YIELD,
HIGH_DIVIDEND_YIELD_IB,
HIGHEST_SLB_BID,
HIGH_GROWTH_RATE,
HIGH_MOODY_RATING_ALL,
HIGH_OPEN_GAP,
HIGH_OPT_IMP_VOLAT,
HIGH_OPT_IMP_VOLAT_OVER_HIST,
HIGH_OPT_OPEN_INTEREST_PUT_CALL_RATIO,
HIGH_OPT_VOLUME_PUT_CALL_RATIO,
HIGH_PE_RATIO,
HIGH_PRICE_2_BOOK_RATIO,
HIGH_PRICE_2_TAN_BOOK_RATIO,
HIGH_QUICK_RATIO,
HIGH_RETURN_ON_EQUITY,
HIGH_SYNTH_BID_REV_NAT_YIELD,
HIGH_VS_13W_HL,
HIGH_VS_26W_HL,
HIGH_VS_52W_HL,
HOT_BY_OPT_VOLUME,
HOT_BY_PRICE,
HOT_BY_PRICE_RANGE,
HOT_BY_VOLUME,
LIMIT_UP_DOWN,
LOW_BOND_BID_CURRENT_YIELD_ALL,
LOW_BOND_BID_YIELD_ALL,
LOW_BOND_DEBT_2_BOOK_RATIO,
LOW_BOND_DEBT_2_EQUITY_RATIO,
LOW_BOND_DEBT_2_TAN_BOOK_RATIO,
LOW_BOND_EQUITY_2_BOOK_RATIO,
LOW_BOND_EQUITY_2_TAN_BOOK_RATIO,
LOW_BOND_NET_BID_CURRENT_YIELD_ALL,
LOW_BOND_NET_BID_YIELD_ALL,
LOW_BOND_NET_SPREAD_ALL,
LOW_BOND_SPREAD_ALL,
LOW_COUPON_RATE,
LOWEST_SLB_ASK,
LOW_GROWTH_RATE,
LOW_MOODY_RATING_ALL,
LOW_OPEN_GAP,
LOW_OPT_IMP_VOLAT,
LOW_OPT_IMP_VOLAT_OVER_HIST,
LOW_OPT_OPEN_INTEREST_PUT_CALL_RATIO,
LOW_OPT_VOLUME_PUT_CALL_RATIO,
LOW_PE_RATIO,
LOW_PRICE_2_BOOK_RATIO,
LOW_PRICE_2_TAN_BOOK_RATIO,
LOW_QUICK_RATIO,
LOW_RETURN_ON_EQUITY,
LOW_SYNTH_ASK_REV_NAT_YIELD,
LOW_VS_13W_HL,
LOW_VS_26W_HL,
LOW_VS_52W_HL,
LOW_WAR_REL_IMP_VOLAT,
MARKET_CAP_USD_ASC,
MARKET_CAP_USD_DESC,
MOST_ACTIVE_AVG_USD,
MOST_ACTIVE_USD,
NEAR_MATURITY_DATE,
NOT_OPEN,
OPT_OPEN_INTEREST_MOST_ACTIVE,
OPT_VOLUME_MOST_ACTIVE,
PMONITOR_AVAIL_CONTRACTS,
PMONITOR_CTT,
PMONITOR_IBOND,
PMONITOR_RFQ,
TOP_OPEN_PERC_GAIN,
TOP_OPEN_PERC_LOSE,
TOP_OPT_IMP_VOLAT_GAIN,
TOP_OPT_IMP_VOLAT_LOSE,
TOP_PRICE_RANGE,
TOP_STOCK_BUY_IMBALANCE_ADV_RATIO,
TOP_STOCK_SELL_IMBALANCE_ADV_RATIO,
TOP_TRADE_COUNT,
TOP_TRADE_RATE,
TOP_VOLUME_RATE,
WSH_NEXT_ANALYST_MEETING,
WSH_NEXT_EARNINGS,
WSH_NEXT_EVENT,
WSH_NEXT_MAJOR_EVENT,
WSH_PREV_ANALYST_MEETING,
WSH_PREV_EARNINGS,
WSH_PREV_EVENT,
}
// for backward compatibility. Type moved to `api`
export {
Instrument,
LocationCode,
ScanCode,
} from "../../api/market-scanner/market-scanner";
13 changes: 8 additions & 5 deletions src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
* Refer to the official {@link https://interactivebrokers.github.io/tws-api/|Trader Workstation API documentation} for
* details.
*/
export class IBApi extends EventEmitter {

Check warning on line 92 in src/api/api.ts

View workflow job for this annotation

GitHub Actions / job

Unsafe declaration merging between classes and interfaces
/**
* Create a IB API object.
*
Expand Down Expand Up @@ -928,12 +928,15 @@
* @param reqId The request's unique identifier.
* @param contract The contract for which we want to retrieve the data.
* @param endDateTime Request's ending time with format yyyyMMdd HH:mm:ss {TMZ}
* @param durationStr The amount of time for which the data needs to be retrieved:
* - " S (seconds) - " D (days)
* - " W (weeks) - " M (months)
* - " Y (years)
* @param durationStr The amount of time for which the data needs to be retrieved (number space unit).
* Note: min duration is "30 S", available units:
* - S (seconds)
* - D (days)
* - W (weeks)
* - M (months)
* - Y (years)
* @param barSizeSetting the size of the bar:
* - 1 sec
* - 1 secs
* - 5 secs
* - 15 secs
* - 30 secs
Expand Down Expand Up @@ -1613,7 +1616,7 @@
}

// Event emitter interface
export declare interface IBApi {

Check warning on line 1619 in src/api/api.ts

View workflow job for this annotation

GitHub Actions / job

Unsafe declaration merging between classes and interfaces
/**
* Notifies when an event has been received (called for the any type for event).
*
Expand Down
4 changes: 2 additions & 2 deletions src/api/historical/bar-size-setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export enum BarSizeSetting {
HOURS_FOUR = "4 hours",
HOURS_EIGHT = "8 hours",
DAYS_ONE = "1 day",
WEEKS_ONE = "1W",
MONTHS_ONE = "1M"
WEEKS_ONE = "1 week", // "1W" or "1 week"?
MONTHS_ONE = "1 month", // "1M" or "1 month"?
}

export default BarSizeSetting;
Loading