コード例 #1
0
ファイル: api.py プロジェクト: sriharikapu/ngcccbase
    def p2porders(self, moniker="", sellonly=False, buyonly=False):
        """Show peer to peer trade orders"""

        # sanitize inputs
        sellonly = sanitize.flag(sellonly)
        buyonly = sanitize.flag(buyonly)
        asset = None
        if moniker and moniker != 'bitcoin':
            asset = sanitize.asset(self.model, moniker)

        # get offers
        agent = self._init_p2ptrade()
        agent.update()
        offers = agent.their_offers.values()
        offers = map(lambda offer: offer.get_data(), offers)

        # filter asset if given
        if asset:
            descs = asset.get_color_set().color_desc_list

            def func(offer):
                return (offer["A"]["color_spec"] in descs
                        or offer["B"]["color_spec"] in descs)

            offers = filter(func, offers)

        # filter sellonly if given
        if sellonly:
            offers = filter(lambda o: o["A"]["color_spec"] != "", offers)

        # filter buyonly if given
        if buyonly:
            offers = filter(lambda o: o["A"]["color_spec"] == "", offers)

        return _print(offers)
コード例 #2
0
ファイル: api.py プロジェクト: killerstorm/ngcccbase
    def p2porders(self, moniker="", sellonly=False, buyonly=False):
        """Show peer to peer trade orders"""

        # sanitize inputs
        sellonly = sanitize.flag(sellonly)
        buyonly = sanitize.flag(buyonly)
        asset = None
        if moniker and moniker != 'bitcoin':
            asset = sanitize.asset(self.model, moniker)

        # get offers
        agent = self._init_p2ptrade()
        agent.update()
        offers = agent.their_offers.values()
        offers = map(lambda offer: offer.get_data(), offers)

        # filter asset if given
        if asset:
            descs = asset.get_color_set().color_desc_list
            def func(offer):
                return (offer["A"]["color_spec"] in descs or
                        offer["B"]["color_spec"] in descs)
            offers = filter(func, offers)

        # filter sellonly if given
        if sellonly:
            offers = filter(lambda o: o["A"]["color_spec"] != "", offers)

        # filter buyonly if given
        if buyonly:
            offers = filter(lambda o: o["A"]["color_spec"] == "", offers)

        return _print(offers)
コード例 #3
0
ファイル: api.py プロジェクト: killerstorm/ngcccbase
    def getbalance(self, moniker, unconfirmed=False, available=False):
        """Returns the balance for a particular asset."""

        # sanitize inputs
        asset = sanitize.asset(self.model, moniker)
        unconfirmed = sanitize.flag(unconfirmed)
        available = sanitize.flag(available)

        balance = dict([self._getbalance(asset, unconfirmed, available)])
        return _print(balance)
コード例 #4
0
ファイル: api.py プロジェクト: sriharikapu/ngcccbase
    def getbalance(self, moniker, unconfirmed=False, available=False):
        """Returns the balance for a particular asset."""

        # sanitize inputs
        asset = sanitize.asset(self.model, moniker)
        unconfirmed = sanitize.flag(unconfirmed)
        available = sanitize.flag(available)

        balance = dict([self._getbalance(asset, unconfirmed, available)])
        return _print(balance)
コード例 #5
0
ファイル: api.py プロジェクト: killerstorm/ngcccbase
    def getbalances(self, unconfirmed=False, available=False):
        """Returns the balances for all assets/colors."""

        # sanitize inputs
        unconfirmed = sanitize.flag(unconfirmed)
        available = sanitize.flag(available)

        assets = self.controller.get_all_assets()
        func = lambda asset: self._getbalance(asset, unconfirmed, available)
        balances = dict(map(func, assets))
        return _print(balances)
コード例 #6
0
ファイル: api.py プロジェクト: sriharikapu/ngcccbase
    def getbalances(self, unconfirmed=False, available=False):
        """Returns the balances for all assets/colors."""

        # sanitize inputs
        unconfirmed = sanitize.flag(unconfirmed)
        available = sanitize.flag(available)

        assets = self.controller.get_all_assets()
        func = lambda asset: self._getbalance(asset, unconfirmed, available)
        balances = dict(map(func, assets))
        return _print(balances)
コード例 #7
0
ファイル: api.py プロジェクト: killerstorm/ngcccbase
    def __init__(self, wallet=None, testnet=False):

        # sanitize inputs
        testnet = sanitize.flag(testnet)

        if not wallet:
            wallet = "%s.wallet" % ("testnet" if testnet else "mainnet")
        self.wallet = PersistentWallet(wallet, testnet)
        self.model_is_initialized = False
コード例 #8
0
ファイル: api.py プロジェクト: killerstorm/ngcccbase
    def __init__(self, wallet=None, testnet=False):

        # sanitize inputs
        testnet = sanitize.flag(testnet)

        if not wallet:
            wallet = "%s.wallet" % ("testnet" if testnet else "mainnet")
        self.wallet = PersistentWallet(wallet, testnet)
        self.model_is_initialized = False
コード例 #9
0
ファイル: api.py プロジェクト: sriharikapu/ngcccbase
    def __init__(self, wallet=None, testnet=False):

        # sanitize inputs
        testnet = sanitize.flag(testnet)

        if not wallet:
            wallet = "%s.wallet" % ("testnet" if testnet else "mainnet")
        self.wallet = PersistentWallet(wallet, testnet)
        self.wallet.init_model()
        self.model = self.wallet.get_model()
        self.controller = WalletController(self.model)
コード例 #10
0
ファイル: api.py プロジェクト: F483/ngcccbase
    def __init__(self, wallet=None, testnet=False):

        # sanitize inputs
        testnet = sanitize.flag(testnet)

        if not wallet:
            wallet = "%s.wallet" % ("testnet" if testnet else "mainnet")
        self.wallet = PersistentWallet(wallet, testnet)
        self.wallet.init_model()
        self.model = self.wallet.get_model()
        self.controller = WalletController(self.model)