Closed harrysun0 closed 5 months ago
Everytime I use CloseAllPositions function, there is always an error "parse error: expected string near offset 30 of '200'"
for example
func (c *Common) CloseAllPositions() error { _, err := c.TradeClient.CloseAllPositions(alpaca.CloseAllPositionsRequest{ CancelOrders: true, }) return err }
it seems this error occurs when unmarshaling response body
// CloseAllPositions liquidates all open positions at market price. func (c *Client) CloseAllPositions(req CloseAllPositionsRequest) ([]Order, error) { u, err := url.Parse(fmt.Sprintf("%s/%s/positions", c.opts.BaseURL, apiVersion)) if err != nil { return nil, err } q := u.Query() q.Set("cancel_orders", strconv.FormatBool(req.CancelOrders)) u.RawQuery = q.Encode() resp, err := c.delete(u) if err != nil { return nil, err } var orders orderSlice if err = unmarshal(resp, &orders); err != nil { return nil, err } return orders, nil }
Everytime I use CloseAllPositions function, there is always an error "parse error: expected string near offset 30 of '200'"
for example
it seems this error occurs when unmarshaling response body