如何在有相同日期但时间不同的行时获得一整天的盈利/损失

发布于 2025-01-30 04:22:55 字数 763 浏览 3 评论 0 原文

Unnamed: 0  open    high    low close   volume  Date    time    Profit  Loss    proforloss
0   0   252.70  254.25  252.35  252.60  319790  2022-01-03  09:15:00    0.000000    0.039573    -0.039573
1   1   252.60  253.65  251.75  252.80  220927  2022-01-03  09:30:00    0.079177    0.000000    0.079177
2   2   252.95  254.90  252.30  252.85  526445  2022-01-03  09:45:00    0.000000    0.039534    -0.039534
3   3   252.85  253.15  252.40  252.55  280414  2022-01-03  10:00:00    0.000000    0.118647    -0.118647
4   4   252.55  253.10  252.25  252.80  112875  2022-01-03  10:15:00    0.098990    0.000000    0.098990

这是给我的数据,我已经获得了15分钟时间范围的损益,但是我如何获得一天的开始时间为09:30:00,而关闭时间为15:00:00。 我如何也能获得最大的利润和最低利润。当资本为100,000时。

感谢您的帮助;

Unnamed: 0  open    high    low close   volume  Date    time    Profit  Loss    proforloss
0   0   252.70  254.25  252.35  252.60  319790  2022-01-03  09:15:00    0.000000    0.039573    -0.039573
1   1   252.60  253.65  251.75  252.80  220927  2022-01-03  09:30:00    0.079177    0.000000    0.079177
2   2   252.95  254.90  252.30  252.85  526445  2022-01-03  09:45:00    0.000000    0.039534    -0.039534
3   3   252.85  253.15  252.40  252.55  280414  2022-01-03  10:00:00    0.000000    0.118647    -0.118647
4   4   252.55  253.10  252.25  252.80  112875  2022-01-03  10:15:00    0.098990    0.000000    0.098990

this is the data given to me i have got the profit and loss for 15 min time frame but how can i get profit of a day starting time is 09:30:00 and closing time is 15:00:00.
how can i also get the max profit and min profit of the day . when capital is 100,000.

thanks for your help;

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

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

发布评论

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

评论(1

听闻余生 2025-02-06 04:22:55

您可以首先在相关交易时间内过滤行,然后使用 groupby() 获得当天的最大收益。最后,用所需的体积乘以。

df['time'] = pd.to_timedelta(df['time'])
df = df[
    (pd.Timedelta(hours=9, minutes=30) <= df["time"])
    & (df["time"] <= pd.Timedelta(hours=15))
]
df = df.groupby("Date", sort=False)[["Profit", "Loss"]].agg(["min", "max"])
df = df * 100_000

输出:

           Profit         Loss         
              min     max  min      max
Date                                   
2022-01-03    0.0  9899.0  0.0  11864.7

You could filter for rows during the relevant trading times first, then use groupby() to get the max / min profit of the day. Finally, multiply with the desired volume.

df['time'] = pd.to_timedelta(df['time'])
df = df[
    (pd.Timedelta(hours=9, minutes=30) <= df["time"])
    & (df["time"] <= pd.Timedelta(hours=15))
]
df = df.groupby("Date", sort=False)[["Profit", "Loss"]].agg(["min", "max"])
df = df * 100_000

Output:

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