<commit_before>package gdax

import (
	"fmt"
)

type Order struct {
	Type      string  `json:"type"`
	Size      float64 `json:"size,string,omitempty"`
	Side      string  `json:"side"`
	ProductId string  `json:"product_id"`
	ClientOID string  `json:"client_oid,omitempty"`
	Stp       string  `json:"stp,omitempty"`
	// Limit Order
	Price       float64 `json:"price,string,omitempty"`
	TimeInForce string  `json:"time_in_force,omitempty"`
	PostOnly    bool    `json:"post_only,omitempty"`
	CancelAfter string  `json:"cancel_after,omitempty"`
	// Market Order
	Funds float64 `json:"funds,string,omitempty"`
	// Response Fields
	Id            string  `json:"id"`
	Status        string  `json:"status,omitempty"`
	Settled       bool    `json:"settled,omitempty"`
	DoneReason    string  `json:"done_reason,omitempty"`
	CreatedAt     Time    `json:"created_at,string,omitempty"`
	FillFees      float64 `json:"fill_fees,string,omitempty"`
	FilledSize    float64 `json:"filled_size,string,omitempty"`
	ExecutedValue float64 `json:"executed_value,string,omitempty"`
}

type CancelAllOrdersParams struct {
	ProductId string
}

type ListOrdersParams struct {
	Status     string
	ProductId  string
	Pagination PaginationParams
}

func (c *Client) CreateOrder(newOrder *Order) (Order, error) {
	var savedOrder Order

	if len(newOrder.Type) == 0 {
		newOrder.Type = "limit"
	}

	url := fmt.Sprintf("/orders")
	_, err := c.Request("POST", url, newOrder, &savedOrder)
	return savedOrder, err
}

func (c *Client) CancelOrder(id string) error {
	url := fmt.Sprintf("/orders/%s", id)
	_, err := c.Request("DELETE", url, nil, nil)
	return err
}

func (c *Client) CancelAllOrders(p ...CancelAllOrdersParams) ([]string, error) {
	var orderIDs []string
	url := "/orders"

	if len(p) > 0 && p[0].ProductId != "" {
		url = fmt.Sprintf("%s?product_id=", p[0].ProductId)
	}

	_, err := c.Request("DELETE", url, nil, &orderIDs)
	return orderIDs, err
}

func (c *Client) GetOrder(id string) (Order, error) {
	var savedOrder Order

	url := fmt.Sprintf("/orders/%s", id)
	_, err := c.Request("GET", url, nil, &savedOrder)
	return savedOrder, err
}

func (c *Client) ListOrders(p ...ListOrdersParams) *Cursor {
	paginationParams := PaginationParams{}
	if len(p) > 0 {
		paginationParams = p[0].Pagination
		if p[0].Status != "" {<commit_msg>Fixed cancel all orders<commit_after>package gdax

import (
	"fmt"
)

type Order struct {
	Type      string  `json:"type"`
	Size      float64 `json:"size,string,omitempty"`
	Side      string  `json:"side"`
	ProductId string  `json:"product_id"`
	ClientOID string  `json:"client_oid,omitempty"`
	Stp       string  `json:"stp,omitempty"`
	// Limit Order
	Price       float64 `json:"price,string,omitempty"`
	TimeInForce string  `json:"time_in_force,omitempty"`
	PostOnly    bool    `json:"post_only,omitempty"`
	CancelAfter string  `json:"cancel_after,omitempty"`
	// Market Order
	Funds float64 `json:"funds,string,omitempty"`
	// Response Fields
	Id            string  `json:"id"`
	Status        string  `json:"status,omitempty"`
	Settled       bool    `json:"settled,omitempty"`
	DoneReason    string  `json:"done_reason,omitempty"`
	CreatedAt     Time    `json:"created_at,string,omitempty"`
	FillFees      float64 `json:"fill_fees,string,omitempty"`
	FilledSize    float64 `json:"filled_size,string,omitempty"`
	ExecutedValue float64 `json:"executed_value,string,omitempty"`
}

type CancelAllOrdersParams struct {
	ProductId string
}

type ListOrdersParams struct {
	Status     string
	ProductId  string
	Pagination PaginationParams
}

func (c *Client) CreateOrder(newOrder *Order) (Order, error) {
	var savedOrder Order

	if len(newOrder.Type) == 0 {
		newOrder.Type = "limit"
	}

	url := fmt.Sprintf("/orders")
	_, err := c.Request("POST", url, newOrder, &savedOrder)
	return savedOrder, err
}

func (c *Client) CancelOrder(id string) error {
	url := fmt.Sprintf("/orders/%s", id)
	_, err := c.Request("DELETE", url, nil, nil)
	return err
}

func (c *Client) CancelAllOrders(p ...CancelAllOrdersParams) ([]string, error) {
	var orderIDs []string
	url := "/orders"

	if len(p) > 0 && p[0].ProductId != "" {
		url = fmt.Sprintf("%s?product_id=%s", url, p[0].ProductId)
	}

	_, err := c.Request("DELETE", url, nil, &orderIDs)
	return orderIDs, err
}

func (c *Client) GetOrder(id string) (Order, error) {
	var savedOrder Order

	url := fmt.Sprintf("/orders/%s", id)
	_, err := c.Request("GET", url, nil, &savedOrder)
	return savedOrder, err
}

func (c *Client) ListOrders(p ...ListOrdersParams) *Cursor {
	paginationParams := PaginationParams{}
	if len(p) > 0 {
		paginationParams = p[0].Pagination
		if p[0].Status != "" {
{'fraction_non_alphanumeric': 0.14461472048348803, 'fraction_numerical': 0.008202028922944096, 'mean_word_length': 4.332566168009206, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2570836', 'n_tokens_mistral': 1617, 'n_tokens_neox': 1570, 'n_words': 380}