mirror of
https://github.com/lukewilson2002/autotrader.git
synced 2025-08-02 21:19:33 +00:00
Display stats on returns
This commit is contained in:
5
utils.go
5
utils.go
@@ -9,6 +9,11 @@ import (
|
||||
|
||||
const floatComparisonTolerance = float64(1e-6)
|
||||
|
||||
// Crossover returns true if the latest a value crosses above the latest b value, but only if it just happened. For example, if a series is [1, 2, 3, 4, 5] and b series is [1, 2, 3, 4, 3], then Crossover(a, b) returns false because the latest a value is 5 and the latest b value is 3. However, if a series is [1, 2, 3, 4, 5] and b series is [1, 2, 3, 4, 6], then Crossover(a, b) returns true because the latest a value is 5 and the latest b value is 6
|
||||
func Crossover(a, b Series) bool {
|
||||
return a.Float(-1) > b.Float(-1) && a.Float(-2) <= b.Float(-2)
|
||||
}
|
||||
|
||||
// EasyIndex returns an index to the `n` -length object that allows for negative indexing. For example, EasyIndex(-1, 5) returns 4. This is similar to Python's negative indexing. The return value may be less than zero if (-i) > n.
|
||||
func EasyIndex(i, n int) int {
|
||||
if i < 0 {
|
||||
|
Reference in New Issue
Block a user