def main(): nasdaq = StockMarket("NASDAQ", ["AAPL", "CSCO", "MSFT", "GOOG"]) newyork = StockMarket("NYSE", ["IBM", "HPQ", "BP"]) agg = Aggregator() agg.add_market(nasdaq) agg.add_symbols(nasdaq.symbols) agg.add_market(newyork) agg.add_symbols(newyork.symbols) print("aggregated symbols:", agg.symbols) view = Viewer() view.aggregator(agg, ["IBM", "AAPL", "MSFT"]) view.print_quotes()
def main(): nasdaq=StockMarket("NASDAQ", ["AAPL", "CSCO", "MSFT", "GOOG"]) newyork=StockMarket("NYSE", ["IBM", "HPQ", "BP"]) agg=Aggregator() agg.add_symbols(nasdaq.symbols()) agg.add_symbols(newyork.symbols()) print("aggregated symbols:", agg.available_symbols()) nasdaq.listener(agg) newyork.listener(agg) view=Viewer() agg.view(view, ["IBM", "AAPL", "MSFT"]) print("") while True: nasdaq.generate() newyork.generate() time.sleep(0.5)
def main(): nasdaq=StockMarket('NASDAQ',['AAPL','CSCO','MSFT','GOOG']) newyork=StockMarket('NYSE',['IBM','HPQ','BP']) agg = Aggregator() agg.add_symbols(nasdaq.symbols()) agg.add_symbols(newyork.symbols()) print("aggregated symbols: ", agg.available_symbols()) nasdaq.listener(agg) newyork.listener(agg) view=Viewer() agg.view(view, ['IBM','AAPL','MSFT']) print("") while True: nasdaq.generate() newyork.generate() time.sleep(0.5)