- Introduced Taxes class in taxes.py to calculate and apply taxes on profits in backtest results. - Updated main.py to include tax calculations in the results processing flow. - Refactored trade logging in TrendDetectorSimple to account for transaction fees and ensure accurate profit calculations. - Added a utility script (apply_taxes_to_file.py) for applying taxes to existing CSV files. - Adjusted date range and timeframe settings in main.py for broader analysis.
24 lines
732 B
Python
24 lines
732 B
Python
import sys
|
|
import os
|
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
from taxes import Taxes
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) < 2:
|
|
print("Usage: python apply_taxes_to_file.py <input_csv> [profit_col]")
|
|
sys.exit(1)
|
|
|
|
input_csv = sys.argv[1]
|
|
profit_col = sys.argv[2] if len(sys.argv) > 2 else 'final_usd'
|
|
|
|
if not os.path.isfile(input_csv):
|
|
print(f"File not found: {input_csv}")
|
|
sys.exit(1)
|
|
|
|
base, ext = os.path.splitext(input_csv)
|
|
output_csv = f"{base}_taxed.csv"
|
|
|
|
taxes = Taxes() # Default 20% tax rate
|
|
taxes.add_taxes_to_results_csv(input_csv, output_csv, profit_col=profit_col)
|
|
print(f"Taxed file saved as: {output_csv}")
|