@@ -156,6 +156,63 @@ func (s *SpotStrategyBase) Name() string {
156
156
return s .name
157
157
}
158
158
159
+ // 组合策略,期现等
160
+ // CStrategyBase Strategy base class
161
+ type CStrategyBase struct {
162
+ self interface {}
163
+ name string
164
+ tradeMode TradeMode
165
+ Exchanges []Exchange
166
+ SpotExchanges []SpotExchange
167
+ }
168
+
169
+ // SetSelf 设置 self 对象
170
+ func (s * CStrategyBase ) SetSelf (self Strategy ) error {
171
+ s .self = self .(interface {})
172
+ return nil
173
+ }
174
+
175
+ // Setup Setups the exchanges
176
+ func (s * CStrategyBase ) Setup (mode TradeMode , exchanges ... interface {}) error { // Exchange
177
+ if len (exchanges ) == 0 {
178
+ return fmt .Errorf ("no exchanges" )
179
+ }
180
+ s .tradeMode = mode
181
+ for _ , v := range exchanges {
182
+ if ex , ok := v .(Exchange ); ok {
183
+ s .Exchanges = append (s .Exchanges , ex )
184
+ continue
185
+ }
186
+
187
+ if ex , ok := v .(SpotExchange ); ok {
188
+ s .SpotExchanges = append (s .SpotExchanges , ex )
189
+ }
190
+ }
191
+ return nil
192
+ }
193
+
194
+ // SetOptions Sets the options for the strategy
195
+ func (s * CStrategyBase ) SetOptions (options map [string ]interface {}) error {
196
+ return setOptions (s .self , options )
197
+ }
198
+
199
+ // GetOptions Returns the options of strategy
200
+ func (s * CStrategyBase ) GetOptions () (optionMap map [string ]* StrategyOption ) {
201
+ return getOptions (s .self )
202
+ }
203
+
204
+ func (s * CStrategyBase ) TradeMode () TradeMode {
205
+ return s .tradeMode
206
+ }
207
+
208
+ func (s * CStrategyBase ) SetName (name string ) {
209
+ s .name = name
210
+ }
211
+
212
+ func (s * CStrategyBase ) Name () string {
213
+ return s .name
214
+ }
215
+
159
216
// SetOptions Sets the options for the strategy
160
217
func setOptions (s interface {}, options map [string ]interface {}) error {
161
218
if len (options ) == 0 {
0 commit comments