Mariner Backtesting - Type Error
TypeError
- A TypeError is thrown when an operand or argument passed to a function is incompatible with the type expected by that operator or function.
Sample Traceback
Traceback (most recent call last):
File "run_simulation.py", line 550, in <module>
main(sys.argv[1:])
File "run_simulation.py", line 525, in main
results = simulator()
File "/opt/anaconda/lib/python2.7/site-packages/tradesim/engine.py", line 542, in __call__
return self.simulate()
File "/opt/anaconda/lib/python2.7/site-packages/tradesim/engine.py", line 661, in simulate
context_collection.process_event(event, delivery_timestamp)
File "/opt/anaconda/lib/python2.7/site-packages/tradesim/context.py", line 712, in process_event
event.context._call_on_timer(event)
File "/opt/anaconda/lib/python2.7/site-packages/tradesim/context.py", line 465, in _call_on_timer
self.strategy.on_timer(event, self.market, self.order, self.service, self.account)
File "job/CQ71ac7bf05f34499bbe2a4df04f2a1908.py", line 105, in on_timer
self.rebalance(md,order,service,account)
File "job/CQ71ac7bf05f34499bbe2a4df04f2a1908.py", line 145, in rebalance
print "Price of :" + new_prices.columns[i] + " is " + new_price
TypeError: cannot concatenate 'str' and 'float' objects
Sample Broken Code
print "Price of :" + new_prices.columns[i] + " is " + new_price
Sample Fixed Code
print "Price of :" + str(new_prices.columns[i]) + " is " + str(new_price)
Notes
- You have tried to add a string and non-string type together. You can fix this by putting the non-string inside the parenthesis of str().