func (client *Client) OpenOrders() (orders bitcoin.OrderList, err error) { var resp ordersResponse params := client.createParams() err = client.postRequest(API_ORDERS, params, &resp) if err != nil { return } for _, responseOrder := range resp { var order bitcoin.Order var price, amount float64 price, err = strconv.ParseFloat(responseOrder.Price, 64) if err != nil { return } amount, err = strconv.ParseFloat(responseOrder.Remaining_amount, 64) if err != nil { return } switch responseOrder.Side { case "buy": order = bitcoin.BuyOrder(price, amount) case "sell": order = bitcoin.SellOrder(price, amount) } order.Id = bitcoin.OrderId(fmt.Sprintf("%d", responseOrder.Id)) orders = append(orders, order) } return }
func (client *Client) OpenOrders() (orders bitcoin.OrderList, err error) { params := client.createParams() params.Set("pair", "btc_usd") var resp activeOrdersResponse err = client.postRequest(API_ACTIVE_ORDERS, params, &resp) if err != nil { return } if resp.Success != 1 { err = errors.New(resp.Error) return } for id, activeOrder := range resp.Return { var order bitcoin.Order if activeOrder.Type == "buy" { order = bitcoin.BuyOrder(activeOrder.Rate, activeOrder.Amount) } else { order = bitcoin.SellOrder(activeOrder.Rate, activeOrder.Amount) } order.Id = id } return }