// GetTradesAllPages returns a pointer to a Trades struct with the data given
// by the api and an error message. It returns (nil, error) when an error
// is raised and (*Trades, nil) when the operation is successful. If end
// argument is not provided, the maximum data amount will be trucated when
// it raises more than 100 elements. It is not sure it will give you
// exactly 100 TradeData Data.
//
// List of accepted Arguments:
//   - required: Market (string)
//   - optional: Start (string YYYY-MM-DD), End (string YYYY-MM-DD)
// https://developers.cryptomkt.com/es/#trades
GetTradesAllPages returns a pointer to a Trades struct with the data given
by the api and an error message. It returns (nil, error) when an error
is raised and (*Trades, nil) when the operation is successful. If end
argument is not provided, the maximum data amount will be trucated when
it raises more than 100 elements. It is not sure it will give you
exactly 100 TradeData Data.


// GetTradesAllPages returns a pointer to a Trades struct with the data given // by the api and an error message . It returns ( nil error ) when an error // is raised and ( * Trades nil ) when the operation is successful . If end // argument is not provided the maximum data amount will be trucated when // it raises more than 100 elements . It is not sure it will give you // exactly 100 TradeData Data . // // List of accepted Arguments : // - required : Market ( string ) // - optional : Start ( string YYYY - MM - DD ) End ( string YYYY - MM - DD ) // https : // developers . cryptomkt . com / es / #trades
func (client *Client) GetTradesAllPages(arguments ...args.Argument) ([]TradeData, error) {
	req, err := makeReq([]string{"market"}, arguments...)
	if err != nil {
		return nil, fmt.Errorf("Error in GetTradesAllPages: %s", err)
	}
	neededArguments := []args.Argument{args.Page(0), args.Limit(100)}
	argsMap := req.GetArguments()
	neededArguments = append(neededArguments, args.Market(argsMap["market"]))
	if val, ok := argsMap["start"]; ok {
		neededArguments = append(neededArguments, args.Start(val))
	}
	if val, ok := argsMap["end"]; ok {
		neededArguments = append(neededArguments, args.End(val))
	}
	tPage, err := client.GetTrades(neededArguments...)
	if err != nil {
		return nil, fmt.Errorf("Error in GetTrades: %s", err)
	}
	allt := make([]TradeData, len(tPage.Data))
	copy(allt, tPage.Data)
	for tPage, err = tPage.GetNext(); err == nil; tPage, err = tPage.GetNext() {
		time.Sleep(2 * time.Second) 
		allt = append(allt, tPage.Data...)
		if _, ok := argsMap["end"]; !ok {
			if len(allt) > 100 {
				break
			}
		}
	}
	return allt, nil
}
func ( client * Client ) GetTradesAllPages ( arguments ... args . Argument ) ( [ ] TradeData , error ) { req , err := makeReq ( [ ] string { " " } , arguments ... ) if err != nil { return nil , fmt . Errorf ( " " , err ) } neededArguments := [ ] args . Argument { args . Page ( 0 ) , args . Limit ( 100 ) } argsMap := req . GetArguments ( ) neededArguments = append ( neededArguments , args . Market ( argsMap [ " " ] ) ) if val , ok := argsMap [ " " ] ; ok { neededArguments = append ( neededArguments , args . Start ( val ) ) } if val , ok := argsMap [ " " ] ; ok { neededArguments = append ( neededArguments , args . End ( val ) ) } tPage , err := client . GetTrades ( neededArguments ... ) if err != nil { return nil , fmt . Errorf ( " " , err ) } allt := make ( [ ] TradeData , len ( tPage . Data ) ) copy ( allt , tPage . Data ) for tPage , err = tPage . GetNext ( ) ; err == nil ; tPage , err = tPage . GetNext ( ) { time . Sleep ( 2 * time . Second ) allt = append ( allt , tPage . Data ... ) if _ , ok := argsMap [ " " ] ; ! ok { if len ( allt ) > 100 { break } } } return allt , nil }
GetTradesAllPages returns a pointer to a Trades struct with the data given
by the api and an error message.
GetTradesAllPages returns a pointer to a Trades struct with the data given by the api and an error message .
//because the server only accepts 30 calls per minute. // When the data length raises 100 elements or more when "end" parameter is not provided, // it breaks. This block limit the number of pages