# get size of state and action from environment openerAgent = DQNAgent(testEnv.observation_space["opener"], testEnv.action_space["opener"].n, fillMemoryByPretrainedModel=True) buyerAgent = DQNAgent(testEnv.observation_space["buyer"], testEnv.action_space["buyer"].n, fillMemoryByPretrainedModel=True) sellerAgent = DQNAgent(testEnv.observation_space["seller"], testEnv.action_space["seller"].n, fillMemoryByPretrainedModel=True) #buyerAgent = AlwaysHoldAgent(testEnv.observation_space["opener"], testEnv.action_space["opener"].n, agentName="buyer") #sellerAgent = AlwaysHoldAgent(testEnv.observation_space["seller"], testEnv.action_space["seller"].n, agentName="seller") agent = CompositeAgent(openerAgent, buyerAgent, sellerAgent) #agent = agent.load_agent("../models/", "best_composite", dropSupportModel=True) #agent = agent.loadPretrainedAgents(dir="../models/", baseName="super_resnet_34_{}_{}".format(symbol, timeframe)) agent = agent.loadPretrainedAgents(dir="../models/", baseName="qrl_resnet_34") #agent = agent.load_agent("../models/", "checkpoint_composite") print("start using agent") dealsStatistics = agent.use_agent(testEnv) ########################### import numpy as np dealAvg = np.sum(dealsStatistics) / len(dealsStatistics) dealStd = np.std(dealsStatistics) print("Avg deal profit: {}".format(dealAvg)) print("Deal's std: {}".format(dealStd)) ########################### sumRew = 0 cumulativeReward = []
# get size of state and action from environment openerAgent = DQNAgent(testEnv.observation_space["opener"], testEnv.action_space["opener"].n, fillMemoryByPretrainedModel=True) #buyerAgent = DQNAgent(testEnv.observation_space["buyer"], testEnv.action_space["buyer"].n, fillMemoryByPretrainedModel=True) #sellerAgent = DQNAgent(testEnv.observation_space["seller"], testEnv.action_space["seller"].n, fillMemoryByPretrainedModel=True) buyerAgent = AlwaysHoldAgent(testEnv.observation_space["opener"], testEnv.action_space["opener"].n, agentName="buyer") sellerAgent = AlwaysHoldAgent(testEnv.observation_space["seller"], testEnv.action_space["seller"].n, agentName="seller") agent = CompositeAgent(openerAgent, buyerAgent, sellerAgent) #agent = agent.load_agent("../models/", "best_composite", dropSupportModel=True) agent = agent.loadPretrainedAgents(dir="../models/", baseName="super_resnet_34_{}_{}".format( symbol, timeframe)) #agent = agent.loadPretrainedAgents(dir="../models/", baseName="qrl_resnet_34") #agent = agent.load_agent("../models/", "checkpoint_composite") print("start using agent") dealsStatistics = agent.use_agent(testEnv) ########################### import numpy as np dealAvg = np.sum(dealsStatistics) / len(dealsStatistics) dealStd = np.std(dealsStatistics) print("Avg deal profit: {}".format(dealAvg)) print("Deal's std: {}".format(dealStd)) ###########################