chengxuan 最近的时间轴更新
chengxuan

chengxuan

V2EX 第 55513 号会员,加入于 2014-02-08 21:32:03 +08:00
chengxuan 最近回复了
sudo reboot 试试吧!
2014-08-19 13:02:16 +08:00
回复了 XXOO 创建的主题 云计算 腾讯云 HK IP 测试
@xxoo 好贵阿!!
@magine 感谢 我试试。。哈哈 没事 没事。。。
@janxin 还有其他吗?
2014-07-16 15:16:59 +08:00
回复了 chengxuan 创建的主题 Linux 求助,如何把 linux 系统制作成为 img 镜像
急急急!!
2014-06-12 00:56:04 +08:00
回复了 sneezry 创建的主题 Bitcoin 收个小算力挖矿机
蚂蚁usb 1.4g oc 2g
2014-05-31 17:49:58 +08:00
回复了 chengxuan 创建的主题 Python 求助 python 报错误 给予解决者 100 元话费
@binux 在线等你。。
2014-05-31 17:42:32 +08:00
回复了 chengxuan 创建的主题 Python 求助 python 报错误 给予解决者 100 元话费
@binux qq或者mail发给我[email protected]
2014-05-31 17:34:24 +08:00
回复了 chengxuan 创建的主题 Python 求助 python 报错误 给予解决者 100 元话费
@liushuaikobe
@binux
@Crossin
源码贴出,跪谢各位大神。

#coding=utf-8
import time, re, requests, md5, urllib, urllib2, json ,sys ,os
#sys.path.append(os.path.dirname(__file__).replace('\\','/'))
from huobi import HuoBi
from bitfinex import Bitfinex
from configs import config,keys
class getprice(object):
def __init__(self):
#获取动态配置
self.huobi = HuoBi(keys['huobi']['key'],keys['huobi']['secretKey'])
self.bitf = Bitfinex(keys['bitf']['key'],keys['bitf']['secretKey'])
def buy_seller(self):
p1 = self.get_huobi()
pr1 = p1['sell']
p2 = self.get_bitf()
pr2 = p2['sell'] * config['rate']
if pr1 > pr2:
pre = (pr1 - pr2) / pr1 * 100
if pre >= config['agio']:
self.huobi_sell(p1['buy'])
self.bitf_sell('buy',p2['sell'])
else:
pre = (pr2 - pr1) / pr2 * 100
if pre >= config['agio']:
self.huobi_buy(p1['sell'])
self.bitf_sell('sell',p2['buy'])
print("huobi : %s %s finex : %s ") % (pr1,pre,pr2)
def get_huobi_seller(self):
try:
r = requests.get('http://market.huobi.com/staticmarket/depth_btc_json.js')
return r
except:
time.sleep(18)
self.get_huobi_seller()
def get_bitf_seller(self):
try:
r = requests.get('https://api.bitfinex.com/v1/book/btcusd')
return r
except:
time.sleep(18)
self.get_bitf_seller()
def get_huobi(self):
r1 = self.get_huobi_seller()
t = r1.json()
p1 = t['asks'][-5]
p2 = t['bids'][4]
pr1 = float(p1[0])
pr2 = float(p2[0])
return {'buy':pr2,'sell':pr1}
def get_bitf(self):
r2 = self.get_bitf_seller()
t = r2.json()
p1 = t['asks'][4]
p2 = t['bids'][4]
pr1 = float(p1['price'])
pr2 = float(p2['price'])
return {'buy':pr2,'sell':pr1}
def huobi_sell(self,price=''):
#getattr(huobi,method)
price = self.get_huobi()
price = price['buy']
info = self.huobi.sell(price,config['amount']) #{u'result': u'success', u'id': 18161354}
print(info)
def huobi_buy(self,price):
info = self.huobi.buy(price,config['amount'])
print(info)
def bitf_sell(self,side='sell',price=''):
"""
symbol (string): The name of the symbol (see `/symbols`).
amount (decimal): Order size: how much to buy or sell.
price (price): Price to buy or sell at. May omit if a market order.
exchange (string): "bitfinex".
side (string): Either "buy" or "sell".
type (string): Either "market" / "limit" / "stop" / "trailing-stop" / "fill-or-kill" / "exchange market" / "exchange limit" / "exchange stop" / "exchange trailing-stop" / "exchange fill-or-kill". (type starting by "exchange " are exchange orders, others are margin trading orders)
is_hidden (bool) true if the order should be hidden. Default is false.
"""
price = self.get_bitf()
price = price['buy']

params = {
"symbol":"btcusd",
"amount" : str(config['amount']),
"price" : str(price),
"exchange" : "bitfinex",
"side" : side,
"type" : "exchange market",
}

info = self.bitf.order_new(params)
print(info)
x = getprice()
while config['start']:
x.buy_seller()
time.sleep(18)
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   999 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 16ms · UTC 22:45 · PVG 06:45 · LAX 15:45 · JFK 18:45
Developed with CodeLauncher
♥ Do have faith in what you're doing.