++
This commit is contained in:
+19
-16
@@ -6,16 +6,15 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/valyala/fasthttp"
|
||||
)
|
||||
|
||||
const (
|
||||
baseURL = "https://api.worldquantbrain.com"
|
||||
baseURL = "https://api.worldquantbrain.com"
|
||||
zeroStreakThreshold = 5 * 252
|
||||
requiredDays = 2920
|
||||
requiredDays = 2920
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
@@ -25,17 +24,17 @@ type Client struct {
|
||||
}
|
||||
|
||||
type AlphaRecord struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
DateCreated string `json:"dateCreated"`
|
||||
Sharpe float64 `json:"sharpe"`
|
||||
Fitness float64 `json:"fitness"`
|
||||
Turnover float64 `json:"turnover"`
|
||||
Margin float64 `json:"margin"`
|
||||
LongCount float64 `json:"longCount"`
|
||||
ShortCount float64 `json:"shortCount"`
|
||||
Decay int `json:"decay"`
|
||||
Code string `json:"code"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
DateCreated string `json:"dateCreated"`
|
||||
Sharpe float64 `json:"sharpe"`
|
||||
Fitness float64 `json:"fitness"`
|
||||
Turnover float64 `json:"turnover"`
|
||||
Margin float64 `json:"margin"`
|
||||
LongCount float64 `json:"longCount"`
|
||||
ShortCount float64 `json:"shortCount"`
|
||||
Decay int `json:"decay"`
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
type AlphaResponse struct {
|
||||
@@ -59,7 +58,11 @@ type PnlResponse struct {
|
||||
|
||||
func NewClient(username, password string) *Client {
|
||||
return &Client{
|
||||
client: &fasthttp.Client{},
|
||||
client: &fasthttp.Client{
|
||||
ReadTimeout: 60 * time.Second,
|
||||
WriteTimeout: 10 * time.Second,
|
||||
MaxIdleConnDuration: 120 * time.Second,
|
||||
},
|
||||
username: username,
|
||||
password: password,
|
||||
}
|
||||
@@ -205,7 +208,7 @@ func GetAlphas(c *Client, startDate, endDate string, sharpeTh, fitnessTh float64
|
||||
|
||||
for _, item := range alphaResp.Results {
|
||||
alphaID := item.ID
|
||||
name := item.Name
|
||||
_ = item.Name // avoid unused variable
|
||||
dateCreated := item.DateCreated
|
||||
sharpe := getFloat(item.Is, "sharpe")
|
||||
fitness := getFloat(item.Is, "fitness")
|
||||
|
||||
Reference in New Issue
Block a user