コード例 #1
0
    portfolios_csv_path = os.path.join(script_dir, 'data/r_xq_portfolios.csv')
    XueQiuFetchPortfoliosJob.XueQiuFetchPortfoliosJob(
        xq, portfolios_csv_path).run()

    holdings_csv_path = os.path.join(
        script_dir, 'data/r_xq_holdings_{}.csv'.format(today_str))
    portfolios = xq.get_portfolios_from_csv(portfolios_csv_path)
    XueQiuFetchHoldingsJob.XueQiuFetchHoldingsJob(xq, holdings_csv_path,
                                                  portfolios['code']).run()

    watches_csv_path = os.path.join(script_dir, 'data/r_xq_watches.csv')
    XueQiuFetchWatchesJob.XueQiuFetchWatchesJob(xq, watches_csv_path).run()

if generate_sw and not only_local_file:
    sw = SW.SW()
    succeed, reason = sw.init()
    if not succeed:
        raise Exception("sw init failed: " + reason)

    SWDownloadFilesJob.SWDownloadFilesJob(sw,
                                          sw_files,
                                          data_file_path=os.path.join(
                                              script_dir, 'data/')).run()

if generate_zz:
    if not only_local_file:
        df = pd.read_csv(os.path.join(script_dir, 'data/r_stocks.csv'))

        StocksDownloadFilesJob.StocksDownloadFilesJob(
            df['code'].str.split('.').str.get(0),
コード例 #2
0
    def __init__(self, station_num):
        self.ebreak = False
        self.station_num = station_num
        #self.station_num["ebreak"][0] = 1
        self.index = {}
        self.index["lw"] = 0
        self.index["sw"] = self.index["lw"] + self.station_num["lw"][0]
        self.index["jmp"] = self.index["sw"] + self.station_num["sw"][0]
        #self.index["jalr"] = self.index["sw"] + self.station_num["sw"]
        #self.index["ret"] = self.index["sw"] + self.station_num["sw"]
        self.index["beq"] = self.index["jmp"] + self.station_num["jmp"][0]
        self.index["add"] = self.index["beq"] + self.station_num["beq"][0]
        #self.index["sub"] = self.index["beq"] + self.station_num["beq"]
        #self.index["addi"] = self.index["beq"] + self.station_num["beq"]
        self.index["nand"] = self.index["add"] + self.station_num["add"][0]
        self.index["mult"] = self.index["nand"] + self.station_num["nand"][0]
        self.index["ebreak"] = self.index["mult"] + self.station_num["mult"][0]

        self.used = {}
        self.used["lw"] = 0
        self.used["sw"] = 0
        self.used["jmp"] = 0
        self.used["beq"] = 0
        self.used["add"] = 0
        self.used["nand"] = 0
        self.used["mult"] = 0
        self.used["ebreak"] = 0

        self.cycle = {}
        self.cycle["lw"] = 0
        self.cycle["sw"] = 0
        self.cycle["jmp"] = 0
        self.cycle["beq"] = 0
        self.cycle["add"] = 0
        self.cycle["nand"] = 0
        self.cycle["mult"] = 0
        self.cycle["ebreak"] = 0

        self.station = []

        for i in range(self.station_num["lw"][0]):
            station_entry = {}
            station_entry["name"] = "lw" + str(i)
            station_entry["busy"] = False
            station_entry["op"] = "init"
            station_entry["Vj"] = 0
            station_entry["Vk"] = 0
            station_entry["Qj"] = -1
            station_entry["Qk"] = -1
            station_entry["dest"] = 0
            station_entry["A"] = 0
            station_entry["status"] = "init"
            station_entry["funct_unit"] = LW(station_num["lw"][1])
            self.station.append(station_entry)

        for i in range(self.station_num["sw"][0]):
            station_entry = {}
            station_entry["name"] = "sw" + str(i)
            station_entry["busy"] = False
            station_entry["op"] = "init"
            station_entry["Vj"] = 0
            station_entry["Vk"] = 0
            station_entry["Qj"] = -1
            station_entry["Qk"] = -1
            station_entry["dest"] = 0
            station_entry["A"] = 0
            station_entry["status"] = "init"
            station_entry["funct_unit"] = SW(station_num["sw"][1])
            self.station.append(station_entry)

        for i in range(self.station_num["jmp"][0]):
            station_entry = {}
            station_entry["name"] = "jmp" + str(i)
            station_entry["busy"] = False
            station_entry["op"] = "init"
            station_entry["Vj"] = 0
            station_entry["Vk"] = 0
            station_entry["Qj"] = -1
            station_entry["Qk"] = -1
            station_entry["dest"] = 0
            station_entry["A"] = 0
            station_entry["status"] = "init"
            station_entry["funct_unit"] = JMP(station_num["jmp"][1])
            self.station.append(station_entry)

        for i in range(self.station_num["beq"][0]):
            station_entry = {}
            station_entry["name"] = "beq" + str(i)
            station_entry["busy"] = False
            station_entry["op"] = "init"
            station_entry["Vj"] = 0
            station_entry["Vk"] = 0
            station_entry["Qj"] = -1
            station_entry["Qk"] = -1
            station_entry["dest"] = 0
            station_entry["A"] = 0
            station_entry["status"] = "init"
            station_entry["funct_unit"] = BEQ(
                station_num["beq"][1])  #TODO change the 1 to be variable
            self.station.append(station_entry)

        for i in range(self.station_num["add"][0]):
            station_entry = {}
            station_entry["name"] = "add" + str(i)
            station_entry["busy"] = False
            station_entry["op"] = "init"
            station_entry["Vj"] = 0
            station_entry["Vk"] = 0
            station_entry["Qj"] = -1
            station_entry["Qk"] = -1
            station_entry["dest"] = 0
            station_entry["A"] = 0
            station_entry["status"] = "init"
            station_entry["funct_unit"] = Adders(station_num["add"][1])
            self.station.append(station_entry)

        for i in range(self.station_num["nand"][0]):
            station_entry = {}
            station_entry["name"] = "nand" + str(i)
            station_entry["busy"] = False
            station_entry["op"] = "init"
            station_entry["Vj"] = 0
            station_entry["Vk"] = 0
            station_entry["Qj"] = -1
            station_entry["Qk"] = -1
            station_entry["dest"] = 0
            station_entry["A"] = 0
            station_entry["status"] = "init"
            station_entry["funct_unit"] = NAND(station_num["nand"][1])
            self.station.append(station_entry)

        for i in range(self.station_num["mult"][0]):
            station_entry = {}
            station_entry["name"] = "mult" + str(i)
            station_entry["busy"] = False
            station_entry["op"] = "init"
            station_entry["Vj"] = 0
            station_entry["Vk"] = 0
            station_entry["Qj"] = -1
            station_entry["Qk"] = -1
            station_entry["dest"] = 0
            station_entry["A"] = 0
            station_entry["status"] = "init"
            station_entry["funct_unit"] = Multipliers(station_num["mult"][1])
            self.station.append(station_entry)

        station_entry = {}
        station_entry["name"] = "ebreak"
        station_entry["busy"] = False
        station_entry["op"] = "init"
        station_entry["Vj"] = 0
        station_entry["Vk"] = 0
        station_entry["Qj"] = -1
        station_entry["Qk"] = -1
        station_entry["dest"] = 0
        station_entry["A"] = 0
        station_entry["status"] = "init"
        station_entry["funct_unit"] = None
        self.station.append(station_entry)