Conda създава виртуална среда python

Примерен код

27
0

conda създава околната среда

conda create -n myenv python=3.6
0
0

Създаване на нова среда - Conda

conda create --name myenv
#Figure([go.Scatter(...), go.Bar(...)])



# Plotting histogram and figures using a class in Python
import plotly.graph_objects as go
from plotly.graph_objs import Figure, Scatter, Bar
import matplotlib.pyplot as plt
import plotly.express as px

def plot_data(self):
        title = f'{self.symbol}: Closing Prices (Start: {self.start} - End: {self.end})'
        fig = self.plot_whole(data = self.data['price'], title = title, label = self.symbol)
        fig.show()
    
    def plot_whole(self, data, title, label):
        fig = Figure([
                go.Scatter(
                    name = f'{label}',
                    x = data.index,
                    y = data.values,
                    mode = 'lines',
                    marker = dict(color="#0a0a0a"),
                    line = dict(width=2),
                    showlegend = True
                )
            ])
        fig.update_layout(yaxis_title='USD ($)', 
                          xaxis_title='Timestamp', 
                          title=f'{title}', 
                          hovermode="x")
        return fig
        
    def add_plots(self, fig, data, label, color):
        fig.add_trace(
                go.Scatter(  
                    name=f'{label}',
                    x=data.index,
                    y=data.values, 
                    marker = dict(color=f"{color}"),
                    line = dict(width=2),
                    mode='lines',                
                    fillcolor='rgba(68, 68, 68, 0.3)',
                    showlegend=True
                )
            )
        return fig
    
    def add_bar_plots(self, fig, data, label, color):
        fig.add_trace(
                go.Bar(  
                    name=f'{label}',
                    x=data.index,
                    y=data.values, 
                    showlegend = True,
                    marker = dict(color=f"{color}"), 
                )
            )
        return fig
    
    def add_line(self, fig, index, line_pos, label, color):
        fig.add_trace(
                go.Scatter(  
                    name=f'{label}',
                    x = index,
                    y = [line_pos]*len(index),
                    marker = dict(color=f"{color}"), # color picker
                    line = dict(width=2),
                    mode='lines',                
                    fillcolor='rgba(68, 68, 68, 0.3)',
                    showlegend=True
                )
            )
        return fig
    
    def add_signal_plots(self, fig, colname, color): 
        if not self.data[colname].isnull().all():
            fig.add_trace(
                go.Scatter(  
                    name= f'{colname}',
                    x = self.data.index,
                    y = self.data[f'{colname}'],
                    marker = dict(color=f'{color}'), # color picker
                    line = dict(width=1),              
                    mode = "markers", 
                    fillcolor = 'rgba(68, 68, 68, 0.3)',
                    showlegend = True
                )
            )
        return fig
    
    def plotMACD(self):
        fig = self.plot_whole(self.data['MACD'], 'MACD', 'MACD Line')
        nonnegative = self.data['MACD_Histogram'][(self.data['MACD_Histogram']>=0)]
        negative = self.data['MACD_Histogram'][(self.data['MACD_Histogram']<0)]
        fig = self.add_bar_plots(fig, nonnegative, 'Non-negative Histogram', "#0a0a0a")
        fig = self.add_bar_plots(fig, negative, 'Negative Histogram', 'red')
        self.add_plots(fig, self.data['MACD_Signal'], 'MACD Signal Line', 'red').show()

Подобни страници

Подобни страници с примери

На други езици

Тази страница на други езици

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Íslensk
..................................................................................................................