Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oqamar cleanup1 #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions historical_data_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "fmt"

// HistoricalDataManager .
type HistoricalDataManager struct {
AbstractManager
*AbstractManager
request RequestHistoricalData
histData []HistoricalDataItem
}
Expand All @@ -18,7 +18,7 @@ func NewHistoricalDataManager(e *Engine, request RequestHistoricalData) (*Histor

request.id = e.NextRequestID()
m := &HistoricalDataManager{
AbstractManager: *am,
AbstractManager: am,
request: request,
}

Expand Down
18 changes: 8 additions & 10 deletions wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ func readInt(b *bufio.Reader) (int64, error) {
if str == "" {
return math.MaxInt64, nil
}
i, err := strconv.ParseInt(str, 10, 64)
return i, err
return strconv.ParseInt(str, 10, 64)
}

// readIntList reads an IB pipe-separated string of integers into a Go slice.
Expand Down Expand Up @@ -83,8 +82,7 @@ func readFloat(b *bufio.Reader) (float64, error) {
if str == "" {
return math.MaxFloat64, nil
}
f, err := strconv.ParseFloat(str, 64)
return f, err
return strconv.ParseFloat(str, 64)
}

// readBool is equivalent of IB API EReader.readBoolFromInt.
Expand Down Expand Up @@ -122,13 +120,13 @@ func readTime(b *bufio.Reader, f timeFmt) (t time.Time, err error) {
if f == timeReadLocalDateTime {
format := "20060102 15:04:05"
if len(timeString) < len(format) {
return time.Now(), fmt.Errorf("ibgo: '%s' too short to be datetime format '%s'", timeString, format)
return t, fmt.Errorf("ibgo: '%s' too short to be datetime format '%s'", timeString, format)
Comment on lines -125 to +123
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for this change? As t is never set, so it would be the default value.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just trying to make consistent with idiomatic Go. For example, in the case of:
t, err := time.Parse("20060102", "bad date")
The value of t is the default value

}

// Truncate any portion this parse does not require (ie timezones)
fields := strings.Fields(timeString)
if len(fields) < 2 {
return time.Now(), fmt.Errorf("ibgo: '%s' does not contain expected whitespace for datetime format '%s'", timeString, format)
return t, fmt.Errorf("ibgo: '%s' does not contain expected whitespace for datetime format '%s'", timeString, format)
Comment on lines -131 to +129
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

}
timeString = fields[0] + " " + fields[1]

Expand All @@ -138,7 +136,7 @@ func readTime(b *bufio.Reader, f timeFmt) (t time.Time, err error) {
if f == timeReadLocalDate {
format := "20060102"
if len(timeString) != len(format) {
return time.Now(), fmt.Errorf("ibgo: '%s' wrong length to be datetime format '%s'", timeString, format)
return t, fmt.Errorf("ibgo: '%s' wrong length to be date format '%s'", timeString, format)
Comment on lines -141 to +139
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

}
return time.ParseInLocation(format, timeString, time.Local)
}
Expand All @@ -156,7 +154,7 @@ func readTime(b *bufio.Reader, f timeFmt) (t time.Time, err error) {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing consistent change if returning error.

}

return time.Now(), fmt.Errorf("ibgo: unsupported read time format '%v'", f)
return t, fmt.Errorf("ibgo: unsupported read time format '%v'", f)
Comment on lines -159 to +157
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above


}

Expand Down Expand Up @@ -212,11 +210,11 @@ func writeTime(b *bytes.Buffer, t time.Time, f timeFmt) error {
}

func detectTime(timeString string) (timeFmt, error) {
if len(timeString) == len("14:52") && strings.Contains(timeString, ":") {
if len(timeString) == len("15:04") && strings.Contains(timeString, ":") {
return timeReadLocalTime, nil
}

if len(timeString) == len("14:52:02") && strings.Contains(timeString, ":") {
if len(timeString) == len("15:04:05") && strings.Contains(timeString, ":") {
return timeReadLocalTime, nil
}

Expand Down