Exemple #1
0
    def get_current_data(cls):
        symbols = []
        dates = []
        bids = []
        asks = []
        last = []
        contract = []
        for i in ['this_week', 'next_week', 'month', 'quarter']:
            response = requests.get(
                'https://www.okcoin.com/api/future_ticker.do',
                params={
                    'symbol': 'btc_usd',
                    'contractType': i
                })
            data = response.json()['ticker'][0]
            d = datetime.date(int(str(data['contractId'])[0:4]),
                              int(str(data['contractId'])[4:6]),
                              int(str(data['contractId'])[6:8]))
            dates.append(date_stamp(d))
            bids.append(data['buy'])
            asks.append(data['sell'])
            last.append(data['last'])
            contract.append('XBT')

        return {
            'contract': contract,
            'dates': dates,
            'bids': [Decimal(str(x)) for x in bids],
            'asks': [Decimal(str(x)) for x in asks],
            'last': [Decimal(str(x)) for x in last]
        }
Exemple #2
0
 def get_current_data(self):
     self.refresh()
     symbols = []
     dates = []
     bids = []
     asks = []
     last = []
     contract = []
     for contracttype in ['XBU', 'XBT']:
         for i in self.data:
             if i['rootSymbol'] == contracttype and i['buyLeg'] == '':
                 dates.append(
                     date_stamp(dateutil.parser.parse(i['expiry']))
                 )
                 symbols.append(i['symbol'])
                 bids.append(i['bidPrice'])
                 asks.append(i['askPrice'])
                 last.append(i['lastPrice'])
                 contract.append(contracttype)
     return {
         'contract' : contract,
         'dates': dates,
         'bids' : [Decimal(str(x)) for x in bids],
         'asks' : [Decimal(str(x)) for x in asks],
         'last' : [Decimal(str(x)) for x in last]
     }
Exemple #3
0
    def get_current_data(cls):
        symbols = []
        dates = []
        bids = []
        asks = []
        last = []
        contract = []
        for i in ['this_week', 'next_week', 'month', 'quarter']:
            response = requests.get(
                'https://www.okcoin.com/api/future_ticker.do',
                params={
                    'symbol': 'btc_usd',
                    'contractType': i
                }
            )
            data = response.json()['ticker'][0]
            d = datetime.date(
                int(str(data['contractId'])[0:4]),
                int(str(data['contractId'])[4:6]),
                int(str(data['contractId'])[6:8])
            )
            dates.append(date_stamp(d))
            bids.append(data['buy'])
            asks.append(data['sell'])
            last.append(data['last'])
            contract.append('XBT')

        return {
            'contract' : contract,
            'dates': dates,
            'bids' : [Decimal(str(x)) for x in bids],
            'asks' : [Decimal(str(x)) for x in asks],
            'last' : [Decimal(str(x)) for x in last]
        }
Exemple #4
0
 def get_current_data(self):
     self.refresh()
     symbols = []
     dates = []
     bids = []
     asks = []
     last = []
     contract = []
     for contracttype in ['XBU', 'XBT']:
         for i in self.data:
             if i['rootSymbol'] == contracttype and i['buyLeg'] == '':
                 dates.append(date_stamp(dateutil.parser.parse(
                     i['expiry'])))
                 symbols.append(i['symbol'])
                 bids.append(i['bidPrice'])
                 asks.append(i['askPrice'])
                 last.append(i['lastPrice'])
                 contract.append(contracttype)
     return {
         'contract': contract,
         'dates': dates,
         'bids': [Decimal(str(x)) for x in bids],
         'asks': [Decimal(str(x)) for x in asks],
         'last': [Decimal(str(x)) for x in last]
     }
 def get_current_data(self):
     self.refresh()
     data = self.data['ticker']
     return {
         'dates':[date_stamp(weekly_expiry())],
         'contract' : ['XBT'],
         'bids' : [Decimal(data['buy'])],
         'asks' : [Decimal(data['sell'])],
         'last' : [Decimal(data['last'])]
     }
 def get_data(self):
     self.refresh()
     data = self.data['ticker']
     return {
         'dates':[date_stamp(weekly_expiry())],
         'contract' : ['XBT'],
         'bids' : [Decimal(data['buy'])],
         'asks' : [Decimal(data['sell'])],
         'last' : [Decimal(data['last'])]
     }
Exemple #7
0
    def get_current_data(self):
        dates = []
        bids = []
        asks = []
        last = []
        contract = []
        for i in ['week', 'next_week', 'quarter']:
            data = requests.get('http://market.bitvc.com/futures/ticker_btc_' +
                                i + '.js').json()
            dates.append(date_stamp(expiry[i]))
            bids.append(data['buy'])
            asks.append(data['sell'])
            last.append(data['last'])
            contract.append('XBT')

        return {
            'dates': dates,
            'bids': [Decimal(str(x)) for x in bids],
            'asks': [Decimal(str(x)) for x in asks],
            'last': [Decimal(str(x)) for x in last],
            'contract': contract
        }
Exemple #8
0
    def get_current_data(self):
        dates= []
        bids = []
        asks = []
        last = []
        contract = []
        for i in ['week', 'next_week', 'quarter']:
            data = requests.get(
                'http://market.bitvc.com/futures/ticker_btc_' + i + '.js'
            ).json()
            dates.append(date_stamp(expiry[i]))
            bids.append(data['buy'])
            asks.append(data['sell'])
            last.append(data['last'])
            contract.append('XBT')

        return {
            'dates':dates,
            'bids' : [Decimal(str(x)) for x in bids],
            'asks' : [Decimal(str(x)) for x in asks],
            'last' : [Decimal(str(x)) for x in last],
            'contract' : contract
        }