1.65K 浏览
0

出错提示:TypeError: get_account() takes from 1 to 2 positional arguments but 4 were given

<span class="kn">

from</span> <span class="nn">tqsdk</span> <span class="kn">import</span> <span class="n">TqApi</span><span class="p">,</span> <span class="n">TqAuth</span>

<span class="n">api</span> <span class="o">=</span> <span class="n">TqApi</span><span class="p">(</span><span class="n">auth</span><span class="o">=</span><span class="n">TqAuth</span><span class="p">(</span><span class="s2">"信易账户"</span><span class="p">,</span> <span class="s2">"账户密码"</span><span class="p">))</span>
<span class="c1"># </span><span class="c1">获得资金账户引用,当账户有变化时 account 中的字段会对应更新</span>
<span class="n">account</span> <span class="o">=</span> <span class="n">api</span><span class="o">.</span><span class="n">get_account</span><span class="p">()</span>

<span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
    <span class="n">api</span><span class="o">.</span><span class="n">wait_update</span><span class="p">()</span>
    <span class="k">if</span> <span class="n">api</span><span class="o">.</span><span class="n">is_changing</span><span class="p">(</span><span class="n">account</span><span class="p">,</span> <span class="s2">"available"</span><span class="p">):</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">"可用资金: </span><span class="si">%.2f</span><span class="s2">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">account</span><span class="o">.</span><span class="n">available</span><span class="p">))</span>
李思恒 已回答的问题 2021年7月27日