areed1192 / interactive-broker-python-api

A python packaged used to interact with the Interactive Brokers REST API.
MIT License
389 stars 124 forks source link

Directory name is invalid #7

Closed ghcmartins closed 3 years ago

ghcmartins commented 4 years ago

Hi Alex! I installed the package, but when trying to use I get this error below:

Traceback (most recent call last):

File "", line 1, in ib_client.create_session()

File "C:\Users\User\anaconda3-64bit\lib\site-packages\ibw\client.py", line 146, in create_session self.connect(start_server=True)

File "C:\Users\User\anaconda3-64bit\lib\site-packages\ibw\client.py", line 455, in connect server_state = self._start_server()

File "C:\Users\User\anaconda3-64bit\lib\site-packages\ibw\client.py", line 422, in _start_server creationflags=subprocess.CREATE_NEW_CONSOLE

File "C:\Users\User\anaconda3-64bit\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 104, in init super(SubprocessPopen, self).init(*args, **kwargs)

File "C:\Users\User\anaconda3-64bit\lib\subprocess.py", line 800, in init restore_signals, start_new_session)

File "C:\Users\User\anaconda3-64bit\lib\subprocess.py", line 1207, in _execute_child startupinfo)

NotADirectoryError: [WinError 267] The directory name is invalid

I´m new to Python, bu tried to find this path or to correct things and couldn´t, can you give an idea of what to do?

Best,

areed1192 commented 4 years ago

Thanks for bringing this up. It's more than likely cause because you installed the library using PyPI. If you install using PyPI I found out that it wasn't downloading the client portal gateway like it was intended to. I went back and modified the library so that it will download and create the folder if needed.

Update it to the latest version (0.1.2) and let me know if it fixes the issue for you.

pip install interactive-broker-python-web-api==0.1.2
ghcmartins commented 4 years ago

Hi1 Thanks for the answer, I updated the package, but it still answers with this error, what I saw different was 5that when calling ib_client.create_session() it brought another issue. I´m using Trader Workstation desktop, do I need to use the IB gateway only?

ib_client.close_session()

The Client Portal Gateway doesn't exist. You need to download it before using the Library.
Downloading the Client Portal file...

Traceback (most recent call last):

  File "<ipython-input-1-da1f5388ae55>", line 10, in <module>
    ib_client.create_session()

  File "C:\Users\User\anaconda3-64bit\lib\site-packages\ibw\client.py", line 150, in create_session
    self.connect(start_server=True)

  File "C:\Users\User\anaconda3-64bit\lib\site-packages\ibw\client.py", line 459, in connect
    server_state = self._start_server()

  File "C:\Users\User\anaconda3-64bit\lib\site-packages\ibw\client.py", line 426, in _start_server
    creationflags=subprocess.CREATE_NEW_CONSOLE

NotADirectoryError: [WinError 267] The directory name is invalid
areed1192 commented 4 years ago

First, did you download the clientportal gateway before running the script?

Also, I don't know why, but I noticed you are using spyder. I would recommend against using that for the time being when using this library. I'm not sure why but there seem to be errors that only appear when using spyder. I need to take a look into it and see what the issue is.

thepian commented 4 years ago

I don't see anywhere what you do with the client portal once downloaded. I have it in the working directory, but I suppose it's supposed to be installed somehow. What I downloaded is called 'clientportal', but it seems your lib expects a different directory name to be under resources.

dhecloud commented 4 years ago

@thepian when you create your ibclient, you have to specify the path to your gate.

ib_client = IBClient(username=REGULAR_USERNAME, account=REGULAR_ACCOUNT, client_gateway_path='clientportal.beta.gw')