Skip to content

ASX Gym Done Condition

James Shen edited this page Jun 13, 2020 · 1 revision

When ASX Env detects that your total value exceeds predefined or lower than the predefined threshold (i.e increased by 200% or lower than the 20% initial fund.or end of given days.

These thresholds are configurable, defaults to 200% and 20%

def _is_done(self):
    done = False
    today = self.display_date
    total_value = self.total_value
    min_lost = round(self.initial_fund * self.expected_fund_decrease_ratio, 3)
    max_gain = round(self.initial_fund * self.expected_fund_increase_ratio, 3)
    stock_index = self.index_df.iloc[
                    self.min_stock_seq + self.step_day_count
                    :self.min_stock_seq + self.step_day_count + 1]
    if (today is None) or stock_index.empty \
            or (self.step_day_count >= self.max_transaction_days - 1) \
            or (total_value < min_lost) or (total_value > max_gain):
        done = True

    return done

ASX GYM

Clone this wiki locally