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

Multiple date ranges #979

Unanswered
Fr94b asked this question in Q&A
Discussion options

Hello, I would need to specify not only the direct strategy for buying/selling, but also evaluate whether when a specific condition arise that day belongs to one of preset date ranges.

Something like this:

df = pd.read_csv('data.csv')
# column 'Date' example '2023-05-06 00:00:00'
... Range1 = between 2023年01月01日 and 2023年01月10日
... Range2 = between 2023年01月21日 and 2023年01月20日
... Range3 = between 2023年02月01日 and 2023年02月10日
class Test(Strategy):
 ...
 def next(self):
 if crossover(self.testA1, self.testA2) and ... 'Date' within Range1 or Range2 or Range3
 self.position.close()
 self.buy()
 elif crossover(self.testB1, self.testB2) and ... 'Date' NOT within Range1 or Range2 or Range3
 self.position.close()
 self.buy()
 elif ...

Thank you

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
Q&A
Labels
None yet
1 participant

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