Skip to content

ASX Gym Configurations

James Shen edited this page Jun 13, 2020 · 6 revisions

ASX Gym Env is also configurable, like support whole 2000+ companies or select a subset of companies for simulations.

# default values and configurations
self.user_set_start_date = kwargs.get('start_date', self.min_stock_date)
self.random_start_days = kwargs.get('random_start_days', RANDOM_START_DAYS_PERIOD)
self.user_set_max_simulation_days = kwargs.get('max_days', -1)
self.start_date = self.user_set_start_date
self.display_days = kwargs.get('display_days', RENDER_DEFAULT_DISPLAY_DAYS)

self.keep_same_company_when_reset = kwargs.get('keep_same_company_when_reset', True)
self.keep_same_start_date_when_reset = kwargs.get('keep_same_start_date_when_reset', False)
self.simulate_company_number = kwargs.get('simulate_company_number', -1)
self.simulate_company_list = kwargs.get('simulate_company_list', None)

self.initial_fund = kwargs.get('initial_fund', DEFAULT_INITIAL_FUND)
self.initial_bank_balance = kwargs.get('initial_bank_balance', 0)

self.expected_fund_increase_ratio = kwargs.get('expected_fund_increase_ratio',
                                                DEFAULT_EXPECTED_FUND_INCREASE_RATIO)
self.expected_fund_decrease_ratio = kwargs.get('expected_fund_decrease_ratio',
                                                DEFAULT_EXPECTED_FUND_DECREASE_RATIO)
transaction_fee_list = kwargs.get('transaction_fee_list', [])

You can pass these configurations when creating the Env.

start_date = date(2019, 5, 1)
simulate_company_list = [2, 3, 4, 5, 6, 44, 300, 67, 100, 200]
# simulate_company_list = [3]
env = gym.make("AsxGym-v0", start_date=start_date,
                simulate_company_list=simulate_company_list)

Default values for these settings:

MINIMUM_SIMULATION_DAYS = 50
RANDOM_START_DAYS_PERIOD = 100
DEFAULT_INITIAL_FUND = 100000
RENDER_DEFAULT_DISPLAY_DAYS = 20
DEFAULT_EXPECTED_FUND_INCREASE_RATIO = 2.0
DEFAULT_EXPECTED_FUND_DECREASE_RATIO = 0.2


DEFAULT_BROKERAGE_FEE = [
    (1000, 10, False),  # amount, fee, is_percentage
    (10000, 19.95, False),
    (25000, 29.95, False),
    (MAX_PRICE_VALUE, 0.12, True)
]

Initial Fund

initial_fund set the initial fund, default is $100,000

Done conditions

expected_fund_increase_ratio increase default as 2.0 (200% increase of initial fund) expected_fund_decrease_ratio descrease default as 0.2 (20% remain of initial fund)

Start Date

start_date set the simulation start date, if not set use the minimum date in the database.date(2010, 10, 10)

Brokerage fee

Every transaction like sell and buy stock incurs brokerage fees. Default settings

$10.00 (Up to and including $1,000)
$19.95 (Over $1,000 up to $10,000 (inclusive))
$29.95 (Over $10,000 up to $25,000 (inclusive))
0.12% (Over $25,000)

you can set transaction_fee_list to [] to get rid of the brokerage fees.

Control the behavior when Asx Gym Env reset

To avoid the simulate the same data when Gym reset to avoid Agent remember daily stock prices and cheat the system. when env reset, it randomly shifts the start date a bit and may choose different companies when reset

keep_same_company_when_reset default to True, it uses the same companies list when env reset. keep_same_start_date_when_reset default set to False, it shifts start date (controls by random_start_days) a bit.