import gradio as gr from utils import Kline_predict_plot, back_test_plot with gr.Blocks() as generator: with gr.Tab("English"): gr.Markdown("# Available Markets: Stocks(Main China, HongKong, USA and so on) / Cryptocurrencies") # gr.Markdown("Powered by AI") with gr.Tab("Predictor"): # gr.Markdown("Most 5 symbols at once can be put in `Symbols` box.") once_max_num = 5 gr.Interface( Kline_predict_plot, [ gr.Dropdown(["model_predict_sk2", ], label="Predict Model", value='model_predict_sk2'), gr.Textbox(label="Symbols", lines=1, placeholder=f"Enter symbols(can't more than {once_max_num} at once), " f"such as '000001.SH, btc-usd, AAPL, 18010.hk'", ), gr.Textbox(label="Your Opinion", lines=2, placeholder=f"Enter your base opinion for next trade day if you have(" f"such as 'I think it would be a big up and I would long absolutely' or " f"'I shall sell a few'); or just leave here blank.", ), gr.Dropdown( ["1hour", "1day", "1week", "1month"], label="Frequency Scale", value='1day', info="Kline scale." ), gr.Slider(label="Feature Saturation", minimum=2, maximum=10, value=3, step=1), gr.Slider(label="Sensitivity", minimum=2, maximum=20, value=5, step=1), gr.Checkbox(label="Completed?", value=True, info="Is the latest bar completed?"), gr.Slider(label="Show Bars", minimum=16, maximum=100, value=21, step=1), gr.Number(label="Once Max", value=once_max_num, visible=False) ], [ gr.Textbox(label=f"Ignored Symbols: not available,too new or more than {once_max_num} symbols."), gr.Gallery(label="Bars Figure", show_label=True, columns=[1]), ], examples=[ ["model_predict_sk2", "000001.sh,600000.sh,000001.sz", "", "1day", 3, 5, True, 21, 5], ["model_predict_sk2", "aapl,goog", "There would be a big up, so long", "1week", 5, 15, True, 21, 5], ["model_predict_sk2", "btc-usd,eth-btc", "A big down is coming", "1day", 3, 3, False, 21, 5], ["model_predict_sk2", "btc-usd,000001.sh,1810.hk goog", "", "1day", 3, 10, False, 30, 5], ], ) with gr.Tab("Back Tester"): # gr.Markdown("Only 1 symbol at once can be put in `Symbols` box.") gr.Interface( back_test_plot, [ gr.Dropdown(["model_predict_sk2", ], label="Predict Model", value='model_predict_sk2'), gr.Textbox(label="Symbols", placeholder=f"Enter 1 Symbol, such as 'btc-usd'"), gr.Dropdown( ["1hour", "1day", "1week", "1month"], label="Frequency Scale", value='1day', info="Kline scale." ), gr.Slider(label="Feature Saturation", minimum=2, maximum=10, value=3, step=1), gr.Slider(label="Sensitivity", minimum=2, maximum=20, value=5, step=1), gr.Slider(label="Test Bars", minimum=10, maximum=200, value=100, step=1), ], [gr.Gallery(label="Profit Figure", show_label=True, columns=[1])], examples=[ ["model_predict_sk2", "000001.sh", "1day", 3, 5, 20], ["model_predict_sk2", "btc-usd", "1day", 3, 10, 30], ["model_predict_sk2", "aapl", "1week", 5, 15, 80], ], ) with gr.Tab("中文"): gr.Markdown("# 可用市场: 股票(A股、港股、美股等) / 加密货币") with gr.Tab("预测器"): # gr.Markdown("`交易标的` 框中一次最多可同时输入5个标的") once_max_num = 5 gr.Interface( Kline_predict_plot, [ gr.Dropdown(["model_predict_sk2", ], label="预测模型", value='model_predict_sk2'), gr.Textbox(label="交易标的", lines=2, placeholder=f"请输入要预测的交易标的(一次最多不能超过{once_max_num}个), " f"例如输入: \"000001.SH, btc-usd, AAPL, 18010.hk\"", ), gr.Textbox(label="主观观点", lines=2, placeholder=f"请输入你的主观多空观点(例如输入: \"我认为后市会大涨,我要全仓做多\" 或者 " f"\"我认为应该少量卖出一部分\"); 如果没有明确的多空观点,此处无需输入"), gr.Dropdown( ["1hour", "1day", "1week", "1month"], label="K线级别", value='1day', info="选择小时K线、日K线、周K线或者月K线" ), gr.Slider(label="特征饱和度", minimum=2, maximum=10, value=3, step=1), gr.Slider(label="敏感度", minimum=2, maximum=20, value=5, step=1), gr.Checkbox(label="已完成?", value=True, info="最新的K线是否已经完成?"), gr.Slider(label="展示K线数", minimum=16, maximum=100, value=21, step=1), gr.Number(label="最多预测数", value=once_max_num, visible=False) ], [ gr.Textbox(label=f"有误交易标的: 不可用、太新或者一次预测数大于{once_max_num}个"), gr.Gallery(label="K线图", show_label=True, columns=[1]), ], examples=[ ["model_predict_sk2", "000001.sh,600000.sh,000001.sz", "", "1day", 3, 5, True, 21, 5], ["model_predict_sk2", "aapl,goog", "我认为后市会大涨,我要全仓做多", "1week", 5, 15, True, 21, 5], ["model_predict_sk2", "btc-usd,eth-btc", "后市很可能会大幅下跌", "1day", 3, 3, False, 21, 5], ["model_predict_sk2", "btc-usd,000001.sh,1810.hk goog", "", "1day", 3, 10, False, 30, 5], ], ) with gr.Tab("回测器"): # gr.Markdown("Only 1 symbol at once can be put in `Symbols` box.") gr.Interface( back_test_plot, [ gr.Dropdown(["model_predict_sk2", ], label="预测模型", value='model_predict_sk2'), gr.Textbox(label="交易标的", placeholder=f"请输入一个交易标的, 例如输入:\"btc-usd\""), gr.Dropdown( ["1hour", "1day", "1week", "1month"], label="K线级别", value='1day', info="选择小时K线、日K线、周K线或者月K线" ), gr.Slider(label="特征饱和度", minimum=2, maximum=10, value=3, step=1), gr.Slider(label="敏感度", minimum=2, maximum=20, value=5, step=1), gr.Slider(label="回测K线数", minimum=10, maximum=200, value=100, step=1), ], [gr.Gallery(label="回测曲线", show_label=True, columns=[1])], examples=[ ["model_predict_sk2", "000001.sh", "1day", 3, 5, 20], ["model_predict_sk2", "btc-usd", "1day", 3, 10, 30], ["model_predict_sk2", "aapl", "1week", 5, 15, 80], ], ) generator.queue(max_size=1).launch()