Buy Contract (buy)

Buy a Contract

Auth Scope(s): trade

buy(buy: str, price: Union[int, float, Decimal], parameters=None, subscribe: Optional[Union[bool, int]] = None, passthrough: Optional[Any] = None, req_id: Optional[int] = None) → int
Parameters:
  • buy (str) – Either the ID received from a Price Proposal (proposal call), or 1 if contract buy parameters are passed in the parameters field.
  • price (Union[int, float, Decimal]) – Maximum price at which to purchase the contract.
  • parameters – [Optional] Used to pass the parameters for contract buy.
  • subscribe (Optional[Union[bool, int]]) – [Optional] 1 to stream.
  • passthrough (Optional[Any]) – [Optional] Used to pass data through the websocket, which may be retrieved via the echo_req output field.
  • req_id (Optional[int]) – [Optional] Used to map request to response.
Returns:

req_id

Return type:

int

Example

binary.api.buy(
    'uw2mk7no3oktoRVVsB4Dz7TQnFfABuFDgO95dlxfMxRuPUsz'
    price=100
)