V2EX chengxuan
 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     Solana     889 人在线   最高记录 6679       Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 16ms UTC 19:48 PVG 03:48 LAX 12:48 JFK 15:48
Do have faith in what you're doing.
ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86