def destroy(self, raise_exception: bool = False) -> bool: try: self.check_instance() ApiRequest.__init__(endpoint="orders/{}/".format(self.uuid), account=self.account, method="DELETE") return True except Exception as e: if raise_exception: raise e else: return False
def retrieve(self): self.check_instance() request = ApiRequest(endpoint="transactions/{}/".format(self.uuid), account=self.account, method="GET") self.set_data(request.response) return self
def retrieve(self): request = ApiRequest(endpoint="data/instruments/{}/".format(self.isin), method="GET", authorization_token=self.authorization_token, account=self.account) self.set_data(request.response) return self
def retrieve(self): self.check_instance() request = ApiRequest(endpoint="accounts/{}/".format(self.uuid), method="GET", authorization_token=self._token) self.set_data(request.response) return self
def retrieve(self): request = ApiRequest( endpoint="portfolio/{}/aggregated/".format(self.isin), account=self.account, method="GET" ) self.set_data(request.response) return self
def latest(self, instrument: Union[str, "Instrument"], authorization_token: Union[str, "Token"] = None): request = ApiRequest( endpoint=self._build_endpoint(instrument=instrument) + "latest/", method="GET", authorization_token=authorization_token ) self.set_data(request.response) return self
def create(self): if self.uuid: raise OrderError( detail="Cannot create order as it already exists.") request = ApiRequest(endpoint="orders/", account=self.account, method="POST", body=self._build_body()) self.set_data(request.response)
def retrieve(self): request = ApiRequest( endpoint="token/{}/".format(self.key), authorization_token=self.key, method="GET", ) self._build_object(request=request) # make the usage of the Account class object more convenient by accessing the token directly if hasattr(self, "account"): self.account._token = self.key return self
def list(object_class: Any, **kwargs) -> ListIterator: query_dict = ListMixin._build_query_params(**kwargs) request_arguments = { "endpoint": object_class._list_endpoint if not kwargs.get("list_endpoint") else kwargs.get("list_endpoint"), "method": "GET", "url_params": query_dict, } if kwargs.get("account"): request_arguments["account"] = kwargs["account"] if kwargs.get("ignore_account_url"): request_arguments["ignore_account_url"] = kwargs["ignore_account_url"] if kwargs.get("authorization_token"): request_arguments["authorization_token"] = kwargs["authorization_token"] request = ApiRequest(**request_arguments) iterator = ListIterator(request=request, object_class=object_class) return iterator
def fetch_account_state(self): request = ApiRequest(endpoint="accounts/{}/state/".format(self.uuid), method="GET", authorization_token=self._token) self._cash_to_invest = request.response.get("cash_to_invest") self._total_balance = request.response.get("total_balance")