def get_advanced_orders(self): """ Retrieves the current created advanced orders :returns: :class:`~haasomeapi.dataobjects.util.HaasomeClientResponse` :returns: In .result Dict[:class:`~haasomeapi.dataobjects.advancedorders.AdvancedOrderBase`] """ response = super()._execute_request("/GetAdvancedOrders", {}) advancedorders = {} for key, value in response["Result"].items(): advancedorders[key] = super()._from_json(value, AdvancedOrderBase) try: return HaasomeClientResponse(EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], advancedorders) except: return HaasomeClientResponse(EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], {})
def get_account_details(self, accountguid: str): """Retrives account details from supplied guid :param accountguid: str: The account guid :returns: :class:`~haasomeapi.dataobjects.util.HaasomeClientResponse` :returns: In .result :class:`~haasomeapi.dataobjects.accountdata.AccountInformation` """ response = super()._execute_request("/GetAccountDetails", {"accountGuid": accountguid}) try: return HaasomeClientResponse( EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], super()._from_json(response["Result"], AccountInformation)) except: return HaasomeClientResponse( EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], {})
def get_template_status(self, templateguid: str): """Gets status for template :param templateguid: str: Template Guid :returns: :class:`~haasomeapi.dataobjects.util.HaasomeClientResponse` :returns: In .result :class:`~haasomeapi.enums.EnumOrderStatus` """ response = super()._execute_request("/GetTemplateStatus", {"templateGuid": templateguid}) try: return HaasomeClientResponse( EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], EnumOrderStatus(int(response["Result"]))) except: return HaasomeClientResponse( EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], {})
def get_wallet(self, accountguid: str): """Get wallet for specific account :param accountguid: str: The account guid :returns: :class:`~haasomeapi.dataobjects.util.HaasomeClientResponse` :returns: In .result :class:`~haasomeapi.dataobjects.accountdata.Wallet` """ response = super()._execute_request("/GetWallet", {"accountGuid": accountguid}) try: return HaasomeClientResponse( EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], super()._from_json(response["Result"], Wallet)) except: return HaasomeClientResponse( EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], {})
def simulated_account_clear_wallet(self, accountguid: str): """Clears the simulated account wallet if the account is a sim account. :param accountguid: str: The account guid :returns: :class:`~haasomeapi.dataobjects.util.HaasomeClientResponse` :returns: In .result :class:`~haasomeapi.dataobjects.accountdata.Wallet` """ response = super()._execute_request("/SimulatedAccountClearWallet", {"accountGuid": accountguid}) try: return HaasomeClientResponse( EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], super()._from_json(response["Result"], Wallet)) except: return HaasomeClientResponse( EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], {})
def get_open_orders(self, accountguid: str): """Gets all open orders for a specific account :param accountguid: str: The account guid :returns: :class:`~haasomeapi.dataobjects.util.HaasomeClientResponse` :returns: In .result :class:`~haasomeapi.dataobjects.accountdata.OrderContainer` """ response = super()._execute_request("/GetOpenOrders", {"accountGuid": accountguid}) order_container = super()._from_json(response["Result"], OrderContainer) exchangeorderlist = {} marginorderlist = {} leverageorderlist = {} for orderstr, order in order_container.exchangeOrderList.items(): exchangeorderlist[orderstr] = super()._from_json(order, BaseOrder) for orderstr, order in order_container.marginOrderList.items(): marginorderlist[orderstr] = super()._from_json(order, BaseOrder) for orderstr, order in order_container.leverageOrderList.items(): leverageorderlist[orderstr] = super()._from_json(order, BaseOrder) order_container.exchangeOrderList = exchangeorderlist order_container.marginOrderList = marginorderlist order_container.leverageOrderList = leverageorderlist try: return HaasomeClientResponse( EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], order_container) except: return HaasomeClientResponse( EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], {})
def get_all_account_details(self): """Retrives a dictionary of all account names with guid :returns: :class:`~haasomeapi.dataobjects.util.HaasomeClientResponse` :returns: In .result Dict[:class:`~haasomeapi.dataobjects.accountdata.AccountInformation`] """ response = super()._execute_request("/GetAllAccountDetails", {}) accounts = {} for key, value in response["Result"].items(): accounts[key] = (super()._from_json(value, AccountInformation)) try: return HaasomeClientResponse( EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], accounts) except: return HaasomeClientResponse( EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], {})
def get_all_price_markets(self): """ Returns all markets :returns: :class:`~haasomeapi.dataobjects.util.HaasomeClientResponse` :returns: In .result List[:class:`~haasomeapi.dataobjects.marketdata.Market`] of markets """ response = super()._execute_request("/GetAllPriceMarkets", {}) markets = [] for market in response["Result"]: markets.append(super()._from_json(market, Market)) try: return HaasomeClientResponse( EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], markets) except: return HaasomeClientResponse( EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], {})
def cancel_order(self, accountguid: str, orderguid: str): """ Cancel a pending order :param accountguid: str: The account guid :param orderguid: str: Order guid to cancel :returns: :class:`~haasomeapi.dataobjects.util.HaasomeClientResponse` :returns: In .result bool: If order cancelled succesfully """ response = super()._execute_request("/CancelOrder", { "accountGuid": accountguid, "order": orderguid }) try: return HaasomeClientResponse( EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], bool(response["Result"])) except: return HaasomeClientResponse( EnumErrorCode(int(response["ErrorCode"])), response["ErrorMessage"], {})