Exemplo n.º 1
0
 def get_stats(self):
     # call get_logs before calling this function
     stats = pf.stats(self.ts, self.tlog, self.dbal, self.capital)
     return stats
Exemplo n.º 2
0
 def _get_stats(self):
     self.stats = pf.stats(self.ts, self.tlog, self.dbal, self.capital)
Exemplo n.º 3
0
    def stats(self):
        tlog, dbal = self.get_logs()

        stats = pf.stats(self._ts, tlog, dbal, self._start, self._end,
                         self._capital)
        return stats
Exemplo n.º 4
0
 def get_stats(self):
     stats = pf.stats(self.ts, self.tlog, self.dbal, self.capital)
     return stats
Exemplo n.º 5
0
 def stats(self):
     tlog, dbal = self.get_logs()
     
     stats = pf.stats(self._ts, tlog, dbal,
                      self._start, self._end, self._capital)
     return stats
Exemplo n.º 6
0
 def _get_stats(self):
     """
     Get the statistics for the benchmark.
     """
     self.stats = pf.stats(self.ts, self.tlog, self.dbal, self.capital)
Exemplo n.º 7
0
            # update cash
            cash = tlog.calc_cash(cash, close, shares)

        else:
            dbal.append(date, high, low, close, shares, cash,
                        pf.TradeState.HOLD)

t1 = time.time()
total = t1 - t0
print(total)
tlog = tlog.get_log()
tlog.tail(100)
dbal = dbal.get_log()

dbal.tail()
stats = pf.stats(ts, tlog, dbal, start, end, capital)
pf.print_full(stats)
benchmark = pf.Benchmark('SPY', capital, start, end)
benchmark.run()
benchmark.tlog, benchmark.dbal = benchmark.get_logs()
benchmark.stats = benchmark.stats()
pf.print_full(benchmark.stats)
pf.plot_equity_curve(dbal, benchmark=benchmark.dbal)
plt.show()
pf.plot_trades(dbal, benchmark=benchmark.dbal)
plt.show()
metrics = ('annual_return_rate', 'max_closed_out_drawdown',
           'drawdown_annualized_return', 'drawdown_recovery', 'best_month',
           'worst_month', 'sharpe_ratio', 'sortino_ratio', 'monthly_std')
df = pf.plot_bar_graph(stats, *metrics)
plt.show()