我试图使用python创建一个体积加权平均价格。 这是我的代码:
Traceback (most recent call last):
File "<ipython-input-9-9724942aa7be>", line 1, in <module>
runfile('/home/intern2/Desktop/VWAP/vwap-v1.py', wdir='/home/intern2/Desktop/VWAP')
File "/usr/lib/python3/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 586, in runfile
execfile(filename, namespace)
File "/usr/lib/python3/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 48, in execfile
exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)
File "/home/intern2/Desktop/VWAP/vwap-v1.py", line 25, in <module>
vol_total = vol_total + lastqty[i-j]
IndexError: index out of bounds
我相信我的想法是正确的,但是当我执行代码时,我有错误:
video = DirectShowSource("Z:\video\vvv.mp4", fps=fps_count, audio=true, convertfps=true).AssumeFPS(fps_count, 1).ConvertToYV12()
audio = BlankClip(audio_rate=audio_sample_rate, channels=2, length = logo_timeout).ResampleAudio(audio_sample_rate)
blank = BlankClip(logo_timeout, res_width, res_height, pixel_type = "RGB32", fps = fps_count).ConvertToYV12()
blank = Overlay(blank, blank_logo, mode = "blend", x = 0, y = 0)
blank = AudioDub(blank, blank_logo).AssumeFPS(fps_count, 1)
我只是不知道为什么错误索引超出范围。当我检查我的代码时,我认为索引完全在范围内。
有人可以帮我吗?