Beispiel #1
0
    def list(cls, params: Dict = {}) -> List[Dict]:
        """Get bitvol data

        Args:
            params (Dict, optional): [description]. Defaults to {}.

        Returns:
            List[Dict]: bitvol objects
        """
        include_api_key = True
        url = gen_url("/trading/bitvol")
        res = HttpClient.get(url, params, include_api_key)
        return res.json()
Beispiel #2
0
    def list_trades(cls, contract_id: int) -> Dict:
        """Returns a list of your trades for a given position.

        Args:
            contract_id (int): LedgerX contract ID.

        Returns:
            Dict: [description]
        """
        include_api_key = True
        url = gen_url(f"/trading/positions/{contract_id}/trades")
        res = HttpClient.get(url, {}, include_api_key)
        return res.json()
Beispiel #3
0
    def list_traded(cls, params: Dict = {}) -> List[Dict]:
        """List traded contracts

        Args:
            params (Dict, optional): [description]. Defaults to {}.

        Returns:
            List[Dict]: [description]
        """
        include_api_key = True
        url = gen_url("/trading/contracts/traded")
        qps = {**cls.default_list_traded, **params}
        res = HttpClient.get(url, qps, include_api_key)
        return res.json()
Beispiel #4
0
    def retrieve_position(cls, contract_id: int) -> Dict:
        """Returns contract details for a a single contract ID.

        https://docs.ledgerx.com/reference#positioncontract

        Args:
            contract_id (int): LedgerX contract ID

        Returns:
            Dict: [description]
        """
        include_api_key = True
        url = gen_url(f"/trading/contracts/{contract_id}/position")
        res = HttpClient.get(url, {}, include_api_key)
        return res.json()
Beispiel #5
0
    def retrieve(cls, contract_id: int) -> Dict:
        """Returns your position for a given contract.

        https://docs.ledgerx.com/reference#retrievecontract

        Args:
            contract_id (int): [description]

        Returns:
            Dict: [description]
        """
        include_api_key = True
        url = gen_url(f"/trading/contracts/{contract_id}")
        res = HttpClient.get(url, {}, include_api_key)
        return res.json()
Beispiel #6
0
    def list_all(cls, params: Dict = {}) -> List[Dict]:
        """Returns a list of all trades in the market.

        https://docs.ledgerx.com/reference#globalstrade

        Args:
            params (Dict, optional): [description]. Defaults to {}.

        Returns:
            List[Dict]: [description]
        """
        include_api_key = False
        url = gen_url("/trading/trades/global")
        request_params = {**cls.default_list_all_params, **params}
        return GenericResource.list_all(url, request_params, include_api_key)
Beispiel #7
0
    def list(cls, params: Dict = {}) -> List[Dict]:
        """Returns a list of all debits and credits to your accounts.

        https://docs.ledgerx.com/reference#gettransactions

        Args:
            params (Dict, optional): [description]. Defaults to {}.

        Returns:
            List[Dict]: [description]
        """
        include_api_key = True
        url = gen_url("/funds/transactions")
        qps = {**cls.default_list_params, **params}
        res = HttpClient.get(url, qps, include_api_key)
        return res.json()
Beispiel #8
0
    def list(cls, params: Dict = {}) -> List[Dict]:
        """Returns all your positions.

        https://docs.ledgerx.com/reference#listpositions

        Args:
            params (Dict, optional): [description]. Defaults to {}.

        Returns:
            List[Dict]: [description]
        """
        include_api_key = True
        url = gen_url("/trading/positions")
        qps = {**cls.default_list_params, **params}
        res = HttpClient.get(url, qps, include_api_key)
        return res.json()
Beispiel #9
0
    def list_all_incremental_return(cls, params: Dict = {}, callback: Callable = None):
        # """List all trades and execute callback function after
        # each HTTP request (ie, in between pagination breaks).

        # This API request calls the Trades.list_all function.

        # See Trades.list_all for more info.

        # Args:
        #     params (Dict, optional): [description]. Defaults to {}.
        #     callback (Callable, optional): [description]. Defaults to None.

        # Returns:
        #     [type]: [description]
        # """
        include_api_key = False
        url = gen_url("/trading/trades/global")
        request_params = {**cls.default_list_params, **params}
        return GenericResource.list_all_incremental_return(
            url, params, include_api_key, callback
        )
Beispiel #10
0
def test_gen_url():
    url = util.gen_url("/myurl")
    assert url == "https://api.ledgerx.com/myurl"
Beispiel #11
0
 def list_all(cls, params: Dict = {}) -> List[str]:
     include_api_key = False
     url = gen_url("/trading/contracts")
     qps = {**cls.default_list_params, **params}
     return GenericResource.list_all(url, qps, include_api_key)