Skip to content

Add few missing fields to SymbolSummary, SecurityInfo. Ignore dates when value is MULTI #94

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/commit-ibflex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8]
python-version: [3.7.17, 3.8]

steps:
- uses: actions/checkout@v2
Expand Down
34 changes: 34 additions & 0 deletions ibflex/Types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,39 @@ class SymbolSummary(FlexElement):
relatedTradeID: Optional[str] = None
origTransactionID: Optional[str] = None
relatedTransactionID: Optional[str] = None
settleDateTarget: Optional[datetime.date] = None
tradePrice: Optional[decimal.Decimal] = None
TradePrice: Optional[decimal.Decimal] = None
tradeMoney: Optional[decimal.Decimal] = None
taxes: Optional[decimal.Decimal] = None
ibCommission: Optional[decimal.Decimal] = None
ibCommissionCurrency: Optional[str] = None
netCash: Optional[decimal.Decimal] = None
closePrice: Optional[decimal.Decimal] = None
openCloseIndicator: Optional[enums.OpenClose] = None
notes: Optional[str] = None
cost: Optional[decimal.Decimal] = None
fifoPnlRealized: Optional[decimal.Decimal] = None
mtmPnl: Optional[decimal.Decimal] = None
origOrderID: Optional[str] = None
ibOrderID: Optional[str] = None
transactionID: Optional[str] = None
ibExecID: Optional[str] = None
rtn: Optional[str] = None
exchOrderId: Optional[str] = None
extExecID: Optional[str] = None
openDateTime: Optional[datetime.datetime] = None
holdingPeriodDateTime: Optional[datetime.datetime] = None
whenRealized: Optional[datetime.datetime] = None
whenReopened: Optional[datetime.datetime] = None
changeInPrice: Optional[decimal.Decimal] = None
changeInQuantity: Optional[decimal.Decimal] = None
initialInvestment: Optional[decimal.Decimal] = None
serialNumber: Optional[str] = None
deliveryType: Optional[str] = None
commodityType: Optional[str] = None
fineness: Optional[str] = None
weight: Optional[decimal.Decimal] = None


@dataclass(frozen=True)
Expand Down Expand Up @@ -2486,6 +2519,7 @@ class SecurityInfo(FlexElement):
commodityType: Optional[str] = None
fineness: Optional[decimal.Decimal] = None
weight: Optional[str] = None
securityType: Optional[str] = None


@dataclass(frozen=True)
Expand Down
4 changes: 4 additions & 0 deletions ibflex/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def parse_element_attr(
def prep_date(value: str) -> Tuple[int, int, int]:
"""Returns a tuple of (year, month, day).
"""
if value == "MULTI":
return None
date_format = DATE_FORMATS[len(value)][value.count('/')]
return datetime.datetime.strptime(value, date_format).timetuple()[:3]

Expand All @@ -189,6 +191,8 @@ def prep_datetime(value: str) -> Tuple[int, ...]:
"""
# HACK - some old data has ", " separator instead of ",".
value = value.replace(", ", ",")
if value == "MULTI":
return None

def merge_date_time(datestr: str, timestr: str) -> Tuple[int, ...]:
"""Convert presplit date/time strings into args ready for datetime().
Expand Down
Loading