-1

The code installs:

cd /PyLimitOrderBook
sudo pip install -r requirements.txt
sudo python setup.py install

Without problems. Right. So the goodies are in

cd /PyLimitOrderBook/bin

In particular, from that subdirectory (/bin/), I try to run the code on XOM_BATS_2010-06-16.csv (this is the test data file delivered with the package) :

python3 -m limitbook-tseries.py /PyLimitOrderBook/sample_data/XOM_BATS_2010-06-16.csv /PyLimitOrderBook/sample_data/XOM_BATS_2010-06-162.csv

But it fails at the import:

Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 174, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.5/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/PyLimitOrderBook/bin/limitbook-tseries.py", line 9, in <module>
    from pylimitbook.researchBook import ResearchBook
ImportError: No module named 'pylimitbook'

Of course that module is in:

/PyLimitOrderBook/pylimitbook

But how to tell him that?

I tried different things:

Go one level up, back to

/PyLimitOrderBook/

and do:

python -m bin/limitbook-tseries.py /PyLimitOrderBook/sample_data/XOM_BATS_2010-06-16.csv /PyLimitOrderBook/sample_data/XOM_BATS_2010-06-162.csv

I get:

/usr/bin/python: Import by filename is not supported.

Grrr. What is the correct way?

user189035
  • 5,589
  • 13
  • 52
  • 112
  • `-m` is for modules. Run this example as an app: `python bin/limitbook-tseries.py` – fukanchik Apr 26 '18 at 21:08
  • Thanks. I'm a total python noob. Following your comment, I get `Traceback (most recent call last): File "bin/limitbook-tseries.py", line 9, in from pylimitbook.researchBook import ResearchBook ImportError: No module named pylimitbook.researchBook` but that module exists;([it is in `/pylimitbook`] how to tell him where to find it? – user189035 Apr 26 '18 at 21:11
  • No it does not exsit. You've installed it using python2 and then are trying to execute using python3. These are separate installations. – fukanchik Apr 26 '18 at 21:12
  • I do `python bin/limitbook-tseries.py sample_data/XOM_BATS_2010-06-16.csv sample_data/XOM_BATS_2010-06-162.csv ` and got the error above – user189035 Apr 26 '18 at 21:16
  • 1
    As soon as you did `python setup.py install` it is available. At least it "worked" for me. The sample input file have different format from what the python code expects though – fukanchik Apr 26 '18 at 21:26
  • You are correct, my bad. I re did too and now I just have an inocuous data error. Just to confirm, you also get `Traceback (most recent call last): File "bin/limitbook-tseries.py", line 68, in quotebook.trade(line.rstrip()) File "build/bdist.linux-x86_64/egg/pylimitbook/researchBook.py", line 33, in trade File "build/bdist.linux-x86_64/egg/pylimitbook/book.py", line 97, in trade File "build/bdist.linux-x86_64/egg/pylimitbook/book.py", line 19, in parse_csv IndexError: list index out of range`, right? – user189035 Apr 26 '18 at 21:31
  • 1
    Yes, I am getting the same data error. – fukanchik Apr 26 '18 at 21:32

1 Answers1

1

You've installed it using python 2's pip:

pip install -r requirements.txt

In your first attempt to launch limitbook-tseries.py you tried to launch it using python3 where it is not installed yet. If you want to use it in python3 as well use pip3 to install this module to python3 as well.

Error message `ImportError: No module named 'pylimitbook' tells you exactly that.

Your second attempt is to use execute python application as if it was a python module. Indeed some python modules can be "executed" using python -m <module-name> syntax but that does not apply to python applications. This is explained in details here: Execution of Python code with -m option or not .

Instead just use python <file-name>.

However I am getting data error when running this application (and all others from bin). This is because sample input file have different format from what the python code expects.

Python code expects the following 16 columns:

['Record_ind', 'segment', 'order_no', 'quote_tm', 'buysell', 'activity_typ', 'symbol', 'series', 'vol_disc', 'vol_orgnl', 'limit_prc', 'price_trig', 'mkt_ord_flg', 'StLoss_I', 'Io_flag', 'Algo_Ind']

while only 7 columns are in the sample csv file.

fukanchik
  • 2,811
  • 24
  • 29