|
12 | 12 | FROZEN_NONCE = 1473459052 |
13 | 13 |
|
14 | 14 |
|
| 15 | +@pytest.mark.asyncio |
| 16 | +async def test_create_sell_order_with_default_expiration( |
| 17 | + mocker: MockerFixture, create_trading_account, create_btc_usd_market |
| 18 | +): |
| 19 | + mocker.patch("x10.utils.starkex.generate_nonce", return_value=FROZEN_NONCE) |
| 20 | + |
| 21 | + freezer = freeze_time("2024-01-05 01:08:56.860694") |
| 22 | + frozen_time = freezer.start() |
| 23 | + |
| 24 | + from x10.perpetual.order_object import create_order_object |
| 25 | + |
| 26 | + frozen_time.move_to("2024-01-05 01:08:57") |
| 27 | + |
| 28 | + trading_account = create_trading_account() |
| 29 | + btc_usd_market = create_btc_usd_market() |
| 30 | + order_obj = create_order_object( |
| 31 | + account=trading_account, |
| 32 | + market=btc_usd_market, |
| 33 | + amount_of_synthetic=Decimal("0.00100000"), |
| 34 | + price=Decimal("43445.11680000"), |
| 35 | + side=OrderSide.SELL, |
| 36 | + ) |
| 37 | + |
| 38 | + freezer.stop() |
| 39 | + |
| 40 | + assert_that( |
| 41 | + order_obj.to_api_request_json(), |
| 42 | + equal_to( |
| 43 | + { |
| 44 | + "id": "2096045681239655445582070517240411138302380632690430411530650608228763263945", |
| 45 | + "market": "BTC-USD", |
| 46 | + "type": "LIMIT", |
| 47 | + "side": "SELL", |
| 48 | + "qty": "0.00100000", |
| 49 | + "price": "43445.11680000", |
| 50 | + "reduceOnly": False, |
| 51 | + "postOnly": False, |
| 52 | + "timeInForce": "GTT", |
| 53 | + "expiryEpochMillis": 1704445737000, |
| 54 | + "fee": "0.0005", |
| 55 | + "nonce": "1473459052", |
| 56 | + "selfTradeProtectionLevel": "ACCOUNT", |
| 57 | + "cancelId": None, |
| 58 | + "settlement": { |
| 59 | + "signature": { |
| 60 | + "r": "0x39ff8493e8e26c9a588a7046e1380b6e1201287a179e10831b7040d3efc26d", |
| 61 | + "s": "0x5c9acd1879bf8d43e4ccd14648186d2a9edf387fe1b61e491fe0a539de3272b", |
| 62 | + }, |
| 63 | + "starkKey": "0x61c5e7e8339b7d56f197f54ea91b776776690e3232313de0f2ecbd0ef76f466", |
| 64 | + "collateralPosition": "10002", |
| 65 | + }, |
| 66 | + "trigger": None, |
| 67 | + "tpSlType": None, |
| 68 | + "takeProfit": None, |
| 69 | + "stopLoss": None, |
| 70 | + "debuggingAmounts": {"collateralAmount": "43445116", "feeAmount": "21723", "syntheticAmount": "1000"}, |
| 71 | + } |
| 72 | + ), |
| 73 | + ) |
| 74 | + |
| 75 | + |
15 | 76 | @freeze_time("2024-01-05 01:08:56.860694") |
16 | 77 | @pytest.mark.asyncio |
17 | 78 | async def test_create_sell_order(mocker: MockerFixture, create_trading_account, create_btc_usd_market): |
|
0 commit comments