First plot

This commit is contained in:
Luke I. Wilson
2023-05-16 20:10:49 -05:00
parent 48313cde01
commit 1110144cea
5 changed files with 76 additions and 0 deletions

View File

@@ -1,6 +1,9 @@
package autotrader
import (
"os/exec"
"runtime"
"golang.org/x/exp/constraints"
)
@@ -46,3 +49,21 @@ func LeverageToMargin(leverage float64) float64 {
func MarginToLeverage(margin float64) float64 {
return 1 / margin
}
// Open opens the specified URL in the default browser of the user.
func Open(url string) error {
var cmd string
var args []string
switch runtime.GOOS {
case "windows":
cmd = "cmd"
args = []string{"/c", "start"}
case "darwin":
cmd = "open"
default: // "linux", "freebsd", "openbsd", "netbsd"
cmd = "xdg-open"
}
args = append(args, url)
return exec.Command(cmd, args...).Start()
}