chengxuan's recent timeline updates
chengxuan

chengxuan

V2EX member #55513, joined on 2014-02-08 21:32:03 +08:00
  •   The specified image does not exist
    chengxuan's recent replies
    sudo reboot 试试吧!
    Aug 19, 2014
    Replied to a topic by XXOO 云计算 腾讯云 HK IP 测试
    @xxoo 好贵阿!!
    @magine 感谢 我试试。。哈哈 没事 没事。。。
    @janxin 还有其他吗?
    Jul 16, 2014
    Replied to a topic by chengxuan Linux 求助,如何把 linux 系统制作成为 img 镜像
    急急急!!
    Jun 12, 2014
    Replied to a topic by sneezry Bitcoin 收个小算力挖矿机
    蚂蚁usb 1.4g oc 2g
    May 31, 2014
    Replied to a topic by chengxuan Python 求助 python 报错误 给予解决者 100 元话费
    @binux 在线等你。。
    May 31, 2014
    Replied to a topic by chengxuan Python 求助 python 报错误 给予解决者 100 元话费
    @binux qq或者mail发给我[email protected]
    May 31, 2014
    Replied to a topic by 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)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1002 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 17ms · UTC 18:58 · PVG 02:58 · LAX 11:58 · JFK 14:58
    ♥ Do have faith in what you're doing.