Post
Topic
Board Trading y especulación
Re: Sistemas y automatización
by
xcbtrader
on 05/07/2016, 16:20:48 UTC
Quote
¿Compartirás el código?

No me ha salido gratis, el que lo ha hecho cobra por su tiempo como es lógico. No tengo problema en compartirlo a cambio de una modesta colaboración.
Mándame un privado si quieres.

Je je je...

No sabia que habías pagado por el.
Yo también estoy trabajando en un código para, por una parte capturar valores de POLONIEX, y una vez tenemos los valores, empezar a buscar indicadores/estrategias para analizarlos.

Pongo de momento la captura y enseñar por pantalla los valores.
Ahora estoy con el cálculo del RSI y otros...

CODIGO:

Code:
__author__ = 'xcbtrader'
# -*- coding: utf-8 -*-
# PROGRAMA PARA AUTOTRADER EN BITCOINS UTILIZANDO LAS APIs DE POLONIEX

import urllib
import requests
import json
import time

class Clase_btc:
BTC_fecha = time.strftime('%d %b %y')
BTC_hora = time.strftime('%H:%M:%S')
BTC_last = 0.0
BTC_high24hr = 0.0
BTC_percentChange = 0.0
BTC_low24hr = 0.0
BTC_highestBid = 0.0
BTC_lowestAsk = 0.0
BTC_baseVolume = 0.0

def actualizar_valores(self):
err = True
while err:
try:
request = 'https://poloniex.com/public?command=returnTicker'
response = requests.get(request)
content = response.json()
err = False

self.BTC_fecha = time.strftime('%d %b %y')
self.BTC_hora = time.strftime('%H:%M:%S')
self.BTC_last = content ['USDT_BTC'] ['last']
self.BTC_high24hr = content ['USDT_BTC'] ['high24hr']
self.BTC_percentChange = content ['USDT_BTC'] ['percentChange']
self.BTC_low24hr = content ['USDT_BTC'] ['low24hr']
self.BTC_highestBid = content ['USDT_BTC'] ['highestBid']
self.BTC_lowestAsk = content ['USDT_BTC'] ['lowestAsk']
self.BTC_baseVolume = content ['USDT_BTC'] ['baseVolume']
except KeyboardInterrupt:
exit()
except:
print ('### ERROR DE CONEXION - ESPERANDO 10 SEGUNDOS ###')
err = True
time.sleep(10)

datosBTC = []
btcAct = Clase_btc()
n = 0
lapso = 60

while True:
btcAct.actualizar_valores()
datosBTC.append(btcAct)
print ('######################################################')
print ('  FECHA:      ' + datosBTC[n].BTC_fecha + ' -- ' + datosBTC[n].BTC_hora)
print ('  LAST:       ' + datosBTC[n].BTC_last)
print ('  HIGH24HR:   ' + datosBTC[n].BTC_high24hr)
print ('  MOVIMIENTO: ' + datosBTC[n].BTC_percentChange)
print ('  LOW24HR:    ' + datosBTC[n].BTC_low24hr)
print ('  HIGHESTBID: ' + datosBTC[n].BTC_highestBid)
print ('  LOWESTASK:  ' + datosBTC[n].BTC_lowestAsk)
print ('  BASEVOLUME: ' + datosBTC[n].BTC_baseVolume)
print ('######################################################')
print ('ESPERANDO ' + str(lapso) + ' SEGUNDOS')
n +=1
time.sleep(lapso)