[英]nested if statement within a for loop doesn't work
I have a nested if statement within a for loop but the first if statement seems not to be progressing onto the rest of the for loop.我在 for 循环中有一个嵌套的 if 语句,但第一个 if 语句似乎没有进入 for 循环的 rest。
for i, x in enumerate(S[start:-1], start):
if i > max(sma_period1, sma_period2, sma_period3):
j = i-start
if ma1[i] == x:
w[j+1] = w[j]
cash[j+1] = cash[j]
if ma1[i] < x:
w[j+1] = cash[j]/x + w[j]
cash[j+1] = 0
if ma1[i] > x:
cash[j+1] = w[j]*x + cash[j]
w[j+1] = 0
tf_strategy_ma1 = [a*b for a,b in zip(w,S[start:])]+ cash
Sorry if this is a very basic question, I am new to coding and completely stuck.抱歉,如果这是一个非常基本的问题,我是编码新手并且完全卡住了。 Thanks for your help.
谢谢你的帮助。
Some debug pointers for a situation like this:针对这种情况的一些调试指针:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.