def breakout(self): try: b = Breakout(self.data, self.mid) breakout = b.breakout() return breakout except Exception as e: print e
if method == 'DQN': num_heads = 1 elif method == 'BDQN': num_heads = 10 if use_eGreedy == 1: epsilon = 1.0 elif use_eGreedy == 0: epsilon = 0.0 if game == 'pong': VALID_ACTION = [0, 2, 5] # 0:no-op 2:up 5:down atari = Pong() elif game == 'breakout': VALID_ACTION = [0, 1, 2, 3] # 0:no-op 1:fire 2:left 3:right atari = Breakout() num_actions = len(VALID_ACTION) dqn_heads = [] act_index = np.zeros(num_heads, dtype=int) epsilon_eval = 0.05 done = False for i in range(num_heads): the_model = torch.load('./tmp/model_epoch_200/model' + str(i) + '.pth') dqn_heads.append(DQN(num_actions)) dqn_heads[i].load_state_dict(the_model) #dqn = DQN() #dqn.load_state_dict(the_model)
def eval_genome(genome_info, config): genome_id, genome = genome_info score = Breakout(genome=genome, config=config, gui=False).play() return score
def main(): print "------ System online -------", datetime.now() parser = argparse.ArgumentParser() common.config.add_argument(parser) parser.add_argument('--instrument', "-i", type=common.args.instrument, required=True, action="append", help="Instrument to get prices for") parser.add_argument('--snapshot', action="store_true", default=True, help="Request an initial snapshot") parser.add_argument('--no-snapshot', dest="snapshot", action="store_false", help="Do not request an initial snapshot") parser.add_argument('--show-heartbeats', "-s", action='store_true', default=False, help="display heartbeats") args = parser.parse_args() #print sys.argv[2] account_id = args.config.active_account api = args.config.create_streaming_context() account_api = args.config.create_context() response = api.pricing.stream(account_id, snapshot=args.snapshot, instruments=",".join(args.instrument)) p = PivotImports(sys.argv[2], datetime.now().date()) dfD = p.daily() #dfW = p.weekly() bal = Balance(account_api, account_id) balance = bal.balance() df = pd.DataFrame([]) for msg_type, msg in response.parts(): if msg_type == "pricing.Heartbeat" and args.show_heartbeats: print(heartbeat_to_string(msg)) if msg_type == "pricing.Price": sd = StreamingData(datetime.now(), instrument_string(msg), mid_string(msg), account_api, account_id, 's', '1min', balance) df = df.append(sd.df()) sd.resample(df) print "df:", df.shape[0], "minuteData:", sd.minuteData().shape[0] #print sd.minuteData(),'\n' if sd.minuteData().shape[0] < 20: continue else: client = oandapyV20.API(settings.ACCESS_TOKEN) r = openPos.OpenPositions(accountID=account_id) client.request(r) openTrades = [] for i in r.response['positions']: trades = i['instrument'] openTrades.append(trades) print 'Open Trades', openTrades if instrument_string(msg) in openTrades: continue else: try: b = Breakout(sd.minuteData(), mid_string(msg)) breakout = b.breakout() #print 'Breakout Units:',breakout s = Spreads(dfD, mid_string(msg)) pivot, rl1, rl2, rl3, sl1, sl2, sl3 = s.spreads() rate1, rate2 = s.spreads_out() strat = Strategy(account_api, account_id, instrument_string(msg), dfD, mid_string(msg), breakout, pivot, rl1, rl2, rl3, sl1, sl2, sl3, rate1, rate2) strat.res_check() strat.sup_check() #except Exception as e: print(e) except: continue
def main(): Breakout().run()
def playGenome(genome, config): return Breakout(genome=genome, config=config, gui=True).play()
import snake.snakeBase as Snake import breakout.Breakout as breakout from pygame.locals import * import pygame import time import writing pygame.display.init() surface = pygame.display.set_mode((500,400)) pygame.display.set_caption('snake_breakout') Snake.init(pygame,surface) breakout.init(pygame,surface) writing.init(pygame,surface) brick_list = breakout.init.generate_bricks() snake = Snake.Snake(12,0,[250,200]) ball = breakout.Ball([250,250],(10,10),[-3,-3]) def handle_events(): for event in pygame.event.get(): if event.type == QUIT: return True if event.type == KEYDOWN: if event.key == K_UP: snake.up() elif event.key == K_DOWN: snake.down() elif event.key == K_LEFT: snake.left() elif event.key == K_RIGHT: snake.right()
from breakout import Breakout import asyncio from schedule import Schedule from students import Work from interactions import Interactions load_dotenv() TOKEN = os.getenv('DISCORD_TOKEN') intents = discord.Intents.default() intents.members = True prefix = '!' bot = commands.Bot(command_prefix='!', intents=intents) bot.add_cog(Breakout(bot)) bot.add_cog(Work(bot)) bot.add_cog(Schedule(bot)) bot.add_cog(Interactions(bot)) @bot.event async def on_ready(): print(f'{bot.user} has connected to Discord!') @bot.command() async def ping(ctx): await ctx.send('pong!')