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

[Question]: Example of get_activities() #192

Open
3 tasks done
sshcli opened this issue Oct 25, 2022 · 2 comments
Open
3 tasks done

[Question]: Example of get_activities() #192

sshcli opened this issue Oct 25, 2022 · 2 comments
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@sshcli
Copy link
Contributor

sshcli commented Oct 25, 2022

Question form pre-submit checklist.

  • I have searched the existing issues to ensure there isn't already an issue about this question.
  • My question has to do with the Python SDK and isn't a general question about the API. (If it is please open your issue here)
  • My question isn't about how to do a specific algorithm or asking for trade advice (answers to these are outside the scope of this repo).

Question

There is no example in documentation about how to get stock activities in the new official SDK

In alpaca-trade-api version: 2.3.0 is as simple as: get_activities()

Please add an example in the docs and close this issue with the reference URL.

Thanks in advance.

Regards,

@haxdds haxdds added documentation Improvements or additions to documentation question Further information is requested labels Nov 7, 2022
@cryb3
Copy link

cryb3 commented Apr 17, 2023

For now, I'm just manually doing this part with requests until it's implemented. This works:
( https://alpaca.markets/docs/api-references/trading-api/account-activities/ )

import requests
from requests.exceptions import ConnectionError, Timeout, TooManyRedirects
import json


url = 'https://paper-api.alpaca.markets'
api_call = '/v2/account/activities/FILL'

headers = {'content-type': 'application/json', 
           'Apca-Api-Key-Id': key, 
           'Apca-Api-Secret-Key': secret, 
       }

params =    { 'page_size': '1', }
response = requests.get(url + api_call,params=params, headers=headers)
response = json.loads(response.text)
assets = [dict(item) for item in response]
df = pd.DataFrame.from_records(assets)
df.head()

@brettelliot
Copy link

Agreed. Would be nice to have alpaca-py support account activities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants