예제 #1
0
 def update(self, timestamp, portfolio_handler):
     """
     Update equity curve and benchmark equity curve that must be tracked
     over time.
     """
     self.equity[timestamp] = PriceParser.display(
         self.portfolio_handler.portfolio.equity)
     if self.benchmark is not None:
         self.equity_benchmark[timestamp] = PriceParser.display(
             self.price_handler.get_last_close(self.benchmark))
예제 #2
0
    def calculate_signals(self, event, agent=None):
        if event.type in [EventType.TICK, EventType.BAR]:
            # Format the event for human display
            if event.type == EventType.BAR:
                event.open_price = PriceParser.display(event.open_price)
                event.high_price = PriceParser.display(event.high_price)
                event.low_price = PriceParser.display(event.low_price)
                event.close_price = PriceParser.display(event.close_price)
                event.adj_close_price = PriceParser.display(
                    event.adj_close_price)
            else:  # event.type == EventType.TICK
                event.bid = PriceParser.display(event.bid)
                event.ask = PriceParser.display(event.ask)

            if self.i % self.n == 0 and self.i != 0:
                print(s_speed(event, self.i, self.t0))
                print("")
            if self.i % self.n in range(self.n_window):
                print("%d %s" % (self.i, event))
            self.i += 1
예제 #3
0
 def x(p):
     return PriceParser.display(p)