Skip to content

Commit

Permalink
API 10.29.01 upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
rylorin committed Jun 16, 2024
1 parent ce0d948 commit d7d2400
Show file tree
Hide file tree
Showing 47 changed files with 1,210 additions and 791 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@
"@types/jest": "^29.5.12",
"@types/node": "^18.19.34",
"@types/source-map-support": "^0.5.10",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"@typescript-eslint/eslint-plugin": "^7.13.0",
"@typescript-eslint/parser": "^7.13.0",
"ajv": "^8.16.0",
"eslint": "^8.57.0",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-rxjs": "^5.0.3",
"jest": "^29.7.0",
"jest-environment-node": "^29.7.0",
"jest-junit": "^16.0.0",
"ts-jest": "^29.1.4",
"ts-jest": "^29.1.5",
"typedoc": "^0.25.13",
"typescript": "^5.4.5"
},
Expand Down
4 changes: 2 additions & 2 deletions ref/client/Builder.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2019 Interactive Brokers LLC. All rights reserved. This code is subject to the terms
/* Copyright (C) 2023 Interactive Brokers LLC. All rights reserved. This code is subject to the terms
* and conditions of the IB API Non-Commercial License or the IB API Commercial License, as applicable. */

package com.ib.client;
Expand Down Expand Up @@ -124,7 +124,7 @@ private static boolean isAsciiPrintable(String str) {
}

private static boolean isAsciiPrintable(char ch) {
return ch >= 32 && ch < 127;
return ch >= 32 && ch < 127 || ch == 9 || ch == 10 || ch == 13;
}

/** inner class: ByteBuffer - storage for bytes and direct access to buffer. */
Expand Down
13 changes: 10 additions & 3 deletions ref/client/Contract.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class Contract implements Cloneable {
private String m_symbol;
private String m_secType;
private String m_lastTradeDateOrContractMonth;
private String m_lastTradeDate;
private double m_strike;
private String m_right;
private String m_multiplier; // should be double
Expand Down Expand Up @@ -44,7 +45,8 @@ public class Contract implements Cloneable {
public String currency() { return m_currency; }
public String exchange() { return m_exchange; }
public String primaryExch() { return m_primaryExch; }
public String lastTradeDateOrContractMonth() { return m_lastTradeDateOrContractMonth; }
public String lastTradeDateOrContractMonth() { return m_lastTradeDateOrContractMonth; }
public String lastTradeDate() { return m_lastTradeDate; }
public String localSymbol() { return m_localSymbol; }
public String tradingClass() { return m_tradingClass; }
public String multiplier() { return m_multiplier; }
Expand All @@ -63,7 +65,8 @@ public class Contract implements Cloneable {
public void conid(int v) { m_conid = v; }
public void currency(String v) { m_currency = v; }
public void exchange(String v) { m_exchange = v; }
public void lastTradeDateOrContractMonth(String v) { m_lastTradeDateOrContractMonth = v; }
public void lastTradeDateOrContractMonth(String v) { m_lastTradeDateOrContractMonth = v; }
public void lastTradeDate(String v) { m_lastTradeDate = v; }
public void localSymbol(String v) { m_localSymbol = v; }
public void tradingClass(String v) { m_tradingClass = v; }
public void multiplier(String v) { m_multiplier = v; }
Expand Down Expand Up @@ -107,7 +110,7 @@ public Contract() {
}
}

public Contract(int p_conId, String p_symbol, String p_secType, String p_lastTradeDateOrContractMonth,
public Contract(int p_conId, String p_symbol, String p_secType, String p_lastTradeDateOrContractMonth, String p_lastTradeDate,
double p_strike, String p_right, String p_multiplier,
String p_exchange, String p_currency, String p_localSymbol, String p_tradingClass,
List<ComboLeg> p_comboLegs, String p_primaryExch, boolean p_includeExpired,
Expand All @@ -116,6 +119,7 @@ public Contract(int p_conId, String p_symbol, String p_secType, String p_lastTra
m_symbol = p_symbol;
m_secType = p_secType;
m_lastTradeDateOrContractMonth = p_lastTradeDateOrContractMonth;
m_lastTradeDate = p_lastTradeDate;
m_strike = p_strike;
m_right = p_right;
m_multiplier = p_multiplier;
Expand Down Expand Up @@ -166,6 +170,7 @@ public boolean equals(Object p_other) {
}

if (Util.StringCompare(m_lastTradeDateOrContractMonth, l_theOther.m_lastTradeDateOrContractMonth) != 0 ||
Util.StringCompare(m_lastTradeDate, l_theOther.m_lastTradeDate) != 0 ||
Util.StringCompare(m_right, l_theOther.m_right) != 0 ||
Util.StringCompare(m_multiplier, l_theOther.m_multiplier) != 0 ||
Util.StringCompare(m_localSymbol, l_theOther.m_localSymbol) != 0 ||
Expand Down Expand Up @@ -239,6 +244,7 @@ public String textDescription() {
}

app( sb, m_lastTradeDateOrContractMonth);
app( sb, m_lastTradeDate);

if (m_strike != 0) {
app( sb, m_strike);
Expand Down Expand Up @@ -270,6 +276,7 @@ public boolean isCombo() {
add( sb, "symbol", m_symbol);
add( sb, "secType", m_secType);
add( sb, "lastTradeDateOrContractMonth", m_lastTradeDateOrContractMonth);
add( sb, "lastTradeDate", m_lastTradeDate);
add( sb, "strike", m_strike);
add( sb, "right", m_right);
add( sb, "multiplier", m_multiplier);
Expand Down
32 changes: 28 additions & 4 deletions ref/client/ContractCondition.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2019 Interactive Brokers LLC. All rights reserved. This code is subject to the terms
/* Copyright (C) 2024 Interactive Brokers LLC. All rights reserved. This code is subject to the terms
* and conditions of the IB API Non-Commercial License or the IB API Commercial License, as applicable. */

package com.ib.client;
Expand All @@ -10,6 +10,11 @@

public abstract class ContractCondition extends OperatorCondition {

private static final String OF = SPACE + "of" + SPACE;
private static final String ON = SPACE + "on" + SPACE;
private static final String LEFT_PARENTHESIS = "(";
private static final String RIGHT_PARENTHESIS = ")";

@Override
public String toString() {
return toString(null);
Expand All @@ -23,10 +28,10 @@ public String toString(ContractLookuper lookuper) {

List<ContractDetails> list = lookuper == null ? null : lookuper.lookupContract(c);
String strContract = list != null && !list.isEmpty() ?
list.get(0).contract().symbol() + " " + list.get(0).contract().secType() + " on " + list.get(0).contract().exchange() :
conId() + "";
list.get(0).contract().symbol() + SPACE + list.get(0).contract().secType() + ON + list.get(0).contract().exchange() :
conId() + LEFT_PARENTHESIS + exchange() + RIGHT_PARENTHESIS;

return type() + " of " + strContract + super.toString();
return type() + OF + strContract + super.toString();
}

private int m_conId;
Expand Down Expand Up @@ -62,4 +67,23 @@ public String exchange() {
public void exchange(String exchange) {
this.m_exchange = exchange;
}

@Override public boolean tryToParse(String conditionStr) {
try
{
if (!conditionStr.substring(0, conditionStr.indexOf(OF)).equals(type().name())) {
return false;
}
conditionStr = conditionStr.substring(conditionStr.indexOf(OF) + OF.length());
m_conId = Integer.parseInt(conditionStr.substring(0, conditionStr.indexOf(LEFT_PARENTHESIS)));
conditionStr = conditionStr.substring(conditionStr.indexOf(LEFT_PARENTHESIS) + 1);
m_exchange = conditionStr.substring(0, conditionStr.indexOf(RIGHT_PARENTHESIS));
conditionStr = conditionStr.substring(conditionStr.indexOf(RIGHT_PARENTHESIS) + 1);
return super.tryToParse(conditionStr);
}
catch (Exception ex)
{
return false;
}
}
}
116 changes: 80 additions & 36 deletions ref/client/ContractDetails.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
/* Copyright (C) 2019 Interactive Brokers LLC. All rights reserved. This code is subject to the terms
/* Copyright (C) 2023 Interactive Brokers LLC. All rights reserved. This code is subject to the terms
* and conditions of the IB API Non-Commercial License or the IB API Commercial License, as applicable. */

package com.ib.client;

import java.util.List;

import com.ib.client.Types.FundAssetType;
import com.ib.client.Types.FundDistributionPolicyIndicator;
import com.ib.client.Types.SecType;

public class ContractDetails {
private Contract m_contract;
private String m_marketName;
Expand Down Expand Up @@ -51,6 +55,25 @@ public class ContractDetails {
private String m_nextOptionType;
private boolean m_nextOptionPartial = false;
private String m_notes;

// FUND values
private String m_fundName;
private String m_fundFamily;
private String m_fundType;
private String m_fundFrontLoad;
private String m_fundBackLoad;
private String m_fundBackLoadTimeInterval;
private String m_fundManagementFee;
private boolean m_fundClosed = false;
private boolean m_fundClosedForNewInvestors = false;
private boolean m_fundClosedForNewMoney = false;
private String m_fundNotifyAmount;
private String m_fundMinimumInitialPurchase;
private String m_fundSubsequentMinimumPurchase;
private String m_fundBlueSkyStates;
private String m_fundBlueSkyTerritories;
private FundDistributionPolicyIndicator m_fundDistributionPolicyIndicator;
private FundAssetType m_fundAssetType;

// Get
public int conid() { return m_contract.conid(); }
Expand Down Expand Up @@ -99,6 +122,24 @@ public class ContractDetails {
public boolean nextOptionPartial() { return m_nextOptionPartial; }
public String notes() { return m_notes; }

public String fundName() { return m_fundName; }
public String fundFamily() { return m_fundFamily; }
public String fundType() { return m_fundType; }
public String fundFrontLoad() { return m_fundFrontLoad; }
public String fundBackLoad() { return m_fundBackLoad; }
public String fundBackLoadTimeInterval() { return m_fundBackLoadTimeInterval; }
public String fundManagementFee() { return m_fundManagementFee; }
public boolean fundClosed() { return m_fundClosed; }
public boolean fundClosedForNewInvestors() { return m_fundClosedForNewInvestors; }
public boolean fundClosedForNewMoney() { return m_fundClosedForNewMoney; }
public String fundNotifyAmount() { return m_fundNotifyAmount; }
public String fundMinimumInitialPurchase() { return m_fundMinimumInitialPurchase; }
public String fundSubsequentMinimumPurchase() { return m_fundSubsequentMinimumPurchase; }
public String fundBlueSkyStates() { return m_fundBlueSkyStates; }
public String fundBlueSkyTerritories() { return m_fundBlueSkyTerritories; }
public FundDistributionPolicyIndicator fundDistributionPolicyIndicator() { return m_fundDistributionPolicyIndicator; }
public FundAssetType fundAssetType() { return m_fundAssetType; }

// Set
public void contract(Contract contract) { m_contract = contract; }
public void marketName(String marketName) { m_marketName = marketName; }
Expand Down Expand Up @@ -145,48 +186,31 @@ public class ContractDetails {
public void nextOptionPartial(boolean nextOptionPartial) { m_nextOptionPartial = nextOptionPartial; }
public void notes(String notes) { m_notes = notes; }

public void fundName(String fundName) { m_fundName = fundName; }
public void fundFamily(String fundFamily) { m_fundFamily = fundFamily; }
public void fundType(String fundType) { m_fundType = fundType; }
public void fundFrontLoad(String fundFrontLoad) { m_fundFrontLoad = fundFrontLoad; }
public void fundBackLoad(String fundBackLoad) { m_fundBackLoad = fundBackLoad; }
public void fundBackLoadTimeInterval(String fundBackLoadTimeInterval) { m_fundBackLoadTimeInterval = fundBackLoadTimeInterval; }
public void fundManagementFee(String fundManagementFee) { m_fundManagementFee = fundManagementFee; }
public void fundClosed(boolean fundClosed) { m_fundClosed = fundClosed; }
public void fundClosedForNewInvestors(boolean fundClosedForNewInvestors) { m_fundClosedForNewInvestors = fundClosedForNewInvestors; }
public void fundClosedForNewMoney(boolean fundClosedForNewMoney) { m_fundClosedForNewMoney = fundClosedForNewMoney; }
public void fundNotifyAmount(String fundNotifyAmount) { m_fundNotifyAmount = fundNotifyAmount; }
public void fundMinimumInitialPurchase(String fundMinimumInitialPurchase) { m_fundMinimumInitialPurchase = fundMinimumInitialPurchase; }
public void fundSubsequentMinimumPurchase(String fundSubsequentMinimumPurchase) { m_fundSubsequentMinimumPurchase = fundSubsequentMinimumPurchase; }
public void fundBlueSkyStates(String fundBlueSkyStates) { m_fundBlueSkyStates = fundBlueSkyStates; }
public void fundBlueSkyTerritories(String fundBlueSkyTerritories) { m_fundBlueSkyTerritories = fundBlueSkyTerritories; }
public void fundDistributionPolicyIndicator(FundDistributionPolicyIndicator fundDistributionPolicyIndicator) { m_fundDistributionPolicyIndicator = fundDistributionPolicyIndicator; }
public void fundAssetType(FundAssetType fundAssetType) { m_fundAssetType = fundAssetType; }

public ContractDetails() {
m_contract = new Contract();
m_minTick = 0;
m_underConid = 0;
m_evMultiplier = 0;
}

public ContractDetails( Contract p_contract, String p_marketName,
double p_minTick, String p_orderTypes, String p_validExchanges, int p_underConId, String p_longName,
String p_contractMonth, String p_industry, String p_category, String p_subcategory,
String p_timeZoneId, String p_tradingHours, String p_liquidHours,
String p_evRule, double p_evMultiplier, int p_aggGroup,
String p_underSymbol, String p_underSecType, String p_marketRuleIds, String p_realExpirationDate, String p_lastTradeTime,
String p_stockType, Decimal p_minSize, Decimal p_sizeIncrement, Decimal p_suggestedSizeIncrement) {
m_contract = p_contract;
m_marketName = p_marketName;
m_minTick = p_minTick;
m_orderTypes = p_orderTypes;
m_validExchanges = p_validExchanges;
m_underConid = p_underConId;
m_longName = p_longName;
m_contractMonth = p_contractMonth;
m_industry = p_industry;
m_category = p_category;
m_subcategory = p_subcategory;
m_timeZoneId = p_timeZoneId;
m_tradingHours = p_tradingHours;
m_liquidHours = p_liquidHours;
m_evRule = p_evRule;
m_evMultiplier = p_evMultiplier;
m_aggGroup = p_aggGroup;
m_underSymbol = p_underSymbol;
m_underSecType = p_underSecType;
m_marketRuleIds = p_marketRuleIds;
m_realExpirationDate = p_realExpirationDate;
m_lastTradeTime = p_lastTradeTime;
m_stockType = p_stockType;
m_minSize = p_minSize;
m_sizeIncrement = p_sizeIncrement;
m_suggestedSizeIncrement = p_suggestedSizeIncrement;
}

@Override public String toString() {
StringBuilder sb = new StringBuilder( m_contract.toString() );

Expand Down Expand Up @@ -233,6 +257,26 @@ public ContractDetails( Contract p_contract, String p_marketName,
add( sb, "nextOptionPartial", m_nextOptionPartial);
add( sb, "notes", m_notes);

if (m_contract.secType() == SecType.FUND) {
add( sb, "fundName", m_fundName);
add( sb, "fundFamily", m_fundFamily);
add( sb, "fundType", m_fundType);
add( sb, "fundFrontLoad", m_fundFrontLoad);
add( sb, "fundBackLoad", m_fundBackLoad);
add( sb, "fundBackLoadTimeInterval", m_fundBackLoadTimeInterval);
add( sb, "fundManagementFee", m_fundManagementFee);
add( sb, "fundClosed", m_fundClosed);
add( sb, "fundClosedForNewInvestors", m_fundClosedForNewInvestors);
add( sb, "fundClosedForNewMoney", m_fundClosedForNewMoney);
add( sb, "fundNotifyAmount", m_fundNotifyAmount);
add( sb, "fundMinimumInitialPurchase", m_fundMinimumInitialPurchase);
add( sb, "fundSubsequentMinimumPurchase", m_fundSubsequentMinimumPurchase);
add( sb, "fundBlueSkyStates", m_fundBlueSkyStates);
add( sb, "fundBlueSkyTerritories", m_fundBlueSkyTerritories);
add( sb, "fundDistributionPolicyIndicator", m_fundDistributionPolicyIndicator != null ? m_fundDistributionPolicyIndicator.name() : "");
add( sb, "fundAssetType", m_fundAssetType != null ? m_fundAssetType.name() : "");
}

return sb.toString();
}

Expand Down
Loading

0 comments on commit d7d2400

Please sign in to comment.