Skip to content

Commit 21d40ba

Browse files
committed
Fix flake8 warnings
1 parent 6f05dd7 commit 21d40ba

File tree

16 files changed

+52
-40
lines changed

16 files changed

+52
-40
lines changed

investing_algorithm_framework/app/app.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ def initialize(self):
243243
portfolio_snap_service = self.container \
244244
.portfolio_snapshot_service()
245245
market_cred_service = self.container.market_credential_service()
246+
portfolio_provider_lookup = \
247+
self.container.portfolio_provider_lookup()
246248
# Override the portfolio service with the backtest
247249
# portfolio service
248250
self.container.portfolio_service.override(
@@ -254,8 +256,7 @@ def initialize(self):
254256
portfolio_repository=self.container.portfolio_repository(),
255257
portfolio_configuration_service=portfolio_conf_service,
256258
portfolio_snapshot_service=portfolio_snap_service,
257-
portfolio_provider_lookup=self.container\
258-
.portfolio_provider_lookup()
259+
portfolio_provider_lookup=portfolio_provider_lookup
259260
)
260261
)
261262

@@ -1080,7 +1081,8 @@ def _initialize_portfolios(self):
10801081
# Check if there are matching portfolio configurations
10811082
for portfolio in portfolios:
10821083
logger.info(
1083-
f"Checking if there is an matching portfolio configuration "
1084+
f"Checking if there is an matching portfolio "
1085+
"configuration "
10841086
f"for portfolio {portfolio.identifier}"
10851087
)
10861088
portfolio_configuration = \
@@ -1094,7 +1096,7 @@ def _initialize_portfolios(self):
10941096
f"existing portfolio {portfolio.market}, "
10951097
f"please make sure that you have configured your "
10961098
f"app with the right portfolio configurations "
1097-
f"for the existing portfolios."
1099+
f"for the existing portfolios."
10981100
f"If you want to create a new portfolio, please "
10991101
f"remove the existing database (WARNING!!: this "
11001102
f"will remove all existing history of your "
@@ -1118,8 +1120,8 @@ def _initialize_portfolios(self):
11181120
# Register a portfolio provider for the portfolio
11191121
portfolio_provider_lookup \
11201122
.register_portfolio_provider_for_market(
1121-
portfolio_configuration.market
1122-
)
1123+
portfolio_configuration.market
1124+
)
11231125
initial_balance = portfolio_configuration\
11241126
.initial_balance
11251127

@@ -1167,7 +1169,8 @@ def _initialize_portfolios(self):
11671169
if market_credential is None:
11681170
raise ImproperlyConfigured(
11691171
f"No market credential found for existing "
1170-
f"portfolio {portfolio_configuration.market} with market "
1172+
f"portfolio {portfolio_configuration.market} "
1173+
"with market "
11711174
"Cannot initialize portfolio configuration."
11721175
)
11731176

investing_algorithm_framework/app/context.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -729,12 +729,12 @@ def close_position(
729729
)
730730

731731
for order in self.order_service \
732-
.get_all(
733-
{
734-
"position": position.id,
735-
"status": OrderStatus.OPEN.value
736-
}
737-
):
732+
.get_all(
733+
{
734+
"position": position.id,
735+
"status": OrderStatus.OPEN.value
736+
}
737+
):
738738
self.order_service.cancel_order(order)
739739

740740
target_symbol = position.get_symbol()
@@ -1150,7 +1150,9 @@ def count_trades(
11501150

11511151
return self.trade_service.count(query_params)
11521152

1153-
def get_pending_trades(self, target_symbol=None, market=None) -> List[Trade]:
1153+
def get_pending_trades(
1154+
self, target_symbol=None, market=None
1155+
) -> List[Trade]:
11541156
"""
11551157
Function to get all pending trades. This function will return all
11561158
pending trades that match the specified query parameters. If the
@@ -1164,7 +1166,8 @@ def get_pending_trades(self, target_symbol=None, market=None) -> List[Trade]:
11641166
market: The market of the asset
11651167
11661168
Returns:
1167-
List[Trade]: A list of pending trades that match the query parameters
1169+
List[Trade]: A list of pending trades that match
1170+
the query parameters
11681171
"""
11691172
return self.trade_service.get_all(
11701173
{

investing_algorithm_framework/dependency_container.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
MarketCredentialService, TradeService, PortfolioSyncService, \
1515
OrderExecutorLookup, PortfolioProviderLookup
1616

17+
1718
def setup_dependency_container(app, modules=None, packages=None):
1819
app.container = DependencyContainer()
1920
app.container.wire(modules=modules, packages=packages)

investing_algorithm_framework/domain/models/trade/trade.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from dateutil.parser import parse
2-
from numpy.ma.core import filled
32

43
from investing_algorithm_framework.domain.models.base_model import BaseModel
54
from investing_algorithm_framework.domain.models.order import OrderSide, Order

investing_algorithm_framework/infrastructure/data_providers/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .ccxt import CCXTDataProvider
22

3+
34
def get_default_data_providers():
45
"""
56
Function to get the default data providers.
@@ -11,6 +12,7 @@ def get_default_data_providers():
1112
CCXTDataProvider(),
1213
]
1314

15+
1416
__all__ = [
1517
'CCXTDataProvider',
1618
'get_default_data_providers',

investing_algorithm_framework/infrastructure/data_providers/csv.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import polars
22
from datetime import datetime
3-
from typing import List
43
from investing_algorithm_framework.domain import DataProvider, \
54
TradingDataType, OperationalException
65

@@ -53,7 +52,7 @@ def has_data(
5352
) -> bool:
5453

5554
if symbol == self.symbol and market == self.market and \
56-
data_type == self.data_type and time_frame == self.time_frame:
55+
data_type == self.data_type and time_frame == self.time_frame:
5756
return True
5857

5958
return False

investing_algorithm_framework/infrastructure/models/order/order_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ def __repr__(self):
4141
return f"<SQLOrderMetadata(id={self.id}, order_id={self.order_id}, " \
4242
f"trade_id={self.trade_id}, stop_loss_id={self.stop_loss_id}, "\
4343
f"take_profit_id={self.take_profit_id}, amount={self.amount}, "\
44-
f"amount_pending={self.amount_pending})>"
44+
f"amount_pending={self.amount_pending})>"

investing_algorithm_framework/infrastructure/order_executors/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .ccxt_order_executor import CCXTOrderExecutor
22

3+
34
def get_default_order_executors():
45
"""
56
Function to get the default order executors.
@@ -11,6 +12,7 @@ def get_default_order_executors():
1112
CCXTOrderExecutor(),
1213
]
1314

15+
1416
__all__ = [
1517
'CCXTOrderExecutor',
1618
'get_default_order_executors',

investing_algorithm_framework/infrastructure/order_executors/ccxt_order_executor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def execute_order(self, portfolio, order, market_credential) -> Order:
3939
if OrderType.LIMIT.equals(order_type):
4040
if OrderSide.BUY.equals(order_side):
4141

42-
# Check if the exchange supports the createLimitBuyOrder method
42+
# Check if the exchange supports the
43+
# createLimitBuyOrder method
4344
if not hasattr(exchange, "createLimitBuyOrder"):
4445
raise OperationalException(
4546
f"Exchange {market} does not support "
@@ -51,7 +52,8 @@ def execute_order(self, portfolio, order, market_credential) -> Order:
5152
symbol, amount, price,
5253
)
5354
else:
54-
# Check if the exchange supports the createLimitSellOrder method
55+
# Check if the exchange supports
56+
# the createLimitSellOrder method
5557
if not hasattr(exchange, "createLimitSellOrder"):
5658
raise OperationalException(
5759
f"Exchange {market} does not support "

investing_algorithm_framework/infrastructure/portfolio_providers/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .ccxt_portfolio_provider import CCXTPortfolioProvider
22

3+
34
def get_default_portfolio_providers():
45
"""
56
Function to get the default portfolio providers.

0 commit comments

Comments
 (0)