Feb-24-2021, 04:32 PM
"Not working" is different from not doing what you expected. What is it you're trying to do? What is an
Based on the last code you shared, here's what I think you're trying to do:
1) if the UnrealizedPnL is ever negative, close the position.
2) if the UnrealizedPnL is less than 50, but was over 100 at any point today, close the position.
If you only want "Stopping out" to be printed once, then turn off the toggle there:
app
, what's calling main()
, etc? The code we're giving might not be helpful, since we're mostly guessing what's going on lol.Based on the last code you shared, here's what I think you're trying to do:
1) if the UnrealizedPnL is ever negative, close the position.
2) if the UnrealizedPnL is less than 50, but was over 100 at any point today, close the position.
If you only want "Stopping out" to be printed once, then turn off the toggle there:
if app.trigger: print("Stopping Out") app.trigger = False