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

Trades for different securities are mixed together #53

Closed
pronebird opened this issue Feb 19, 2022 · 5 comments
Closed

Trades for different securities are mixed together #53

pronebird opened this issue Feb 19, 2022 · 5 comments
Assignees
Labels

Comments

@pronebird
Copy link
Contributor

pronebird commented Feb 19, 2022

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 to companies.xml, either conid or securityID should be used instead to distinguish between securities.

@jamsix jamsix added the bug label Feb 20, 2022
@jamsix jamsix self-assigned this Feb 20, 2022
@jamsix
Copy link
Owner

jamsix commented Feb 20, 2022

@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

Code below merges trades based on these IDs in the order of ISIN > CUSIP > securityID > CONID > Symbol

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.

@pronebird
Copy link
Contributor Author

pronebird commented Feb 20, 2022

@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 ()"/>

Screen Shot 2022-02-20 at 12 08 02

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.

@jamsix
Copy link
Owner

jamsix commented Feb 20, 2022

I see where the issue is, give me half an hour.

@jamsix
Copy link
Owner

jamsix commented Feb 20, 2022

@pronebird try this: #54

@pronebird
Copy link
Contributor Author

pronebird commented Feb 22, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants