siglab-py 0.1.5__tar.gz → 0.1.6__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.

Potentially problematic release.


This version of siglab-py might be problematic. Click here for more details.

Files changed (33) hide show
  1. {siglab_py-0.1.5 → siglab_py-0.1.6}/PKG-INFO +1 -1
  2. {siglab_py-0.1.5 → siglab_py-0.1.6}/pyproject.toml +1 -1
  3. {siglab_py-0.1.5 → siglab_py-0.1.6}/setup.cfg +1 -1
  4. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/ordergateway/client.py +43 -5
  5. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/ordergateway/test_ordergateway.py +14 -39
  6. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py.egg-info/PKG-INFO +1 -1
  7. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/__init__.py +0 -0
  8. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/constants.py +0 -0
  9. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/exchanges/__init__.py +0 -0
  10. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/exchanges/any_exchange.py +0 -0
  11. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/market_data_providers/__init__.py +0 -0
  12. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/market_data_providers/aggregated_orderbook_provider.py +0 -0
  13. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/market_data_providers/candles_provider.py +0 -0
  14. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/market_data_providers/candles_ta_provider.py +0 -0
  15. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/market_data_providers/deribit_options_expiry_provider.py +0 -0
  16. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/market_data_providers/orderbooks_provider.py +0 -0
  17. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/market_data_providers/test_provider.py +0 -0
  18. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/ordergateway/__init__.py +0 -0
  19. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/ordergateway/encrypt_keys_util.py +0 -0
  20. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/ordergateway/gateway.py +0 -0
  21. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/tests/__init__.py +0 -0
  22. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/tests/integration/__init__.py +0 -0
  23. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/tests/integration/market_data_util_tests.py +0 -0
  24. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/tests/unit/__init__.py +0 -0
  25. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/util/__init__.py +0 -0
  26. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/util/analytic_util.py +0 -0
  27. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/util/aws_util.py +0 -0
  28. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/util/market_data_util.py +0 -0
  29. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py/util/retry_util.py +0 -0
  30. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py.egg-info/SOURCES.txt +0 -0
  31. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py.egg-info/dependency_links.txt +0 -0
  32. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py.egg-info/requires.txt +0 -0
  33. {siglab_py-0.1.5 → siglab_py-0.1.6}/siglab_py.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: siglab_py
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Summary: Market data fetches, TA calculations and generic order gateway.
5
5
  Author: r0bbarh00d
6
6
  Author-email: r0bbarh00d <r0bbarh00d@gmail.com>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "siglab_py"
7
- version = "0.1.5"
7
+ version = "0.1.6"
8
8
  description = "Market data fetches, TA calculations and generic order gateway."
9
9
  authors = [{name = "r0bbarh00d", email = "r0bbarh00d@gmail.com"}]
10
10
  license = {text = "MIT"}
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = siglab_py
3
- version = 0.1.5
3
+ version = 0.1.6
4
4
  description = Market data fetches, TA calculations and generic order gateway.
5
5
  author = r0bbarh00d
6
6
  author_email = r0bbarh00d@gmail.com
@@ -1,10 +1,11 @@
1
1
 
2
- from typing import List, Dict, Any
2
+ from typing import List, Dict, Any, Union
3
+ import json
4
+ import time
5
+ from redis import StrictRedis
3
6
 
4
- from ccxt.base.types import Position
5
-
6
- from ..exchanges.any_exchange import AnyExchange
7
- from ..constants import JSON_SERIALIZABLE_TYPES
7
+ from exchanges.any_exchange import AnyExchange
8
+ from constants import JSON_SERIALIZABLE_TYPES
8
9
 
9
10
  '''
10
11
  Example,
@@ -135,3 +136,40 @@ class DivisiblePosition(Order):
135
136
  rv['filled_amount'] = self.filled_amount
136
137
  rv['average_cost'] = self.average_cost
137
138
  return rv
139
+
140
+ def execute_positions(
141
+ redis_client : StrictRedis,
142
+ positions : List[DivisiblePosition],
143
+ ordergateway_pending_orders_topic : str,
144
+ ordergateway_executions_topic : str
145
+ ) -> Union[Dict[JSON_SERIALIZABLE_TYPES, JSON_SERIALIZABLE_TYPES], None]:
146
+
147
+ executed_positions : Union[Dict[JSON_SERIALIZABLE_TYPES, JSON_SERIALIZABLE_TYPES], None] = None
148
+
149
+ # https://redis.io/commands/publish/
150
+ _positions = [ position.to_dict() for position in positions ]
151
+ redis_client.set(name=ordergateway_pending_orders_topic, value=json.dumps(_positions).encode('utf-8'), ex=60*15)
152
+
153
+ print(f"{ordergateway_pending_orders_topic}: Orders sent {_positions}.")
154
+
155
+ # Wait for fills
156
+ fills_received : bool = False
157
+ while not fills_received:
158
+ try:
159
+ keys = redis_client.keys()
160
+ for key in keys:
161
+ s_key : str = key.decode("utf-8")
162
+ if s_key==ordergateway_executions_topic:
163
+ message = redis_client.get(key)
164
+ if message:
165
+ message = message.decode('utf-8')
166
+ executed_positions = json.loads(message)
167
+ fills_received = True
168
+ break
169
+
170
+ except Exception as loop_err:
171
+ raise loop_err
172
+ finally:
173
+ time.sleep(1)
174
+
175
+ return executed_positions
@@ -5,15 +5,14 @@ from datetime import datetime
5
5
  from typing import Any, Dict, List, Union
6
6
  import logging
7
7
  import json
8
- import pandas as pd
9
- import numpy as np
10
8
  from redis import StrictRedis
11
9
 
12
- from ordergateway.client import DivisiblePosition
10
+ from ordergateway.client import DivisiblePosition, execute_positions
11
+ from constants import JSON_SERIALIZABLE_TYPES
13
12
 
14
13
  '''
15
14
  set PYTHONPATH=%PYTHONPATH%;D:\dev\siglab\siglab_py
16
- python test_ordergateway.py --gateway_id bybit_01
15
+ python test_ordergateway.py --gateway_id bybit_03
17
16
  '''
18
17
 
19
18
  param : Dict[str, str] = {
@@ -42,16 +41,6 @@ def init_redis_client() -> StrictRedis:
42
41
 
43
42
  return redis_client
44
43
 
45
- def execute_positions(
46
- redis_client : StrictRedis,
47
- positions : List[DivisiblePosition],
48
- ordergateway_pending_orders_topic : str):
49
- # https://redis.io/commands/publish/
50
- _positions = [ position.to_dict() for position in positions ]
51
- redis_client.set(name=ordergateway_pending_orders_topic, value=json.dumps(_positions).encode('utf-8'), ex=60*15)
52
-
53
- print(f"{ordergateway_pending_orders_topic}: Orders sent {_positions}.")
54
-
55
44
  if __name__ == '__main__':
56
45
  parse_args()
57
46
 
@@ -109,32 +98,18 @@ if __name__ == '__main__':
109
98
  wait_fill_threshold_ms=60000
110
99
  )
111
100
  ]
112
- execute_positions(
101
+
102
+
103
+ executed_positions : Union[Dict[JSON_SERIALIZABLE_TYPES, JSON_SERIALIZABLE_TYPES], None] = execute_positions(
113
104
  redis_client=redis_client,
114
105
  positions=positions_2,
115
- ordergateway_pending_orders_topic=ordergateway_pending_orders_topic)
116
-
117
- # Wait for fills
118
- fills_received : bool = False
119
- while not fills_received:
120
- try:
121
- keys = redis_client.keys()
122
- for key in keys:
123
- s_key : str = key.decode("utf-8")
124
- if s_key==ordergateway_executions_topic:
125
- message = redis_client.get(key)
126
- if message:
127
- message = message.decode('utf-8')
128
- positions = json.loads(message)
129
-
130
- for position in positions:
131
- print(f"{position['ticker']} {position['side']} amount: {position['amount']} leg_room_bps: {position['leg_room_bps']} slices: {position['slices']}, filled_amount: {position['filled_amount']}, average_cost: {position['average_cost']}, # executions: {len(position['executions'])}")
132
- fills_received = True
133
- break
134
-
135
- except Exception as loop_err:
136
- print(f"Oops {loop_err}")
137
- finally:
138
- time.sleep(1)
106
+ ordergateway_pending_orders_topic=ordergateway_pending_orders_topic,
107
+ ordergateway_executions_topic=ordergateway_executions_topic
108
+ )
109
+ if executed_positions:
110
+ for position in executed_positions:
111
+ print(f"{position['ticker']} {position['side']} amount: {position['amount']} leg_room_bps: {position['leg_room_bps']} slices: {position['slices']}, filled_amount: {position['filled_amount']}, average_cost: {position['average_cost']}, # executions: {len(position['executions'])}") # type: ignore
112
+
113
+
139
114
 
140
115
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: siglab-py
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Summary: Market data fetches, TA calculations and generic order gateway.
5
5
  Author: r0bbarh00d
6
6
  Author-email: r0bbarh00d <r0bbarh00d@gmail.com>