Skip to content

Commit 3723ec8

Browse files
committed
Fix order executor priority queue
1 parent 1b024ed commit 3723ec8

File tree

15 files changed

+203
-152
lines changed

15 files changed

+203
-152
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,5 @@ bumpversion.egg-info/
153153
**/databases/
154154
.vscode/
155155
.logs
156-
venv
156+
venv
157+
**/app_logs.log

investing_algorithm_framework/app/app.py

Lines changed: 154 additions & 116 deletions
Large diffs are not rendered by default.

investing_algorithm_framework/app/context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ def add_stop_loss(
12051205
self,
12061206
trade,
12071207
percentage: float,
1208-
trade_risk_type: TradeRiskType = TradeRiskType.FIXED,
1208+
trade_risk_type = TradeRiskType.FIXED,
12091209
sell_percentage: float = 100,
12101210
):
12111211
"""
@@ -1248,7 +1248,7 @@ def add_take_profit(
12481248
self,
12491249
trade,
12501250
percentage: float,
1251-
trade_risk_type: TradeRiskType = TradeRiskType.FIXED,
1251+
trade_risk_type = TradeRiskType.FIXED,
12521252
sell_percentage: float = 100,
12531253
) -> None:
12541254
"""

investing_algorithm_framework/cli/cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def cli():
2323
'--type',
2424
default="default",
2525
help="Type of app to create. "
26-
"Options are: 'default', 'default-web', 'azure-function'."
26+
"Options are: 'default', 'default_web', 'azure_function'."
2727
)
2828
@click.option(
2929
'--path', default=None, help="Path to directory to initialize the app in"
@@ -43,6 +43,8 @@ def init(type, path, replace):
4343
type (str): Type of app to create. Options are: 'default',
4444
'default-web', 'azure-function'.
4545
path (str): Path to directory to initialize the app in
46+
replace (bool): If True, existing files will be replaced.
47+
If False, existing files will not be replaced.
4648
4749
Returns:
4850
None

investing_algorithm_framework/cli/templates/app-web.py.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ load_dotenv()
99
logging.config.dictConfig(DEFAULT_LOGGING_CONFIG)
1010

1111
app = create_app(web=True)
12+
app.add_market(market="binance", initial_balance=1000, trading_symbol="EUR")
1213
algorithm = Algorithm(name="MyTradingBot")
1314
algorithm.add_strategy(MyTradingStrategy)
1415
app.add_algorithm(algorithm)

investing_algorithm_framework/cli/templates/app.py.template

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@ load_dotenv()
99
logging.config.dictConfig(DEFAULT_LOGGING_CONFIG)
1010

1111
app = create_app()
12-
app.add_portfolio_configuration(
13-
PortfolioConfiguration(
14-
initial_balance=1000,
15-
trading_symbol="EUR",
16-
market="bitvavo"
17-
)
18-
)
12+
app.add_market(market="binance", initial_balance=1000, trading_symbol="EUR")
1913
algorithm = Algorithm(name="MyTradingBot")
2014
algorithm.add_strategy(MyTradingStrategy)
2115
app.add_algorithm(algorithm)

investing_algorithm_framework/cli/templates/app_azure_function.py.template

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@ from strategies.strategy import MyTradingStrategy
88
load_dotenv()
99

1010
app = create_app()
11-
app.add_portfolio_configuration(
12-
PortfolioConfiguration(
13-
initial_balance=1000,
14-
trading_symbol="EUR",
15-
market="bitvavo"
16-
)
17-
)
11+
app.add_market(market="binance", initial_balance=1000, trading_symbol="EUR")
1812
algorithm = Algorithm(name="MyTradingBot")
1913
algorithm.add_strategy(MyTradingStrategy)
2014
app.add_algorithm(algorithm)

investing_algorithm_framework/cli/templates/app_web.py.template

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@ load_dotenv()
99
logging.config.dictConfig(DEFAULT_LOGGING_CONFIG)
1010

1111
app = create_app(web=True)
12-
app.add_portfolio_configuration(
13-
PortfolioConfiguration(
14-
initial_balance=1000,
15-
trading_symbol="EUR",
16-
market="bitvavo"
17-
)
18-
)
12+
app.add_market(market="binance", initial_balance=1000, trading_symbol="EUR")
1913
algorithm = Algorithm(name="MyTradingBot")
2014
algorithm.add_strategy(MyTradingStrategy)
2115
app.add_algorithm(algorithm)

investing_algorithm_framework/domain/order_executor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,9 @@ def supports_market(self, market):
8585
raise NotImplementedError(
8686
"Subclasses must implement this method."
8787
)
88+
89+
def __repr__(self):
90+
"""
91+
Returns a string representation of the order executor.
92+
"""
93+
return f"{self.__class__.__name__}(priority={self._priority})"

investing_algorithm_framework/domain/portfolio_provider.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ def priority(self):
2626
"""
2727
return self._priority
2828

29+
@priority.setter
30+
def priority(self, value: int):
31+
"""
32+
Sets the priority of the portfolio provider.
33+
"""
34+
self._priority = value
35+
2936
@abstractmethod
3037
def get_order(
3138
self, portfolio, order, market_credential
@@ -87,3 +94,6 @@ def supports_market(self, market) -> bool:
8794
bool: True if the market is supported, False otherwise
8895
"""
8996
raise NotImplementedError("Subclasses must implement this method.")
97+
98+
def __repr__(self):
99+
return f"{self.__class__.__name__}(priority={self.priority})"

0 commit comments

Comments
 (0)