Skip to content

Commit

Permalink
Fix portfolio history format
Browse files Browse the repository at this point in the history
  • Loading branch information
ttt733 committed Feb 28, 2020
1 parent 8dcca49 commit 954032a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 6 additions & 4 deletions alpaca/entities.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,12 @@ type AccountActvity struct {
}

type PortfolioHistory struct {
Arrays []interface{} `json:"arrays"`
Attributes []map[string]string `json:"attributes"`
Timeframe RangeFreq `json:"timeframe"`
BaseValue float64 `json:"base_value"`
BaseValue decimal.Decimal `json:"base_value"`
Equity []decimal.Decimal `json:"equity"`
ProfitLoss []decimal.Decimal `json:"profit_loss"`
ProfitLossPct []decimal.Decimal `json:"profit_loss_pct"`
Timeframe RangeFreq `json:"timeframe"`
Timestamp []int64 `json:"timestamp"`
}

type PlaceOrderRequest struct {
Expand Down
12 changes: 11 additions & 1 deletion alpaca/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,17 @@ func (c *Client) GetPortfolioHistory(startDate, endDate *time.Time, period *Hist
}
q.Set("extended", strconv.FormatBool(extended))

return &PortfolioHistory{}, nil
resp, err := c.get(u)
if err != nil {
return nil, err
}

portfolioHistory := PortfolioHistory{}
if err = unmarshal(resp, &portfolioHistory); err != nil {
return nil, err
}

return &portfolioHistory, nil
}

// ListPositions lists the account's open positions.
Expand Down

0 comments on commit 954032a

Please sign in to comment.