-
-
Save anthonymorast/0c9a38a2f9c03ec6ab2775b523053c19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def percent_profitable(data): | |
return len(data.loc[data.profit > 0]) / len(data) | |
def show_losers(data): | |
return data.loc[data.profit <= 0] | |
def top_performers_per_trade(data): | |
return data.sort_values(by=["avg_return"], ascending=False)[:5] | |
def best_returns_wrt_start_price(data): | |
data["pct_return_start"] = data["profit"]/data["start_price"] | |
return data.sort_values(by=["pct_return_start"], ascending=False)[:5] | |
if __name__ == '__main__': | |
d1 = pd.read_csv('BollingerBot/results_1yr.dat') | |
d5 = pd.read_csv('BollingerBot/results_5yr.dat') | |
d10 = pd.read_csv('BollingerBot/results_10yr.dat') | |
d1 = d1[d1.profit != 0] | |
d5 = d5[d5.profit != 0] | |
d10 = d10[d10.profit != 0] | |
data = [d1, d5, d10] | |
for d in data: | |
print("% Profitable:", percent_profitable(d)) | |
print("Unprofitable:", show_losers(d)) | |
print("Top per trade:", top_performers_per_trade(d)) | |
print("Top w.r.t start:", best_returns_wrt_start_price(d)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment