-
Notifications
You must be signed in to change notification settings - Fork 54
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
[Futures] update API and fix simulator #1126
Conversation
d16d9b6
to
3ab2064
Compare
4abe237
to
893f561
Compare
else enums.PositionMode.ONE_WAY | ||
) | ||
if position_mode is enums.PositionMode.HEDGE: | ||
# todo when handling helge positions |
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.
# todo when handling helge positions | |
# todo when handling hedge positions |
😉
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.
😮 indeed, thanks
raise NotImplementedError(amount_type) | ||
if context.exchange_manager.is_future: | ||
if position_kw.is_in_one_way_position_mode(context): | ||
# use abs() since short positions have negative size |
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.
👍
decimal.Decimal("16.66666666666666666666666667") | ||
decimal.Decimal("116.6666666666666666666666667") |
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.
Can you please explain this change? A price change has no impact in the bankruptcy price? (this test seems to have a 20 price and the second one has a 100 price and the bankruptcy price does not change)
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.
Right it does not change compared the the next line because with_mark_price=True
so we use the position mark_price and not the given price arguement.
The previous value was due to a mistake in the ternary operator in get_bankruptcy_price
impl
decimal.Decimal("16.66666666666666666666666667") | ||
decimal.Decimal("116.6666666666666666666666667") |
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.
Right it does not change compared the the next line because with_mark_price=True
so we use the position mark_price and not the given price arguement.
The previous value was due to a mistake in the ternary operator in get_bankruptcy_price
impl
@@ -217,13 +217,11 @@ async def test_get_bankruptcy_price_with_long(future_trader_simulator_with_defau | |||
assert position_inst.get_bankruptcy_price(position_inst.entry_price, position_inst.side, with_mark_price=True) == decimal.Decimal(50) | |||
default_contract.set_current_leverage(constants.ONE_HUNDRED) | |||
assert position_inst.get_bankruptcy_price(position_inst.entry_price, position_inst.side) == decimal.Decimal("99.00990099009900990099009901") | |||
assert position_inst.get_bankruptcy_price(position_inst.entry_price, position_inst.side, with_mark_price=True) == decimal.Decimal("0.9900990099009900990099009901") | |||
assert position_inst.get_bankruptcy_price(position_inst.entry_price, position_inst.side, with_mark_price=True) == decimal.Decimal('99.00990099009900990099009901') | |||
await position_inst.update(update_size=constants.ONE_HUNDRED, | |||
mark_price=decimal.Decimal(2) * constants.ONE_HUNDRED) | |||
assert position_inst.get_bankruptcy_price(position_inst.entry_price, position_inst.side) == decimal.Decimal("99.00990099009900990099009901") |
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.
here is an example of a bankruptcy_price that changes according to the given price (with_mark_price
is unset and therefore false by default, we get a different price from the next line)
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.
👍
No description provided.