Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get reduce_only to work on bybit #38

Closed
DutchTowel opened this issue Sep 11, 2022 · 1 comment
Closed

How to get reduce_only to work on bybit #38

DutchTowel opened this issue Sep 11, 2022 · 1 comment

Comments

@DutchTowel
Copy link

DutchTowel commented Sep 11, 2022

Hello, first of all thanks for all the time and effort you put in to creating this. I have the following issue: i am not familiar with python. And after trying all sorts of things for a week with changing tradingview alerts and the actions.py to get my problem solved. i just cant get it to work.

So i use bybit in hedge mode (both shorts and longs can be open at same time). To close a position the extra parameter reduce_only is needed, with values true or false. I also wanted to add a stop loss which i thought should also be added through params. I added them in actions.py as follows

print('Sending:', data['symbol'], data['type'], data['side'], data['amount'], data['reduce_only'], data['stop_loss'])
order = exchange.create_order(data['symbol'], data['type'], data['side'], data['amount'], params={'reduce_only': data['reduce_only'], 'stop_loss': data['stop_loss']})

i keep getting the error:
NameError: name 'reduce_only' is not defined
NameError: name 'stop_loss' is not defined

Any help would be greatly appreciated..
Thank you

@DutchTowel
Copy link
Author

Got it to work like this:
print('Sending:', data['symbol'], data['type'], data['side'], data['amount'], data['reduce_only'])
order = exchange.create_order(data['symbol'], data['type'], data['side'], data['amount'], params={'reduce_only': data['reduce_only'], 'stop_loss': data['stop_loss']})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant