tradx 0.1.2__tar.gz → 0.1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. {tradx-0.1.2 → tradx-0.1.4}/PKG-INFO +1 -1
  2. {tradx-0.1.2 → tradx-0.1.4}/pyproject.toml +1 -1
  3. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/baseAlgo.py +56 -25
  4. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/order.py +2 -0
  5. {tradx-0.1.2 → tradx-0.1.4}/.gitignore +0 -0
  6. {tradx-0.1.2 → tradx-0.1.4}/.vscode/settings.json +0 -0
  7. {tradx-0.1.2 → tradx-0.1.4}/README.md +0 -0
  8. {tradx-0.1.2 → tradx-0.1.4}/examples/example1.log +0 -0
  9. {tradx-0.1.2 → tradx-0.1.4}/examples/example1.py +0 -0
  10. {tradx-0.1.2 → tradx-0.1.4}/examples/example2.log +0 -0
  11. {tradx-0.1.2 → tradx-0.1.4}/examples/example2.py +0 -0
  12. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/__init__.py +0 -0
  13. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/algoContainer.py +0 -0
  14. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/candleData.py +0 -0
  15. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/cmInstrument.py +0 -0
  16. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/futureInstrument.py +0 -0
  17. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/index.py +0 -0
  18. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/instrumentPropertyChangeData.py +0 -0
  19. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/ltpData.py +0 -0
  20. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/ltpPartialData.py +0 -0
  21. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/marketDepthData.py +0 -0
  22. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/marketStatusData.py +0 -0
  23. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/openInterestData.py +0 -0
  24. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/openInterestPartialData.py +0 -0
  25. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/optionsInstrument.py +0 -0
  26. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/orderEvent.py +0 -0
  27. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/position.py +0 -0
  28. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/positionEvent.py +0 -0
  29. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/touchLineData.py +0 -0
  30. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/touchLinePartialData.py +0 -0
  31. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/tradeConversionEvent.py +0 -0
  32. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/baseClass/tradeEvent.py +0 -0
  33. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/constants/holidays.py +0 -0
  34. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/dualHashMap.py +0 -0
  35. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/interactiveEngine.py +0 -0
  36. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/logger/logger.py +0 -0
  37. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/logger/logger2.py +0 -0
  38. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/marketDataEngine.py +0 -0
  39. {tradx-0.1.2 → tradx-0.1.4}/src/tradx/py.typed +0 -0
  40. {tradx-0.1.2 → tradx-0.1.4}/test/test_candleData.py +0 -0
  41. {tradx-0.1.2 → tradx-0.1.4}/test/test_interactiveEngine.log +0 -0
  42. {tradx-0.1.2 → tradx-0.1.4}/test/test_interactiveEngine.py +0 -0
  43. {tradx-0.1.2 → tradx-0.1.4}/test/test_logger.log +0 -0
  44. {tradx-0.1.2 → tradx-0.1.4}/test/test_logger.py +0 -0
  45. {tradx-0.1.2 → tradx-0.1.4}/test/test_ltpData.py +0 -0
  46. {tradx-0.1.2 → tradx-0.1.4}/test/test_ltpPartailData.py +0 -0
  47. {tradx-0.1.2 → tradx-0.1.4}/test/test_marketDataEngine.log +0 -0
  48. {tradx-0.1.2 → tradx-0.1.4}/test/test_marketDataEngine.py +0 -0
  49. {tradx-0.1.2 → tradx-0.1.4}/test/test_marketDepthData.py +0 -0
  50. {tradx-0.1.2 → tradx-0.1.4}/test/test_marketStatusData.py +0 -0
  51. {tradx-0.1.2 → tradx-0.1.4}/test/test_openInterestData.py +0 -0
  52. {tradx-0.1.2 → tradx-0.1.4}/test/test_openInterestPartialData.py +0 -0
  53. {tradx-0.1.2 → tradx-0.1.4}/test/test_option.py +0 -0
  54. {tradx-0.1.2 → tradx-0.1.4}/test/test_orderEvent.py +0 -0
  55. {tradx-0.1.2 → tradx-0.1.4}/test/test_positionEvent.py +0 -0
  56. {tradx-0.1.2 → tradx-0.1.4}/test/test_touchLineData.py +0 -0
  57. {tradx-0.1.2 → tradx-0.1.4}/test/test_tradeConversionEvent.py +0 -0
  58. {tradx-0.1.2 → tradx-0.1.4}/test/test_tradeEvent.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tradx
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: A Package Designed to simplify strategy development on package xts-api-client
5
5
  Author-email: "jatin.kumawat" <jatin.kumawat@rmoneyindia.com>
6
6
  Requires-Python: >=3.12
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "tradx"
3
- version = "0.1.2"
3
+ version = "0.1.4"
4
4
  description = "A Package Designed to simplify strategy development on package xts-api-client"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -1,7 +1,7 @@
1
1
  from abc import ABC, abstractmethod
2
2
  import shortuuid
3
3
  from typing import Any, TYPE_CHECKING, List, Dict
4
- from datetime import datetime, timedelta
4
+ from decimal import Decimal
5
5
  from tradx.baseClass.order import Order
6
6
  from tradx.baseClass.position import Position
7
7
 
@@ -167,8 +167,9 @@ class BaseAlgo(ABC):
167
167
  order.OrderDisclosedQuantity,
168
168
  order.OrderPrice,
169
169
  order.OrderStopPrice,
170
- order.OrderStatus,
171
170
  order.OrderSide,
171
+ order.TimeInForce,
172
+ order.OrderStatus,
172
173
  )
173
174
  self.order_diary.append(new_order)
174
175
  if self.interactiveEngine.user_logger:
@@ -198,7 +199,8 @@ class BaseAlgo(ABC):
198
199
  3. Logs the update or insertion of the position.
199
200
  4. Ensures the on_tradeEvent callback is called asynchronously.
200
201
  """
201
-
202
+ if trade.OrderStatus != "Filled":
203
+ return
202
204
  # Check if the trade exists in the position diary
203
205
  existing_position = next(
204
206
  (
@@ -370,23 +372,35 @@ class BaseAlgo(ABC):
370
372
  5. If the order is not filled, modifies the order with updated market data.
371
373
  """
372
374
  OrderUniqueIdentifier = self.order_no()
373
- Data: TouchLineData = await self.marketDataEngine.fetch_ltp(
374
- [
375
- {
376
- "exchangeSegment": ExchangeSegment,
377
- "exchangeInstrumentID": ExchangeInstrumentID,
378
- }
379
- ]
375
+ _adjust = Decimal("0.05")
376
+ Data: TouchLineData = (
377
+ await self.marketDataEngine.fetch_ltp(
378
+ [
379
+ {
380
+ "exchangeSegment": ExchangeSegment,
381
+ "exchangeInstrumentID": ExchangeInstrumentID,
382
+ }
383
+ ]
384
+ )
380
385
  )[0]
386
+
381
387
  await self.interactiveEngine.limit_order(
382
388
  ExchangeSegment,
383
389
  ExchangeInstrumentID,
384
390
  ProductType,
385
391
  Quantity,
386
- (Data.AskInfo.Price + 0.05 if Quantity > 0 else Data.BidInfo.Price - 0.05),
392
+ (
393
+ (Data.AskInfo.Price + _adjust).to_eng_string()
394
+ if Quantity > 0
395
+ else (Data.BidInfo.Price - _adjust).to_eng_string()
396
+ ),
387
397
  OrderUniqueIdentifier,
388
398
  )
389
-
399
+ if self.interactiveEngine.user_logger:
400
+ self.interactiveEngine.user_logger.info(
401
+ f"Placing Limit Order for {ExchangeInstrumentID} with Quantity {Quantity}",
402
+ caller=f"{self.__class__.__name__}.safe_market_order",
403
+ )
390
404
  await asyncio.sleep(0.1)
391
405
  order = next(
392
406
  (
@@ -396,7 +410,7 @@ class BaseAlgo(ABC):
396
410
  ),
397
411
  None,
398
412
  )
399
- while order is None or (order is not None and order.OrderStatus != "Filled"):
413
+ while order is None or (order is not None and "Filled" not in order.OrderStatus):
400
414
  await asyncio.sleep(0.1)
401
415
  order = next(
402
416
  (
@@ -406,15 +420,25 @@ class BaseAlgo(ABC):
406
420
  ),
407
421
  None,
408
422
  )
409
- if order is not None and order.OrderStatus != "Filled":
410
- Data: TouchLineData = await self.marketDataEngine.fetch_ltp(
411
- [
412
- {
413
- "exchangeSegment": ExchangeSegment,
414
- "exchangeInstrumentID": ExchangeInstrumentID,
415
- }
416
- ]
423
+ if order is not None and order.OrderStatus == "Rejected":
424
+ if self.interactiveEngine.user_logger:
425
+ self.interactiveEngine.user_logger.info(
426
+ f"Order Rejected for {ExchangeInstrumentID} with Quantity {Quantity}",
427
+ caller=f"{self.__class__.__name__}.safe_market_order",
428
+ )
429
+ break
430
+ if order is not None and "Filled" not in order.OrderStatus:
431
+ Data: TouchLineData = (
432
+ await self.marketDataEngine.fetch_ltp(
433
+ [
434
+ {
435
+ "exchangeSegment": ExchangeSegment,
436
+ "exchangeInstrumentID": ExchangeInstrumentID,
437
+ }
438
+ ]
439
+ )
417
440
  )[0]
441
+
418
442
  await self.interactiveEngine.xt.modify_order(
419
443
  order.AppOrderID,
420
444
  order.ProductType,
@@ -422,15 +446,22 @@ class BaseAlgo(ABC):
422
446
  order.OrderQuantity,
423
447
  order.OrderDisclosedQuantity,
424
448
  (
425
- Data.AskInfo.Price + 0.05
449
+ (Data.AskInfo.Price + _adjust).to_eng_string()
426
450
  if Quantity > 0
427
- else Data.BidInfo.Price - 0.05
451
+ else (Data.BidInfo.Price - _adjust).to_eng_string()
428
452
  ),
429
- order.OrderStopPrice,
453
+ order.OrderStopPrice.to_eng_string(),
430
454
  order.TimeInForce,
431
455
  order.OrderUniqueIdentifier,
456
+ "*****",
432
457
  )
433
- await asyncio.sleep(0.3)
458
+ if self.interactiveEngine.user_logger:
459
+ self.interactiveEngine.user_logger.info(
460
+ f"Modifying Order for {ExchangeInstrumentID} with Quantity {Quantity} and Price "
461
+ f"{(Data.AskInfo.Price + _adjust).to_eng_string() if Quantity > 0 else (Data.BidInfo.Price - _adjust).to_eng_string()}",
462
+ caller=f"{self.__class__.__name__}.safe_market_order",
463
+ )
464
+ await asyncio.sleep(0.7)
434
465
 
435
466
  async def safeLiquidateIntraday(self) -> None:
436
467
  """
@@ -37,6 +37,7 @@ class Order(BaseModel):
37
37
  OrderPrice: Decimal,
38
38
  OrderStopPrice: Decimal,
39
39
  OrderSide: str,
40
+ TimeInForce: str,
40
41
  OrderStatus: str = "",
41
42
  ):
42
43
  super().__init__(
@@ -50,4 +51,5 @@ class Order(BaseModel):
50
51
  OrderStopPrice=OrderStopPrice,
51
52
  OrderStatus=OrderStatus,
52
53
  OrderSide=OrderSide,
54
+ TimeInForce=TimeInForce,
53
55
  )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes