Skip to content

Commit a6a5925

Browse files
committed
Add support for account activity API
1 parent d10c505 commit a6a5925

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

alpaca_trade_api/entity.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ class Position(Entity):
5555
pass
5656

5757

58+
class AccountActivity(Entity):
59+
pass
60+
61+
5862
class Bar(Entity):
5963
def __getattr__(self, key):
6064
if key == 't':

alpaca_trade_api/rest.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
get_api_version,
1111
)
1212
from .entity import (
13-
Account, AccountConfigurations, Asset,
14-
Order, Position, BarSet, Clock, Calendar,
13+
Account, AccountConfigurations, AccountActivity,
14+
Asset, Order, Position, BarSet, Clock, Calendar,
1515
)
1616
from . import polygon
1717

@@ -346,6 +346,30 @@ def get_clock(self):
346346
resp = self.get('/clock')
347347
return Clock(resp)
348348

349+
def get_activities(
350+
self,
351+
activity_type=None,
352+
until=None,
353+
after=None,
354+
direction=None,
355+
date=None,
356+
page_size=None,
357+
):
358+
url = '/account/activities/{}'.format(activity_type)
359+
params = {}
360+
if after is not None:
361+
params['after'] = after
362+
if until is not None:
363+
params['until'] = until
364+
if direction is not None:
365+
params['direction'] = direction
366+
if date is not None:
367+
params['date'] = date
368+
if page_size is not None:
369+
params['page_size'] = page_size
370+
resp = self.get(url, data=params)
371+
return [AccountActivity(o) for o in resp]
372+
349373
def get_calendar(self, start=None, end=None):
350374
params = {}
351375
if start is not None:

0 commit comments

Comments
 (0)