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

error: invalid size with close-order #149

Open
witsgh opened this issue May 2, 2023 · 0 comments
Open

error: invalid size with close-order #149

witsgh opened this issue May 2, 2023 · 0 comments

Comments

@witsgh
Copy link

witsgh commented May 2, 2023

def close_position():
if get_position_size() > 0:
# order using market price
entry_price = float(get_position_entry_price())
position_size = float(get_position_size())

    close_price = ((float(min_markup) * entry_price) + entry_price)
    last_price = get_last_price()


    if close_price > last_price:
        
        print(f"The desired close_price of {close_price} is greater than the last price of {last_price}")
    else:
        print(f"The desired close_price of {close_price} is lower than the last price of {last_price}")
       
        order = FuturesOrder(contract=contract, size='0', price='0', close='true', tif='ioc')
        try:
            
            
            order_response = futures_api.create_futures_order(settle, order)
        except GateApiException as ex:
            logger.error("error encountered creating futures order: %s", ex)
            print(f"Error: {ex}")       
    
else:
    print(f"No position found. Position size is {get_position_size()}")

Am trying to close an order with the above code, the docs says to set size='0' and close='true' but I get invalid size with close-order error. what am I doing wrong

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