COLLEGAMENTO DA ATTIVARE

di il
5 risposte

COLLEGAMENTO DA ATTIVARE

Qualcuno puo` delucidarmi come collegarmi alla porta?

ERROR -1 502 Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket EClients"
is enabled and connection port is the same as "Socket Port" on the
TWS "Edit->Global Configuration...->API->Settings" menu. Live Trading ports:
TWS: 7496; IB Gateway: 4001. Simulated Trading ports for new installations
of version 954.1 or newer: TWS: 7497; IB Gateway: 4002
Traceback (most recent call last):

Grazie

5 Risposte

  • Re: COLLEGAMENTO DA ATTIVARE

    alberto ha scritto:


    Qualcuno puo` delucidarmi come collegarmi alla porta?
    Quale "porta"? Di cosa si tratta?
    Magari un po' di informazioni di contorno per capire qual è il problema, cosa stai facendo e con che cosa ti stai collegando nello specifico sarebbe utile.
  • Re: COLLEGAMENTO DA ATTIVARE

    Il collegamento e` alle stocks di interactive brokers.


    stock_lppl_daily_mod.py', wdir='/home/alberto/Documenti/Padovan')
    /usr/lib/python3/dist-packages/spyder_kernels/customize/spydercustomize.py:110: FutureWarning: In a future version of pandas all arguments of read_csv except for the argument 'filepath_or_buffer' will be keyword-only.
    exec(compile(f.read(), filename, 'exec'), namespace)
    /home/alberto/Documenti/Padovan/stock_lppl_daily_mod.py:71: ParserWarning: Falling back to the 'python' engine because the 'c' engine does not support regex separators (separators > 1 char and different from '\s+' are interpreted as regex); you can avoid this warning by specifying engine='python'.
    df = pd.read_csv(filename, DataFrame, header = 0, index_col= 0)
    Traceback (most recent call last):



    File "/home/alberto/.local/lib/python3.8/site-packages/mplfinance/plotting.py", line 402, in plot
    dates,opens,highs,lows,closes,volumes = _check_and_prepare_data(data, config)

    File "/home/alberto/.local/lib/python3.8/site-packages/mplfinance/_arg_validators.py", line 31, in _check_and_prepare_data
    raise TypeError('Expect data.index as DatetimeIndex')

    TypeError: Expect data.index as DatetimeIndex
  • Re: COLLEGAMENTO DA ATTIVARE

    Niente commenti... solo copia incolla... bella richiesta di aiuto
  • Re: COLLEGAMENTO DA ATTIVARE

    alberto ha scritto:


    Il collegamento e` alle stocks di interactive brokers.
    Sì, ma non puoi copiare/incollare solo gli errori che ottieni senza dare una idea del contesto generale, riportare parte del codice, in breve spiegare quello che stai facendo.
  • Re: COLLEGAMENTO DA ATTIVARE

    Sto leggendo il file con pandas e voglio stampare i grafici sulla consolle








    Questa e` la parte del codice interessata:

    ticker= 'LYY7'
    filename='LYY7_D1CC.csv'
    engine='ipython3'
    df = pd.DataFrame(columns=['DateTime', 'Open', 'High', 'Low', 'Close', 'Volume'])
    df = pd.read_csv(filename, DataFrame, header = 0, index_col= 0)
    #df.index.name = 'date'
    #print("ccccccccccccccccccc", df)

    #df['DateTime'] = pd.to_DateTime(df['DateTime'], format='%Y%m%d')
    #df.to_csv('LPPL/'+ticker+'_D1.csv')
    print('hhhhh00000000 ', df)



    #print("vvvvvv", df, 'date = ', date)
    #print(date)
    #df.index = pd.DateTimeIndex(df['date'])
    #app.disconnect()

    import sys
    print(11111111111111)
    class Logger(object): #(sostituisce la riga 59)
    def __init__(self):
    self.terminal = sys.stdout
    self.log = open('LPPL/'+ticker+'_'+timerange+'_out.txt', "a")

    def write(self, message):
    self.terminal.write(message)
    self.log.write(message)

    def flush(self):
    #this flush method is needed for python 3 compatibility.
    #this handles the flush command by doing nothing.
    #you might want to specify some extra behavior here.
    pass

    sys.stdout = Logger()

    import matplotlib.pyplot as plt
    import mplfinance as mplf
    print(222222222222222222, DateTime)

    #df[ '*args, **kwargs'].plot(kind='hist')
    #df.set_index('DateTime', inplace=False) #set DateTime.date as index
    # .stack(dropna=False)
    # .droplevel(1)
    # .reset_index(name='final values'))
    print("33333333 ", DateTime, " -- date ", date)
    #Define candlestick layout and styling
    mc = mplf.make_marketcolors(up='white',down='black',
    edge='inherit',
    wick={'up':'black','down':'black'},
    volume='tab:blue')
    print(4444444)
    s = mplf.make_mpf_style(base_mpl_style='ggplot', marketcolors=mc,mavcolors=['orange','purple'],
    rc={'font.size':6})
    print(555555555555, df.tail, 666666666, DataFrame)
    # Plot candlesticks
    # Add volume (if True)ame(filename, columns=['DateTime', 'Open', 'High', 'Low', 'Close', 'Volume'])
    # Add two moving averages
    # Save graph to *.png.
    #tmax_df = pd.DataFrame(filename, columns=['DateTime', 'Open', 'High', 'Low', 'Close', 'Volume'])
    #tmin_df = pd., engine='python'ataFr




    import pandas as pd








    mplf.plot(df.tail(250), type='line',
    title=ticker+' '+'Daily Chart',
    ylabel='Price',
    volume=True,
    figscale=1,
    scale_width_adjustment=dict(ohlc=1.0,lines=2.0),
    mav=(20,110),
    show_nontrading=False,
    savefig=dict(fname='LPPL/'+ticker+'_'+timerange+'_gp1_plt.png',dpi=150,pad_inches=0.25),
    style=s)
    close_px = df['Close']
    rets = close_px / close_px.shift(1) - 1
    fig, ax = plt.subplots()
    plt.plot(rets)
    ax.tick_params(axis='both', which='major', labelsize=10, rotation=45)
    ax.tick_params(axis='both', which='minor', labelsize=8, rotation=45)
    fig.suptitle(ticker+ ' ' + 'Daily Returns', fontsize=10)
    plt.xlabel('Date', fontsize=10)
    plt.ylabel('Return', fontsize=10)
    plt.tight_layout()
    fig.savefig(fname= ticker+'_'+timerange+'_gp2_ret.png',dpi=150)
    plt.close(fig)

    #Pre-processing & cross validatio
    from sklearn import preprocessing





    questo e` l'errore completo:
    runfile('/home/alberto/Documenti/Padovan/stock_lppl_daily_mod.py', wdir='/home/alberto/Documenti/Padovan')
    /usr/lib/python3/dist-packages/spyder_kernels/customize/spydercustomize.py:110: FutureWarning: In a future version of pandas all arguments of read_csv except for the argument 'filepath_or_buffer' will be keyword-only.
    exec(compile(f.read(), filename, 'exec'), namespace)
    /home/alberto/Documenti/Padovan/stock_lppl_daily_mod.py:71: ParserWarning: Falling back to the 'python' engine because the 'c' engine does not support regex separators (separators > 1 char and different from '\s+' are interpreted as regex); you can avoid this warning by specifying engine='python'.
    df = pd.read_csv(filename, DataFrame, header = 0, index_col= 0)
    Traceback (most recent call last):

    File "<ipython-input-8-e32ae33a6bdd>", line 1, in <module>
    runfile('/home/alberto/Documenti/Padovan/stock_lppl_daily_mod.py', wdir='/home/alberto/Documenti/Padovan')

    File "/usr/lib/python3/dist-packages/spyder_kernels/customize/spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

    File "/usr/lib/python3/dist-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

    File "/home/alberto/Documenti/Padovan/stock_lppl_daily_mod.py", line 143, in <module>
    mplf.plot(df.tail(250), type='line',

    File "/home/alberto/.local/lib/python3.8/site-packages/mplfinance/plotting.py", line 402, in plot
    dates,opens,highs,lows,closes,volumes = _check_and_prepare_data(data, config)

    File "/home/alberto/.local/lib/python3.8/site-packages/mplfinance/_arg_validators.py", line 31, in _check_and_prepare_data
    raise TypeError('Expect data.index as DatetimeIndex')

    TypeError: Expect data.index as DatetimeIndex


    hhhhh00000000 Empty DataFrame
    Columns: []
    Index: [241,20181207,103.2,103.64,102.66,102.7,12780, 242,20181210,102.0,102.06,100.56,100.68,12026, 243,20181211,101.78,103.28,101.48,102.36,18219, 244,20181212,102.74,104.06,102.74,103.98,14504, 245,20181213,104.18,104.2,103.36,103.84,11302, 246,20181214,102.64,103.48,101.86,103.24,13102, 247,20181215,103.14,103.32,101.68,102.46,16427, 248,20181216,101.78,102.84,101.78,102.02,10175, 249,20181217,102.04,102.7,102.04,102.26,9323, 250,20181218,102.0,102.0,100.32,100.62,27553, 251,20181219,100.3,101.1,99.74,100.66,19688]
    11111111111111
    222222222222222222
    33333333 -- date
    4444444
    555555555555 <bound method NDFrame.tail of Empty DataFrame
    Columns: []
    Index: [241,20181207,103.2,103.64,102.66,102.7,12780, 242,20181210,102.0,102.06,100.56,100.68,12026, 243,20181211,101.78,103.28,101.48,102.36,18219, 244,20181212,102.74,104.06,102.74,103.98,14504, 245,20181213,104.18,104.2,103.36,103.84,11302, 246,20181214,102.64,103.48,101.86,103.24,13102, 247,20181215,103.14,103.32,101.68,102.46,16427, 248,20181216,101.78,102.84,101.78,102.02,10175, 249,20181217,102.04,102.7,102.04,102.26,9323, 250,20181218,102.0,102.0,100.32,100.62,27553, 251,20181219,100.3,101.1,99.74,100.66,19688]> 666666666
Devi accedere o registrarti per scrivere nel forum
5 risposte