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

UUID from TradingClient.get_all_assets does not match UUID from TradingClient.get_all_positions() [Bug]: #490

Open
2 tasks done
jose-main-sequence opened this issue Jul 18, 2024 · 5 comments
Assignees

Comments

@jose-main-sequence
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When i request TradingClient.get_all_assets() Bitcoin to USD with symbol BTC/USD has a uid 276e2673764b4ab6a611caf665ca6340, however when i query my position in th paper account I get BTCUSD with UUID of 64bbff5159d64b3c935113ad85e3c752. Also symbol is BTCUSD rather than BTC/USD

Expected Behavior

The expected behavior should be consistent UUID and symbols from

SDK Version I encountered this issue in

alpaca-py==0.28.0

Steps To Reproduce

trading_client = TradingClient(api_key, secret_key)
search_params = GetAssetsRequest(asset_class=asset_class, status="active")
assets = trading_client.get_all_assets(search_params)
target_asset=[a for a in assets if a.symbol=="BTC/USD"][0]

#get positions
positions = trading_client.get_all_positions()
assert len([p for p in positions if p.asset_id.hex==target_asset.id.hex])>0

Filled out the Steps to Reproduce section?

  • I have entered valid steps to reproduce my issue or have attached a minimally reproducible case in code that shows my issue happening; and understand that without this my issue will be flagged as invalid and closed after 30 days.

Anything else?

No response

@hiohiohio hiohiohio self-assigned this Jul 18, 2024
@hiohiohio
Copy link
Contributor

@jose-main-sequence Thank you for the feedback.

The difference of assets in list assets and list positions is expected behaviour and by design.

Basically order assets and positions assets are different.

  • orders are what you are trading it can be ETH/USD, BTC/USD, ETH/BTC,
  • positions are basically what you hold, you could be holding ETH, BTC , these are denoted by ETHUSD, BTCUSD

Do you have any issue/concern of this difference?

@jose-main-sequence
Copy link
Author

jose-main-sequence commented Jul 22, 2024 via email

@hiohiohio
Copy link
Contributor

how can someone map an order to a position? In the case of equities, orders and positions
do match. I believe this originates from the design where all US equities
settle in USD. However, in the case of cryptocurrencies, how can a user
match an order with a position?

I think it depends on purpose of the mapping though.
As a one way for the crypto, you could divide the asset symbol into two parts by slash (/).
i.e. <quote>/<base>, ETH/BTC => quote: ETH, base: BTC
Then you can then get two position assets by putting USD as suffix into quote/base.
a. <quote>USD => ETHUSD
b. <base>USD => BTCUSD

By the way, asset_id of equity could be changed by corporate actions in time as well as symbol.
Therefore, asset_id/symbol of orders vs positions cannot be matching 100% for equity as well.

Is there any endpoint that provides this mapping?
For example, can one obtain the UUID of BTCUSD (position asset) before trading on it?

Currently we do not provide the API endpoint.
And also I cannot remember/find the way to get UUID of BTCUSD other than positions api.

It will be good to add then the "settlement asset" UUID to the endpoint so
when i get BTC/ETH asset the response also shows me that this will settle
as ETHUSD (position valuation)

Could you please elaborate on the reason/purpose of necessity of asset UUID of positions API?

@jose-main-sequence
Copy link
Author

jose-main-sequence commented Jul 23, 2024 via email

@hiohiohio
Copy link
Contributor

@jose-main-sequence Thank you for letting us know the details. Understood the reality of data mapping and data management. Please feel free to contact us if there are things we can help.

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

No branches or pull requests

2 participants