human
I am working on the file ".ipynb_checkpoints/Matching Market v8-checkpoint.ipynb".
The first task is:
Observer
The observer holds the clock and collects data. In this setup it tells the market another tick has past and it is time to act. The market will instruct the other agents. The observer initializes the model, thereby making real objects out of the classes defined above.
Can you write Python code for it?

=====
Can you provide a the Python code you requested?
assistant
#Here is the Python code you requested.

class Observer():
    def __init__(self, x, y, z):
        self.init_buyer = x
        self.init_seller = y
        self.maxrun = z
        self.hist_book = []
        self.buyer_dict = {}
        self.seller_dict = {}
        self.timetick = 0
        self.gas_market = ''
        self.reserve = []
    
    def set_buyer(self, buyer_info):
        for name in buyerinfo:
            self.buyer_dict[name] = Buyer('%s' % name)
            self.buyer_dict[name].base_demand = buyer_info[name]['b']
            self.buyer_dict[name].max_demand = buyer_info[name]['m']

    
    def set_seller(self, seller_info):
        for name in seller_info:
            self.seller_dict[name] = Seller('%s' % name)
            self.seller_dict[name].prod = seller_info[name][0]
            
    def get_reserve(self):
        reserve = []
        for name in self.seller_dict:
            reserve.append(self.seller_dict[name].reserve)
        return reserve
    
    def set_market(self):
        self.gas_market = Market()
        #add suplliers and buyers to this market
        for supplier in self.seller_dict.values():
            self.gas_market.add_seller(supplier)
        for buyer in self.buyer_dict.values():
            self.gas_market.add_buyer(buyer)
        self.gas_market.seller_dict = self.seller_dict
        self.gas_market.buyer_dict = self.buyer_dict

    def run_it(self):
        # Timing
        # time initialising
        startit_init = time.time()
        
        #initialise, setting up all the agents
        first_run = True
        if first_run:
            self.set_buyer(self.init_buyer)
            self.set_seller(self.init_seller)
            self.set_market()
            first_run=False
            
        # time init stop
        stopit_init = time.time() - startit_init
        print('%s : init' % stopit_init)
        
        for period in range(self.maxrun):
            # time the period
            startit_period = time.time()

            self.timetick += 1
           ...