tedchou12 / webull

Unofficial APIs for Webull.
MIT License
597 stars 181 forks source link

Can't get all assets data (accountAssetSummary) #377

Open MatricomHQ opened 1 year ago

MatricomHQ commented 1 year ago

The "get_positions" function doesn't return all of the options positions, so I have attempted to get this through the following URL (found from sniffing):

https://ustrade.webullfinance.com/api/trading/v1/webull/account/accountAssetSummary/v2?secAccountId=(your account ID)

This returns all of the positions data that is necessary to understand the positions and what options are being used. However, when I try to build this function out it gives me a 403 error:

def get_assets(self, id):
    headers = self.build_req_headers()
    url = f'https://ustrade.webullfinance.com/api/trading/v1/webull/account/accountAssetSummary/v2?secAccountId=20248310{id}'
    response = requests.get(url, headers=headers, timeout=self.timeout)
    result = response.json()
    return result

Not sure what I'm doing wrong, however, this data is vital (unless there's another way to get it?)

Thank! Kris

ICANTFINDAUSERNAMEATALL commented 1 year ago

The function seems to be working for me. Heres what I got when I ran it. I have 2 BA puts rn. Heres what the raw data is for me:

[{'id': [SOME RANDOM INT], 'brokerPosId': [SOME RANDOM STUFF AS WELL], 'brokerId': 8, 'tickerId': 1036893880, 'ticker': {'tickerId': 913254998, 'symbol': 'BA', 'name': 'Boeing', 'tinyName': 'Boeing', 'listStatus': 1, 'exchangeCode': 'NYSE', 'exchangeId': 11, 'type': 2, 'regionId': 6, 'currencyId': 247, 'currencyCode': 'USD', 'secType': [61], 'disExchangeCode': 'NYSE', 'disSymbol': 'BA'}, 'exchange': 'NYSE', 'position': '2', 'assetType': 'OPTION', 'cost': '288.00', 'costPrice': '1.440', 'currency': 'USD', 'lastPrice': '1.400', 'marketValue': '280.00', 'unrealizedProfitLoss': '-8.00', 'unrealizedProfitLossRate': '-0.0278', 'positionProportion': '1.0000', 'exchangeRate': '1', 'lastOpenTime': '02/03/2023 18:34:22 GMT', 'updatePositionTimeStamp': 1675449262283, 'lock': False}]