Closed pronebird closed 2 years ago
@pronebird
IB is PITA in terms of unique security ID, old outputs and some asset types only have conid, same assets have ISIN but had none in the past, euro ETFs can have different symbols but same ISIN. Code below merges trades based on these IDs in the order of ISIN > CUSIP > securityID > CONID > Symbol https://github.com/jamsix/ib-edavki/blob/9bccfe856f64e30d400c081ff3f4d1c192a4bfe4/ib_edavki.py#L346
Symbol should be the last parameter used. Can you check the ISIN, CUSIP, securityID of these two companies/trades and whether any of these matches? If symbol is really the only matching parameter between the two, we need to take a look into why the code is not behaving as expected.
@jamsix
Definitely different ISINs:
<SecurityInfo currency="USD" assetCategory="STK" symbol="WEAT" description="TEUCRIUM WHEAT FUND" conid="94440558" securityID="US88166A5083" securityIDType="ISIN" cusip="88166A508" isin="US88166A5083" listingExchange="ARCA" underlyingConid="" underlyingSymbol="" underlyingSecurityID="" underlyingListingExchange="" issuer="" multiplier="1" strike="" expiry="" putCall="" principalAdjustFactor="" maturity="" issueDate="" underlyingCategory="" subCategory="ETF" settlementPolicyMethod="" code="" serialNumber="" deliveryType="" commodityType="" fineness="0.0" weight="0.0 ()"/>
<SecurityInfo currency="USD" assetCategory="STK" symbol="WEAT" description="WT WHEAT" conid="41015971" securityID="GB00B15KY765" securityIDType="ISIN" cusip="" isin="GB00B15KY765" listingExchange="LSE" underlyingConid="" underlyingSymbol="" underlyingSecurityID="" underlyingListingExchange="" issuer="" multiplier="1" strike="" expiry="" putCall="" principalAdjustFactor="" maturity="" issueDate="" underlyingCategory="" subCategory="ETF" settlementPolicyMethod="" code="" serialNumber="" deliveryType="" commodityType="" fineness="0.0" weight="0.0 ()"/>
Now the thing is, entries and exits were via long/short call or put options. So I think that there is something going on in that part of the code. I am trying to figure out why assignments are falling into the wrong ticker.
I see where the issue is, give me half an hour.
@pronebird try this: https://github.com/jamsix/ib-edavki/pull/54
Looks like it works as expected after your patch. The only issue is, E-davki is being silly telling me that there are two securities with the same symbol. I suppose it's a bug on their side, they should probably use ISIN or whatever, so manually editing symbols and adding something to distinguish them did the trick. Ideally we could add the country of origin from ISIN to the name of contract, i.e CORN (US)
or CORN (GB)
but I guess it's ok.
Hi,
I hold positions in both WT WEAT trading on LSE and Teucrium WEAT trading on NYSE. It's the same symbol, but different exchange and price. WT WEAT on LSE trades at a fraction of dollar, while Teucrium WEAT on NYSE trades at an order of magnitude of WT WEAT.
I think the script cannot solely rely on
symbol
. Same logic applies tocompanies.xml
, eitherconid
orsecurityID
should be used instead to distinguish between securities.