11import os
2+ from typing import Dict , Any
23from unittest import TestCase
34
5+ import pandas as pd
6+
47from investing_algorithm_framework import create_app , TradingStrategy , \
58 TimeUnit , PortfolioConfiguration , RESOURCE_DIRECTORY , Algorithm , \
69 MarketCredential
@@ -12,17 +15,23 @@ class StrategyOne(TradingStrategy):
1215 time_unit = TimeUnit .SECOND
1316 interval = 2
1417
15- def apply_strategy (self , context , data ):
18+ def generate_sell_signals (self , data : Dict [str , Any ]) -> Dict [
19+ str , pd .Series ]:
1620 pass
1721
22+ def generate_buy_signals (self , data : Dict [str , Any ]) -> Dict [
23+ str , pd .Series ]:
24+ pass
1825
1926class StrategyTwo (TradingStrategy ):
2027 time_unit = TimeUnit .SECOND
2128 interval = 2
2229
23- def apply_strategy (self , context , data ) :
30+ def generate_sell_signals (self , data : Dict [ str , Any ]) -> Dict [ str , pd . Series ] :
2431 pass
2532
33+ def generate_buy_signals (self , data : Dict [str , Any ]) -> Dict [str , pd .Series ]:
34+ pass
2635
2736class Test (TestCase ):
2837 portfolio_configurations = [
@@ -98,34 +107,6 @@ def test_with_strategy_object(self):
98107 self .assertTrue (app .has_run ("StrategyOne" ))
99108 self .assertTrue (app .has_run ("StrategyTwo" ))
100109
101- def test_with_decorator (self ):
102- app = create_app (config = {RESOURCE_DIRECTORY : self .resource_dir })
103- app .add_portfolio_provider (PortfolioProviderTest )
104- app .add_order_executor (OrderExecutorTest )
105- app .container .portfolio_configuration_service ().clear ()
106- app .add_portfolio_configuration (
107- PortfolioConfiguration (
108- market = "BINANCE" ,
109- trading_symbol = "EUR" ,
110- )
111- )
112- app .add_market_credential (
113- MarketCredential (
114- market = "BINANCE" ,
115- api_key = random_string (10 ),
116- secret_key = random_string (10 )
117- )
118- )
119- algorithm = Algorithm ()
120-
121- @app .strategy (time_unit = TimeUnit .SECOND , interval = 1 )
122- def run_strategy (context , data ):
123- pass
124-
125- app .add_algorithm (algorithm )
126- app .run (number_of_iterations = 1 )
127- self .assertTrue (app .has_run ("run_strategy" ))
128-
129110 def test_stateless (self ):
130111 app = create_app (config = {RESOURCE_DIRECTORY : self .resource_dir })
131112 app .add_portfolio_provider (PortfolioProviderTest )
0 commit comments