Graeme22 / tastyworks-cli

Easy to use command line interface for Tastyworks!
MIT License
15 stars 2 forks source link

Error while launching tw plot #22

Closed Mappazzone closed 3 years ago

Mappazzone commented 3 years ago

Hi, I'm getting this error when launching tw plot on my csv file.

File "/usr/local/bin/tw", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/src/app.py", line 49, in main
    app.run()
  File "/usr/local/lib/python3.9/site-packages/cement/core/foundation.py", line 916, in run
    return_val = self.controller._dispatch()
  File "/usr/local/lib/python3.9/site-packages/cement/ext/ext_argparse.py", line 808, in _dispatch
    return func()
  File "/usr/local/lib/python3.9/site-packages/src/controller.py", line 69, in plot
    pf.calculate()
  File "/usr/local/lib/python3.9/site-packages/src/plot/base.py", line 205, in calculate
    self.positions[t.symbol].quantity -= t.quantity
TypeError: unsupported operand type(s) for -=: 'str' and 'str'

Any idea if it's my problem?

Graeme22 commented 3 years ago

Could be, depends on where you got the CSV from. Did you follow the instructions on the readme to obtain it? There are multiple different CSVs tastyworks will generate.

If so, sounds like something that needs to be addressed. Looks like one of the quantity fields is being typed wrong. Any chance you could figure out what line it is? If you're willing to share your CSV (you can anonymize it if you want) I can solve this quicker.

Graeme22 commented 3 years ago

I found the problem. This is already fixed on the main branch. I just published a new version for you. Can you verify it works with the newest version?

pip install --upgrade tastyworks-cli

Mappazzone commented 3 years ago

Thanks for the fix, that error is solved! But when I run it again it finds another conversion error .

/usr/local/lib/python3.9/site-packages/src/plot/commands.py", line 22, in plot pf = Portfolio(df, net_liq=netliq) File "/usr/local/lib/python3.9/site-packages/src/plot/csv.py", line 55, in __init__ self._calculate() File "/usr/local/lib/python3.9/site-packages/src/plot/csv.py", line 185, in _calculate t = Trade(trade) File "/usr/local/lib/python3.9/site-packages/src/plot/csv.py", line 28, in __init__ self.quantity = float(trade['Quantity']) ValueError: could not convert string to float: '1,000'

I couldn't find something that in the "quantity" column had some strange numbers, I got some 0 but in the "Regulatory fee adjustment" type.

I don't know how to debug it and put a breakpoint on it, but could you add some error message that says at what row of the csv the error occurs? Maybe that could help.

Thanks anyway!

Graeme22 commented 3 years ago

Ah good catch! Glad the other error is fixed. I had never found this because I don't think I've ever traded that large of a quantity of something. Will address this when I can.

Graeme22 commented 3 years ago

If this didn't fix the issue, please reopen. Hope you don't run into anything else and thanks for filing the bugs!