Skip to content

Commit 368de8b

Browse files
authored
fix for annoying volatility filter (#15)
* fixes * fixes * fixes * fixes
1 parent e770a99 commit 368de8b

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

.github/workflows/docker_image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Docker Image CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [ main, debug ]
66
tags:
77
- v*
88
pull_request:

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
.PHONY: help build clean
1+
.PHONY: help build build-local clean
22

33
.DEFAULT_GOAL := help
44

5+
build-local:
6+
go build -trimpath -o ./bin/freqtrade-proxy
7+
58
build: ## build binaries
69
go build -trimpath -o ./bin/freqtrade-proxy-darwin-amd64
710
for arch in "linux/amd64" "linux/arm/v6" "linux/arm/v7" "linux/arm64" ; do \

proxy/kucoin/kucoin.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,19 @@ type subscriptionManager struct {
2121
clients []*ws
2222
rl ratelimit.Limiter
2323
l *sync.Mutex
24+
subs map[string]struct{}
2425
}
2526

2627
func (m *subscriptionManager) Subscribe(svc *sdk.ApiService, msg *sdk.WebSocketSubscribeMessage, store *store.Store) {
2728
m.l.Lock()
2829
defer m.l.Unlock()
2930

31+
if _, ok := m.subs[msg.Topic]; ok {
32+
return
33+
}
34+
35+
m.subs[msg.Topic] = struct{}{}
36+
3037
for i, c := range m.clients {
3138
if c.count == 250 {
3239
continue
@@ -87,7 +94,7 @@ func New(s *store.Store) *kucoin {
8794
instance := &kucoin{
8895
client: fasthttp.Client{},
8996
store: s,
90-
subscriptionManager: &subscriptionManager{clients: nil, rl: ratelimit.New(9), l: new(sync.Mutex)},
97+
subscriptionManager: &subscriptionManager{clients: nil, rl: ratelimit.New(9), l: new(sync.Mutex), subs: map[string]struct{}{}},
9198
}
9299

93100
svc := sdk.NewApiService(sdk.ApiKeyVersionOption(sdk.ApiKeyVersionV2))
@@ -178,8 +185,7 @@ func (kucoin *kucoin) getKlines(pair string, timeframe string, startAt int64, en
178185
break
179186
}
180187

181-
logrus.Warn(i)
182-
if i == retryCount {
188+
if i == retryCount || !strings.HasPrefix(resp.Code, "429") {
183189
return sdk.KLinesModel{}, resp, err
184190
}
185191

@@ -232,7 +238,7 @@ func (kucoin *kucoin) truncateTs(timeframe string, ts time.Time) time.Time {
232238
type apiResp struct {
233239
Code string `json:"code"`
234240
RawData json.RawMessage `json:"data,omitempty"`
235-
Message string `json:"msg"`
241+
Message string `json:"msg,omitempty"`
236242
}
237243

238244
func (resp *apiResp) json() []byte {

store/store.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,6 @@ func (store *Store) Get(exchange string, pair string, timeframe string, from tim
243243
logrus.Panic()
244244
}
245245

246-
if fromCandle.Ts == 0 {
247-
if err := tx.Get(&fromCandle, store.selectFirstCandleAfterTs(exchange, pair, timeframe, from.Unix())); err != nil && !errors.Is(err, sql.ErrNoRows) {
248-
logrus.Panic()
249-
}
250-
}
251-
252246
if fromCandle.Ts == 0 {
253247
return nil
254248
}

0 commit comments

Comments
 (0)