The client provides convenient constants for order types:
Copy
from polyhush import PolyhushClientclient = PolyhushClient(api_key="your-api-key")client.GTC # "GTC" - Good Till Cancelledclient.FOK # "FOK" - Fill Or Kill client.FAK # "FAK" - Fill And Kill
Market order behavior - Use market_buy() and market_sell() for convenience
A FAK order fills as much as possible immediately at the best available prices, then cancels any unfilled remainder.
Copy
# Using FAK directlyresult = client.buy( token_id="your-token-id", shares=100, price=0.99, # High price to ensure fill order_type="FAK")# Or use the convenient market order methodsresult = client.market_buy(token_id="your-token-id", usdc_amount=50)result = client.market_sell(token_id="your-token-id", shares=100)
# Patient entry - wait for price to come to youresult = client.buy( token_id=token_id, shares=50, price=0.40, # Below current market order_type="GTC")print(f"Order {result['order_id']} placed on book")
# Need exactly 100 shares or nothingresult = client.buy( token_id=token_id, shares=100, price=0.55, order_type="FOK")if result['status'] == 'FILLED': print("Got all 100 shares!")else: print("Couldn't fill - no position taken")
# Get in immediately at market priceresult = client.market_buy( token_id=token_id, usdc_amount=100 # Spend $100 at market)# Or sell shares immediatelyresult = client.market_sell( token_id=token_id, shares=50)