We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f0fb22d commit 0c4c63fCopy full SHA for 0c4c63f
1 file changed
examples/basic_tpsl.py
@@ -16,8 +16,10 @@ def main():
16
position_is_long = args.is_buy
17
quantity = 1
18
px = 184.80
19
- tp = px * 1.05 # take profit at +5%
20
- sl = px * 0.95 # stop loss at -5%
+ tpsl_percent = 0.05 # 5%
+
21
+ tp = px * (1 + (tpsl_percent * (1 if position_is_long else -1)))
22
+ sl = px * (1 - (tpsl_percent * (1 if position_is_long else -1)))
23
24
orders = [
25
{
@@ -59,11 +61,8 @@ def main():
59
61
},
60
62
]
63
- try:
- resp = exchange.bulk_orders(orders, grouping="normalTpsl")
64
- print(resp)
65
- except Exception as e:
66
- print(e)
+ resp = exchange.bulk_orders(orders, grouping="normalTpsl")
+ print(resp)
67
68
69
if __name__ == "__main__":
0 commit comments