1
1
import os
2
+ from typing import Dict , Any
2
3
from unittest import TestCase
3
4
5
+ import pandas as pd
6
+
4
7
from investing_algorithm_framework import create_app , TradingStrategy , \
5
8
TimeUnit , PortfolioConfiguration , RESOURCE_DIRECTORY , Algorithm , \
6
9
MarketCredential
@@ -12,17 +15,23 @@ class StrategyOne(TradingStrategy):
12
15
time_unit = TimeUnit .SECOND
13
16
interval = 2
14
17
15
- def apply_strategy (self , context , data ):
18
+ def generate_sell_signals (self , data : Dict [str , Any ]) -> Dict [
19
+ str , pd .Series ]:
16
20
pass
17
21
22
+ def generate_buy_signals (self , data : Dict [str , Any ]) -> Dict [
23
+ str , pd .Series ]:
24
+ pass
18
25
19
26
class StrategyTwo (TradingStrategy ):
20
27
time_unit = TimeUnit .SECOND
21
28
interval = 2
22
29
23
- def apply_strategy (self , context , data ) :
30
+ def generate_sell_signals (self , data : Dict [ str , Any ]) -> Dict [ str , pd . Series ] :
24
31
pass
25
32
33
+ def generate_buy_signals (self , data : Dict [str , Any ]) -> Dict [str , pd .Series ]:
34
+ pass
26
35
27
36
class Test (TestCase ):
28
37
portfolio_configurations = [
@@ -98,34 +107,6 @@ def test_with_strategy_object(self):
98
107
self .assertTrue (app .has_run ("StrategyOne" ))
99
108
self .assertTrue (app .has_run ("StrategyTwo" ))
100
109
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
-
129
110
def test_stateless (self ):
130
111
app = create_app (config = {RESOURCE_DIRECTORY : self .resource_dir })
131
112
app .add_portfolio_provider (PortfolioProviderTest )
0 commit comments