이 문제를 어떻게 디버그할 수 있을까요? 계정에는 포지션이 없는 경우 아래의 코드를 사용하여 포지션 정보를 얻을 수 있습니다. while(true){ var position=_C(exchange.GetPosition)
if(position==null){ continue } type=position[0].Type if(type==PD_LONG){ if(exsell!==sellPrice){ CancelPendingOrders() exchange.SetDirection(“closebuy”) exchange.Sell(sellPrice,position[0].Amount) exsell=sellPrice } } 계정에서 포지션이 없는 경우, getposition은 빈 배열을 가져야 합니다.[그래서 if 문장 안의 continuue를 실행해서 루크를 다시 시작하지만 실디 테스트는 여전히 오류가 발생합니다. TypeError: cannot read property ‘Type’ of undefined at main (FILE:129)
만약 제가 만약의 조건을 바꾸려고 한다면,[0]==null 또는 typeof(position) ==undefined는 모두 작동하지 않습니다.[0].Type bar가 정책 오류를 발생시킵니다.
이 문제는 어떻게 해결될까요?