def main(): """主程序入口 """ logger.init_logger(LOG_ITEMS, suffix=OPTIONS.port) application = Application() http_server = tornado.httpserver.HTTPServer(application, xheaders=True) http_server.listen(OPTIONS.port) tornado.ioloop.IOLoop.instance().start()
def __init__(self, mode, initial_invest, session_name, brain, stock): """ Initializes a Live_Session. Args: mode (string): Whether training, finetuning, or testing. initial_invest (int): Starting budget. brain (stable_baselines.ppo2.PPO2 model): Model to use. stock (string): Ticker representing a chosen stock. Returns: None """ self.session_name = session_name self.mode = mode self.initial_invest = initial_invest self.portfolio_value = [] self.test_ep_rewards = [] self.actions = generate_actions() self.timestamp = dir_setup(mode) self.env = None self.scaler = joblib.load('saved_scaler.pkl') self.stock = stock self.logger = init_logger(__name__, show_debug=True) self.brain = PPO2.load(brain) coloredlogs.install(level='TEST', logger=self.logger) self.logger.info("Bot is live: [{}]".format(datetime.datetime.now()))
def main(): """主程序入口 """ # lib from lib import load from lib import uimodule, uimethods from lib.utils import logger from lib.utils import pyshell # conf from conf import log from conf.settings import ( LOG_ITEMS, OPTIONS, ) logger.init_logger(LOG_ITEMS, suffix=OPTIONS.port) application = Application() http_server = tornado.httpserver.HTTPServer(application, xheaders=True) http_server.listen(OPTIONS.port) tornado.ioloop.IOLoop.instance().start()
def __init__(self, mode, test_episodes, initial_invest, session_name, stock=None, brain=None): """ Initializes a Static_Session. Args: mode (string): Whether training, finetuning, or testing. test_episodes (int): How many episodes to test the model for. initial_invest (int): Starting budget. stock (string): Ticker representing a chosen stock. Defaults to None. brain (stable_baselines model): Model to use. Defaults to None. Returns: None """ # SESSION_VARIABLES self.session_name = session_name self.mode = mode self.test_episodes = test_episodes self.initial_invest = initial_invest self.portfolio_value = [] self.test_ep_rewards = [] self.losses = 0 self.actions = generate_actions() self.timestamp = dir_setup(mode) self.env = None self.brain = brain self.n_steps_per_eval = 10000000 self.logger = init_logger(__name__, show_debug=True) self.stock = stock coloredlogs.install(level='TEST') self.train_ds, self.val_ds, self.test_ds = \ train_val_test_split(TOTAL_DATA_PATH) self.optuna_study = optuna.create_study( study_name="{}_study".format(self.session_name), storage="sqlite:///data/params.db", load_if_exists=True, pruner=optuna.pruners.MedianPruner()) self.logger.debug(f'Initialized Static Session: {self.session_name}') self.logger.debug(f'Mode: {self.mode}')
def __init__(self, mode, initial_invest, session_name, brain, stock): self.session_name = session_name self.mode = mode self.initial_invest = initial_invest self.portfolio_value = [] self.test_ep_rewards = [] self.actions = generate_actions() self.timestamp = dir_setup(mode) self.env = None self.scaler = joblib.load('saved_scaler.pkl') self.stock = stock self.logger = init_logger(__name__, show_debug=True) self.brain = PPO2.load(brain) coloredlogs.install(level='TEST', logger=self.logger) n_features = 22 state_size = n_features action_size = len(ACTIONS) * 10 self.logger.info("Bot is live: [{}]".format(datetime.datetime.now()))