Skip to content

Commit

Permalink
Interactive Brokers statement import: import of T-Bills maturity corp…
Browse files Browse the repository at this point in the history
…orate action.
  • Loading branch information
titov-vv committed Apr 9, 2024
1 parent 8c55f46 commit 33a8165
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion jal/data_import/broker_statements/ibkr.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, asset_type, subtype):
class IBKR_CorpActionType:
NotSupported = -1
_corporate_action_types = {
'BM': FOF.ACTION_BOND_MATURITY, # No separate value as will be converted to ordinary bond sell operation
'BM': FOF.ACTION_BOND_MATURITY, # Bond maturity (will be converted to bond sell operation)
'DW': FOF.ACTION_DELISTING, # Delisting with loss of value
'FS': FOF.ACTION_SPLIT, # Forward split
'HI': FOF.PAYMENT_STOCK_DIVIDEND, # Choice dividend
Expand All @@ -76,6 +76,7 @@ class IBKR_CorpActionType:
'SO': FOF.ACTION_SPINOFF, # Spin-off of new company
'SD': FOF.PAYMENT_STOCK_DIVIDEND, # Dividend paid in stocks
'TC': FOF.ACTION_MERGER, # Conversion of one stock into another
'TM': FOF.ACTION_BOND_MATURITY, # T-Bill maturity (will be converted to bond sell operation)
'TO': FOF.ACTION_MERGER # Voluntary conversion of one asset into another
}

Expand Down
6 changes: 4 additions & 2 deletions tests/test_data/ibkr_corp_actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"outcome": [{"asset": 2, "quantity": 0.035, "share": 1.0}], "description": "TWOH(US90187E4026) SPLIT 1 FOR 1000 (TWOHD, TWO HANDS CORP, US90187E5015)"}
],
"income_spending": [],
"trades": [],
"transfers": []
"trades": [
{"id": 1, "number": "26300000000", "timestamp": 1706127900, "settlement": 1706127900, "account": 1, "asset": 4, "quantity": -5.0, "price": 1000.0, "fee": 0.0, "note": "(US912796ZY88) TBILL MATURITY (912796ZY8, B 01/25/24, US912796ZY88)"}
],
"transfers": []
}
1 change: 1 addition & 0 deletions tests/test_data/ibkr_corp_actions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<CorporateAction accountId="U7654321" acctAlias="" model="" currency="USD" fxRateToBase="1" assetCategory="STK" symbol="TWOHD" description="TWOH(US90187E4026) SPLIT 1 FOR 1000 (TWOHD, TWO HANDS CORP, US90187E5015)" conid="657142858" securityID="US90187E5015" securityIDType="ISIN" cusip="90187E501" isin="US90187E5015" listingExchange="PINK" underlyingConid="" underlyingSymbol="" underlyingSecurityID="" underlyingListingExchange="" issuer="" multiplier="1" strike="" expiry="" putCall="" principalAdjustFactor="" reportDate="20230929" dateTime="20230928;202500" actionDescription="TWOH(US90187E4026) SPLIT 1 FOR 1000 (TWOHD, TWO HANDS CORP, US90187E5015)" amount="0" proceeds="0" value="0" quantity="0.035" fifoPnlRealized="0" mtmPnl="0" code="" type="RS" transactionID="25164201871" levelOfDetail="DETAIL" />
<CorporateAction accountId="U7654321" acctAlias="" model="" currency="USD" fxRateToBase="1" assetCategory="STK" symbol="TWOHD.OLD" description="TWOH(US90187E4026) SPLIT 1 FOR 1000 (TWOHD.OLD, TWO HANDS CORP, US90187E4026)" conid="558667700" securityID="US90187E4026" securityIDType="ISIN" cusip="90187E402" isin="US90187E4026" listingExchange="PINK" underlyingConid="" underlyingSymbol="" underlyingSecurityID="" underlyingListingExchange="" issuer="" multiplier="1" strike="" expiry="" putCall="" principalAdjustFactor="" reportDate="20230929" dateTime="20230928;202500" actionDescription="TWOH(US90187E4026) SPLIT 1 FOR 1000 (TWOHD.OLD, TWO HANDS CORP, US90187E4026)" amount="0" proceeds="0" value="0" quantity="-35" fifoPnlRealized="0" mtmPnl="0" code="" type="RS" transactionID="25164201877" levelOfDetail="DETAIL" />
<!-- T-Bill maturity -->
<CorporateAction accountId="U7654321" acctAlias="" model="" currency="USD" fxRateToBase="1" assetCategory="BILL" subCategory="" symbol="912796ZY8" description="(US912796ZY88) TBILL MATURITY (912796ZY8, B 01/25/24, US912796ZY88)" conid="610571310" securityID="US912796ZY88" securityIDType="ISIN" cusip="912796ZY8" isin="US912796ZY88" figi="" listingExchange="" underlyingConid="" underlyingSymbol="" underlyingSecurityID="" underlyingListingExchange="" issuer="" issuerCountryCode="US" multiplier="1" strike="" expiry="" putCall="" principalAdjustFactor="" reportDate="20240125" dateTime="20240124;202500" actionDescription="(US912796ZY88) TBILL MATURITY (912796ZY8, B 01/25/24, US912796ZY88)" amount="-5000" proceeds="5000" value="0" quantity="-5000" fifoPnlRealized="115.03" mtmPnl="3.6372" code="" type="TM" transactionID="26300000000" actionID="111118555" levelOfDetail="DETAIL" serialNumber="" deliveryType="" commodityType="" fineness="0.0" weight="0.0" />
</CorporateActions>
</FlexStatement>
</FlexStatements>
Expand Down

0 comments on commit 33a8165

Please sign in to comment.