bbgo_origin/pkg/bbgo/interact_test.go

34 lines
628 B
Go
Raw Permalink Normal View History

2022-01-14 18:52:46 +00:00
package bbgo
import (
"context"
2022-06-06 09:34:39 +00:00
"fmt"
2022-01-14 18:52:46 +00:00
"testing"
"github.com/stretchr/testify/assert"
)
type myStrategy struct {
Symbol string `json:"symbol"`
}
func (m myStrategy) ID() string {
return "mystrategy"
}
2022-06-06 09:34:39 +00:00
func (m myStrategy) InstanceID() string {
return fmt.Sprintf("%s:%s", m.ID(), m.Symbol)
}
2022-01-14 18:52:46 +00:00
func (m *myStrategy) Run(ctx context.Context, orderExecutor OrderExecutor, session *ExchangeSession) error {
return nil
}
func Test_getStrategySignature(t *testing.T) {
signature, err := getStrategySignature(&myStrategy{
Symbol: "BTCUSDT",
})
assert.NoError(t, err)
2022-06-07 02:45:55 +00:00
assert.Equal(t, "mystrategy:BTCUSDT", signature)
2022-01-14 18:52:46 +00:00
}