forked from thrasher-corp/gocryptotrader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent_manager_types.go
74 lines (63 loc) · 1.8 KB
/
event_manager_types.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package engine
import (
"errors"
"sync"
"time"
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
)
// Event const vars
const (
ItemPrice = "PRICE"
ItemOrderbook = "ORDERBOOK"
ConditionGreaterThan = ">"
ConditionGreaterThanOrEqual = ">="
ConditionLessThan = "<"
ConditionLessThanOrEqual = "<="
ConditionIsEqual = "=="
ActionSMSNotify = "SMS"
ActionConsolePrint = "CONSOLE_PRINT"
ActionTest = "ACTION_TEST"
defaultSleepDelay = time.Millisecond * 500
)
// vars related to events package
var (
EventSleepDelay = defaultSleepDelay
errInvalidItem = errors.New("invalid item")
errInvalidCondition = errors.New("invalid conditional option")
errInvalidAction = errors.New("invalid action")
errExchangeDisabled = errors.New("desired exchange is disabled")
errNilEvent = errors.New("nil event received")
errNilComManager = errors.New("nil communications manager received")
errTickerLastPriceZero = errors.New("ticker last price is 0")
)
// EventConditionParams holds the event condition variables
type EventConditionParams struct {
Condition string
Price float64
CheckBids bool
CheckAsks bool
OrderbookAmount float64
}
// Event struct holds the event variables
type Event struct {
ID int64
Exchange string
Item string
Condition EventConditionParams
Pair currency.Pair
Asset asset.Item
Action string
Executed bool
}
// eventManager holds communication manager data
type eventManager struct {
started int32
comms iCommsManager
events []Event
verbose bool
sleepDelay time.Duration
exchangeManager iExchangeManager
shutdown chan struct{}
m sync.Mutex
}