Is there a way to get the date of purchase of a position, i want to check the date before i sell the position to avoid day trade
Currently the position entity does not have purchase date.
Is there a way to get the date of purchase of a position, i want to check the date before i sell the position to avoid day trade
Currently the position entity does not have purchase date.
There doesn’t appear to be a built in method for finding the purchase date. One way would be to get your order list and check the fill date for your position.
Another method to avoid buying and selling on the same day could be to check if the position has an unrealized_intraday_pl and unrealized_pl that are not equal.
Thanks for the suggestion, but I think i can make use of daytrade_count in account entity
May be not
I finally did what u said
def todays_buy_fill_date(symbol):
orders=api.list_orders(status=‘closed’, limit=500, after=midnight, until=None, direction=‘desc’)
for order in orders:
if order.symbol==symbol:
return order.filled_at.astimezone(local_timezone)
A little late to this thread, but it looks like you can review account activity.
def prevent_daytrading(symbol):
trades_today = api.get_activities(date=<today’s date>)
for trade in trades_today:
if symbol == trade.symbol:
return False
Something like that might do it