<commit_before>__author__ = 'alex'

import requests
from .market import Market

#http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=132
class Cryptsy(Market):
    def __init__(self):
        super(Cryptsy, self).__init__()
        self.update_rate = 60

    def update_depth(self):
        #Dogecoin/BTC exchange URL
        url = 'http://pubapi.cryptsy.com/api.php?method=singleorderdata&marketid=132'
        res = requests.get(url)
        depth = res.json()
        self.depth = self.format_depth(depth)

    def sort_and_format(self, orders, reverse=False):
        orders.sort(key=lambda x: float(x['price']), reverse=reverse)
        r = []
        for i in orders:
            r.append({'price': float(i['price']), 'amount': float(i['quantity'])})
        r[:] = [d for d in r if d.get('amount') != 0]
        return r

    def format_depth(self, depth):
        bids = self.sort_and_format(
            depth['return']['DOGE']['buyorders'], True)
        asks = self.sort_and_format(
            depth['return']['DOGE']['sellorders'], False)
        return {'asks': asks, 'bids': bids}

if __name__ == "__main__":
    market = Cryptsy()
    print(market.get_ticker())
<commit_msg>Cryptsy public market throws away bids with quantity < 10<commit_after>__author__ = 'alex'

import requests
from .market import Market

#http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=132
class Cryptsy(Market):
    def __init__(self):
        super(Cryptsy, self).__init__()
        self.update_rate = 60

    def update_depth(self):
        #Dogecoin/BTC exchange URL
        url = 'http://pubapi.cryptsy.com/api.php?method=singleorderdata&marketid=132'
        res = requests.get(url)
        depth = res.json()
        self.depth = self.format_depth(depth)

    def sort_and_format(self, orders, reverse=False):
        orders.sort(key=lambda x: float(x['price']), reverse=reverse)
        r = []
        for i in orders:
            r.append({'price': float(i['price']), 'amount': float(i['quantity'])})
        r[:] = [d for d in r if d.get('amount') >= 10.0]
        return r

    def format_depth(self, depth):
        bids = self.sort_and_format(
            depth['return']['DOGE']['buyorders'], True)
        asks = self.sort_and_format(
            depth['return']['DOGE']['sellorders'], False)
        return {'asks': asks, 'bids': bids}

if __name__ == "__main__":
    market = Cryptsy()
    print(market.get_ticker())

{'fraction_non_alphanumeric': 0.1514041514041514, 'fraction_numerical': 0.008954008954008955, 'mean_word_length': 2.9454253611556984, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3292723', 'n_tokens_mistral': 832, 'n_tokens_neox': 778, 'n_words': 168}