Skip to content

Commit

Permalink
Fix flake 8 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
MDUYN committed Apr 25, 2024
1 parent 5875722 commit 767d723
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion investing_algorithm_framework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Trade, OHLCVMarketDataSource, OrderBookMarketDataSource, SYMBOLS, \
TickerMarketDataSource, MarketService, BacktestReportsEvaluation, \
pretty_print_backtest_reports_evaluation, load_backtest_reports, \
RESERVED_BALANCES, APP_MODE, AppMode, DATETIME_FORMAT,\
RESERVED_BALANCES, APP_MODE, AppMode, DATETIME_FORMAT, \
load_backtest_report, BacktestDateRange
from investing_algorithm_framework.infrastructure import \
CCXTOrderBookMarketDataSource, CCXTOHLCVMarketDataSource, \
Expand Down
2 changes: 1 addition & 1 deletion investing_algorithm_framework/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from datetime import datetime
from distutils.sysconfig import get_python_lib
from time import sleep
from typing import List, Optional, Tuple
from typing import List, Optional

from flask import Flask

Expand Down
3 changes: 2 additions & 1 deletion investing_algorithm_framework/domain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
from .stateless_actions import StatelessActions
from .strategy import Strategy
from .utils import random_string, append_dict_as_row_to_csv, \
add_column_headers_to_csv, get_total_amount_of_rows, load_backtest_report,\
add_column_headers_to_csv, get_total_amount_of_rows, \
load_backtest_report, \
csv_to_list, StoppableThread, pretty_print_backtest_reports_evaluation, \
pretty_print_backtest, load_csv_into_dict, load_backtest_reports

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class BacktestDateRange:
"""
Represents a date range for a backtest
"""
def __init__(self, start_date, end_date = None, name = None):
def __init__(self, start_date, end_date=None, name=None):
self._start_date = start_date
self._end_date = end_date
self._name = name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ def to_dict(self):
"amount_pending_buy": self.amount_pending_buy,
"amount_pending_sell": self.amount_pending_sell,
"percentage_of_portfolio": self.percentage_of_portfolio
}
}
6 changes: 4 additions & 2 deletions investing_algorithm_framework/domain/models/trade/trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,10 @@ def to_dict(self):
"open_price": self.open_price,
"current_price": self.current_price,
"closed_price": self.closed_price,
"opened_at": self.opened_at.strftime(DATETIME_FORMAT) if self.opened_at else None,
"closed_at": self.closed_at.strftime(DATETIME_FORMAT) if self.closed_at else None,
"opened_at": self.opened_at.strftime(DATETIME_FORMAT)
if self.opened_at else None,
"closed_at": self.closed_at.strftime(DATETIME_FORMAT)
if self.closed_at else None,
"change": self.percentage_change,
"absolute_change": self.absolute_change,
}
Expand Down
1 change: 1 addition & 0 deletions investing_algorithm_framework/domain/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
'pretty_print_backtest',
'pretty_print_backtest_reports_evaluation',
'load_csv_into_dict',
'load_backtest_report',
'load_backtest_reports',
]
1 change: 0 additions & 1 deletion investing_algorithm_framework/domain/utils/csv.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import csv
import json
import shutil
import tempfile
from typing import Dict, List
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class UsTreasuryYieldDataSource(MarketDataSource):
UsTreasuryYield is a subclass of MarketDataSource.
It is used to get the US Treasury Yield data.
"""

def to_backtest_market_data_source(self) -> BacktestMarketDataSource:
pass

URL = "https://api.fiscaldata.treasury.gov/services/api/fiscal_service/" \
"v2/accounting/od/avg_interest_rates?" \
"filter=record_date:gte:2024-01-01"
Expand All @@ -22,7 +26,8 @@ def get_data(
response = requests.get(self.URL)

if response.status_code == 200:
# Extract risk-free rate from API response (e.g., 10-year Treasury yield)
# Extract risk-free rate from API response
# (e.g., 10-year Treasury yield)
treasury_yield_data = response.json()
entries = treasury_yield_data["data"]
for entry in entries:
Expand All @@ -31,11 +36,12 @@ def get_data(
print(entries[-1]["avg_interest_rate_amt"])
# print(treasury_yield_data)
# ten_year_yield = treasury_yield_data["data"][0]["value"]
# risk_free_rate = ten_year_yield / 100 # Convert percentage to decimal
# risk_free_rate = ten_year_yield / 100 # Convert
# percentage to decimal
# print("10-Year Treasury Yield (Risk-Free Rate):", risk_free_rate)
else:
print("Failed to retrieve Treasury yield data. Status code:",
response.status_code)

def to_backtest_market_data_source(self) -> BacktestMarketDataSource:
pass
pass

0 comments on commit 767d723

Please sign in to comment.