(类)(int)和负值滞后

发布于 2025-02-03 22:41:18 字数 673 浏览 3 评论 0原文

我正在构建一个小的加密项目,并尝试了各种方法来对移动量的平均值(以前的行)进行测试,与当前卷(当前行)相比。

我在上面和低于0的案例语句测试中尝试了滞后,因为滞后将负值视为正值。 IE:-2大于-1。

在这里的一个问题的帮助下,我更改了使用的代码(类)(int),但是This Treats -2也大于-1。

lag :(

 (case when lag(volume) over (partition by name order by recordid) < volume \
             then '1' \
             when lag(volume) over (partition by name order by recordid) > volume \
             then '0' \

class)(int):

for x in records:
            rid = (x[0])
            result = int(x[1] > x[2])
            data+= [(result, rid)]

我是新手,但仍然很开心。我通过做学习并正在快速学习。 有人有任何建议吗?

希望这个问题有足够的信息,并符合一个好问题的标准。

I am building a little crypto project and have tried various methods to run a test on moving volume average (previous rows) compared to current volume (current row).

I have tried LAG in a case statement testing above and below 0 does not work as LAG treats negative values as positive. Ie: -2 is greater than -1.

With the help of a previous question here I changed the code to use (Class) (Int) however this treats -2 is greater than -1 also.

LAG:

 (case when lag(volume) over (partition by name order by recordid) < volume \
             then '1' \
             when lag(volume) over (partition by name order by recordid) > volume \
             then '0' \

(Class) (Int):

for x in records:
            rid = (x[0])
            result = int(x[1] > x[2])
            data+= [(result, rid)]

Im new to this but having fun none the less. I learn by doing and am learning fast.
Does anyone have any suggestions?

Hopefully this Question has sufficient info and meets the criteria for a good question.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

手长情犹 2025-02-10 22:41:19

这似乎奏效了。

    cursor1.execute("select recordid, cast(mvavgvol as integer), cast(quote_usd_volume_change_24h as integer) from pumped")
    records = cursor1.fetchall()
    
    data= []
    for x in records:
                rid = (x[0])
                result= int(x[2]) > int(x[1])
                data+= [(result, rid)]

cursor2.executemany("UPDATE pumped SET mvavgvolcheck = %s WHERE recordid = %s", (data))

Result:
quote_usd_volume_change_24h mvavgvol    mvavgvolcheck
-33.7011                    7.836209091       0
-31.6161                    1.897163636       0
-40.0176                   -4.020654545       0

在更改之前,最后一个输入结果是1。

This seems to have worked.

    cursor1.execute("select recordid, cast(mvavgvol as integer), cast(quote_usd_volume_change_24h as integer) from pumped")
    records = cursor1.fetchall()
    
    data= []
    for x in records:
                rid = (x[0])
                result= int(x[2]) > int(x[1])
                data+= [(result, rid)]

cursor2.executemany("UPDATE pumped SET mvavgvolcheck = %s WHERE recordid = %s", (data))

Result:
quote_usd_volume_change_24h mvavgvol    mvavgvolcheck
-33.7011                    7.836209091       0
-31.6161                    1.897163636       0
-40.0176                   -4.020654545       0

Prior to the change the last entry result would have been 1.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文