提供火币网交易接口API最简封装,提供现货买入、卖出、huobi币安查询账户余额等接口,数字货币,虚拟货币,BTC量化交易框架,自动交易,轻量便携,不用安装,即开即用

Overview

火币网交易接口的最简封装(只管用,不用再关注细节)

提供火币网交易接口的python封装,提供买入、卖出、查询账户余额等接口

接口说明

  • order_value() 进行买入操作,参数为买入的币和买入的金额
    买入返回的详情数据:
    {'单号': '272229546125038', '成交数量': 0.000177, '成交金额': '10.000000', '扣手续费': 3.56240360358, '平均价格': 56497.18}
  • order_target() 进行卖出操作,参数为卖出的币和卖出的金额
    卖出返回的详情数据:
    {'单号': '272229722396768', '成交数量': 0.000177, '成交金额': 9.93279219, '扣手续费': 0.01986558438, '平均价格': 56229.7}
  • get_amount() 获取币的账户余额

最简单的例子,开箱即用 (trade_app.py)

# btc的买入和卖出,以及查询账户余额
from huobi_trade_api import HuobiData
from tools import *

#自己的火币账户的access_key, secret_key (火币每个主账号能创建200个子账号,尽量使用子账号操作,防范风险)
access_key = 'XXXXXXXXXXXXXXXXXXXX'
secret_key = 'XXXXXXXXXXXXXXXXXXXXXXX'
huobi_trade = hb_trade(access_key, secret_key)              #初始化交易类

usdt_balance = huobi_trade.trade.get_balance('usdt')        #查询稳定币usdt的余额

coin_code = 'btc.usdt'                                      #定义交易对 
init_money = 10.00                                          #买入金额(单位:usdt)
buy_json = huobi_trade.order_value(coin_code, init_money)   #用1000USDT 买入btc
#  buy_json 返回字典类型,买入成交回报:
# {'单号':'2722295','成交数量':0.000177,'成交金额':'10.0000','扣手续费':3.562403,'平均价格':56497.18}


amount = huobi_trade.trade.get_amount(coin_code)            #查询btc.usdt交易对的数量,有精度控制
print('当前账户%s数量:' % (coin_code) + str(amount))



sell_json = huobi_trade.order_target(coin_code, amount)     #卖出当前持仓所有btc
# sell_json 返回字典类型,卖出成交回报:
# {'单号':'2722297','成交数量': 0.000177,'成交金额': 9.9327,'扣手续费':0.019865,'平均价格': 56229.7}

最底层的高阶例子 (api_test.py)

from huobi_trade_api import HuobiData
from tools import *

hb = HuobiData(huobi_access_key=access_key, huobi_secret_key=secret_key)
user_info = hb.get_api_user_info()            #账号查询 get_api_user_info
 #    返回的账户信息
 #   [ {'id': 754585, 'type': 'spot', 'subtype': '', 'state': 'working'}, 
 #     {'id': 20605202, 'type': 'otc', 'subtype': '', 'state': 'working'}  ]
user_balance = hb.get_api_user_balance()  # 获取账号余额

# 返回的账号余额信息
#    { "id": 754585,  "type": "spot",    "state": "working",
#    "list": [    {   "currency": "fil",    "type": "trade",   "balance": "0.608150192"     },
#                 {   "currency": "theta",  "type": "trade",  "balance": "0.308798576"     } ]}
amount = hb.get_amount_valuation(currency='CNY')  #获取账户估值 可选BTC,CNY,USD
balance = hb.get_balance('usdt')               #查询币种余额 如btc,usdt,doge
symbols = hb.get_symbols()    #获取交易对精度信息,只获取TradePair内的值
quote-currency price-precision amount-precision value-precision min-order-value sell-market-min-order-amt
hcbtc btc 8 4 8 0.0001
rvnbtc btc 10 2 8 0.0001
insurusdt usdt 4 4 8 5.0000
actbtc btc 10 2 8 0.0001
thetausdt usdt 4 4 8 5.0000
#市价委托下单买
buy_billno = hb.buy_order(code='doge.usdt', amount=10.00)           #用usdt市价买入币doge
#市价委托下单卖
coin_amount = hb.get_balance('doge')                                #查询出doge的余额  
sell_billno = hb.sell_order(code='doge.usdt', amount=coin_amount)   #市价卖出doge币
#查询订单详情 
find_order = hb.find_order('272249503181077')                         #入参是成交单号
#订单详情返回值
{
    "id": 272249503181077,"symbol": "btcusdt","account-id": 754585,
    "client-order-id": "20210508-150246-731828","amount": "10.000000000000000000",
    "price": "0.0","created-at": 1620457349520,"type": "buy-market",
    "field-amount": "0.000173342760868287","field-cash-amount": "9.999999999999956351",
    "field-fees": "0.000000346685521737","finished-at": 1620457349539,
    "source": "spot-api","state": "filled","canceled-at": 0
}
#获取成交明细
order_details = hb.get_order_details('272249503181077')               #入参是成交单号
#成交明细返回值,返回list数组
[
  {
    "fee-currency": "btc", "symbol": "btcusdt", "trade-id": 102415396093,
    "match-id": 127130574857, "source": "spot-api", "role": "taker",
    "order-id": 272249503181077, "price": "57689.17", "created-at": 1620457349541,
    "filled-amount": "0.000173342760868287", "fee-deduct-currency": "", 
    "fee-deduct-state": "done","filled-fees": "0.000000346685521737", 
    "filled-points": "0.0", "id": 267299340030943, "type": "buy-market"
  }
]
#策略委托市价下单
order_detail = hb.set_algo_order(code='ada.usdt', orderValue='10', stopPrice='1.5') 
#策略委托市价下单返回值 {'clientOrderId': '20210510-154908-999949'}
#策略委托撤单
cancel_detail = hb.cancel_algo_order(['20210510-154908-999949'])  
#策略委托撤单返回值 撤销成功的单号在accepted列表里,撤销失败的单号在rejected列表里
#{'accepted': ['20210510-154908-999949'], 'rejected': []}

需安装第三方库

  • requests
  • pandas

巴特量化

  • 数字货币 股市量化工具 行情系统软件开发

  • BTC虚拟货币量化交易策略开发 自动化交易策略运行


加入群聊

Telegram Group Manager Bot + Userbot Written In Python Using Pyrogram.

Telegram Group Manager Bot + Userbot Written In Python Using PyrogramTelegram Group Manager Bot + Userbot Written In Python Using Pyrogram

1 Nov 11, 2021
VC-Music , Playing music without bot.

VC-Userbot A Telegram Userbot to play or streaming Audio and Video songs / files in Telegram Voice Chats. It's made with PyTgCalls and Pyrogram Requir

RioProjectX 8 Aug 04, 2022
Discord Custom Playing Status Redirecting

Discord-Custom-Playing-Status-Redirecting THINGS TO DO :- - Create an application from https://discord.com/developers/applications give it ur desired

WarLorD oP 1 Oct 30, 2021
PyManGenerator is a token generator for discord, it joins servers using webbot to automate everything

PyManGenerator is a token generator for discord, it joins servers using webbot to automate everything. Captcha can be done by itself unless you used your current IP Address more than once.

5 Nov 27, 2021
A discord bot that send SMS spam!

bruh-bot send spam sms! send spam with email! it sends you spam via sms and Email using two tools, quack and impulse! if you have some problem contact

pai 32 Dec 25, 2022
A link shortner telegram bot version 2 with advanced features

URL-Shortner-Bot-V2 A link shortner telegram bot version 2 with advanced features Made with Python3 (C) @FayasNoushad Copyright permission under MIT L

Fayas Noushad 18 Dec 29, 2022
A discord token grabber made in Python 3

Discord Token Grabber A Discord token grabber written in Python 3. This version of the grabber only supports Windows. Features Transfers via Discord w

Mega145 4 Aug 04, 2022
Morpy Bot Linux - Morpy Bot Linux With Python

Morpy_Bot_Linux Guide to using the robot : 🔸 Lsmod = to identify admins and st

2 Jan 20, 2022
Hermes Bytecode Reverse Engineering Tool (Assemble/Disassemble Hermes Bytecode)

hbctool A command-line interface for disassembling and assembling the Hermes Bytecode. Since the React Native team created their own JavaScript engine

Pongsakorn Sommalai 216 Jan 03, 2023
471 Dec 24, 2022
Stack Overflow Error Parser

A python tool that executes python files and opens respective Stack Overflow threads in browser for errors encountered.

Raghavendra Khare 3 Jul 24, 2022
wyscoutapi is an extremely basic API client for the Wyscout API (v2 & v3) for Python

wyscoutapi wyscoutapi is an extremely basic API client for the Wyscout API (v2 & v3). Usage Install with pip install wyscoutapi. To connect to the Wys

Ben Torvaney 11 Nov 22, 2022
It is automated instagram follower bot.

Instagram-Follower-Bot It is automated instagram follower bot. In This project I've used Selenium and Python. Work-Flow When I run my code. It's gonna

Falak Shair 3 Sep 28, 2022
聚合空间测绘搜索(Fofa,Zoomeye,Quake,Shodan,Censys,BinaryEdge)

#Search-Tools Search-Tools集合比较常见的网络空间探测引擎 Fofa,Zoomeye,Quake,Shodan,Censys,BinaryEdge 简单说明 ICO搜索目前只有Fofa,Shodan,Quake支持 代理设置是防止在API请求过于频繁,或者在实战中,好多红队打

311 Dec 16, 2022
A Telegram Bin Checker Bot made with python for check Bin valid or Invalid. 💳

Bin Checker Bot A Telegram Bin Checker Bot made with python for check Bin valid or Invalid. 📌 Deploy On Heroku 🏷 Environment Variables API_ID - Your

Chamindu Denuwan 20 Dec 10, 2022
An Open Source ALL-In-One Telegram RoBot, that can do lot of things.

An Open Source ALL-In-One Telegram RoBot, that can do lot of things.

JOBIN 0 Dec 01, 2021
ImaginaryTicketing is a simple ticketing system for running CTF Competitions on discord.

ImaginaryTicketing ImaginaryTicketing is a simple ticketing system for running CTF Competitions on discord. Be sure to checkout ImaginaryCTF. See docs

GudOreos 8 Jul 18, 2022
This is a Innexia Group Manager Bot with many features

⚡ Innexia ⚡ A Powerful, Smart And Simple Group Manager ... Written with AioGram , Pyrogram and Telethon... Available on Telegram as @Innexia ❤️ Suppor

TeamDeeCode 84 Jun 04, 2022
Revolt account generator. Bypassing Hcaptcha using AI solver.

RevoltGenerator Revolt account generator. Bypassing Hcaptcha using AI solver. Config settings in config.json then put your usernames / proxies. If you

&! Ѵιchy.#0110 27 Nov 01, 2022
A Python wrapper for the QQ Channel API

A Python wrapper for the QQ Channel API

Fox_white 55 Dec 07, 2022