Ejemplo n.º 1
0
# Third party imports
import seaborn as sns
import matplotlib.pyplot as plt

# Local application imports
from scifin import timeseries as ts
from scifin import statistics as st
from scifin import montecarlo as mc
from scifin import classifier as cl

# Generate random walk processes
mc1 = mc.generate_series(n=100,
                         names_base="RW-",
                         series_model=ts.random_walk,
                         start_date="2000-01-01",
                         end_date="2020-01-01",
                         frequency='M',
                         start_value=1.,
                         sigma=0.01)

# Plot
ts.multi_plot(mc1)

# Build their covariance matrix
cov1 = st.covariance_from_ts(list_ts=mc1, min_periods=10)
corr1 = st.covariance_to_correlation(cov1)

# Plot this correlation matrix
sns.heatmap(corr1, cmap='viridis')
plt.title("Initial correlation matrix")
plt.show()
import numpy as np
import seaborn as sns
from sklearn import cluster

# Local application imports
from scifin import timeseries as ts
from scifin import montecarlo as mc
from scifin import classifier as cl

# Generate two kinds of processes
N = 50
mc_MA = mc.generate_series(n=N,
                           names_base="MA-",
                           series_model=ts.moving_average,
                           start_date="2000-01-01",
                           end_date="2020-01-01",
                           frequency='M',
                           cst=1.,
                           order=2,
                           coeffs=[0.5, 0.2],
                           sigma=0.4)

mc_Garch = mc.generate_series(n=N,
                              names_base="Garch-",
                              series_model=ts.garch,
                              start_date="2000-01-01",
                              end_date="2020-01-01",
                              frequency='M',
                              cst=0.2,
                              order_a=1,
                              coeffs_a=[0.2],
                              order_sig=1,