Closed igkoh closed 4 years ago
@igkoh The error:"Incorrect Access key" means that your apikey is not correct.You have to double check your apikey.
what ".vn" in "host": "https://api.hbdm.vn", "wss": "wss://api.hbdm.vn", does mean? Is it test network? Then real network for my api keys(in real network) is required.
I may be wrong in the above conjecture.
Best regards, Ingyu
Dear foonsun,
Thanks for kind reply.
I double checked my api key in my previous working code as shown in
__from HuobiDMService import HuobiDM from pprint import pprint
URL = 'https://dm.hbg.com'
ACCESS_KEY = '5813b5f3-0a6ba013-...' SECRET_KEY = 'd464609a-5d3dfb5e-...'
dm = HuobiDM(URL, ACCESS_KEY, SECRET_KEY) pprint (dm.get_contract_account_info())__
with the correct result.
_pprint (dm.get_contract_account_info()) {'data': [{'adjust_factor': 0.05, 'is_debit': 0, 'lever_rate': 10, 'liquidation_price': None, 'margin_available': 0.47401505710312275, 'margin_balance': 0.47401505710312275, 'margin_frozen': 0.0, 'margin_position': 0.0, 'margin_static': 0.47401505710312275, 'profit_real': -0.001688544343764775, 'profit_unreal': 0, 'riskrate': None, 'symbol': 'BTC', ... I tried with different host and wss as without success in _"ACCOUNTS": [ { "platform": "huobi_swap", "account": "account", "host": 'https://dm.hbg.com', "wss": 'https://dm.hbg.com', "access_key": "5813b5f3-0a6ba013-...", "secret_key": "d464609a-5d3dfb5e-..." } ], instead of "ACCOUNTS": [ { "platform": "huobi_swap", "account": "account", "host": "https://api.hbdm.vn", "wss": "wss://api.hbdm.vn", "access_key": "5813b5f3-0a6ba013-...", "secret_key": "d464609a-5d3dfb5e-..." }__
with the same error "Websocket connection authorized failed"
Thus I think the api keys are correct. I conjecture that host and wss address is not correct?
Best regards, Ingyu
Dear @igkoh Ingyu,
1、I have run the latest version,and the ws subscription of private orders can be received.
init logger ...
I [2020-07-20 15:56:54,593] [-] [Quant] version: 1.0.13_200716_alpha
I [2020-07-20 15:56:54,786] [-] [Quant] start io loop ...
I [2020-07-20 15:56:54,786] [-] [HuobiFutureTrade] url: wss://api.hbdm.vn/notification
I [2020-07-20 15:56:54,797] [-] [HuobiFutureMarket] url: wss://api.hbdm.vn/ws
I [2020-07-20 15:56:58,425] [-] [MyStrategy] my_test_strategy create future orders success: [734801033729339392]
I [2020-07-20 15:56:58,846] [-] [HuobiFutureTrade] symbol: BTC/quarter order: [platform: huobi_future, account: account, strategy: my_test_strategy, order_no: 734801033729339392, action: BUY, symbol: BTC/quarter, price: 9304.9, quantity: 1, remain: 1, status: SUBMITTED, avg_price: None, order_type: LIMIT, trade_type: 4, ctime: 1595231818384, utime: 1595231818384]
The config.json is shown as below for your reference.
{
"SERVER_ID": "future_maker_strategy",
"LOG": {
"console": true,
"level": "INFO",
"path": "/data/logs/servers/future_maker_strategy",
"name": "future_maker_strategy.log",
"clear": true,
"backup_count": 5
},
"ACCOUNTS": [
{
"platform": "huobi_future",
"account": "account",
"host": "https://api.hbdm.vn",
"wss": "wss://api.hbdm.vn",
"access_key": "hrf5gdfghe… ",
"secret_key": "d5269ef6… "
}
],
"MARKETS": [
{
"platform": "huobi_future",
"channels":[
"orderbook", "kline", "trade"
],
"orderbook_length": 10,
"orderbooks_length": 100,
"klines_length": 100,
"trades_length": 100,
"wss": "wss://api.hbdm.vn"
}
],
"strategy": "my_test_strategy",
"symbol": "BTC",
"contract_type": "quarter"
}
2、The domain:api.hbdm.vn can be used in AWS servers. You can also use this domain:api.hbdm.com to check whether it is normal.
3、You can also try this command in your terminal: curl https://api.hbdm.vn/api/v1/contract_contract_info
to check whether it is normal.
Dear Foonsun,
Thank you for precise answer with config.json. Cause of my previous error was:"ACCOUNTS": [ { "platform": "huobi_future", "account": "ingyukoh@gmail.com",
I reproduced your output as (base) E:\BitCoin2\hb3\hbdm_Python\examples\huobi_future>python main.py config.json init logger ... I [2020-07-20 18:01:10,555] [-] [Quant] version: 1.0.13_200716_alpha I [2020-07-20 18:01:10,973] [-] [Quant] start io loop ... I [2020-07-20 18:01:10,973] [-] [HuobiFutureTrade] url: wss://api.hbdm.vn/notification I [2020-07-20 18:01:11,137] [-] [HuobiFutureMarket] url: wss://api.hbdm.vn/ws I [2020-07-20 18:01:12,585] [-] [MyStrategy] my_test_strategy create future orders success: [734817200371884032] I [2020-07-20 18:01:12,678] [-] [HuobiFutureTrade] symbol: BTC/quarter order: [platform: huobi_future, account: ingyukoh@gmail.com, strategy: my_test_strategy, order_no: 734817200371884032, action: SELL, symbol: BTC/quarter, price: 9309.1, quantity: 44, remain: 44, status: SUBMITTED, avg_price: 0.0, order_type: LIMIT, trade_type: 2, ctime: 1595235672812, utime: 1595235672906] I [2020-07-20 18:01:14,246] [-] [MyStrategy] my_test_strategy cancel future order: ['734817200371884032'] I [2020-07-20 18:01:14,343] [-] [HuobiFutureTrade] symbol: BTC/quarter order: [platform: huobi_future, account: ingyukoh@gmail.com, strategy: my_test_strategy, order_no: 734817200371884032, action: SELL, symbol: BTC/quarter, price: 9309.1, quantity: 44, remain: 44, status: CANCELED, avg_price: 0.0, order_type: LIMIT, trade_type: 2, ctime: 1595235672812, utime: 1595235674572] I [2020-07-20 18:01:15,850] [-] [MyStrategy] my_test_strategy create future orders success: [734817214061985792] I [2020-07-20 18:01:15,948] [-] [HuobiFutureTrade] symbol: BTC/quarter order: [platform: huobi_future, account: ingyukoh@gmail.com, stra
Best regards, Ingy
With the sample config.json in examples\huobi_future,
with _my own API access_key and secretkey,
the following error in authorization failure has occurred. (base) E:\BitCoin2\hb2\hbdm_Python\examples\huobi_future>python main.py config.json init logger ... I [2020-07-20 11:16:06,220] [-] [Quant] version: 1.0.13_200716_alpha I [2020-07-20 11:16:06,719] [-] [Quant] start io loop ... I [2020-07-20 11:16:06,719] [-] [HuobiFutureTrade] url: wss://api.hbdm.vn/notification I [2020-07-20 11:16:06,877] [-] [HuobiFutureMarket] url: wss://api.hbdm.vn/ws E [2020-07-20 11:16:07,208] **** E [2020-07-20 11:16:07,208] [-] [HuobiFutureTrade] Websocket connection authorized failed: {'op': 'auth', 'type': 'api', 'ts': 1595211367253, 'err-code': 2003, 'err-msg': 'Incorrect Access key [Access key错误]'} E [2020-07-20 11:16:07,210] **** KeyboardInterrupt (ID: 2) has been caught. Cleaning up...
How can I correct this error?
Best regards, Ingyu Koh