shared/plotly_draw.py
def generate_candle_image_from_db(share_item, weeks=52, output_folder=''):
    '''
    Generates candle image using data from the database
    '''
    share_data = ShareDataItem.objects.filter(share=share_item).order_by('-date')
    df = pd.DataFrame(list(share_data.values()))
    last_df = df.head(weeks)
    trace = go.Candlestick(
        x=df.date,
        open=last_df.open_price,
        high=last_df.high_price,
        low=last_df.low_price,
        close=last_df.close_price
    )
    layout = go.Layout(xaxis=dict(rangeslider=dict(visible=False)))
    fig = go.Figure(data=[trace], layout=layout)
    fig.layout.template = 'plotly_white'
    base_name = share_item.ticker + '.png'
    image_path = output_folder + '/' + base_name
    pio.write_image(fig, image_path, width=500, height=335)
    print('Successfully created image ' + image_path)

    Generates candle image using data from the database
    
Generates candle image using data from the database
Generates candle image using data from the database
def generate_candle_image_from_db(share_item, weeks=52, output_folder=''):
    share_data = ShareDataItem.objects.filter(share=share_item).order_by('-date')
    df = pd.DataFrame(list(share_data.values()))
    last_df = df.head(weeks)
    trace = go.Candlestick(
        x=df.date,
        open=last_df.open_price,
        high=last_df.high_price,
        low=last_df.low_price,
        close=last_df.close_price
    )
    layout = go.Layout(xaxis=dict(rangeslider=dict(visible=False)))
    fig = go.Figure(data=[trace], layout=layout)
    fig.layout.template = 'plotly_white'
    base_name = share_item.ticker + '.png'
    image_path = output_folder + '/' + base_name
    pio.write_image(fig, image_path, width=500, height=335)
    print('Successfully created image ' + image_path)
def generate_candle_image_from_db ( share_item , weeks = 52 , output_folder = '' ) : share_data = ShareDataItem . objects . filter ( share = share_item ) . order_by ( '-date' ) df = pd . DataFrame ( list ( share_data . values ( ) ) ) last_df = df . head ( weeks ) trace = go . Candlestick ( x = df . date , open = last_df . open_price , high = last_df . high_price , low = last_df . low_price , close = last_df . close_price ) layout = go . Layout ( xaxis = dict ( rangeslider = dict ( visible = False ) ) ) fig = go . Figure ( data = [ trace ] , layout = layout ) fig . layout . template = 'plotly_white' base_name = share_item . ticker + '.png' image_path = output_folder + '/' + base_name pio . write_image ( fig , image_path , width = 500 , height = 335 ) print ( 'Successfully created image ' + image_path )
Generates candle image using data from the database
Generates candle image using data from the database
'''
    Generates candle image using data from the database
    '''
share_item
weeks
output_folder