Mariner Backtesting - NameError

  • If Python encounters a name that it does not recognize, you will probably get this error.
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 525, in __call__
    results = 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 766, in fast_simulation_process_event
    context.on_minute_bar(event)
  File "/opt/anaconda/lib/python2.7/site-packages/tradesim/context.py", line 383, in on_minute_bar
    self.strategy.on_minute_bar(event, self.market, self.order, self.service, self.account, self.market.bar)
  File "job/Gr8Scriptfdf354e095b647fa9d4237e5ee24d838.py", line 172, in on_minute_bar
    and ((symbol) != ('SPY')) ):
NameError: global name 'symbol' is not defined

Sample Broken Code

 = Something()
s.out()

class Something:
    def out():
        print("it works")

Sample Fixed Code

 class Something:
    def out(self):
        print("it works")

s = Something()
s.out()