Created
February 5, 2018 17:40
-
-
Save zaydek-old/7a99f30bc13b14a617e9de8c417e24e2 to your computer and use it in GitHub Desktop.
Example of some source code: this aggregates all US stock securities given desired parameters, e.g. price, average volume, and market cap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ traverse -open=,25k -avgv=500k -mcap=500m | |
SYMBL Name Open AvgV MCap | |
GTES Gates Industrial Corporation plc 18.76 4746935 5502345000 | |
AVYA Avaya Holdings Corp. 21.27 808037 10602883400 | |
LILAK Liberty Latin America Ltd. Class C Common Stock 22.13 834480 3807396300 | |
LFIN LongFin Corp Class A Common Stock 33.00 1278735 2399625000 | |
NMRK Newmark Group, Inc. Class A Common Stock 15.97 867653 2477118700 | |
CEIX CONSOL Energy Inc. 30.70 602684 866433400 | |
SAIL SailPoint Technologies Holdings 15.04 783591 1323225400 | |
SFIX Stitch Fix, Inc. Class A Common Stock 19.83 1267414 1945274900 | |
SOGO Sogou Inc. 9.90 3151604 1150198700 | |
AQUA Evoqua Water Technologies Corp. 22.11 747460 2330917300 | |
TERP TerraForm Power, Inc. Class A Common Stock NEW 10.96 638451 1013722300 | |
BPMP BP Midstream Partners LP 20.23 661188 2186154800 | |
REDU RISE Education Cayman Ltd American Depositary Shares 15.83 742692 800000000 | |
SE Sea Limited 11.78 1893367 2064239600 | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" | |
"time" | |
"owl.delivery/traverse/intv" | |
"owl.delivery/traverse/rbh" | |
) | |
var open, avgv, mcap intv.Interval | |
func init() { | |
log.SetFlags(0) | |
http.DefaultClient.Timeout = 10 * time.Second | |
} | |
func init() { | |
flag.CommandLine.SetOutput(ioutil.Discard) | |
flag.Usage = func() { log.Fatalln("e.g. traverse -open=,25k -avgv=500k -mcap=500m") } | |
flag.Var(&open, "open", "") | |
flag.Var(&avgv, "avgv", "") | |
flag.Var(&mcap, "mcap", "") | |
flag.Parse() | |
if len(flag.Args()) != 0 { | |
flag.Usage() | |
} | |
} | |
func main() { | |
outputC := make(chan rbh.Security) | |
go func() { | |
fmt.Print("SYMBL\tName\tOpen\tAvgV\tMCap\n") | |
for sec := range outputC { | |
if filter(sec) { | |
fmt.Printf("%s\t%s\t%0.2f\t%d\t%d\n", | |
sec.SYMBL, sec.Name, sec.Open, sec.AvgV, sec.MCap, | |
) | |
} | |
} | |
}() | |
if err := rbh.Traverse(rbh.Base+"/instruments/", outputC); err != nil { | |
log.Println(err) | |
} | |
} | |
func filter(sec rbh.Security) bool { | |
return open.Covers(int64(sec.Open)) && avgv.Covers(sec.AvgV) && mcap.Covers(sec.MCap) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment