Skip to content

Commit 8bad859

Browse files
committed
Fix flake warnings
1 parent 5cd079f commit 8bad859

File tree

11 files changed

+44
-88
lines changed

11 files changed

+44
-88
lines changed

investing_algorithm_framework/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@
7878
"Context",
7979
"APPLICATION_DIRECTORY",
8080
"download"
81-
]
81+
]

investing_algorithm_framework/domain/data_provider.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, List
1+
from typing import List
22
from abc import ABC, abstractmethod
33
from datetime import datetime
44
from investing_algorithm_framework.domain import TradingDataType, TimeFrame
@@ -45,9 +45,9 @@ def __init__(
4545
symbol: str = None,
4646
markets: list = None,
4747
priority: int = 0,
48-
time_frame = None,
49-
window_size = None,
50-
storage_path = None,
48+
time_frame=None,
49+
window_size=None,
50+
storage_path=None,
5151
market_credentials: List = None,
5252
):
5353
"""
@@ -113,7 +113,7 @@ def has_data(
113113
time_frame: str = None,
114114
start_date: datetime = None,
115115
end_date: datetime = None,
116-
window_size = None,
116+
window_size=None,
117117
) -> None:
118118
"""
119119
Checks if the data provider has data for the given parameters.
@@ -130,9 +130,9 @@ def get_data(
130130
time_frame: str = None,
131131
start_date: datetime = None,
132132
end_date: datetime = None,
133-
storage_path = None,
134-
window_size = None,
135-
pandas = False,
133+
storage_path=None,
134+
window_size=None,
135+
pandas=False,
136136
):
137137
"""
138138
Fetches data for a given symbol and date range.
@@ -147,7 +147,7 @@ def pre_pare_backtest_data(
147147
symbol: str = None,
148148
market: str = None,
149149
time_frame: str = None,
150-
window_size = None,
150+
window_size=None,
151151
) -> None:
152152
"""
153153
Prepares backtest data for a given symbol and date range.
@@ -163,8 +163,8 @@ def get_backtest_data(
163163
time_frame: str = None,
164164
backtest_start_date: datetime = None,
165165
backtest_end_date: datetime = None,
166-
window_size = None,
167-
pandas = False,
166+
window_size=None,
167+
pandas=False,
168168
) -> None:
169169
"""
170170
Fetches backtest data for a given symbol and date range.

investing_algorithm_framework/domain/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def to_response(self):
6161
"message": self.error_message
6262
}
6363

64+
6465
class NetworkError(Exception):
6566
"""
6667
Class NetworkError: Exception class indicating a problem occurred

investing_algorithm_framework/domain/models/backtesting/backtest_report.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Set, Dict
1+
from typing import List, Set
22
from datetime import datetime
33
from logging import getLogger
44

@@ -503,17 +503,6 @@ def from_dict(data):
503503

504504
return report
505505

506-
def get_trades(self, symbol=None):
507-
"""
508-
Function to get trades. If a symbol is provided, it will
509-
return the trades for that symbol. If no symbol is provided,
510-
it will return all the trades.
511-
"""
512-
if symbol is None:
513-
return self.trades
514-
515-
return [trade for trade in self.trades if trade.symbol == symbol]
516-
517506
def get_profit(self) -> float:
518507
return self._total_net_gain
519508

@@ -635,7 +624,6 @@ def get_orders(
635624
if order.created_at < created_at_lt
636625
]
637626

638-
639627
if target_symbol is not None:
640628
selection = [
641629
order for order in selection
@@ -700,7 +688,6 @@ def get_symbols(self) -> Set[str]:
700688
"""
701689
unique_symbols = set()
702690

703-
704691
for order in self.orders:
705692
if order.target_symbol not in self.symbols:
706693
unique_symbols.add(order.target_symbol)

investing_algorithm_framework/domain/order_executor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ def market_credentials(self, credentials):
2929
Args:
3030
value (dict): A dictionary containing the market credentials.
3131
"""
32-
self._market_credentials = value
33-
32+
self._market_credentials = credentials
3433

3534
@abstractmethod
3635
def execute_order(self, order):

investing_algorithm_framework/domain/portfolio_provider.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ class PortfolioProvider(ABC):
88
99
Attributes:
1010
portfolio_id (str): The unique identifier for the portfolio.
11-
user_id (str): The unique identifier for the user associated with the portfolio.
11+
user_id (str): The unique identifier for the user associated
12+
with the portfolio.
1213
balance (float): The current balance of the portfolio.
13-
assets (dict): A dictionary containing the assets in the portfolio and their quantities.
14+
assets (dict): A dictionary containing the assets in the
15+
portfolio and their quantities.
1416
"""
1517

1618
@abstractmethod

investing_algorithm_framework/domain/utils/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from .backtesting import pretty_print_backtest, load_backtest_report, \
22
pretty_print_backtest_reports_evaluation, load_backtest_reports, \
3-
get_backtest_report, pretty_print_positions, pretty_print_trades, pretty_print_orders
3+
get_backtest_report, pretty_print_positions, pretty_print_trades, \
4+
pretty_print_orders
45
from .csv import get_total_amount_of_rows, append_dict_as_row_to_csv, \
56
add_column_headers_to_csv, csv_to_list, load_csv_into_dict
67
from .random import random_string

investing_algorithm_framework/download_data.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from dateutil import parser
2-
from datetime import datetime
32
from investing_algorithm_framework.services import DataProviderService, \
43
ConfigurationService, MarketCredentialService
54
from investing_algorithm_framework.infrastructure import \
@@ -8,8 +7,8 @@
87

98
def download(
109
symbol: str,
11-
market = None,
12-
date = None,
10+
market=None,
11+
date=None,
1312
time_frame: str = None,
1413
data_type: str = "ohlcv",
1514
start_date: str = None,
@@ -69,17 +68,3 @@ def download(
6968
save=save,
7069
storage_path=storage_path
7170
)
72-
73-
if __name__ == "__main__":
74-
# Example usage
75-
data = download(
76-
symbol="DOT/EUR",
77-
market="bitvavo",
78-
data_type="ohlcv",
79-
window_size=200,
80-
pandas=False,
81-
save=False,
82-
storage_path="./data",
83-
time_frame="1d",
84-
)
85-
print(len(data))

investing_algorithm_framework/infrastructure/data_providers/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def get_default_data_providers():
1212
CCXTDataProvider(),
1313
]
1414

15+
1516
__all__ = [
1617
'CCXTDataProvider',
1718
'get_default_data_providers',

investing_algorithm_framework/infrastructure/data_providers/ccxt.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
logger = logging.getLogger("investing_algorithm_framework")
1414

1515

16-
1716
class CCXTDataProvider(DataProvider):
1817
"""
1918
"""
@@ -29,7 +28,7 @@ def __init__(
2928
symbol=None,
3029
time_frame=None,
3130
window_size=None,
32-
priority = 1
31+
priority=1
3332
):
3433
super().__init__(
3534
data_type=data_type,
@@ -134,12 +133,13 @@ def has_data(
134133
symbols = list(symbols.keys())
135134
return symbol in symbols
136135

137-
except ccxt.NetworkError as e:
136+
except ccxt.NetworkError:
138137
raise NetworkError(
139138
"Network error occurred, make sure you have "
140139
"an active internet connection"
141140
)
142-
except Exception as e:
141+
142+
except Exception:
143143
return False
144144

145145
def get_data(
@@ -161,15 +161,17 @@ def get_data(
161161

162162
if market is None:
163163
raise OperationalException(
164-
"Market is not set. Please set the market before calling get_data."
164+
"Market is not set. Please set the market "
165+
"before calling get_data."
165166
)
166167

167168
if symbol is None:
168169
symbol = self.symbol
169170

170171
if symbol is None:
171172
raise OperationalException(
172-
"Symbol is not set. Please set the symbol before calling get_data."
173+
"Symbol is not set. Please set the symbol "
174+
"before calling get_data."
173175
)
174176

175177
if data_type is None:
@@ -195,7 +197,6 @@ def get_data(
195197
if end_date is None:
196198
end_date = datetime.now(tz=timezone.utc)
197199

198-
199200
if start_date is None:
200201

201202
if date is not None:
@@ -309,4 +310,4 @@ def get_ohlcv(
309310

310311
def create_start_date(self, end_date, time_frame, window_size):
311312
minutes = TimeFrame.from_value(time_frame).amount_of_minutes
312-
return end_date - timedelta(minutes=window_size * minutes)
313+
return end_date - timedelta(minutes=window_size * minutes)

0 commit comments

Comments
 (0)