siglab-py 0.5.10__py3-none-any.whl → 0.5.12__py3-none-any.whl

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.

@@ -62,4 +62,25 @@ class TradingUtilTests(unittest.TestCase):
62
62
  pnl_percent_notional = pnl_percent_notional,
63
63
  default_effective_tp_trailing_percent = default_effective_tp_trailing_percent
64
64
  )
65
- assert(effective_tp_trailing_percent==0) # Most tight trailing SL
65
+ assert(effective_tp_trailing_percent==0) # Most tight trailing SL
66
+
67
+ def test_round_to_level(self):
68
+ prices = [
69
+ { 'price' : 15080, 'rounded' : 15000},
70
+ { 'price' : 15180, 'rounded' : 15200},
71
+ { 'price' : 25080, 'rounded' : 25200},
72
+ { 'price' : 25180, 'rounded' : 25200},
73
+ { 'price' : 25380, 'rounded' : 25500},
74
+ { 'price' : 95332, 'rounded' : 95000},
75
+ { 'price' : 95878, 'rounded' : 96000},
76
+ { 'price' : 103499, 'rounded' : 103000},
77
+ { 'price' : 103500, 'rounded' : 104000},
78
+ { 'price' : 150800, 'rounded' : 150000},
79
+ { 'price' : 151800, 'rounded' : 152000}
80
+ ]
81
+ for entry in prices:
82
+ price = entry['price']
83
+ expected = entry['rounded']
84
+ rounded_price = round_to_level(price, level_granularity=0.01)
85
+ print(f"{price} rounded to: {rounded_price}")
86
+ assert(rounded_price==expected)
@@ -1,3 +1,4 @@
1
+ import math
1
2
 
2
3
  '''
3
4
  pnl_percent_notional = Trade's current pnl in percent.
@@ -115,3 +116,15 @@ def calc_eff_trailing_sl(
115
116
  effective_tp_trailing_percent = default_effective_tp_trailing_percent
116
117
 
117
118
  return effective_tp_trailing_percent
119
+
120
+ # https://norman-lm-fung.medium.com/levels-are-psychological-7176cdefb5f2
121
+ def round_to_level(
122
+ price : float,
123
+ level_granularity : float = 0.01
124
+ ) -> float:
125
+ level_size = price * level_granularity
126
+ magnitude = math.floor(math.log10(level_size))
127
+ base_increment = 10 ** magnitude
128
+ rounded_level_size = round(level_size / base_increment) * base_increment
129
+ rounded_price = round(price / rounded_level_size) * rounded_level_size
130
+ return rounded_price
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: siglab-py
3
- Version: 0.5.10
3
+ Version: 0.5.12
4
4
  Summary: Market data fetches, TA calculations and generic order gateway.
5
5
  Author: r0bbarh00d
6
6
  Author-email: r0bbarh00d <r0bbarh00d@gmail.com>
@@ -24,7 +24,7 @@ siglab_py/tests/integration/market_data_util_tests.py,sha256=p-RWIJZLyj0lAdfi4QT
24
24
  siglab_py/tests/unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
25
  siglab_py/tests/unit/analytic_util_tests.py,sha256=eeusM5zkQR2QyVhT7nqF0mwHVg7vlxwtgv2JnLqwQgY,3852
26
26
  siglab_py/tests/unit/market_data_util_tests.py,sha256=A1y83itISmMJdn6wLpfwcr4tGola8wTf1D1xbelMvgw,2026
27
- siglab_py/tests/unit/trading_util_tests.py,sha256=hkAEZHT-8Ncbm9sG-H4WRoyryJSTCj9BsWTdDX7e4hU,2970
27
+ siglab_py/tests/unit/trading_util_tests.py,sha256=0dhqyzK4swCu7Q5DSXlUb4DrFJhS8iXvfr8Vwpa367s,3915
28
28
  siglab_py/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
29
  siglab_py/util/analytic_util.py,sha256=blFJ1kY_aSJeuzzk28vdB4nhLgmosz0L8IJaJCZy9OM,47272
30
30
  siglab_py/util/aws_util.py,sha256=KGmjHrr1rpnnxr33nXHNzTul4tvyyxl9p6gpwNv0Ygc,2557
@@ -32,8 +32,8 @@ siglab_py/util/market_data_util.py,sha256=mUXg4uaiX3b6_klgJWIEgnUQU4IUd6CwTOqKLi
32
32
  siglab_py/util/notification_util.py,sha256=vySgHjpHgwFDLW0tHSi_AGh9JBbPc25IUgvWxmjAeT8,2658
33
33
  siglab_py/util/retry_util.py,sha256=g-UU6pkPouWZZRZEqP99R2Z0lX5xzckYkzjwqqSDpVQ,922
34
34
  siglab_py/util/slack_notification_util.py,sha256=G27n-adbT3Q6oaHSMvu_Nom794rrda5PprSF-zvmzkM,1912
35
- siglab_py/util/trading_util.py,sha256=9eWhW8y71ID7r9JLDcT3ZAPMHHyvNjIrwUCza4GtAcw,5239
36
- siglab_py-0.5.10.dist-info/METADATA,sha256=VqXrEOz2MGpTeXZmTMiPJd3YEOpKzTb2GATKlbr6ANk,980
37
- siglab_py-0.5.10.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
38
- siglab_py-0.5.10.dist-info/top_level.txt,sha256=AbD4VR9OqmMOGlMJLkAVPGQMtUPIQv0t1BF5xmcLJSk,10
39
- siglab_py-0.5.10.dist-info/RECORD,,
35
+ siglab_py/util/trading_util.py,sha256=-TGNgJdy4HMDPgq31KQn_lRawFxuXnFU5NnLRb1XM5o,5757
36
+ siglab_py-0.5.12.dist-info/METADATA,sha256=QS0mtJr12ZWB60_OMOV6S5Q6GgFh7T4V38bREAUuZoc,980
37
+ siglab_py-0.5.12.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
38
+ siglab_py-0.5.12.dist-info/top_level.txt,sha256=AbD4VR9OqmMOGlMJLkAVPGQMtUPIQv0t1BF5xmcLJSk,10
39
+ siglab_py-0.5.12.dist-info/RECORD,,