コード例 #1
0
ファイル: equity_curve.py プロジェクト: edupard/portfolio
    def decide(self, date: datetime.date, next_trading_date: datetime.datetime):
        close_pos = False
        open_pos = False
        # check if we need to close position
        if self.in_pos:
            if next_trading_date is None or not is_same_week(date, next_trading_date):
                close_pos = True
                self.in_pos = False
        if not self.in_pos:
            if next_trading_date is not None:
                if not is_same_week(date, next_trading_date):
                    open_pos = True
                    self.in_pos = True

        return close_pos, open_pos
コード例 #2
0
ファイル: equity_curve.py プロジェクト: edupard/portfolio
 def decide(self, date: datetime.date, next_trading_date: datetime.datetime):
     predict = True
     close_pos = True
     open_pos = True
     if next_trading_date is None:
         open_pos = False
         predict = False
     else:
         if not is_same_week(date, next_trading_date):
             open_pos = False
             predict = False
     return predict, close_pos, open_pos
コード例 #3
0
ファイル: equity_curve.py プロジェクト: edupard/portfolio
    def decide(self, date: datetime.date, next_trading_date: datetime.datetime):
        predict = False
        close_pos = False
        open_pos = False
        # check if we need to close position
        if self.in_pos:
            if next_trading_date is not None:
                if is_same_week(date, next_trading_date):
                    close_pos = True
                    self.in_pos = False

        if not self.in_pos:
            if next_trading_date is not None:
                if is_same_week(date, next_trading_date):
                    predict = True
                    self.has_prediction = True
                    if self.has_prediction:
                        open_pos = True
                        self.in_pos = True

        return predict, close_pos, open_pos
コード例 #4
0
ファイル: equity_curve.py プロジェクト: edupard/portfolio
    def decide(self, date: datetime.date, next_trading_date: datetime.datetime):
        predict = False
        close_pos = False
        open_pos = False
        # check if we need to close position
        if self.in_pos:
            if next_trading_date is None or not is_same_week(date, next_trading_date) or (self.prev_trading_date is not None and not is_same_week(self.prev_trading_date, date)):
                close_pos = True
                self.in_pos = False
        # predict and open position in any day
        if not self.in_pos:
            if next_trading_date is not None:
                predict = True
                open_pos = True
                self.in_pos = True

        self.prev_trading_date = date
        return predict, close_pos, open_pos