-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update order_target_portfolio #893
Conversation
@@ -70,14 +72,26 @@ def _get_account_position_ins(id_or_ins): | |||
return account, position, ins | |||
|
|||
|
|||
def _round_order_quantity(ins, quantity) -> int: | |||
def _round_order_quantity(ins, quantity, method: str = "round_down") -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里直直接把 round 函数作为参数传进来吧
@@ -373,16 +387,8 @@ def order_target_portfolio( | |||
)) | |||
|
|||
account_value = account.total_value | |||
if total_percent == 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个我感觉还是得留着,要不然后边的买单会稳定少于目标
order.set_frozen_price(last_price) | ||
order_list.append(order) | ||
open_orders.append(order) | ||
estimate_cash -= order.quantity * order.frozen_price + env.get_order_transaction_cost(order) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果 delta_quantity 不变的话订单花费的金额没必要重复计算。
No description provided.