Python novice here. I have the following simple logic to be implemented in python. I have made basic progress but cannot get into the logic to stop the execution when certain actions are performed.
I am summarizing the logic in simple english, if there's anything thats not clear, please let me know.
I kinda know that this can be achieved by a 'break' or 'continue' logic, but cannot seem to figure out and have been struggling since couple of days. Condition 5 and 6 are the pain points :-(
In a loop or in while
GET below values from XLS
Qty : Values 0, 1 or -1
Signal : Values Buy, Sell, Hold
Trade Profit : 10
Daily Profit : 50
Condition 1
If Signal = Buy and Qty = 0 then
Buy 1 stock; #Open a long position. This will be a new trade
Condition 2
If Signal = Sell and Qty = 1 then
Sell 1 stock; #Close the long position from above. Closing the trade above
Condition 3
If Signal = Sell and Qty = 0 then
Sell 1 stock; #Open a short position. This will be a new trade
Condition 4
If Signal = Sell and Qty = -1 then
Buy 1 stock; #Close the short position from above. Closing the trade above
Condition 5
If Trade Profit is met do not take any new trades until the Signal changes (from Hold to Buy or from Hold to Sell)
(Qty = 1 or Qty = -1, Signal value will be HOLD)
Condition 6
If Daily Profit is met do not do anything
Any help or guidance will be much appreciated.
Thanks
Stock
question from:
https://stackoverflow.com/questions/65860446/python-break-or-continue-for-a-simple-logic 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…