mirror of
https://github.com/KhizarImran/backtestingfx.git
synced 2026-07-28 12:37:43 +00:00
getting it ready for publishing
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
|
||||
import pandas as pd
|
||||
from backtest import Backtest, Strategy
|
||||
from backtestingfx import Backtest, Strategy
|
||||
from dotenv import load_dotenv
|
||||
from lse import LSE
|
||||
|
||||
@@ -17,7 +17,7 @@ df.to_csv("data/EURUSD_1H.csv", index=False)
|
||||
class BuyEveryBar(Strategy):
|
||||
def next(self):
|
||||
self.close_all()
|
||||
self.buy(1.0)
|
||||
self.buy(0.1)
|
||||
|
||||
|
||||
df = pd.read_csv("data/EURUSD_1H.csv")
|
||||
@@ -25,11 +25,4 @@ df = pd.read_csv("data/EURUSD_1H.csv")
|
||||
bt = Backtest(df, BuyEveryBar, cash=10000.0, commission=0.0, spread=0.0001)
|
||||
stats = bt.run()
|
||||
|
||||
print(f"Return: {stats.total_return_pct:.2f}%")
|
||||
print(f"Trades: {stats.num_trades}")
|
||||
print(f"Win Rate: {stats.win_rate_pct:.1f}%")
|
||||
print(f"Avg PnL: {stats.avg_pnl:.5f}")
|
||||
print(f"Best Trade: {stats.best_trade:.5f}")
|
||||
print(f"Worst Trade: {stats.worst_trade:.5f}")
|
||||
print(f"Max Drawdown: {stats.max_drawdown_pct:.2f}%")
|
||||
print(f"Profit Factor:{stats.profit_factor:.2f}")
|
||||
print(stats)
|
||||
|
||||
Reference in New Issue
Block a user