Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A feature to exit at the end of day. #529

wolfcuring started this conversation in Ideas
Discussion options

As I am interested in intra-day trading, I need to exit at the last bar of day. I checked kernc's package, it does not seem to support this functionality. So I coded a func to added a column to the OHLC data, so that when it is the second last bar of a day, it gives a signal of 1.

def col_day_end(es):
 es['end_of_day'] = 0 
 es['day'] = es.index.astype(str).str.split(' ').str[0]
 last = pd.DataFrame.last_valid_index
 es.loc[es.groupby('day').apply(last),'end_of_day'] = 1 
 es.end_of_day = es.end_of_day.shift(periods=-1)
 return es.end_of_day 
 ...
 if self.position:
 if self.data.end_of_day == 1 :
 self.position.close()
 

It works, but seems quite clumsy. Maybe this can be added to the package in further version.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /