-
Notifications
You must be signed in to change notification settings - Fork 59
/
scanner.go
73 lines (64 loc) · 2.25 KB
/
scanner.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
package ibapi
import "fmt"
// ScanData is the data retureed by IB, which matches the ScannerSubscription
type ScanData struct {
ContractDetails ContractDetails
Rank int64
Distance string
Benchmark string
Projection string
Legs string
}
func (s ScanData) String() string {
return fmt.Sprintf("Rank: %d, ContractDetails: %v, Distance: %s, Benchmark: %s, Projection: %s, Legs String: %s",
s.Rank,
s.ContractDetails,
s.Distance,
s.Benchmark,
s.Projection,
s.Legs)
}
// ScannerSubscription defines a market scanner request
type ScannerSubscription struct {
NumberOfRows int64 `default:"-1"`
Instrument string
LocationCode string
ScanCode string
AbovePrice float64 `default:"UNSETFLOAT"`
BelowPrice float64 `default:"UNSETFLOAT"`
AboveVolume int64 `default:"UNSETINT"`
MarketCapAbove float64 `default:"UNSETFLOAT"`
MarketCapBelow float64 `default:"UNSETFLOAT"`
MoodyRatingAbove string
MoodyRatingBelow string
SpRatingAbove string
SpRatingBelow string
MaturityDateAbove string
MaturityDateBelow string
CouponRateAbove float64 `default:"UNSETFLOAT"`
CouponRateBelow float64 `default:"UNSETFLOAT"`
ExcludeConvertible bool
AverageOptionVolumeAbove int64 `default:"UNSETINT"`
ScannerSettingPairs string
StockTypeFilter string
}
func (s ScannerSubscription) String() string {
return fmt.Sprintf("Instrument: %s, LocationCode: %s, ScanCode: %s",
s.Instrument,
s.LocationCode,
s.ScanCode)
}
// NewScannerSubscription create a default ScannerSubscription
func NewScannerSubscription() *ScannerSubscription {
scannerSubscription := &ScannerSubscription{}
scannerSubscription.NumberOfRows = -1
scannerSubscription.AbovePrice = UNSETFLOAT
scannerSubscription.BelowPrice = UNSETFLOAT
scannerSubscription.AboveVolume = UNSETINT
scannerSubscription.MarketCapAbove = UNSETFLOAT
scannerSubscription.MarketCapBelow = UNSETFLOAT
scannerSubscription.CouponRateAbove = UNSETFLOAT
scannerSubscription.CouponRateBelow = UNSETFLOAT
scannerSubscription.AverageOptionVolumeAbove = UNSETINT
return scannerSubscription
}