-
Notifications
You must be signed in to change notification settings - Fork 5
/
custom_subscription_calls.go
52 lines (41 loc) · 1.7 KB
/
custom_subscription_calls.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package deriv
import (
"context"
"github.com/ksysoev/deriv-api/schema"
)
// SubscribeTicksHistory Get historic tick data for a given symbol.
//
//nolint:gocritic // don't want to break backward compatibility for now
func (api *Client) SubscribeTicksHistory(ctx context.Context, r schema.TicksHistory) (rsp schema.TicksHistoryResp, s *Subsciption[schema.TicksHistoryResp, schema.TicksResp], err error) {
var f schema.TicksHistorySubscribe = 1
id := api.getNextRequestID()
r.ReqId = &id
r.Subscribe = &f
r.Style = schema.TicksHistoryStyleTicks
s = NewSubcription[schema.TicksHistoryResp, schema.TicksResp](ctx, api)
rsp, err = s.Start(id, r)
return
}
// SubscribeTicksHistory Get historic candles data for a given symbol.
//
//nolint:gocritic // don't want to break backward compatibility for now
func (api *Client) SubscribeCandlesHistory(ctx context.Context, r schema.TicksHistory) (rsp schema.TicksHistoryResp, s *Subsciption[schema.TicksHistoryResp, schema.TicksHistoryResp], err error) {
var f schema.TicksHistorySubscribe = 1
id := api.getNextRequestID()
r.ReqId = &id
r.Subscribe = &f
r.Style = schema.TicksHistoryStyleCandles
s = NewSubcription[schema.TicksHistoryResp, schema.TicksHistoryResp](ctx, api)
rsp, err = s.Start(id, r)
return
}
// SubscribeTransaction Subscribe to transaction notifications
func (api *Client) SubscribeTransaction(ctx context.Context, r schema.Transaction) (rsp schema.TransactionResp, s *Subsciption[schema.TransactionResp, schema.TransactionResp], err error) {
var f schema.TransactionSubscribe = 1
id := api.getNextRequestID()
r.ReqId = &id
r.Subscribe = f
s = NewSubcription[schema.TransactionResp, schema.TransactionResp](ctx, api)
rsp, err = s.Start(id, r)
return
}