You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
958 B

import pytest
from typing import Union
from auto_trading.orders import Short, Long
@pytest.mark.parametrize(
"order, usd",
[
(Long("BTC", 1, 1), 1),
(Short("BTC", 1, 1), 1),
(Long("BTC", 1, 10), 10),
(Short("BTC", 1, 10), 10),
(Long("BTC", 10, 1), 10),
(Short("BTC", 10, 1), 10),
],
)
def test_order_usd(order: Union[Long, Short], usd: float):
"""Test the USD value of an order."""
assert order.amount_usd == usd
10 months ago
@pytest.mark.parametrize(
"order, string",
[
(Long("BTC", 1, 1), "Long(BTC: 1$)"),
(Short("BTC", 1, 1), "Short(BTC: 1$)"),
(Long("BTC", 1, 10), "Long(BTC: 10$)"),
(Short("BTC", 1, 10), "Short(BTC: 10$)"),
(Long("BTC", 10, 1), "Long(BTC: 10$)"),
(Short("BTC", 10, 1), "Short(BTC: 10$)"),
],
)
def test_repr(order: Union[Long, Short], string: str):
"""Test repr of an order."""
10 months ago
assert str(order) == string