Skip to content

Commit

Permalink
Update according to API update in May and June
Browse files Browse the repository at this point in the history
  • Loading branch information
eynzhang committed Sep 18, 2020
1 parent db3ee94 commit 57d6bb0
Show file tree
Hide file tree
Showing 73 changed files with 1,335 additions and 133 deletions.
6 changes: 6 additions & 0 deletions example/account/post_account_transfer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from huobi.client.account import AccountClient
from huobi.constant import *

account_client = AccountClient(api_key=g_api_key, secret_key=g_secret_key)
transfer_result = account_client.post_account_transfer(36979737, 'spot', 3684354, 122946475, 'spot', 11907558, 'usdt', 1)
transfer_result.print_object()
10 changes: 10 additions & 0 deletions example/algo/get_open_orders.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from huobi.client.algo import AlgoClient
from huobi.constant import *
from huobi.utils import *

symbol_test = "adausdt"
account_id = g_account_id

algo_client = AlgoClient(api_key=g_api_key, secret_key=g_secret_key)
result = algo_client.get_open_orders()
LogInfo.output_list(result)
10 changes: 10 additions & 0 deletions example/algo/get_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from huobi.client.algo import AlgoClient
from huobi.constant import *

account_id = g_account_id
client_order_id = "test002"

# get specific order by clientOrderId
algo_client = AlgoClient(api_key=g_api_key, secret_key=g_secret_key)
result = algo_client.get_order(client_order_id)
result.print_object()
10 changes: 10 additions & 0 deletions example/algo/get_order_history.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from huobi.client.algo import AlgoClient
from huobi.constant import *
from huobi.utils import *

symbol_test = "adausdt"
account_id = g_account_id

algo_client = AlgoClient(api_key=g_api_key, secret_key=g_secret_key)
result = algo_client.get_order_history(symbol_test, AlgoOrderStatus.TRIGGERED)
LogInfo.output_list(result)
17 changes: 17 additions & 0 deletions example/algo/post_cancel_algo_orders.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from huobi.client.algo import AlgoClient
from huobi.constant import *
from huobi.utils import *

symbol_test = "adausdt"
account_id = g_account_id

orders_to_cancel = ["test003", "test001"]
algo_client = AlgoClient(api_key=g_api_key, secret_key=g_secret_key)
result = algo_client.cancel_orders(orders_to_cancel)
result.print_object()

# order_id = algo_client.create_order(symbol=symbol_test, account_id=account_id, order_type=OrderType.BUY_MARKET, source=OrderSource.API, amount=5.0, price=1.292)
# LogInfo.output("created order id : {id}".format(id=order_id))
#
# order_id = algo_client.create_order(symbol=symbol_test, account_id=account_id, order_type=OrderType.SELL_MARKET, source=OrderSource.API, amount=1.77, price=None)
# LogInfo.output("created order id : {id}".format(id=order_id))
12 changes: 12 additions & 0 deletions example/algo/post_create_algo_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from huobi.client.algo import AlgoClient
from huobi.constant import *
from huobi.utils import *

symbol_test = "adausdt"
account_id = g_account_id

algo_client = AlgoClient(api_key=g_api_key, secret_key=g_secret_key)
order_id = algo_client.create_order(symbol=symbol_test, account_id=account_id, order_side=OrderSide.BUY,
order_type=AlgoOrderType.LIMIT, order_size=65, order_price=0.08, stop_price=0.085,
client_order_id="test004")
LogInfo.output("created order id : {id}".format(id=order_id))
8 changes: 8 additions & 0 deletions example/generic/get_market_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from huobi.client.generic import GenericClient

generic_client = GenericClient()
market_status = generic_client.get_market_status()
print(market_status)



5 changes: 3 additions & 2 deletions example/market/req_mbp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
def callback(mbp_event: 'MbpIncreaseEvent'):
mbp_event.print_object()


def error(e: 'HuobiApiException'):
print(e.error_code + e.error_message)

market_client = MarketClient(init_log=True)
market_client.req_mbp("btcusdt,eosusdt", MbpLevel.MBP150, callback, error)

market_client = MarketClient(init_log=True)
market_client.req_mbp("btcusdt", MbpLevel.MBP5, callback, error)
6 changes: 4 additions & 2 deletions example/market/sub_mbp_full.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from huobi.client.market import MarketClient
from huobi.constant import *


def callback(mbp_event: 'MbpFullEvent'):
mbp_event.print_object()


def error(e: 'HuobiApiException'):
print(e.error_code + e.error_message)

market_client = MarketClient(init_log=True)
market_client.sub_mbp_full("btcusdt,eosusdt", MbpLevel.MBP20, callback, error)

market_client = MarketClient(init_log=True)
market_client.sub_mbp_full("btcusdt,eosusdt", MbpLevel.MBP5, callback, error)
5 changes: 3 additions & 2 deletions example/market/sub_mbp_increase.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
def callback(mbp_event: 'MbpIncreaseEvent'):
mbp_event.print_object()


def error(e: 'HuobiApiException'):
print(e.error_code + e.error_message)

market_client = MarketClient(init_log=True)
market_client.sub_mbp_increase("btcusdt,eosusdt", MbpLevel.MBP150, callback, error)

market_client = MarketClient(init_log=True)
market_client.sub_mbp_increase("btcusdt,eosusdt", MbpLevel.MBP5, callback, error)
7 changes: 7 additions & 0 deletions example/subuser/get_user_apikey_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from huobi.client.subuser import SubuserClient
from huobi.constant import *
from huobi.utils import *

subuser_client = SubuserClient(api_key=g_api_key, secret_key=g_secret_key)
apikey_info = subuser_client.get_user_apikey_info(122946475)
LogInfo.output_list(apikey_info)
17 changes: 17 additions & 0 deletions example/subuser/post_create_subuser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from huobi.client.subuser import SubuserClient
from huobi.constant import *
from huobi.utils import *
import string
import random

subuser_client = SubuserClient(api_key=g_api_key, secret_key=g_secret_key)
userName = ''.join(random.choices(string.ascii_uppercase + string.digits, k=7))
params = {"userList": [
{
"userName": userName,
"note": "huobi"
}
]}

userList = subuser_client.post_create_subuser(params)
LogInfo.output_list(userList)
9 changes: 9 additions & 0 deletions example/subuser/post_set_subuser_transferability.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from huobi.client.subuser import SubuserClient
from huobi.constant import *
from huobi.utils import *

subuser_client = SubuserClient(api_key=g_api_key, secret_key=g_secret_key)
sub_uids = '122946475'

transferability_result = subuser_client.post_set_subuser_transferability(sub_uids, False)
LogInfo.output_list(transferability_result)
10 changes: 10 additions & 0 deletions example/subuser/post_subuser_apikey_deletion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from huobi.client.subuser import SubuserClient
from huobi.constant import *
from huobi.utils import *

subuser_client = SubuserClient(api_key=g_api_key, secret_key=g_secret_key)
sub_uid = '122946475'
access_key = '7ab679d7-b9fee8ed-9cd4cd8a-bgbfh5tv3f'

result = subuser_client.post_subuser_apikey_deletion(sub_uid, access_key)
LogInfo.output(result)
13 changes: 13 additions & 0 deletions example/subuser/post_subuser_apikey_generation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from huobi.client.subuser import SubuserClient
from huobi.constant import *

subuser_client = SubuserClient(api_key=g_api_key, secret_key=g_secret_key)

otp_token = '746316'
sub_uid = 122946475
note = "huobi_subuser"
permission = 'readOnly'
# ip_addresses = ''

result = subuser_client.post_subuser_apikey_generate(otp_token, sub_uid, note, permission)
result.print_object()
12 changes: 12 additions & 0 deletions example/subuser/post_subuser_apikey_modification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from huobi.client.subuser import SubuserClient
from huobi.constant import *

subuser_client = SubuserClient(api_key=g_api_key, secret_key=g_secret_key)

subUid = 122946475
access_key = "abc"
note = "test"
permission = 'readOnly,trade'

result = subuser_client.post_subuser_apikey_modification(subUid, access_key, permission=permission, note=note)
result.print_object()
12 changes: 12 additions & 0 deletions example/subuser/post_trade_market.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from huobi.client.subuser import SubuserClient
from huobi.constant import *
from huobi.utils import *

subuser_client = SubuserClient(api_key=g_api_key, secret_key=g_secret_key)

subUids = '159284259'
accountType = SubuserTradePrivilegeType.MARGIN
activation = SubUserTradeStatus.DEACTIVATED

subUserList = subuser_client.post_set_tradable_market(subUids, accountType, activation)
LogInfo.output_list(subUserList)
14 changes: 14 additions & 0 deletions example/wallet/get_account_withdraw_address.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

from huobi.client.wallet import WalletClient
from huobi.constant import *
from huobi.utils import *


wallet_client = WalletClient(api_key=g_api_key, secret_key=g_secret_key)
list_obj = wallet_client.get_account_withdraw_address(currency="usdt")
LogInfo.output_list(list_obj)





Loading

0 comments on commit 57d6bb0

Please sign in to comment.