File size: 1,860 Bytes
6475c61
 
 
2e06999
6475c61
 
 
 
c8d4f69
6475c61
 
 
 
 
c8d4f69
2e06999
6475c61
9216a7b
6475c61
 
 
 
 
 
 
 
2e06999
6475c61
 
 
 
 
 
 
 
 
 
 
4128290
6475c61
2e06999
6475c61
 
 
 
 
 
0e5c662
 
2e06999
6475c61
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from dotenv import load_dotenv
load_dotenv('.env')

import gradio as gr
from utils import *
import os


days_to_plot = 40

data = get_data().iloc[-500:]


data_to_plot = data.iloc[-days_to_plot:][["Close"]]
data_to_plot['date'] = data_to_plot.index.strftime('%Y-%m-%d')

with gr.Blocks() as demo:
    gr.Markdown("# Apple Stock Predictor")
    predict_button = gr.Button("Predict")
    with gr.Row() as row0:
        with gr.Column() as col0:
            gr.Markdown("## Last candle info")
            last_open = gr.Textbox(get_last_candle_value(data, 'Open') ,label="Last Open")
            last_max = gr.Textbox( get_last_candle_value(data, 'High') ,label="Last Max")
            last_min = gr.Textbox( get_last_candle_value(data, 'Low') ,label="Last Min")
            last_close = gr.Textbox( get_last_candle_value(data, 'Close') ,label="Last Close")

        with gr.Column() as col1:
            gr.Markdown("## Next Candle Prediction")
            jump_text = gr.Textbox(label="Jump")
            open_text = gr.Textbox(label="Open")
            max_text = gr.Textbox(label="Max")
            min_text = gr.Textbox(label="Min")
            next_close_text = gr.Textbox(label="Close")
    with gr.Row() as row1:
        value_plot = gr.LinePlot(data_to_plot,
                                 x="date",
                                 y="Close",
                                 title=f'Closes in last {days_to_plot} days',
                                 y_lim=[float(data_to_plot['Close'].min())-5, float(data_to_plot['Close'].max())+5])

    outputs = [jump_text,
               open_text,
               max_text,
               min_text,
               next_close_text
               ]
    predict_button.click(lambda: predict(data), outputs=outputs)
    # predict_button.click(lambda: predict_mock(data), outputs=outputs)

demo.launch(debug=True)