Пример #1
0
        if len(df) > 0 and 'ticker' in df.columns:
            proc_all_tickers = list(df['ticker'].unique()) + all_tickers
            proc_all_tickers = set(proc_all_tickers)
        print('Processing: %s' % len(proc_all_tickers))
        iticker = 0
        for ticker in proc_all_tickers:
            if debug: print(ticker, iticker)
            iticker += 1
            sys.stdout.flush()
            # if really high up on the list, then reprocess
            # if not loaded, then let's compute stuff
            if len(df_store_data[(df_store_data['ticker'] == ticker)]) == 0:

                # checking if it is shortable and tradeable:
                try:
                    aapl_asset = api.get_asset(ticker)
                    #pass
                    #print(aapl_asset) # this is info about it being tradeable
                    #print(aapl_asset.shortable)
                except (alpaca_trade_api.rest.APIError,
                        requests.exceptions.HTTPError, ValueError,
                        urllib3.exceptions.ProtocolError, ConnectionResetError,
                        urllib3.exceptions.ProtocolError, ConnectionResetError,
                        requests.exceptions.ConnectionError,
                        requests.exceptions.ReadTimeout) as e:
                    print("Testing multiple exceptions for alpaca api. {}".
                          format(e.args[-1]))
                    continue

                hour_prices_thirty = []
                minute_prices_thirty = []
Пример #2
0
    today = datetime.datetime.now(tz=est)
    my_days = []
    for i in range(0, 10):
        new_date = today + datetime.timedelta(-1 * i)
        if new_date.weekday() < 5:
            my_days += [new_date]
    st.write('The current ticker is %s and number of days checked: %i' %
             (today, len(my_days)))
    #st.table(pd.DataFrame(list(api.get_asset(title)._raw.items())))

    doRelativeToSpyAll = st.checkbox('Show relative to SPY', key='relTitleSpy')
    doEarnings = st.checkbox('Show earnings', key='do earnings')

    if title != 'Select':
        # Print a table of stock information on Alpaca
        st.json(api.get_asset(title)._raw)

        # Collect figures
        fig_table, figs_minute_price = generateFigure(api, title)

        # Plot!
        for fig_minute_price in figs_minute_price:
            st.plotly_chart(fig_minute_price)

        mean_figs = generateMeanRevFigure(api, sqlcursor, ts, title,
                                          doRelativeToSpyAll)
        st.markdown('Number of entries: %s' % len(mean_figs))
        for mean_fig in mean_figs:
            st.plotly_chart(mean_fig)

        if st.button("Show table"):