|
10 | 10 | get_api_version, |
11 | 11 | ) |
12 | 12 | from .entity import ( |
13 | | - Account, AccountConfigurations, Asset, |
14 | | - Order, Position, BarSet, Clock, Calendar, |
| 13 | + Account, AccountConfigurations, AccountActivity, |
| 14 | + Asset, Order, Position, BarSet, Clock, Calendar, |
15 | 15 | ) |
16 | 16 | from . import polygon |
17 | 17 |
|
@@ -346,6 +346,34 @@ def get_clock(self): |
346 | 346 | resp = self.get('/clock') |
347 | 347 | return Clock(resp) |
348 | 348 |
|
| 349 | + def get_activities( |
| 350 | + self, |
| 351 | + activity_types=None, |
| 352 | + until=None, |
| 353 | + after=None, |
| 354 | + direction=None, |
| 355 | + date=None, |
| 356 | + page_size=None, |
| 357 | + ): |
| 358 | + url = '/account/activities' |
| 359 | + params = {} |
| 360 | + if isinstance(activity_types, list): |
| 361 | + params['activity_types'] = ','.join(activity_types) |
| 362 | + elif activity_types is not None: |
| 363 | + url += '/{}'.format(activity_types) |
| 364 | + if after is not None: |
| 365 | + params['after'] = after |
| 366 | + if until is not None: |
| 367 | + params['until'] = until |
| 368 | + if direction is not None: |
| 369 | + params['direction'] = direction |
| 370 | + if date is not None: |
| 371 | + params['date'] = date |
| 372 | + if page_size is not None: |
| 373 | + params['page_size'] = page_size |
| 374 | + resp = self.get(url, data=params) |
| 375 | + return [AccountActivity(o) for o in resp] |
| 376 | + |
349 | 377 | def get_calendar(self, start=None, end=None): |
350 | 378 | params = {} |
351 | 379 | if start is not None: |
|
0 commit comments