Esempio n. 1
0
 def init_shock(self, name, limits, rounds, input_path, input_file_market_shock, output_path, session_name):
     self.name = name
     self.limits = limits
     self.num_market_rounds = rounds
     self.mkt = env.SpotEnvironmentModel()  # instantiate environment object
     self.da = ins.Auction('da', self.limits[0], self.limits[1])  # instantiate auction
     self.load_market(input_path, input_file_market_shock, output_path, session_name, "SD After")
Esempio n. 2
0
 def init_spot_system_gui(self, name, limits, rounds, input_path, input_file, output_path, session_name):
     self.name = name  # session name
     self.limits = limits  # price ceiling and floor
     self.num_market_rounds = rounds  # total number of rounds to run
     self.mkt = env.SpotEnvironmentModel()  # instantiate environment object
     self.da = ins.Auction('da', self.limits[0], self.limits[1])  # instantiate auction
     self.load_market_gui(input_path, input_file, output_path, session_name, "SD Before")  # loads market file from gui inputs
Esempio n. 3
0
    def prepare_traders(self, tn, mkt, limits):
        d = {}
        t = {}
        if len(tn) != mkt.num_buyers + mkt.num_sellers:
            print("tn = {} does not have the right length".format(tn))
        for k in range(mkt.num_buyers + mkt.num_sellers):
            t_id = "t" + str(k)  # make trader id
            t[t_id] = globals()[tn[k]]()  # create object
            t[t_id].name = t_id  # set objects name
            t[t_id].da = ins.Auction("da", limits[0], limits[1])
            d[t_id] = {}
            d[t_id]['units'] = 0  # keep track of units used
            d[t_id]['earn'] = 0  # keep track of earnings
            d[t_id]['strat'] = tn[k]  # traders strategy

            if k < mkt.num_buyers:
                t[t_id].type = "buyer"  # set objects type
                t[t_id].values = mkt.get_buyer_values(k)  # set objects values
                d[t_id]['type'] = "B"  # traders type
                d[t_id]['values'] = mkt.get_buyer_values(k)  # trader's values
            else:  # note seller index is trader_index - num_buyers
                t[t_id].type = "seller"  # set objects type
                t[t_id].costs = mkt.get_seller_costs(
                    k - mkt.num_buyers)  # set objects values
                d[t_id]['type'] = "S"  # traders type
                d[t_id]['costs'] = mkt.get_seller_costs(
                    k - mkt.num_buyers)  # trader's values

        d["strategies"] = [k for k in set(tn)]
        # get market efficiency
        eqv = mkt.get_equilibrium(
        )  # (Price low, Price High Quantity, Maximum Surplus)
        ep_low = eqv[0]
        ep_high = eqv[1]
        e_quantity = eqv[2]
        maximum_surplus = eqv[3]
        d["equilibrium"] = (ep_low, ep_high, e_quantity, maximum_surplus)
        traders = [t[t_id] for t_id in t.keys()]
        self.traders = [t[t_id] for t_id in t.keys()]
        return d
# input - output and display options
input_path = "C:\\Users\\Summer17\\Desktop\\Repos\\DoubleAuctionMisc\\Data\\projects\\"  # TODO change file path
input_file = "TEST"  # TODO change file to TEST
t_name = "testing..testing"
display = True

# market/auction parameters
num_buyers = 4  # number of buyers
num_sellers = 4  # number of sellers
limits = (999, 0)  # ceiling and floor for bidding
num_market_periods = 100  # number of periods auction runs

# Put Trader Class Names Here - note traders strategy is named trader class name
zi = "ZeroIntelligenceTrader"
si = "SimpleTrader"
trader_names = [zi, si, zi, si, zi, si, zi,
                si]  # Order of trader strategies in generic trader array

# tournament parameters
num_trials = 1  # number of times market is run

# create objects to run tournament
mkt = b.BuildMarketEnv(t_name, 4, 4)  # instantiate market object
mkt.prepare_market(input_path, input_file)  # set and show market parameters
da = ins.Auction('da', limits[0], limits[1])  # instantiate auction
trn = trna.Tournament(t_name, num_market_periods, da)  # instatiate tournament
trader_info = trn.prepare_traders(trader_names, mkt,
                                  limits)  # instantiate traders
trn.sim(display, num_trials, trader_info)
del mkt