-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changed trades in strategy to a pd.df - started implementing Strategy…
…Analysis
- Loading branch information
Showing
11 changed files
with
523 additions
and
430 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import pandas as pd | ||
|
||
from .trade import TradeOutcome, TradeStatus | ||
|
||
|
||
class StrategyAnalysis: | ||
def __init__(self, | ||
trades: pd.DataFrame | ||
) -> None: | ||
|
||
self.trades = trades | ||
|
||
@property | ||
def average_PL(self) -> float: | ||
return self.trades[self.trades.trade_status == TradeStatus.CLOSED].PL.mean() | ||
|
||
@property | ||
def average_R_PL(self) -> float: | ||
return self.trades[self.trades.trade_status == TradeStatus.CLOSED].R_PL.mean() | ||
|
||
@property | ||
def win_rate(self) -> float: | ||
_trades = self.trades[self.trades.trade_status == TradeStatus.CLOSED] | ||
return len(_trades[_trades.outcome_status == TradeOutcome.WIN]) / len(_trades) | ||
|
||
@property | ||
def number_of_wins(self) -> int: | ||
return len(self.trades[self.trades.outcome_status == TradeOutcome.WIN]) | ||
|
||
@property | ||
def number_of_losses(self) -> int: | ||
return len(self.trades[self.trades.outcome_status == TradeOutcome.LOSS]) |
Oops, something went wrong.