Exemplo n.º 1
0
    def stats_perf(self, data):

        # print date from and to
        days_difference = data.tail(1)["close_time"].values[0] - data.head(
            1)["open_time"].values[0]
        days_difference = int(round(days_difference / np.timedelta64(1, 'D')))

        time_from = data.head(1)["open_time"].astype(str).values[0]
        time_to = data.tail(1)["close_time"].astype(str).values[0]
        print("From {} to {} ({} days)\n".format(time_from, time_to,
                                                 days_difference))

        # print total number of trades
        # we can sum up every time a fee was applied to get total trades
        total_trades = data.apply_fee.sum()
        print("Total number of trades: {}".format(total_trades))

        # print avg. trades per date
        print("Avg. trades per day: {}".format(
            round(total_trades / days_difference, 2)))

        # print profit/loss (log returns)
        cum_return = round(data["cum_pl"].iloc[-1] * 100, 2)
        print("Profit/Loss [Log Return]: {0}%".format(cum_return))

        # # print profit/loss (simple return)
        # simple_return = (np.exp(data.iloc[-1].cum_pl) - 1) * 100
        # print("Profit/Loss [Simple Return]: {0}%".format(round(simple_return, 2)))

        # print maximum gains (log returns)
        max_cum_pl = round(data["cum_pl"].max() * 100, 2)
        print("Maximum Gain: {0}%".format(max_cum_pl))

        #print maximum loss (log returns)
        min_cum_pl = round(data["cum_pl"].min() * 100, 2)
        print("Maximum Drawdown: {0}%".format(min_cum_pl))

        # print sharpe ratio
        # 96 (15 minutes in a day) and 365 days for the crypto market
        # we compute the sharpe ratio based on profit and loss
        sharpe_ratio = fs.sharpe_ratio(96 * 365, data.pl)
        print("Annualised Sharpe Ratio: {0}".format(round(sharpe_ratio, 6)))
Exemplo n.º 2
0
    def stats_perf(self, data):

        # print date from and to
        time_from = data.head(1)["open_time"].astype(str).values[0]
        time_to = data.tail(1)["close_time"].astype(str).values[0]
        print("From {} to {}".format(time_from, time_to))

        # print price bought at and current price
        bought_price = data.iloc[0]["close"]
        current_price = data.iloc[-1]["close"]
        print("Bought at price {} and current price is {}\n".format(
            round(bought_price, 5), round(current_price, 5)))

        # print total number of trades, in this strategy always 1
        print("Total number of trades: {}".format(1))

        # print profit/loss (log returns)
        cum_return = round(data["cum_pl"].iloc[-1] * 100, 2)
        print("Profit/Loss [Log Return]: {0}%".format(cum_return))

        # # print profit/loss (simple return)
        # simple_return = (np.exp(data.iloc[-1].cum_pl) - 1) * 100
        # print("Profit/Loss [Simple Return]: {0}%".format(round(simple_return, 2)))

        # print maximum gains (log returns)
        max_cum_pl = round(data["cum_pl"].max() * 100, 2)
        print("Maximum Gain: {0}%".format(max_cum_pl))

        #print maximum loss (log returns)
        min_cum_pl = round(data["cum_pl"].min() * 100, 2)
        print("Maximum Drawdown: {0}%".format(min_cum_pl))

        # print sharpe ratio
        # 96 (15 minutes in a day) and 365 days for the crypto market
        # we compute the sharpe ratio based on profit and loss
        sharpe_ratio = fs.sharpe_ratio(96 * 365, data.log_returns)
        print("Annualised Sharpe Ratio: {0}".format(round(sharpe_ratio, 6)))