I have log(return) data as time series, how I can fit this data in a Generalized Pareto distribution and estimate the parameters of this distribution, any kind of resource pointer with clear code would be good for me, If it can be done using open-source like R or Python that would be great.
In addition to the package gPdtest that COOLSerdash mentioned, you can also use function
pargpa in package lmomco. Here, the L-moments of data are applied to estimate the parameters. Here is an example:
library(lmomco) X <- rexp(200) lmr <- lmom.ub(X) fit.1 <- pargpa(lmr) fit.1 $type  "gpa" $para xi alpha kappa 0.02608930 1.03320329 0.03903811 $zeta  1 $source  "pargpa"
Assuming that when you say Generalized Pareto you mean the two-parameter version such as the one discussed in (McNeil 1997) and not the three parameter version as brought in (Klugman et. al. 1998)—also known as the Beta of the second kind—you can use the pot for
R which provides among its fitting functions the function
fitgpd which will fit a GPD. It also provides the set of
[d,p,q,r]gpd functions for density, distribution, quantile, and random variate generation if you have your own fitting routine.
If you have need of the other kind of GPD, the actuar package has the suite of distribution functions as
[d,p,q,r]genpareto but no built-in fitting routines.
There are at least four distributions which sometimes go by the name "generalized Pareto" These include the Pareto Type II through IV distributions and the Stoppa distribution. See, e.g. C. Kleiber & S. Kotz (2003) Statistical Size Distributions in Economics and Actuarial Sciences. Most of these, but not the Stoppa I believe, are sub-distributions of the distribution sometimes called the Feller-Pareto, Sometimes the Generalized Beta, and sometimes the generalized beta of the second kind (though each of these names have been applied to other distributions as well. I think the GB2 is the plurality name. Note that in their most common parameterizations, the Feller-Pareto is a five-parameter distribution which includes a location term, and the GB2 is a four-parameter distribution which does not. As a result, the Pareto types II through IV, which also have a location term, can all be regarded as within the FP family but not the GB2 family.
See e.g. McDonald & Xu (1995). "A generalization of the beta distribution with applications," Journal of Econometrics, vol. 66(1-2), pages 133-152, for a nice presentation of the tree of nested distributions under the generalized beta and the GB2.
The R package ‘GB2’ by Graf and Nedyalkova, and the related Laeken package, will let you do just about anything you might want with the GB2.