diff --git a/api/serializers.py b/api/serializers.py index f08ceb9f..55e207f2 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -628,7 +628,7 @@ class TickSerializer(serializers.ModelSerializer): "premium", "fee", ) - depth = 1 + depth = 0 class StealthSerializer(serializers.Serializer): diff --git a/api/views.py b/api/views.py index 92f50945..3737d27a 100644 --- a/api/views.py +++ b/api/views.py @@ -872,11 +872,17 @@ class TickView(ListAPIView): # Perform the query with date range filtering try: if start_date_str: - start_date = datetime.strptime(start_date_str, "%d-%m-%Y").date() - self.queryset = self.queryset.filter(timestamp__gte=start_date) + naive_start_date = datetime.strptime(start_date_str, "%d-%m-%Y") + aware_start_date = timezone.make_aware( + naive_start_date, timezone=timezone.get_current_timezone() + ) + self.queryset = self.queryset.filter(timestamp__gte=aware_start_date) if end_date_str: - end_date = datetime.strptime(end_date_str, "%d-%m-%Y").date() - self.queryset = self.queryset.filter(timestamp__lte=end_date) + naive_end_date = datetime.strptime(end_date_str, "%d-%m-%Y") + aware_end_date = timezone.make_aware( + naive_end_date, timezone=timezone.get_current_timezone() + ) + self.queryset = self.queryset.filter(timestamp__lte=aware_end_date) except ValueError: return Response( {"bad_request": "Invalid date format"}, diff --git a/docs/assets/schemas/api-latest.yaml b/docs/assets/schemas/api-latest.yaml index ac6b680c..55ce967d 100644 --- a/docs/assets/schemas/api-latest.yaml +++ b/docs/assets/schemas/api-latest.yaml @@ -920,164 +920,6 @@ components: nullable: true description: A valid LN invoice with the reward amount to withdraw maxLength: 2000 - CurrencyEnum: - enum: - - 1 - - 2 - - 3 - - 4 - - 5 - - 6 - - 7 - - 8 - - 9 - - 10 - - 11 - - 12 - - 13 - - 14 - - 15 - - 16 - - 17 - - 18 - - 19 - - 20 - - 21 - - 22 - - 23 - - 24 - - 25 - - 26 - - 27 - - 28 - - 29 - - 30 - - 31 - - 32 - - 33 - - 34 - - 35 - - 36 - - 37 - - 38 - - 39 - - 40 - - 41 - - 42 - - 43 - - 44 - - 45 - - 46 - - 47 - - 48 - - 49 - - 50 - - 51 - - 52 - - 53 - - 54 - - 55 - - 56 - - 57 - - 58 - - 59 - - 60 - - 61 - - 62 - - 63 - - 64 - - 65 - - 66 - - 67 - - 68 - - 69 - - 70 - - 71 - - 72 - - 73 - - 74 - - 75 - - 300 - - 1000 - type: integer - description: |- - * `1` - USD - * `2` - EUR - * `3` - JPY - * `4` - GBP - * `5` - AUD - * `6` - CAD - * `7` - CHF - * `8` - CNY - * `9` - HKD - * `10` - NZD - * `11` - SEK - * `12` - KRW - * `13` - SGD - * `14` - NOK - * `15` - MXN - * `16` - BYN - * `17` - RUB - * `18` - ZAR - * `19` - TRY - * `20` - BRL - * `21` - CLP - * `22` - CZK - * `23` - DKK - * `24` - HRK - * `25` - HUF - * `26` - INR - * `27` - ISK - * `28` - PLN - * `29` - RON - * `30` - ARS - * `31` - VES - * `32` - COP - * `33` - PEN - * `34` - UYU - * `35` - PYG - * `36` - BOB - * `37` - IDR - * `38` - ANG - * `39` - CRC - * `40` - CUP - * `41` - DOP - * `42` - GHS - * `43` - GTQ - * `44` - ILS - * `45` - JMD - * `46` - KES - * `47` - KZT - * `48` - MYR - * `49` - NAD - * `50` - NGN - * `51` - AZN - * `52` - PAB - * `53` - PHP - * `54` - PKR - * `55` - QAR - * `56` - SAR - * `57` - THB - * `58` - TTD - * `59` - VND - * `60` - XOF - * `61` - TWD - * `62` - TZS - * `63` - XAF - * `64` - UAH - * `65` - EGP - * `66` - LKR - * `67` - MAD - * `68` - AED - * `69` - TND - * `70` - ETB - * `71` - GEL - * `72` - UGX - * `73` - RSD - * `74` - IRT - * `75` - BDT - * `300` - XAU - * `1000` - BTC ExpiryReasonEnum: enum: - 0 @@ -1345,28 +1187,6 @@ components: required: - currency - type - Nested: - type: object - properties: - id: - type: integer - readOnly: true - currency: - allOf: - - $ref: '#/components/schemas/CurrencyEnum' - minimum: 0 - maximum: 32767 - exchange_rate: - type: string - format: decimal - pattern: ^-?\d{0,14}(?:\.\d{0,4})?$ - nullable: true - timestamp: - type: string - format: date-time - required: - - currency - - id NoticeSeverityEnum: enum: - none @@ -1948,9 +1768,8 @@ components: type: string format: date-time currency: - allOf: - - $ref: '#/components/schemas/Nested' - readOnly: true + type: integer + nullable: true volume: type: string format: decimal @@ -1968,8 +1787,6 @@ components: fee: type: string format: decimal - required: - - currency TypeEnum: enum: - 0 diff --git a/tests/test_coordinator_info.py b/tests/test_api_info.py similarity index 98% rename from tests/test_coordinator_info.py rename to tests/test_api_info.py index ce4b90e9..d7bc813c 100644 --- a/tests/test_coordinator_info.py +++ b/tests/test_api_info.py @@ -15,7 +15,7 @@ NOTICE_SEVERITY = config("NOTICE_SEVERITY", cast=str, default="none") NOTICE_MESSAGE = config("NOTICE_MESSAGE", cast=str, default="") -class CoordinatorInfoTest(BaseAPITestCase): +class APIInfoTest(BaseAPITestCase): su_pass = "12345678" su_name = config("ESCROW_USERNAME", cast=str, default="admin") diff --git a/tests/test_coordinator_limits.py b/tests/test_api_limits.py similarity index 96% rename from tests/test_coordinator_limits.py rename to tests/test_api_limits.py index bbeb1b65..19662ba9 100644 --- a/tests/test_coordinator_limits.py +++ b/tests/test_api_limits.py @@ -7,7 +7,7 @@ from api.tasks import cache_market from tests.test_api import BaseAPITestCase -class CoordinatorInfoTest(BaseAPITestCase): +class APILimitsTest(BaseAPITestCase): su_pass = "12345678" su_name = config("ESCROW_USERNAME", cast=str, default="admin") diff --git a/tests/test_trade_pipeline.py b/tests/test_trade_pipeline.py index 0e2969bc..8d78bb40 100644 --- a/tests/test_trade_pipeline.py +++ b/tests/test_trade_pipeline.py @@ -851,6 +851,9 @@ class TradeTest(BaseAPITestCase): self.assertIsHash(data["maker_summary"]["payment_hash"]) def test_cancel_public_order(self): + """ + Tests the cancellation of a public order + """ maker_index = 1 maker_form = self.maker_form_buy_with_range @@ -866,6 +869,9 @@ class TradeTest(BaseAPITestCase): ) def test_collaborative_cancel_order_in_chat(self): + """ + Tests the collaborative cancellation of an order in the chat state + """ maker_index = 1 taker_index = 2 maker_form = self.maker_form_buy_with_range @@ -894,9 +900,28 @@ class TradeTest(BaseAPITestCase): # Taker accepts (ask) the cancellation response = self.cancel_order(response.json()["id"], taker_index) data = response.json() - print(data) self.assertEqual(response.status_code, 400) self.assertResponse(response) self.assertEqual( data["bad_request"], "This order has been cancelled collaborativelly" ) + + def test_ticks(self): + """ + Tests the historical ticks serving endpoint after creating a contract + """ + path = reverse("ticks") + params = "?start=01-01-1970&end=01-01-2070" + self.make_and_lock_contract(self.maker_form_buy_with_range) + + response = self.client.get(path + params) + data = response.json() + + self.assertEqual(response.status_code, 200) + self.assertResponse(response) + + self.assertIsInstance(datetime.fromisoformat(data[0]["timestamp"]), datetime) + self.assertIsInstance(data[0]["volume"], str) + self.assertIsInstance(data[0]["price"], str) + self.assertIsInstance(data[0]["premium"], str) + self.assertIsInstance(data[0]["fee"], str)