├── .gitignore ├── README.md ├── new ├── deploy.sh ├── docker │ ├── .gitignore │ ├── docker-compose.yaml │ └── volumes │ │ ├── nginx │ │ └── config │ │ │ └── default │ │ └── redis │ │ ├── config │ │ └── redis.conf │ │ └── data │ │ └── .gitignore ├── docker_acc.sh ├── readme ├── setup.sh └── src │ ├── collector │ ├── .gitignore │ ├── cmd │ ├── config.py │ ├── eth_usdt_kline.py │ ├── history_scanner.py │ ├── huobi │ │ ├── __init__.py │ │ ├── client │ │ │ ├── __init__.py │ │ │ ├── account.py │ │ │ ├── algo.py │ │ │ ├── etf.py │ │ │ ├── generic.py │ │ │ ├── margin.py │ │ │ ├── market.py │ │ │ ├── subuser.py │ │ │ ├── trade.py │ │ │ └── wallet.py │ │ ├── connection │ │ │ ├── __init__.py │ │ │ ├── impl │ │ │ │ ├── __init__.py │ │ │ │ ├── private_def.py │ │ │ │ ├── restapi_invoker.py │ │ │ │ ├── restapi_request.py │ │ │ │ ├── websocket_manage.py │ │ │ │ ├── websocket_request.py │ │ │ │ └── websocket_watchdog.py │ │ │ ├── restapi_sync_client.py │ │ │ ├── subscribe_client.py │ │ │ └── websocket_req_client.py │ │ ├── constant │ │ │ ├── __init__.py │ │ │ ├── definition.py │ │ │ ├── result.py │ │ │ ├── system.py │ │ │ └── test.py │ │ ├── exception │ │ │ ├── __init__.py │ │ │ └── huobi_api_exception.py │ │ ├── model │ │ │ ├── __init__.py │ │ │ ├── account │ │ │ │ ├── __init__.py │ │ │ │ ├── account.py │ │ │ │ ├── account_asset_valuation.py │ │ │ │ ├── account_balance.py │ │ │ │ ├── account_balance_req.py │ │ │ │ ├── account_history.py │ │ │ │ ├── account_ledger.py │ │ │ │ ├── account_point_group.py │ │ │ │ ├── account_point_result.py │ │ │ │ ├── account_point_transfer_result.py │ │ │ │ ├── account_transfer_result.py │ │ │ │ ├── account_update.py │ │ │ │ ├── account_update_event.py │ │ │ │ ├── balance.py │ │ │ │ ├── complete_subaccount.py │ │ │ │ ├── margin_balance_detail.py │ │ │ │ └── sub_uid_management.py │ │ │ ├── algo │ │ │ │ ├── __init__.py │ │ │ │ ├── cancel_order_result.py │ │ │ │ ├── order_history_item.py │ │ │ │ └── order_list_item.py │ │ │ ├── etf │ │ │ │ ├── __init__.py │ │ │ │ ├── etf_swap_config.py │ │ │ │ ├── etf_swap_in_out.py │ │ │ │ ├── etf_swap_list.py │ │ │ │ └── unitprice.py │ │ │ ├── generic │ │ │ │ ├── __init__.py │ │ │ │ ├── chain.py │ │ │ │ ├── exchange_info.py │ │ │ │ ├── market_status.py │ │ │ │ ├── reference_currency.py │ │ │ │ └── symbol.py │ │ │ ├── margin │ │ │ │ ├── __init__.py │ │ │ │ ├── cross_margin_account_balance.py │ │ │ │ ├── cross_margin_loan_ino.py │ │ │ │ ├── general_repay_loan_record.py │ │ │ │ ├── general_repay_loan_result.py │ │ │ │ ├── loan_ino.py │ │ │ │ ├── loan_order.py │ │ │ │ ├── margin_account_balance.py │ │ │ │ └── margin_loan_ino.py │ │ │ ├── market │ │ │ │ ├── __init__.py │ │ │ │ ├── candlestick.py │ │ │ │ ├── candlestick_event.py │ │ │ │ ├── candlestick_req.py │ │ │ │ ├── depth_entry.py │ │ │ │ ├── last_trade_bestquote.py │ │ │ │ ├── market_detail.py │ │ │ │ ├── market_detail_event.py │ │ │ │ ├── market_detail_merged.py │ │ │ │ ├── market_detail_req.py │ │ │ │ ├── market_ticker.py │ │ │ │ ├── mbp.py │ │ │ │ ├── mbp_full_event.py │ │ │ │ ├── mbp_increase_event.py │ │ │ │ ├── mbp_req.py │ │ │ │ ├── pricedepth.py │ │ │ │ ├── pricedepth_bbo.py │ │ │ │ ├── pricedepth_bbo_event.py │ │ │ │ ├── pricedepth_event.py │ │ │ │ ├── pricedepth_req.py │ │ │ │ ├── trade.py │ │ │ │ ├── trade_detail.py │ │ │ │ ├── trade_detail_event.py │ │ │ │ └── trade_detail_req.py │ │ │ ├── subuser │ │ │ │ ├── __init__.py │ │ │ │ ├── subuser_apikey_generation.py │ │ │ │ ├── subuser_apikey_modification.py │ │ │ │ ├── subuser_creation.py │ │ │ │ ├── subuser_transferability.py │ │ │ │ ├── trade_market.py │ │ │ │ └── user_apikey_info.py │ │ │ ├── trade │ │ │ │ ├── __init__.py │ │ │ │ ├── batch_cancel_count.py │ │ │ │ ├── batch_cancel_result.py │ │ │ │ ├── batch_create_order.py │ │ │ │ ├── feerate.py │ │ │ │ ├── matchresult.py │ │ │ │ ├── order.py │ │ │ │ ├── order_detail_req.py │ │ │ │ ├── order_list_item.py │ │ │ │ ├── order_list_req.py │ │ │ │ ├── order_update.py │ │ │ │ ├── order_update_event.py │ │ │ │ ├── trade_clearing.py │ │ │ │ ├── trade_clearing_event.py │ │ │ │ └── transact_feerate.py │ │ │ └── wallet │ │ │ │ ├── __init__.py │ │ │ │ ├── chain_deposit_address.py │ │ │ │ ├── chain_withdraw_address.py │ │ │ │ ├── deposit.py │ │ │ │ ├── deposit_history.py │ │ │ │ ├── deposit_history_item.py │ │ │ │ ├── withdraw.py │ │ │ │ └── withdraw_quota.py │ │ ├── service │ │ │ ├── __init__.py │ │ │ ├── account │ │ │ │ ├── __init__.py │ │ │ │ ├── get_account_asset_valuation.py │ │ │ │ ├── get_account_balance_by_subuid.py │ │ │ │ ├── get_account_history.py │ │ │ │ ├── get_account_ledger.py │ │ │ │ ├── get_account_point.py │ │ │ │ ├── get_accounts.py │ │ │ │ ├── get_aggregate_subuser_balance.py │ │ │ │ ├── get_balance.py │ │ │ │ ├── post_account_transfer.py │ │ │ │ ├── post_futures_and_pro_transfer.py │ │ │ │ ├── post_point_transfer.py │ │ │ │ ├── post_sub_uid_management.py │ │ │ │ ├── post_subaccount_transfer.py │ │ │ │ ├── req_account_balance.py │ │ │ │ └── sub_account_update_v2.py │ │ │ ├── algo │ │ │ │ ├── __init__.py │ │ │ │ ├── get_open_orders.py │ │ │ │ ├── get_order_by_cid.py │ │ │ │ ├── get_order_history.py │ │ │ │ ├── post_cancel_orders.py │ │ │ │ └── post_create_order.py │ │ │ ├── etf │ │ │ │ ├── __init__.py │ │ │ │ ├── get_etf_swap_config.py │ │ │ │ ├── get_etf_swap_list.py │ │ │ │ ├── post_etf_swap_in.py │ │ │ │ └── post_etf_swap_out.py │ │ │ ├── generic │ │ │ │ ├── __init__.py │ │ │ │ ├── get_exchange_currencies.py │ │ │ │ ├── get_exchange_symbols.py │ │ │ │ ├── get_exchange_timestamp.py │ │ │ │ ├── get_market_status.py │ │ │ │ ├── get_reference_currencies.py │ │ │ │ └── get_system_status.py │ │ │ ├── margin │ │ │ │ ├── __init__.py │ │ │ │ ├── get_cross_margin_account_balance.py │ │ │ │ ├── get_cross_margin_loan_info.py │ │ │ │ ├── get_cross_margin_loan_orders.py │ │ │ │ ├── get_general_repayment_loan_records.py │ │ │ │ ├── get_margin_account_balance.py │ │ │ │ ├── get_margin_loan_info.py │ │ │ │ ├── get_margin_loan_orders.py │ │ │ │ ├── post_create_margin_order.py │ │ │ │ ├── post_cross_margin_create_loan_orders.py │ │ │ │ ├── post_cross_margin_loan_order_repay.py │ │ │ │ ├── post_cross_margin_transfer_in.py │ │ │ │ ├── post_cross_margin_transfer_out.py │ │ │ │ ├── post_general_repay_loan.py │ │ │ │ ├── post_repay_margin_order.py │ │ │ │ ├── post_transfer_in_margin.py │ │ │ │ └── post_transfer_out_margin.py │ │ │ ├── market │ │ │ │ ├── __init__.py │ │ │ │ ├── get_candlestick.py │ │ │ │ ├── get_history_trade.py │ │ │ │ ├── get_market_detail.py │ │ │ │ ├── get_market_detail_merged.py │ │ │ │ ├── get_market_tickers.py │ │ │ │ ├── get_market_trade.py │ │ │ │ ├── get_pricedepth.py │ │ │ │ ├── req_candlestick.py │ │ │ │ ├── req_market_detail.py │ │ │ │ ├── req_mbp.py │ │ │ │ ├── req_pricedepth.py │ │ │ │ ├── req_trade_detail.py │ │ │ │ ├── sub_candlestick.py │ │ │ │ ├── sub_market_detail.py │ │ │ │ ├── sub_mbp_full.py │ │ │ │ ├── sub_mbp_increase.py │ │ │ │ ├── sub_pricedepth.py │ │ │ │ ├── sub_pricedepth_bbo.py │ │ │ │ └── sub_trade_detail.py │ │ │ ├── subuser │ │ │ │ ├── __init__.py │ │ │ │ ├── get_uid.py │ │ │ │ ├── get_user_apikey_info.py │ │ │ │ ├── post_create_subuser.py │ │ │ │ ├── post_set_transferability.py │ │ │ │ ├── post_subuser_apikey_deletion.py │ │ │ │ ├── post_subuser_apikey_generation.py │ │ │ │ ├── post_subuser_apikey_modification.py │ │ │ │ └── post_tradable_market.py │ │ │ ├── trade │ │ │ │ ├── __init__.py │ │ │ │ ├── get_feerate.py │ │ │ │ ├── get_history_orders.py │ │ │ │ ├── get_match_results.py │ │ │ │ ├── get_match_results_by_order_id.py │ │ │ │ ├── get_open_orders.py │ │ │ │ ├── get_order_by_client_order_id.py │ │ │ │ ├── get_order_by_id.py │ │ │ │ ├── get_orders.py │ │ │ │ ├── get_transact_feerate.py │ │ │ │ ├── post_batch_cancel_open_order.py │ │ │ │ ├── post_batch_cancel_order.py │ │ │ │ ├── post_batch_create_order.py │ │ │ │ ├── post_cancel_client_order.py │ │ │ │ ├── post_cancel_order.py │ │ │ │ ├── post_create_order.py │ │ │ │ ├── post_transfer_futures_pro.py │ │ │ │ ├── req_order_detail.py │ │ │ │ ├── req_order_list.py │ │ │ │ ├── sub_order_update_v2.py │ │ │ │ └── sub_trade_clearing_v2.py │ │ │ └── wallet │ │ │ │ ├── __init__.py │ │ │ │ ├── get_account_deposit_address.py │ │ │ │ ├── get_account_withdraw_address.py │ │ │ │ ├── get_account_withdraw_quota.py │ │ │ │ ├── get_deposit_withdraw.py │ │ │ │ ├── get_sub_user_deposit_address.py │ │ │ │ ├── get_sub_user_deposit_history.py │ │ │ │ ├── post_cancel_withdraw.py │ │ │ │ └── post_create_withdraw.py │ │ └── utils │ │ │ ├── __init__.py │ │ │ ├── api_signature.py │ │ │ ├── api_signature_v2.py │ │ │ ├── channel_parser.py │ │ │ ├── channels.py │ │ │ ├── channels_request.py │ │ │ ├── etf_result.py │ │ │ ├── input_checker.py │ │ │ ├── json_parser.py │ │ │ ├── log_info.py │ │ │ ├── print_mix_object.py │ │ │ ├── time_service.py │ │ │ └── url_params_builder.py │ ├── huobi_contract1.py │ ├── huobi_contract2.py │ ├── log.py │ ├── mysql_tools.py │ ├── requirements.txt │ ├── statistic_server.py │ ├── tools │ │ └── get_coin_list.py │ └── trade_controller.py │ └── website │ ├── front_end │ ├── .babelrc │ ├── .editorconfig │ ├── .eslintignore │ ├── .eslintrc.js │ ├── .gitignore │ ├── .postcssrc.js │ ├── README.md │ ├── build │ │ ├── build.js │ │ ├── check-versions.js │ │ ├── logo.png │ │ ├── utils.js │ │ ├── vue-loader.conf.js │ │ ├── webpack.base.conf.js │ │ ├── webpack.dev.conf.js │ │ └── webpack.prod.conf.js │ ├── config │ │ ├── dev.env.js │ │ ├── index.js │ │ ├── prod.env.js │ │ └── test.env.js │ ├── index.html │ ├── package.json │ ├── src │ │ ├── App.vue │ │ ├── assets │ │ │ └── logo.png │ │ ├── components │ │ │ ├── CoinView.vue │ │ │ └── Login.vue │ │ ├── main.js │ │ ├── router │ │ │ └── index.js │ │ ├── script │ │ │ ├── CoinView.js │ │ │ └── Login.js │ │ └── scss │ │ │ ├── CoinView.scss │ │ │ ├── color.scss │ │ │ └── common.scss │ ├── static │ │ └── .gitkeep │ └── test │ │ ├── e2e │ │ ├── custom-assertions │ │ │ └── elementCount.js │ │ ├── nightwatch.conf.js │ │ ├── runner.js │ │ └── specs │ │ │ └── test.js │ │ └── unit │ │ ├── .eslintrc │ │ ├── jest.conf.js │ │ ├── setup.js │ │ └── specs │ │ └── HelloWorld.spec.js │ └── php │ └── coin_view │ ├── get_balance_now.php │ ├── get_history.php │ ├── get_login_status.php │ ├── get_profit.php │ ├── get_profit_now.php │ ├── get_statistic_all.php │ ├── login.php │ └── test.php └── old ├── README.md ├── collect_script ├── .gitignore ├── article2coin_anylse.py ├── coin_crawl.py ├── config.py ├── db_base.py ├── depth_binance.py ├── depth_crawl.py ├── depth_huobi.py ├── depth_info.py ├── depth_ok.py ├── depth_watcher.py ├── get_all_stone.py ├── market_base_common_binance.py ├── market_base_common_crawl.py ├── market_base_common_huobi.py ├── market_base_common_ok.py ├── news_55coin.py ├── news_8btc.py ├── news_base.py ├── news_chainfor.py ├── news_chainnews.py ├── news_crawl.py ├── news_jinse.py ├── start_analyse.py ├── start_depth_service.py ├── start_detail_service.py ├── start_news_service.py ├── test.txt ├── trade_detail_binance.py ├── trade_detail_crawl.py ├── trade_detail_huobi.py ├── trade_detail_info.py ├── trade_detail_ok.py ├── website_anylse.py ├── word_anylse.py └── word_import.py └── website ├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .postcssrc.js ├── README.md ├── build ├── build.js ├── check-versions.js ├── logo.png ├── utils.js ├── vue-loader.conf.js ├── webpack.base.conf.js ├── webpack.dev.conf.js └── webpack.prod.conf.js ├── config ├── dev.env.js ├── index.js ├── prod.env.js └── test.env.js ├── dist ├── back │ ├── db.php │ ├── getcoinbase.php │ ├── getnews.php │ └── getnewsbycoinid.php ├── index.html └── static │ ├── css │ ├── app.fd90c710912354abe414e9bf2e60f08b.css │ └── app.fd90c710912354abe414e9bf2e60f08b.css.map │ └── js │ ├── app.c007c4f92200173237ad.js │ ├── app.c007c4f92200173237ad.js.map │ ├── manifest.2ae2e69a05c33dfc65f8.js │ ├── manifest.2ae2e69a05c33dfc65f8.js.map │ ├── vendor.919463bff274fd47eb27.js │ └── vendor.919463bff274fd47eb27.js.map ├── index.html ├── package.json ├── src ├── App.vue ├── assets │ └── logo.png ├── components │ └── PC │ │ ├── Coin │ │ ├── CoinDescribe.vue │ │ ├── Item │ │ │ ├── CoinDepth.vue │ │ │ ├── CoinDescribeIntruduce.vue │ │ │ ├── CoinDetail.vue │ │ │ ├── CoinNews.vue │ │ │ ├── CoinNewsOnCoin.vue │ │ │ ├── CoinTable.vue │ │ │ └── CoinTradeInfo.vue │ │ └── Main.vue │ │ ├── Common │ │ ├── ErrorBody.vue │ │ ├── Footer.vue │ │ └── Header.vue │ │ ├── Main │ │ ├── Body.vue │ │ └── Main.vue │ │ ├── News │ │ └── Main.vue │ │ └── Stone │ │ └── Main.vue ├── config │ └── server_config.js ├── main.js ├── router │ └── index.js └── style │ ├── clearfix.scss │ └── index.scss ├── static └── .gitkeep └── test ├── e2e ├── custom-assertions │ └── elementCount.js ├── nightwatch.conf.js ├── runner.js └── specs │ └── test.js └── unit ├── .eslintrc ├── jest.conf.js ├── setup.js └── specs └── HelloWorld.spec.js /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc -------------------------------------------------------------------------------- /new/deploy.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | cd src/website/front_end 3 | npm install 4 | npm run build 5 | cd ../../../ -------------------------------------------------------------------------------- /new/docker/.gitignore: -------------------------------------------------------------------------------- 1 | volumes/ -------------------------------------------------------------------------------- /new/docker/volumes/nginx/config/default: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | root /var/www/html; 4 | index index.html index.htm index.nginx-debian.html; 5 | server_name _; 6 | location / { 7 | try_files $uri $uri/ =404; 8 | } 9 | location ~ \.php$ { 10 | include snippets/fastcgi-php.conf; 11 | fastcgi_pass unix:/run/php/php7.4-fpm.sock; 12 | } 13 | } -------------------------------------------------------------------------------- /new/docker/volumes/redis/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /new/docker_acc.sh: -------------------------------------------------------------------------------- 1 | if [ `whoami` != "root" ];then 2 | echo "Error:This script must be run as root!" 3 | exit 4 | fi 5 | echo '{ 6 | "registry-mirrors": [ 7 | "https://registry.docker-cn.com", 8 | "http://hub-mirror.c.163.com", 9 | "https://docker.mirrors.ustc.edu.cn" 10 | ] 11 | }' > /etc/docker/daemon.json -------------------------------------------------------------------------------- /new/readme: -------------------------------------------------------------------------------- 1 | pip3 install websocket_client -i https://pypi.tuna.tsinghua.edu.cn/simple 2 | pip3 install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple -------------------------------------------------------------------------------- /new/setup.sh: -------------------------------------------------------------------------------- 1 | if [ `whoami` != "root" ];then 2 | echo "Error:This script must be run as root!" 3 | exit 4 | fi 5 | apt install curl 6 | curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun 7 | apt install docker-compose -y 8 | 9 | apt install python3 -y 10 | apt install python3-pip -y 11 | pip3 install pipreqs -y 12 | 13 | 14 | apt install npm -y 15 | 16 | 17 | 18 | #apt install snapd -y 19 | #sudo snap install --classic certbot 20 | #sudo ln -s /snap/bin/certbot /usr/bin/certbot 21 | #certbot --server https://acme-v02.api.letsencrypt.org/directory -d "blocktools.site" -d "*.blocktools.site" --manual --preferred-challenges dns-01 certonly 22 | -------------------------------------------------------------------------------- /new/src/collector/.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | key_main.py 3 | key_sub1.py 4 | old/ -------------------------------------------------------------------------------- /new/src/collector/config.py: -------------------------------------------------------------------------------- 1 | config = { 2 | "proxy_config":{ 3 | "proxy_use":False, 4 | "proxy_ip":"127.0.0.1", 5 | "proxy_port":45971 6 | }, 7 | "redis_config":{ 8 | "host":'redis', 9 | "port":6379 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /new/src/collector/huobi/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /new/src/collector/huobi/client/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/new/src/collector/huobi/client/__init__.py -------------------------------------------------------------------------------- /new/src/collector/huobi/connection/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/new/src/collector/huobi/connection/__init__.py -------------------------------------------------------------------------------- /new/src/collector/huobi/connection/impl/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /new/src/collector/huobi/connection/impl/private_def.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class ConnectionState: 4 | IDLE = 0 5 | CONNECTED = 1 6 | WAIT_RECONNECT = 2 7 | CLOSED_ON_ERROR = 3 8 | CLOSED = 4 9 | 10 | CONNECT_HEART_BEAT_LIMIT_MS = 60000 # max interval between two package 11 | RECONNECT_AFTER_TIME_MS = 63000 # if not need connect immediately, it will enter delay connect status and will connect after setting times -------------------------------------------------------------------------------- /new/src/collector/huobi/connection/impl/restapi_request.py: -------------------------------------------------------------------------------- 1 | 2 | class RestApiRequest(object): 3 | 4 | def __init__(self): 5 | self.method = "" 6 | self.url = "" 7 | self.host = "" 8 | self.post_body = "" 9 | self.header = dict() 10 | self.json_parser = None 11 | 12 | -------------------------------------------------------------------------------- /new/src/collector/huobi/connection/impl/websocket_request.py: -------------------------------------------------------------------------------- 1 | from huobi.constant import ApiVersion 2 | 3 | 4 | class WebsocketRequest(object): 5 | 6 | def __init__(self): 7 | self.subscription_handler = None 8 | self.auto_close = False # close connection after receive data, for subscribe set False, for request set True 9 | self.is_trading = False 10 | self.is_mbp_feed = False 11 | self.error_handler = None 12 | self.json_parser = None 13 | self.update_callback = None 14 | self.api_version = ApiVersion.VERSION_V1 # v1 as default 15 | -------------------------------------------------------------------------------- /new/src/collector/huobi/constant/__init__.py: -------------------------------------------------------------------------------- 1 | from huobi.constant.definition import * 2 | from huobi.constant.result import * 3 | from huobi.constant.system import * 4 | from huobi.constant.test import * 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /new/src/collector/huobi/constant/result.py: -------------------------------------------------------------------------------- 1 | 2 | class OutputKey: 3 | KeyData = "data" 4 | KeyTick = "tick" 5 | KeyChannelCh = "ch" 6 | KeyChannelRep = "rep" 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /new/src/collector/huobi/constant/system.py: -------------------------------------------------------------------------------- 1 | 2 | HUOBI_URL_PRO = "https://api.huobi.pro" 3 | HUOBI_URL_VN = "https://api.huobi.vn" 4 | HUOBI_URL_SO = "https://api.huobi.so" 5 | 6 | 7 | HUOBI_WEBSOCKET_URI_PRO = "wss://api.huobi.pro" 8 | HUOBI_WEBSOCKET_URI_VN = "wss://api.huobi.vn" 9 | HUOBI_WEBSOCKET_URI_SO = "wss://api.huobi.so" 10 | 11 | class WebSocketDefine: 12 | Uri = HUOBI_WEBSOCKET_URI_PRO 13 | 14 | class RestApiDefine: 15 | Url = HUOBI_URL_PRO 16 | 17 | class HttpMethod: 18 | GET = "GET" 19 | GET_SIGN = "GET_SIGN" 20 | POST = "POST" 21 | POST_SIGN = "POST_SIGN" 22 | 23 | 24 | class ApiVersion: 25 | VERSION_V1 = "v1" 26 | VERSION_V2 = "v2" 27 | 28 | def get_default_server_url(user_configed_url): 29 | if user_configed_url and len(user_configed_url): 30 | return user_configed_url 31 | else: 32 | return RestApiDefine.Url 33 | -------------------------------------------------------------------------------- /new/src/collector/huobi/constant/test.py: -------------------------------------------------------------------------------- 1 | g_api_key="xxxxxx" 2 | g_secret_key="xxxxxx" 3 | 4 | 5 | 6 | 7 | g_sub_uid = 123456 8 | 9 | g_account_id = 123456 10 | 11 | -------------------------------------------------------------------------------- /new/src/collector/huobi/exception/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/new/src/collector/huobi/exception/__init__.py -------------------------------------------------------------------------------- /new/src/collector/huobi/exception/huobi_api_exception.py: -------------------------------------------------------------------------------- 1 | 2 | class HuobiApiException(Exception): 3 | 4 | RUNTIME_ERROR = "RuntimeError" 5 | INPUT_ERROR = "InputError" 6 | KEY_MISSING = "KeyMissing" 7 | SYS_ERROR = "SysError" 8 | SUBSCRIPTION_ERROR = "SubscriptionError" 9 | ENV_ERROR = "EnvironmentError" 10 | EXEC_ERROR = "ExecuteError" 11 | 12 | def __init__(self, error_code, error_message): 13 | self.error_code = error_code 14 | self.error_message = error_message 15 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/account/__init__.py: -------------------------------------------------------------------------------- 1 | from huobi.model.account.account import Account 2 | from huobi.model.account.account_balance import AccountBalance 3 | from huobi.model.account.account_balance_req import AccountBalanceReq 4 | from huobi.model.account.account_update import AccountUpdate 5 | from huobi.model.account.account_update_event import AccountUpdateEvent 6 | from huobi.model.account.balance import Balance 7 | from huobi.model.account.complete_subaccount import CompleteSubAccount 8 | from huobi.model.account.margin_balance_detail import MarginBalanceDetail 9 | from huobi.model.account.account_history import AccountHistory 10 | from huobi.model.account.sub_uid_management import SubUidManagement 11 | from huobi.model.account.account_ledger import AccountLedger 12 | from huobi.model.account.account_transfer_result import AccountTransferResult 13 | from huobi.model.account.account_point_result import AccountPointResult 14 | from huobi.model.account.account_point_transfer_result import AccountPointTransferResult 15 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/account/account.py: -------------------------------------------------------------------------------- 1 | from huobi.constant import * 2 | 3 | 4 | class Account: 5 | """ 6 | The account information for spot account, margin account etc. 7 | 8 | :member 9 | id: The unique account id. 10 | account_type: The type of this account, possible value: spot, margin, otc, point. 11 | account_state: The account state, possible value: working, lock. 12 | balances: The balance list of the specified currency. The content is Balance class 13 | 14 | """ 15 | 16 | def __init__(self): 17 | self.id = 0 18 | self.type = AccountType.INVALID 19 | self.state = AccountState.INVALID 20 | self.subtype = "" 21 | 22 | def print_object(self, format_data=""): 23 | from huobi.utils.print_mix_object import PrintBasic 24 | PrintBasic.print_basic(self.id, format_data + "ID") 25 | PrintBasic.print_basic(self.type, format_data + "Account Type") 26 | PrintBasic.print_basic(self.state, format_data + "Account State") 27 | PrintBasic.print_basic(self.subtype, format_data + "Subtype") 28 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/account/account_asset_valuation.py: -------------------------------------------------------------------------------- 1 | class AccountAssetValuationResult: 2 | """ 3 | The account information for spot account, margin account etc. 4 | 5 | :member 6 | balance: balance valuation bases on given valuation currency. 7 | timestamp: unix timestamp from server. 8 | 9 | """ 10 | 11 | def __init__(self): 12 | self.balance = "" 13 | self.timestamp = 0 14 | 15 | def print_object(self, format_data=""): 16 | from huobi.utils.print_mix_object import PrintBasic 17 | PrintBasic.print_basic(self.balance, format_data + "balance") 18 | PrintBasic.print_basic(self.timestamp, format_data + "timestamp") 19 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/account/account_balance_req.py: -------------------------------------------------------------------------------- 1 | 2 | class AccountBalanceReq: 3 | """ 4 | The account change information received by subscription of account. 5 | 6 | :member 7 | ts: The UNIX formatted timestamp generated by server in UTC. 8 | cid: client request ID 9 | topic: request Channel or Topic 10 | data: The list of account and balance 11 | 12 | """ 13 | 14 | def __init__(self): 15 | self.ts = 0 16 | self.cid = "" 17 | self.topic = "" 18 | self.data = list() 19 | 20 | 21 | def print_object(self, format_data=""): 22 | from huobi.utils.print_mix_object import PrintBasic 23 | PrintBasic.print_basic(self.ts, format_data + "Timestamp") 24 | PrintBasic.print_basic(self.cid, format_data + "Client Order ID") 25 | PrintBasic.print_basic(self.topic, format_data + "Topic") 26 | print() 27 | if len(self.data): 28 | for account_balance in self.data: 29 | account_balance.print_object() 30 | print() -------------------------------------------------------------------------------- /new/src/collector/huobi/model/account/account_point_group.py: -------------------------------------------------------------------------------- 1 | from huobi.constant import * 2 | 3 | 4 | class AccountPointGroup: 5 | """ 6 | The account information for spot account, margin account etc. 7 | 8 | :member 9 | id: The unique account id. 10 | account_type: The type of this account, possible value: spot, margin, otc, point. 11 | account_state: The account state, possible value: working, lock. 12 | list: The balance list of the specified currency. The content is Balance class 13 | 14 | """ 15 | 16 | def __init__(self): 17 | self.groupId = "" 18 | self.expiryDate = "" 19 | self.remainAmt = "" 20 | 21 | def print_object(self, format_data=""): 22 | from huobi.utils.print_mix_object import PrintBasic 23 | PrintBasic.print_basic(self.groupId, format_data + "Group Id") 24 | PrintBasic.print_basic(self.expiryDate, format_data + "Expiration date") 25 | PrintBasic.print_basic(self.remainAmt, format_data + "Remain Amount") 26 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/account/account_point_transfer_result.py: -------------------------------------------------------------------------------- 1 | class AccountPointTransferResult: 2 | """ 3 | The account change information received by subscription of account. 4 | 5 | :member 6 | timestamp: The UNIX formatted timestamp generated by server in UTC. 7 | change_type: The event that asset change notification related. 8 | account_change_list: The list of account change, the content is AccountChange class 9 | 10 | """ 11 | 12 | def __init__(self): 13 | self.transactId = "" 14 | self.transactTime = 0 15 | 16 | def print_object(self, format_data=""): 17 | from huobi.utils.print_mix_object import PrintBasic 18 | PrintBasic.print_basic(self.transactId, format_data + "transactId") 19 | PrintBasic.print_basic(self.transactTime, format_data + "transactTime") 20 | self.data.print_object() 21 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/account/account_transfer_result.py: -------------------------------------------------------------------------------- 1 | class AccountTransferResult: 2 | """ 3 | The account information for spot account, margin account etc. 4 | 5 | :member 6 | id: The unique account id. 7 | account_type: The type of this account, possible value: spot, margin, otc, point. 8 | account_state: The account state, possible value: working, lock. 9 | balances: The balance list of the specified currency. The content is Balance class 10 | 11 | """ 12 | 13 | def __init__(self): 14 | self.transact_id = 0 15 | self.transact_time = 0 16 | 17 | def print_object(self, format_data=""): 18 | from huobi.utils.print_mix_object import PrintBasic 19 | PrintBasic.print_basic(self.transact_id, format_data + "TransactionId") 20 | PrintBasic.print_basic(self.transact_time, format_data + "TransactionTime") 21 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/account/account_update_event.py: -------------------------------------------------------------------------------- 1 | from huobi.constant import * 2 | from huobi.model.account import AccountUpdate 3 | 4 | 5 | class AccountUpdateEvent: 6 | """ 7 | The account change information received by subscription of account. 8 | 9 | :member 10 | timestamp: The UNIX formatted timestamp generated by server in UTC. 11 | change_type: The event that asset change notification related. 12 | account_change_list: The list of account change, the content is AccountChange class 13 | 14 | """ 15 | 16 | def __init__(self): 17 | self.ch = 0 18 | self.data = AccountUpdate() 19 | 20 | def print_object(self, format_data=""): 21 | from huobi.utils.print_mix_object import PrintBasic 22 | PrintBasic.print_basic(self.ch, format_data + "Topic") 23 | self.data.print_object() -------------------------------------------------------------------------------- /new/src/collector/huobi/model/account/balance.py: -------------------------------------------------------------------------------- 1 | from huobi.constant import * 2 | from huobi.utils import default_parse_list_dict 3 | 4 | 5 | class Balance: 6 | """ 7 | The balance of specified account. 8 | 9 | :member 10 | currency: The currency of this balance. 11 | balance_type: The balance type, trade or frozen. 12 | balance: The balance in the main currency unit. 13 | 14 | """ 15 | 16 | def __init__(self): 17 | self.currency = "" 18 | self.type = AccountBalanceUpdateType.INVALID 19 | self.balance = 0.0 20 | 21 | def print_object(self, format_data=""): 22 | from huobi.utils.print_mix_object import PrintBasic 23 | PrintBasic.print_basic(self.currency, format_data + "Currency") 24 | PrintBasic.print_basic(self.type, format_data + "Balance Type") 25 | PrintBasic.print_basic(self.balance, format_data + "Balance") -------------------------------------------------------------------------------- /new/src/collector/huobi/model/account/complete_subaccount.py: -------------------------------------------------------------------------------- 1 | 2 | from huobi.constant import * 3 | 4 | 5 | class CompleteSubAccount: 6 | """ 7 | Sub-account completed info 8 | 9 | :member 10 | id: The sub-id. 11 | account_type: The sub account type. 12 | balances: The balance list, the content is Balance class. 13 | """ 14 | 15 | def __init__(self): 16 | self.id = 0 17 | self.account_type = AccountType.INVALID 18 | self.balances = list() 19 | 20 | def print_object(self, format_data=""): 21 | from huobi.utils.print_mix_object import PrintBasic 22 | PrintBasic.print_basic(self.id, format_data + "ID") 23 | PrintBasic.print_basic(self.account_type, format_data + "Account Type") 24 | if len(self.balances): 25 | for row in self.balances: 26 | row.print_object() 27 | print() -------------------------------------------------------------------------------- /new/src/collector/huobi/model/account/margin_balance_detail.py: -------------------------------------------------------------------------------- 1 | 2 | from huobi.constant import * 3 | 4 | 5 | class MarginBalanceDetail: 6 | def __init__(self): 7 | self.id = 0 8 | self.symbol = 0 9 | self.state = AccountState.INVALID 10 | self.type = AccountType.INVALID 11 | self.risk_rate = 0.0 12 | self.fl_price = 0.0 13 | self.fl_type = "" 14 | self.sub_account_balance_list = list() 15 | 16 | def print_object(self, format_data=""): 17 | from huobi.utils.print_mix_object import PrintBasic 18 | PrintBasic.print_basic(self.id, format_data + "ID") 19 | PrintBasic.print_basic(self.type, format_data + "Account Type") 20 | PrintBasic.print_basic(self.symbol, format_data + "Symbol") 21 | PrintBasic.print_basic(self.state, format_data + "Account State") 22 | PrintBasic.print_basic(self.fl_price, format_data + "Burst Price") 23 | PrintBasic.print_basic(self.fl_type, format_data + "Burst Type") 24 | PrintBasic.print_basic(self.risk_rate, format_data + "Risk Rate") -------------------------------------------------------------------------------- /new/src/collector/huobi/model/account/sub_uid_management.py: -------------------------------------------------------------------------------- 1 | from huobi.constant import SubUidState 2 | 3 | 4 | class SubUidManagement: 5 | """ 6 | The trade information with price and amount etc. 7 | 8 | :member 9 | subUid: sub user ID. 10 | userState: sub user account state, states see SubUidState. 11 | """ 12 | 13 | def __init__(self): 14 | self.subUid = 0 15 | self.userState = SubUidState.INVALID 16 | 17 | def print_object(self, format_data=""): 18 | from huobi.utils.print_mix_object import PrintBasic 19 | PrintBasic.print_basic(self.subUid, format_data + "subUid") 20 | PrintBasic.print_basic(self.userState, format_data + "userState") 21 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/algo/__init__.py: -------------------------------------------------------------------------------- 1 | from huobi.model.algo.cancel_order_result import CancelOrderResult 2 | from huobi.model.algo.order_list_item import OrderListItem 3 | from huobi.model.algo.order_history_item import OrderHistoryItem 4 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/algo/cancel_order_result.py: -------------------------------------------------------------------------------- 1 | class CancelOrderResult: 2 | """ 3 | The result of batch cancel operation. 4 | 5 | :member 6 | accepted: The clientOrderIds accepted. 7 | rejected: The clientOrderIds rejected . 8 | 9 | """ 10 | 11 | def __init__(self): 12 | self.accepted = [] 13 | self.rejected = [] 14 | 15 | def print_object(self, format_data=""): 16 | print("Success Order Counts", len(self.accepted), " accepted Order Ids : ", self.accepted) 17 | print("Fail Order Counts", len(self.rejected), " Rejected Order Ids : ", self.rejected) -------------------------------------------------------------------------------- /new/src/collector/huobi/model/etf/__init__.py: -------------------------------------------------------------------------------- 1 | from huobi.model.etf.etf_swap_config import EtfSwapConfig 2 | from huobi.model.etf.etf_swap_list import EtfSwapList 3 | from huobi.model.etf.etf_swap_in_out import EtfSwapInOut 4 | from huobi.model.etf.unitprice import UnitPrice -------------------------------------------------------------------------------- /new/src/collector/huobi/model/etf/etf_swap_in_out.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class EtfSwapInOut: 4 | """ 5 | :member 6 | """ 7 | 8 | def __init__(self): 9 | self.code = 0 10 | self.data = None 11 | self.message = "" 12 | self.success = False 13 | 14 | def print_object(self, format_data=""): 15 | from huobi.utils.print_mix_object import PrintBasic 16 | PrintBasic.print_basic(self.code, format_data + "Return Code") 17 | PrintBasic.print_basic_bool(self.data, format_data + "Data") 18 | PrintBasic.print_basic(self.message, format_data + "Message") 19 | PrintBasic.print_basic_bool(self.success, format_data + "Success") 20 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/etf/unitprice.py: -------------------------------------------------------------------------------- 1 | class UnitPrice: 2 | 3 | def __init__(self): 4 | self.currency = "" 5 | self.amount = 0.0 6 | 7 | def print_object(self, format_data=""): 8 | from huobi.utils.print_mix_object import PrintBasic 9 | PrintBasic.print_basic(self.currency, format_data + "Currency") 10 | PrintBasic.print_basic(self.amount, format_data + "Amount") -------------------------------------------------------------------------------- /new/src/collector/huobi/model/generic/__init__.py: -------------------------------------------------------------------------------- 1 | from huobi.model.generic.symbol import Symbol 2 | from huobi.model.generic.exchange_info import ExchangeInfo 3 | from huobi.model.generic.chain import Chain 4 | from huobi.model.generic.reference_currency import ReferenceCurrency 5 | from huobi.model.generic.market_status import MarketStatus 6 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/generic/exchange_info.py: -------------------------------------------------------------------------------- 1 | class ExchangeInfo: 2 | """ 3 | The Huobi supported the symbols and currencies. 4 | 5 | :member 6 | symbol_list: The symbol list. The content is Symbol class. 7 | currencies: The currency list. The content is string value. 8 | """ 9 | 10 | def __init__(self): 11 | self.symbol_list = list() 12 | self.currencies = list() 13 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/generic/market_status.py: -------------------------------------------------------------------------------- 1 | from huobi.constant import * 2 | 3 | 4 | class MarketStatus: 5 | """ 6 | The Huobi market status info. 7 | 8 | :member 9 | marketStatus: . 10 | haltStartTime: . 11 | haltEndTime: . 12 | haltReason: 13 | affectedSymbols: 14 | """ 15 | 16 | def __init__(self): 17 | self.marketStatus = MarketStatus.NORMAL 18 | self.haltStartTime = -1 19 | self.haltEndTime = -1 20 | self.affectedSymbols = "" 21 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/generic/reference_currency.py: -------------------------------------------------------------------------------- 1 | from huobi.constant import * 2 | 3 | class ReferenceCurrency: 4 | """ 5 | The Huobi supported static reference information for each currency. 6 | 7 | :member 8 | currency: currency 9 | instStatus: Instrument status 10 | chains: chain list 11 | """ 12 | 13 | def __init__(self): 14 | self.currency = "" 15 | self.instStatus = InstrumentStatus.INVALID 16 | self.chains = [] 17 | 18 | 19 | def print_object(self, format_data=""): 20 | from huobi.utils.print_mix_object import PrintBasic 21 | PrintBasic.print_basic(self.currency, format_data + "Currency") 22 | PrintBasic.print_basic(self.instStatus, format_data + "Instrument Status") 23 | if self.chains and len(self.chains): 24 | for chain_obj in self.chains: 25 | chain_obj.print_object("\t") 26 | print() 27 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/margin/__init__.py: -------------------------------------------------------------------------------- 1 | from huobi.model.margin.loan_order import LoanOrder 2 | from huobi.model.margin.margin_account_balance import MarginAccountBalance 3 | from huobi.model.margin.loan_ino import LoanInfo 4 | from huobi.model.margin.margin_loan_ino import MarginLoanInfo 5 | from huobi.model.margin.cross_margin_loan_ino import CrossMarginLoanInfo 6 | from huobi.model.margin.cross_margin_account_balance import CrossMarginAccountBalance 7 | 8 | 9 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/margin/cross_margin_loan_ino.py: -------------------------------------------------------------------------------- 1 | 2 | from huobi.model.margin.loan_ino import LoanInfo 3 | 4 | class CrossMarginLoanInfo(LoanInfo): 5 | def __init__(self): 6 | LoanInfo.__init__(self) 7 | 8 | def print_object(self, format_data=""): 9 | LoanInfo.print_object(self) 10 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/margin/general_repay_loan_result.py: -------------------------------------------------------------------------------- 1 | from huobi.constant import * 2 | 3 | 4 | class GeneralRepayLoanResult: 5 | """ 6 | The margin order information. 7 | 8 | :member 9 | id: Inner id. 10 | type: The account type. 11 | state: The account state. 12 | symbol: The symbol, like "btcusdt". 13 | fl_price: The trigger price. 14 | fl_type: The trigger type. 15 | risk_rate: The risk rate. 16 | list:Balance Object list 17 | """ 18 | 19 | def __init__(self): 20 | self.repayId = 0 21 | self.repayTime = 0 22 | 23 | def print_object(self, format_data=""): 24 | from huobi.utils.print_mix_object import PrintBasic 25 | PrintBasic.print_basic(self.repayId, format_data + "repayId") 26 | PrintBasic.print_basic(self.repayTime, format_data + "repayTime") 27 | 28 | print() 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/margin/loan_ino.py: -------------------------------------------------------------------------------- 1 | 2 | class LoanInfo: 3 | """ 4 | The margin rate define. 5 | 6 | :member 7 | currency: The currency name. 8 | interest_rate: all interest rate 9 | min_loan_amt: min loan amount. 10 | max_loan_amt: max loan amount. 11 | loanable_amt: loanable amount. 12 | actual_rate: rate after deduction. 13 | """ 14 | 15 | def __init__(self): 16 | self.currency = "" 17 | self.interest_rate = "" 18 | self.min_loan_amt = "" 19 | self.max_loan_amt = "" 20 | self.loanable_amt = "" 21 | self.actual_rate = "" 22 | 23 | def print_object(self, format_data=""): 24 | from huobi.utils.print_mix_object import PrintBasic 25 | PrintBasic.print_basic(self.currency, format_data + "Currency") 26 | PrintBasic.print_basic(self.interest_rate, format_data + "Interest Rate") 27 | PrintBasic.print_basic(self.min_loan_amt, format_data + "Min Loan Amount") 28 | PrintBasic.print_basic(self.max_loan_amt, format_data + "Max Loan Amount") 29 | PrintBasic.print_basic(self.loanable_amt, format_data + "Loanable Amount") 30 | PrintBasic.print_basic(self.actual_rate, format_data + "Actual Rate") 31 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/market/candlestick_event.py: -------------------------------------------------------------------------------- 1 | from huobi.constant import * 2 | from huobi.model.market import * 3 | 4 | 5 | class CandlestickEvent: 6 | """ 7 | The candlestick/kline data received by subscription of candlestick/kline. 8 | 9 | :member 10 | ch: the topic you subscribed 11 | ts: the UNIX formatted timestamp generated by server in UTC. 12 | tick: the data of candlestick/kline. 13 | """ 14 | 15 | def __init__(self): 16 | self.ch = "" 17 | self.ts = 0 18 | self.tick = Candlestick() 19 | 20 | 21 | def print_object(self, format_data=""): 22 | from huobi.utils.print_mix_object import PrintBasic 23 | PrintBasic.print_basic(self.ts, format_data + "Unix Time") 24 | PrintBasic.print_basic(self.ch, format_data + "Channel") 25 | if self.tick: 26 | self.tick.print_object() 27 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/market/candlestick_req.py: -------------------------------------------------------------------------------- 1 | from huobi.constant import * 2 | 3 | class CandlestickReq: 4 | """ 5 | The candlestick/kline data received by subscription of candlestick/kline. 6 | 7 | :member 8 | rep: the Channel or topic you subscribed. 9 | id: the UNIX formatted timestamp generated by server in UTC. 10 | data: the data of candlestick/kline. 11 | 12 | """ 13 | 14 | def __init__(self): 15 | self.rep = "" 16 | self.id = 0 17 | self.data = list() 18 | 19 | def print_object(self, format_data=""): 20 | from huobi.utils.print_mix_object import PrintBasic 21 | PrintBasic.print_basic(self.rep, format_data + "Channel") 22 | PrintBasic.print_basic(self.id, format_data + "Unix Time") 23 | print() 24 | if len(self.data): 25 | for row in self.data: 26 | row.print_object() 27 | print() -------------------------------------------------------------------------------- /new/src/collector/huobi/model/market/depth_entry.py: -------------------------------------------------------------------------------- 1 | 2 | class DepthEntry: 3 | """ 4 | An depth entry consisting of price and amount. 5 | 6 | :member 7 | price: The price of the depth. 8 | amount: The amount of the depth. 9 | """ 10 | 11 | def __init__(self): 12 | self.price = 0.0 13 | self.amount = 0.0 14 | 15 | @staticmethod 16 | def json_parse(data_array): 17 | entry = DepthEntry() 18 | entry.price = data_array[0] 19 | entry.amount = data_array[1] 20 | return entry 21 | 22 | def print_object(self, format_data=""): 23 | from huobi.utils.print_mix_object import PrintBasic 24 | PrintBasic.print_basic(self.price, format_data + "Price") 25 | PrintBasic.print_basic(self.amount, format_data + "Amount") -------------------------------------------------------------------------------- /new/src/collector/huobi/model/market/last_trade_bestquote.py: -------------------------------------------------------------------------------- 1 | class LastTradeAndBestQuote: 2 | """ 3 | The last trade and best bid/ask. 4 | 5 | :member 6 | last_trade_price: The last trade price. 7 | last_trade_amount: The last trade amount. 8 | ask_price: The best ask price. 9 | ask_amount: The best ask amount. 10 | bid_price: The best bid price. 11 | bid_amount: The best bid amount. 12 | 13 | """ 14 | 15 | def __init__(self): 16 | self.last_trade_price = 0.0 17 | self.last_trade_amount = 0.0 18 | self.ask_price = 0.0 19 | self.ask_amount = 0.0 20 | self.bid_price = 0.0 21 | self.bid_amount = 0.0 22 | 23 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/market/market_detail_event.py: -------------------------------------------------------------------------------- 1 | from huobi.model.market.market_detail import MarketDetail 2 | 3 | class MarketDetailEvent: 4 | """ 5 | The 24H trade statistics received by subscription of trade statistics. 6 | 7 | :member 8 | Channel: topic you subscribe, include symbol. 9 | timestamp: The UNIX formatted timestamp generated by server in UTC. 10 | trade_statistics: The trade statistics. 11 | """ 12 | 13 | def __init__(self): 14 | self.ch = "" 15 | self.ts = 0 16 | self.tick = MarketDetail() 17 | 18 | def print_object(self, format_data=""): 19 | from huobi.utils.print_mix_object import PrintBasic 20 | PrintBasic.print_basic(self.ch, format_data + "Channel") 21 | PrintBasic.print_basic(self.ts, format_data + "Timestamp") 22 | self.tick.print_object() -------------------------------------------------------------------------------- /new/src/collector/huobi/model/market/market_detail_req.py: -------------------------------------------------------------------------------- 1 | from huobi.model.market.market_detail import MarketDetail 2 | 3 | class MarketDetailReq: 4 | """ 5 | The 24H trade statistics received by request of trade statistics only once. 6 | 7 | :member 8 | rep: The topic you subscribed. 9 | ts: The UNIX formatted timestamp generated by server in UTC. 10 | trade_statistics: The trade statistics. 11 | """ 12 | 13 | def __init__(self): 14 | self.rep = 0 15 | self.ts = 0 16 | self.data = MarketDetail() 17 | 18 | def print_object(self, format_data=""): 19 | from huobi.utils.print_mix_object import PrintBasic 20 | PrintBasic.print_basic(self.ts, format_data + "Timestamp") 21 | PrintBasic.print_basic(self.rep, format_data + "Channel") 22 | self.data.print_object() -------------------------------------------------------------------------------- /new/src/collector/huobi/model/market/mbp_full_event.py: -------------------------------------------------------------------------------- 1 | from huobi.model.market import Mbp 2 | 3 | 4 | class MbpFullEvent: 5 | """ 6 | full price depth. 7 | 8 | :member 9 | ch: Topic of subscribed. 10 | timestamp: The UNIX formatted timestamp generated by server in UTC. 11 | data: The price depth. 12 | 13 | """ 14 | 15 | def __init__(self): 16 | self.ch = "" 17 | self.ts = 0 18 | self.data = Mbp() 19 | 20 | @staticmethod 21 | def json_parse(json_data): 22 | mbp_event = MbpFullEvent() 23 | mbp_event.ts = json_data.get("ts") 24 | mbp_event.ch = json_data.get("ch") 25 | mbp = Mbp.json_parse(json_data.get("tick", {})) 26 | mbp_event.data = mbp 27 | return mbp_event 28 | 29 | def print_object(self, format_data=""): 30 | from huobi.utils.print_mix_object import PrintBasic 31 | PrintBasic.print_basic(self.ch, format_data + "Topic") 32 | PrintBasic.print_basic(self.ts, format_data + "Timestamp") 33 | self.data.print_object(format_data + "\t") -------------------------------------------------------------------------------- /new/src/collector/huobi/model/market/mbp_increase_event.py: -------------------------------------------------------------------------------- 1 | from huobi.model.market import Mbp 2 | 3 | 4 | class MbpIncreaseEvent: 5 | """ 6 | increasement of price depth. 7 | 8 | :member 9 | ch: Topic of subscribed. 10 | timestamp: The UNIX formatted timestamp generated by server in UTC. 11 | data: The price depth. 12 | 13 | """ 14 | 15 | def __init__(self): 16 | self.ch = "" 17 | self.ts = 0 18 | self.data = Mbp() 19 | 20 | @staticmethod 21 | def json_parse(json_data): 22 | mbp_event = MbpIncreaseEvent() 23 | mbp_event.ts = json_data.get("ts") 24 | mbp_event.ch = json_data.get("ch") 25 | mbp = Mbp.json_parse(json_data.get("tick", {})) 26 | mbp_event.data = mbp 27 | return mbp_event 28 | 29 | def print_object(self, format_data=""): 30 | from huobi.utils.print_mix_object import PrintBasic 31 | PrintBasic.print_basic(self.ch, format_data + "Topic") 32 | PrintBasic.print_basic(self.ts, format_data + "Timestamp") 33 | 34 | self.data.print_object(format_data + "\t") 35 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/market/mbp_req.py: -------------------------------------------------------------------------------- 1 | from huobi.model.market import Mbp, PriceDepth 2 | 3 | 4 | class MbpReq: 5 | """ 6 | The market price depth. 7 | 8 | :member 9 | rep: request Topic 10 | id: The UNIX formatted timestamp generated by server in UTC. 11 | data: The price depth. 12 | """ 13 | 14 | def __init__(self): 15 | self.rep = "" 16 | self.id = "" 17 | 18 | self.data = Mbp() 19 | 20 | 21 | @staticmethod 22 | def json_parse(data_json): 23 | mbp_event = MbpReq() 24 | mbp_event.id = data_json.get("id") 25 | mbp_event.rep = data_json.get("rep") 26 | data = data_json.get("data", {}) 27 | mbp = Mbp.json_parse(data) 28 | mbp_event.data = mbp 29 | return mbp_event 30 | 31 | def print_object(self, format_data=""): 32 | from huobi.utils.print_mix_object import PrintBasic 33 | PrintBasic.print_basic(self.rep, format_data + "Topic") 34 | PrintBasic.print_basic(self.id, format_data + "Timestamp") 35 | 36 | self.data.print_object(format_data + "\t") 37 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/market/pricedepth_bbo.py: -------------------------------------------------------------------------------- 1 | 2 | class PriceDepthBbo: 3 | """ 4 | The price depth information. 5 | 6 | :member 7 | timestamp: The UNIX formatted timestamp in UTC. 8 | bid: the first bid near trade value. 9 | bidSize: the bid size. 10 | ask: The first ask near trade value. 11 | askSize: the ask size. 12 | quoteTime : quote time 13 | symbol : trade symbol 14 | 15 | 16 | """ 17 | def __init__(self): 18 | self.seqId = 0 19 | self.ask = 0.0 20 | self.askSize = 0.0 21 | self.bid = 0.0 22 | self.bidSize = 0.0 23 | self.quoteTime = 0 24 | self.symbol = "" 25 | 26 | def print_object(self, format_data=""): 27 | from huobi.utils.print_mix_object import PrintBasic 28 | PrintBasic.print_basic(self.seqId, format_data + "Seq ID") 29 | PrintBasic.print_basic(self.ask, format_data + "Ask") 30 | PrintBasic.print_basic(self.askSize, format_data + "Ask Size") 31 | PrintBasic.print_basic(self.bid, format_data + "Bid") 32 | PrintBasic.print_basic(self.bidSize, format_data + "Bid Size") 33 | PrintBasic.print_basic(self.quoteTime, format_data + "Quote Time") 34 | PrintBasic.print_basic(self.symbol, format_data + "Symbol") -------------------------------------------------------------------------------- /new/src/collector/huobi/model/market/pricedepth_bbo_event.py: -------------------------------------------------------------------------------- 1 | from huobi.model.market import PriceDepthBbo 2 | 3 | 4 | class PriceDepthBboEvent: 5 | """ 6 | The price depth received by subscription of price depth. 7 | 8 | :member 9 | symbol: The symbol you subscribed. 10 | timestamp: The UNIX formatted timestamp generated by server in UTC. 11 | data: The price depth. 12 | 13 | """ 14 | 15 | def __init__(self): 16 | self.ts = 0 17 | self.ch = "" 18 | self.tick = PriceDepthBbo() 19 | 20 | 21 | def print_object(self, format_data=""): 22 | from huobi.utils.print_mix_object import PrintBasic 23 | PrintBasic.print_basic(self.ts, format_data + "Time") 24 | PrintBasic.print_basic(self.ch, format_data + "Channel") 25 | self.tick.print_object(format_data) -------------------------------------------------------------------------------- /new/src/collector/huobi/model/market/pricedepth_event.py: -------------------------------------------------------------------------------- 1 | 2 | from huobi.model.market.pricedepth import PriceDepth 3 | class PriceDepthEvent: 4 | """ 5 | The price depth information. 6 | 7 | :member 8 | ts: The UNIX formatted timestamp in UTC. 9 | version: 10 | bids: The list of the bid depth. The content is DepthEntry class. 11 | asks: The list of the ask depth. The content is DepthEntry class. 12 | 13 | """ 14 | def __init__(self): 15 | self.ch = "" 16 | self.tick = PriceDepth() 17 | 18 | 19 | 20 | def print_object(self, format_data=""): 21 | from huobi.utils.print_mix_object import PrintBasic 22 | PrintBasic.print_basic(self.ch, format_data + "Channel") 23 | self.tick.print_object("\t") -------------------------------------------------------------------------------- /new/src/collector/huobi/model/market/pricedepth_req.py: -------------------------------------------------------------------------------- 1 | 2 | from huobi.model.market.pricedepth import PriceDepth 3 | 4 | class PriceDepthReq: 5 | """ 6 | The price depth information. 7 | 8 | :member 9 | ts: The UNIX formatted timestamp in UTC. 10 | version: 11 | bids: The list of the bid depth. The content is DepthEntry class. 12 | asks: The list of the ask depth. The content is DepthEntry class. 13 | 14 | """ 15 | def __init__(self): 16 | self.rep = "" 17 | self.data = PriceDepth() 18 | 19 | def print_object(self, format_data=""): 20 | from huobi.utils.print_mix_object import PrintBasic 21 | PrintBasic.print_basic(self.rep, format_data + "Channel") 22 | self.data.print_object("\t") -------------------------------------------------------------------------------- /new/src/collector/huobi/model/market/trade.py: -------------------------------------------------------------------------------- 1 | 2 | class Trade: 3 | """ 4 | The trade information with price and amount etc. 5 | 6 | :member 7 | price: The trading price in quote currency. 8 | amount: The trading volume in base currency. 9 | trade_id: The unique trade id of this trade. 10 | timestamp: The UNIX formatted timestamp generated by server in UTC. 11 | direction: The direction of the taker trade: 'buy' or 'sell'. 12 | """ 13 | 14 | def __init__(self): 15 | self.price = 0.0 16 | self.amount = 0.0 17 | self.trade_id = 0 18 | self.ts = 0 19 | self.direction = "" 20 | 21 | 22 | 23 | def print_object(self, format_data=""): 24 | from huobi.utils.print_mix_object import PrintBasic 25 | PrintBasic.print_basic(self.trade_id, format_data + "Trade Id") 26 | PrintBasic.print_basic(self.ts, format_data + "Trade Time") 27 | PrintBasic.print_basic(self.price, format_data + "Price") 28 | PrintBasic.print_basic(self.amount, format_data + "Amount") 29 | PrintBasic.print_basic(self.direction, format_data + "Direction") -------------------------------------------------------------------------------- /new/src/collector/huobi/model/market/trade_detail.py: -------------------------------------------------------------------------------- 1 | 2 | class TradeDetail: 3 | """ 4 | The trade information with price and amount etc. 5 | 6 | :member 7 | price: The trading price in quote currency. 8 | amount: The trading volume in base currency. 9 | tradeId: The unique trade id of this trade. 10 | timestamp: The UNIX formatted timestamp generated by server in UTC. 11 | direction: The direction of the taker trade: 'buy' or 'sell'. 12 | """ 13 | 14 | def __init__(self): 15 | self.price = 0.0 16 | self.amount = 0.0 17 | self.tradeId = 0 18 | self.ts = 0 19 | self.direction = "" 20 | 21 | 22 | 23 | def print_object(self, format_data=""): 24 | from huobi.utils.print_mix_object import PrintBasic 25 | PrintBasic.print_basic(self.tradeId, format_data + "Trade Id") 26 | PrintBasic.print_basic(self.ts, format_data + "Trade Time") 27 | PrintBasic.print_basic(self.price, format_data + "Price") 28 | PrintBasic.print_basic(self.amount, format_data + "Amount") 29 | PrintBasic.print_basic(self.direction, format_data + "Direction") -------------------------------------------------------------------------------- /new/src/collector/huobi/model/market/trade_detail_event.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class TradeDetailEvent: 4 | """ 5 | The trade received by subscription of trade. 6 | 7 | :member 8 | symbol: The symbol you subscribed. 9 | timestamp: The UNIX formatted timestamp generated by server in UTC. 10 | trade_list: The trade list. The content is Trade class. 11 | """ 12 | 13 | def __init__(self): 14 | self.ch = "" 15 | self.id = 0 16 | self.ts = 0 17 | self.data = list() 18 | 19 | 20 | def print_object(self, format_data=""): 21 | from huobi.utils.print_mix_object import PrintBasic 22 | PrintBasic.print_basic(self.ch, format_data + "Channel") 23 | PrintBasic.print_basic(self.id, format_data + "ID") 24 | PrintBasic.print_basic(self.ts, format_data + "Unix Time") 25 | if len(self.data): 26 | for trade_detail in self.data: 27 | trade_detail.print_object() 28 | print() -------------------------------------------------------------------------------- /new/src/collector/huobi/model/market/trade_detail_req.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class TradeDetailReq: 4 | """ 5 | The trade received by subscription of trade. 6 | 7 | :member 8 | rep: The Channel you subscribed. 9 | trade_list: The trade list. The content is Trade class. 10 | """ 11 | 12 | def __init__(self): 13 | self.rep = "" 14 | self.data = list() 15 | 16 | def print_object(self, format_data=""): 17 | from huobi.utils.print_mix_object import PrintBasic 18 | PrintBasic.print_basic(self.rep, format_data + "Channel") 19 | print() 20 | if len(self.data): 21 | for trade_detail in self.data: 22 | trade_detail.print_object() 23 | print() -------------------------------------------------------------------------------- /new/src/collector/huobi/model/subuser/__init__.py: -------------------------------------------------------------------------------- 1 | from huobi.model.subuser.subuser_creation import SubuserCreation 2 | from huobi.model.subuser.subuser_transferability import SubuserTransferability 3 | from huobi.model.subuser.subuser_apikey_generation import SubuserApikeyGeneration 4 | from huobi.model.subuser.user_apikey_info import UserApikeyInfo 5 | from huobi.model.subuser.subuser_apikey_modification import SubuserApikeyModification 6 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/subuser/subuser_apikey_generation.py: -------------------------------------------------------------------------------- 1 | class SubuserApikeyGeneration: 2 | """ 3 | The trade information with price and amount etc. 4 | 5 | :member 6 | accessKey: 7 | secretKey: 8 | note: 9 | permission: "trade,readOnly", 10 | ipAddresses": 11 | """ 12 | 13 | def __init__(self): 14 | self.accessKey = "" 15 | self.secretKey = "" 16 | self.note = "" 17 | self.permission = "" 18 | self.ipAddresses = "" 19 | 20 | def print_object(self, format_data=""): 21 | from huobi.utils.print_mix_object import PrintBasic 22 | PrintBasic.print_basic(self.accessKey, format_data + "accessKey") 23 | PrintBasic.print_basic(self.secretKey, format_data + "secretKey") 24 | PrintBasic.print_basic(self.note, format_data + "note") 25 | PrintBasic.print_basic(self.permission, format_data + "permission") 26 | PrintBasic.print_basic(self.ipAddresses, format_data + "ipAddresses") 27 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/subuser/subuser_apikey_modification.py: -------------------------------------------------------------------------------- 1 | class SubuserApikeyModification: 2 | """ 3 | The trade information with price and amount etc. 4 | 5 | :member 6 | note: 7 | permission: "trade,readOnly", 8 | ipAddresses": 9 | """ 10 | 11 | def __init__(self): 12 | self.note = "" 13 | self.permission = "" 14 | self.ipAddresses = "" 15 | 16 | def print_object(self, format_data=""): 17 | from huobi.utils.print_mix_object import PrintBasic 18 | PrintBasic.print_basic(self.note, format_data + "note") 19 | PrintBasic.print_basic(self.permission, format_data + "permission") 20 | PrintBasic.print_basic(self.ipAddresses, format_data + "ipAddresses") 21 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/subuser/subuser_creation.py: -------------------------------------------------------------------------------- 1 | 2 | class SubuserCreation: 3 | """ 4 | The trade information with price and amount etc. 5 | 6 | :member 7 | subUid: sub user ID. 8 | userState: sub user account state, states see SubUidState. 9 | """ 10 | 11 | def __init__(self): 12 | self.user_name = "" 13 | self.note = "" 14 | self.uid = 0 15 | self.err_code = 0 16 | self.err_message = "" 17 | 18 | def print_object(self, format_data=""): 19 | from huobi.utils.print_mix_object import PrintBasic 20 | PrintBasic.print_basic(self.user_name, format_data + "userName") 21 | PrintBasic.print_basic(self.note, format_data + "note") 22 | PrintBasic.print_basic(self.uid, format_data + "uid") 23 | PrintBasic.print_basic(self.err_code, format_data + "errCode") 24 | PrintBasic.print_basic(self.err_message, format_data + "errMessage") 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/subuser/subuser_transferability.py: -------------------------------------------------------------------------------- 1 | 2 | class SubuserTransferability: 3 | """ 4 | The trade information with price and amount etc. 5 | 6 | :member 7 | subUid: sub user ID. 8 | userState: sub user account state, states see SubUidState. 9 | """ 10 | 11 | def __init__(self): 12 | self.transferrable = "" 13 | self.accountType = "" 14 | self.subUid = "" 15 | 16 | def print_object(self, format_data=""): 17 | from huobi.utils.print_mix_object import PrintBasic 18 | PrintBasic.print_basic(self.subUid, format_data + "subUid") 19 | PrintBasic.print_basic(self.accountType, format_data + "accountType") 20 | PrintBasic.print_basic(self.transferrable, format_data + "transferrable") 21 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/subuser/trade_market.py: -------------------------------------------------------------------------------- 1 | 2 | class TradeMarket: 3 | """ 4 | The trade information with price and amount etc. 5 | 6 | :member 7 | subUid: sub user ID. 8 | accountType: 9 | activation: sub user account state for given accountType. 10 | """ 11 | 12 | def __init__(self): 13 | self.sub_uid = "" 14 | self.account_type = "" 15 | self.activation = "" 16 | 17 | def print_object(self, format_data=""): 18 | from huobi.utils.print_mix_object import PrintBasic 19 | PrintBasic.print_basic(self.sub_uid, format_data + "subUid") 20 | PrintBasic.print_basic(self.account_type, format_data + "accountType") 21 | PrintBasic.print_basic(self.activation, format_data + "activation") 22 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/trade/__init__.py: -------------------------------------------------------------------------------- 1 | from huobi.model.trade.batch_cancel_result import BatchCancelResult 2 | from huobi.model.trade.batch_cancel_count import BatchCancelCount 3 | from huobi.model.trade.feerate import FeeRate 4 | from huobi.model.trade.matchresult import MatchResult 5 | from huobi.model.trade.order import Order 6 | from huobi.model.trade.order_detail_req import OrderDetailReq 7 | from huobi.model.trade.order_list_item import OrderListItem 8 | from huobi.model.trade.order_list_req import OrderListReq 9 | from huobi.model.trade.order_update_event import OrderUpdateEvent 10 | from huobi.model.trade.order_update import OrderUpdate 11 | from huobi.model.trade.batch_create_order import BatchCreateOrder 12 | from huobi.model.trade.transact_feerate import TransactFeeRate 13 | from huobi.model.trade.trade_clearing import TradeClearing 14 | from huobi.model.trade.trade_clearing_event import TradeClearingEvent 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/trade/batch_cancel_count.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | class BatchCancelCount: 5 | """ 6 | The result of batch cancel operation. 7 | 8 | :member 9 | success_count: The number of cancel request sent successfully. 10 | failed_count: The number of cancel request failed. 11 | next_id:next open order id 12 | """ 13 | 14 | def __init__(self): 15 | self.success_count = 0 16 | self.failed_count = 0 17 | self.next_id = -1 18 | 19 | def print_object(self, format_data=""): 20 | from huobi.utils import PrintBasic 21 | PrintBasic.print_basic(self.success_count, format_data + "Success Count") 22 | PrintBasic.print_basic(self.failed_count, format_data + "Failed Count") 23 | PrintBasic.print_basic(self.next_id, format_data + "Next Open Order ID") -------------------------------------------------------------------------------- /new/src/collector/huobi/model/trade/batch_cancel_result.py: -------------------------------------------------------------------------------- 1 | class BatchCancelResult: 2 | """ 3 | The result of batch cancel operation. 4 | 5 | :member 6 | success_count: The number of cancel request sent successfully. 7 | failed_count: The number of cancel request failed. 8 | 9 | """ 10 | 11 | def __init__(self): 12 | self.success = [] 13 | self.failed = [] 14 | 15 | def print_object(self, format_data=""): 16 | print("Success Order Counts", len(self.success), " Success Order Ids : ", self.success) 17 | print("Fail Order Counts", len(self.failed), " Fail Order Ids : ", self.failed) -------------------------------------------------------------------------------- /new/src/collector/huobi/model/trade/batch_create_order.py: -------------------------------------------------------------------------------- 1 | class BatchCreateOrder: 2 | """ 3 | batch create order result 4 | 5 | :member 6 | order_id: The transfer id. 7 | client_order_id: The crypto currency to deposit. 8 | err_code: The on-chain transaction hash. 9 | err_msg: The number of crypto asset transferred in its minimum unit. 10 | 11 | """ 12 | def __init__(self): 13 | self.order_id = 0 14 | self.client_order_id = "" 15 | self.err_code = "" 16 | self.err_msg = "" 17 | 18 | def print_object(self, format_data=""): 19 | from huobi.utils import PrintBasic 20 | PrintBasic.print_basic(self.order_id, format_data + "Order Id") 21 | PrintBasic.print_basic(self.client_order_id, format_data + "Client Order Id") 22 | PrintBasic.print_basic(self.err_code, format_data + "Error Code") 23 | PrintBasic.print_basic(self.err_msg, format_data + "Error Message") -------------------------------------------------------------------------------- /new/src/collector/huobi/model/trade/feerate.py: -------------------------------------------------------------------------------- 1 | 2 | class FeeRate: 3 | """ 4 | The account information for spot account, margin account etc. 5 | 6 | :member 7 | symbol: The symbol, like "btcusdt". 8 | maker_fee: maker fee rate 9 | taker_fee: taker fee rate 10 | 11 | """ 12 | 13 | def __init__(self): 14 | self.symbol = "" 15 | self.maker_fee = "" 16 | self.taker_fee = "" 17 | 18 | def print_object(self, format_data=""): 19 | from huobi.utils.print_mix_object import PrintBasic 20 | PrintBasic.print_basic(self.symbol, format_data + "Symbol") 21 | PrintBasic.print_basic(self.maker_fee, format_data + "Maker Fee") 22 | PrintBasic.print_basic(self.taker_fee, format_data + "Taker Fee") -------------------------------------------------------------------------------- /new/src/collector/huobi/model/trade/order_detail_req.py: -------------------------------------------------------------------------------- 1 | from huobi.model.trade.order_list_item import OrderListItem 2 | 3 | 4 | class OrderDetailReq: 5 | """ 6 | The order update received by subscription of order update. 7 | 8 | :member 9 | symbol: The symbol you subscribed. 10 | timestamp: The UNIX formatted timestamp generated by server in UTC. 11 | topic : request topic 12 | client_req_id : client request id 13 | data: The order detail. 14 | 15 | """ 16 | 17 | def __init__(self): 18 | self.ts = 0 19 | self.topic = "" 20 | self.cid = "" 21 | self.data = OrderListItem() 22 | 23 | 24 | def print_object(self, format_data=""): 25 | from huobi.utils.print_mix_object import PrintBasic 26 | PrintBasic.print_basic(self.ts, format_data + "Timestamp") 27 | PrintBasic.print_basic(self.cid, format_data + "Client Req ID") 28 | PrintBasic.print_basic(self.topic, format_data + "Topic") 29 | self.data.print_object("\t") -------------------------------------------------------------------------------- /new/src/collector/huobi/model/trade/order_list_req.py: -------------------------------------------------------------------------------- 1 | 2 | class OrderListReq: 3 | """ 4 | The order update received by request of order list. 5 | 6 | :member 7 | symbol: The symbol you subscribed. 8 | timestamp: The UNIX formatted timestamp generated by server in UTC. 9 | topic: request topic 10 | data : OrderListItem 11 | 12 | """ 13 | 14 | def __init__(self): 15 | self.ts = 0 16 | self.topic = "" 17 | self.data = list() 18 | 19 | 20 | def print_object(self, format_data=""): 21 | from huobi.utils.print_mix_object import PrintBasic 22 | PrintBasic.print_basic(self.ts, format_data + "Timestamp") 23 | PrintBasic.print_basic(self.topic, format_data + "Channel") 24 | print("Order List as below : count " + str(len(self.data))) 25 | if len(self.data): 26 | for orderlistitem_obj in self.data: 27 | orderlistitem_obj.print_object("\t ") 28 | print() 29 | 30 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/trade/order_update_event.py: -------------------------------------------------------------------------------- 1 | from huobi.model.trade.order_update import OrderUpdate 2 | 3 | 4 | class OrderUpdateEvent: 5 | """ 6 | The order update received by subscription of order update. 7 | 8 | :member 9 | ch: The symbol you subscribed. 10 | data: The order detail. 11 | 12 | """ 13 | 14 | def __init__(self): 15 | self.ch = "" 16 | self.data = OrderUpdate() 17 | 18 | def print_object(self, format_data=""): 19 | from huobi.utils.print_mix_object import PrintBasic 20 | PrintBasic.print_basic(self.ch, format_data + "Topic") 21 | 22 | orderupdate = self.data 23 | orderupdate.print_object() -------------------------------------------------------------------------------- /new/src/collector/huobi/model/trade/trade_clearing_event.py: -------------------------------------------------------------------------------- 1 | from huobi.model.trade import TradeClearing 2 | 3 | 4 | class TradeClearingEvent: 5 | """ 6 | subscribe trading clearing information 7 | 8 | :member 9 | action: current is "sub" for subscribe 10 | ch: subscribe topic. 11 | data: data detail in TradeClearing. 12 | """ 13 | 14 | def __init__(self): 15 | self.action = "" 16 | self.ch = "" 17 | self.seq = 0 18 | self.data = TradeClearing() 19 | 20 | @staticmethod 21 | def json_parse(data_json): 22 | event_obj = TradeClearingEvent() 23 | event_obj.action = data_json.get("action") 24 | event_obj.ch = data_json.get("ch") 25 | event_obj.seq = data_json.get("seq", 0) 26 | event_obj.data = TradeClearing.json_parse(data_json.get("data", {})) 27 | return event_obj 28 | 29 | def print_object(self, format_data=""): 30 | from huobi.utils.print_mix_object import PrintBasic 31 | PrintBasic.print_basic(self.ch, format_data + "Channel") 32 | self.data.print_object() 33 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/trade/transact_feerate.py: -------------------------------------------------------------------------------- 1 | 2 | class TransactFeeRate: 3 | """ 4 | The transact fee rate. 5 | 6 | :member 7 | symbol: symbol like "btcusdt" 8 | makerFeeRate: maker fee rate 9 | takerFeeRate: taker fee rate 10 | actualMakerRate: actual maker fee rate 11 | actualTakerRate: actual taker fee rate 12 | """ 13 | 14 | def __init__(self): 15 | self.symbol = "" 16 | self.makerFeeRate = "" 17 | self.takerFeeRate = "" 18 | self.actualMakerRate = "" 19 | self.actualTakerRate = "" 20 | 21 | def print_object(self, format_data=""): 22 | from huobi.utils.print_mix_object import PrintBasic 23 | PrintBasic.print_basic(self.symbol, format_data + "Symbol") 24 | PrintBasic.print_basic(self.makerFeeRate, format_data + "makerFeeRate") 25 | PrintBasic.print_basic(self.takerFeeRate, format_data + "takerFeeRate") 26 | PrintBasic.print_basic(self.actualMakerRate, format_data + "actualMakerRate") 27 | PrintBasic.print_basic(self.actualTakerRate, format_data + "actualTakerRate") -------------------------------------------------------------------------------- /new/src/collector/huobi/model/wallet/__init__.py: -------------------------------------------------------------------------------- 1 | from huobi.model.wallet.deposit import Deposit 2 | from huobi.model.wallet.withdraw import Withdraw 3 | from huobi.model.wallet.chain_deposit_address import ChainDepositAddress 4 | from huobi.model.wallet.chain_withdraw_address import ChainWithdrawAddress 5 | from huobi.model.wallet.withdraw_quota import WithdrawQuota 6 | from huobi.model.wallet.deposit_history import DepositHistory 7 | from huobi.model.wallet.deposit_history_item import DepositHistoryItem 8 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/wallet/chain_deposit_address.py: -------------------------------------------------------------------------------- 1 | 2 | class ChainDepositAddress: 3 | """ 4 | The deposit address. 5 | 6 | :member 7 | currency: The crypto currency to deposit. 8 | address: Deposit address 9 | addressTag: Deposit address tag. 10 | chain: Block chain name. 11 | """ 12 | def __init__(self): 13 | self.currency = "" 14 | self.address = "" 15 | self.addressTag = "" 16 | self.chain = "" 17 | 18 | 19 | 20 | def print_object(self, format_data=""): 21 | from huobi.utils.print_mix_object import PrintBasic 22 | PrintBasic.print_basic(self.currency, format_data + "Currency") 23 | PrintBasic.print_basic(self.address, format_data + "Address") 24 | PrintBasic.print_basic(self.addressTag, format_data + "addressTag") 25 | PrintBasic.print_basic(self.chain, format_data + "Chain") 26 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/wallet/chain_withdraw_address.py: -------------------------------------------------------------------------------- 1 | class ChainWithdrawAddress: 2 | """ 3 | The deposit address. 4 | 5 | :member 6 | currency: The crypto currency to deposit. 7 | address: Deposit address 8 | addressTag: Deposit address tag. 9 | chain: Block chain name. 10 | """ 11 | 12 | def __init__(self): 13 | self.currency = "" 14 | self.address = "" 15 | self.addressTag = "" 16 | self.chain = "" 17 | self.note = "" 18 | 19 | def print_object(self, format_data=""): 20 | from huobi.utils.print_mix_object import PrintBasic 21 | PrintBasic.print_basic(self.currency, format_data + "Currency") 22 | PrintBasic.print_basic(self.address, format_data + "Address") 23 | PrintBasic.print_basic(self.addressTag, format_data + "addressTag") 24 | PrintBasic.print_basic(self.chain, format_data + "Chain") 25 | PrintBasic.print_basic(self.note, format_data + "Note") 26 | -------------------------------------------------------------------------------- /new/src/collector/huobi/model/wallet/deposit_history.py: -------------------------------------------------------------------------------- 1 | from huobi.model.wallet.deposit_history_item import DepositHistoryItem 2 | class DepositHistory: 3 | """ 4 | The deposit history 5 | 6 | :member 7 | nextId: next id. 8 | data: history list. 9 | """ 10 | 11 | def __init__(self): 12 | self.data = list() 13 | self.nextId = 0 14 | 15 | def print_object(self, format_data=""): 16 | from huobi.utils.print_mix_object import PrintBasic 17 | PrintBasic.print_basic(self.nextId, format_data + "NextId") 18 | if self.data and len(self.data): 19 | for item in self.data: 20 | item.print_object() 21 | PrintBasic.print_basic("", format_data + "") 22 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/new/src/collector/huobi/service/__init__.py -------------------------------------------------------------------------------- /new/src/collector/huobi/service/account/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/new/src/collector/huobi/service/account/__init__.py -------------------------------------------------------------------------------- /new/src/collector/huobi/service/account/get_account_asset_valuation.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.account.account_asset_valuation import AccountAssetValuationResult 4 | from huobi.utils import * 5 | 6 | 7 | class GetAccountAssetValuationService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/account/asset-valuation" 14 | 15 | def parse(dict_data): 16 | data = dict_data.get("data", {}) 17 | return default_parse(data, AccountAssetValuationResult, []) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 20 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/account/get_account_balance_by_subuid.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.account import * 4 | 5 | 6 | class GetAccountBalanceBySubUidService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | sub_uid = self.params["sub-uid"] 13 | 14 | def get_channel(): 15 | path = "/v1/account/accounts/{}" 16 | return path.format(sub_uid) 17 | 18 | def parse(dict_data): 19 | data_list = dict_data.get("data", []) 20 | return AccountBalance.json_parse_list(data_list) 21 | 22 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, get_channel(), self.params, parse) 23 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/account/get_account_history.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.account import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetAccountHistoryService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v1/account/history" 14 | 15 | def parse(dict_data): 16 | response = dict() 17 | data_list = dict_data.get("data", []) 18 | response['data'] = default_parse_list_dict(data_list, AccountHistory, []) 19 | response['next_id'] = dict_data.get("next-id", 0) 20 | return response 21 | 22 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 23 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/account/get_account_ledger.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.account import * 4 | from huobi.utils import * 5 | 6 | 7 | 8 | class GetAccountLedgerService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | channel = "/v2/account/ledger" 15 | 16 | def parse(dict_data): 17 | data_list = dict_data.get("data", []) 18 | return default_parse_list_dict(data_list, AccountLedger, []) 19 | 20 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/account/get_account_point.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.account import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetAccountPointService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/point/account" 14 | 15 | def parse(dict_data): 16 | data = dict_data.get("data", {}) 17 | return default_parse(data, AccountPointResult, {}) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 20 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/account/get_accounts.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.account import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetAccountsService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v1/account/accounts" 14 | 15 | def parse(dict_data): 16 | data_list = dict_data.get("data", []) 17 | return default_parse_list_dict(data_list, Account, []) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 20 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/account/get_aggregate_subuser_balance.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.account import * 4 | from huobi.utils import * 5 | 6 | 7 | 8 | class GetAggregateSubUserBalanceService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | channel = "/v1/subuser/aggregate-balance" 15 | 16 | def parse(dict_data): 17 | data = dict_data.get("data", []) 18 | return default_parse_list_dict(data, Balance) 19 | 20 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/account/post_account_transfer.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.account import * 4 | from huobi.utils import * 5 | 6 | 7 | class PostAccountTransferService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v1/account/transfer" 14 | 15 | def parse(dict_data): 16 | data = dict_data.get("data", {}) 17 | return default_parse(data, AccountTransferResult, []) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 20 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/account/post_futures_and_pro_transfer.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.utils.json_parser import default_parse_data_as_long 4 | 5 | 6 | class PostTransferBetweenFuturesAndProService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | channel = "/v1/futures/transfer" 13 | 14 | def parse(dict_data): 15 | return default_parse_data_as_long(dict_data, None) 16 | 17 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/account/post_point_transfer.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.account import * 4 | from huobi.utils import * 5 | 6 | 7 | class PostPointTransferService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/point/transfer" 14 | 15 | def parse(dict_data): 16 | data = dict_data.get("data", {}) 17 | return default_parse(data, AccountPointTransferResult, {}) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 20 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/account/post_sub_uid_management.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.utils import * 4 | from huobi.model.account import * 5 | 6 | 7 | class PostSubUidManagementService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/sub-user/management" 14 | 15 | def parse(dict_data): 16 | return default_parse_list_dict(dict_data.get("data", {}), SubUidManagement) 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/account/post_subaccount_transfer.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.utils.json_parser import default_parse_data_as_long 4 | 5 | 6 | class PostSubaccountTransferService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | channel = "/v1/subuser/transfer" 13 | 14 | def parse(dict_data): 15 | return default_parse_data_as_long(dict_data, None) 16 | 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/account/req_account_balance.py: -------------------------------------------------------------------------------- 1 | 2 | from huobi.utils import * 3 | 4 | from huobi.connection.websocket_req_client import * 5 | from huobi.model.account import * 6 | 7 | 8 | 9 | class ReqAccountBalanceService: 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def subscribe(self, callback, error_handler, **kwargs): 14 | client_req_id = self.params["client_req_id"] 15 | def subscription(connection): 16 | connection.send(request_account_list_channel(client_req_id)) 17 | 18 | def parse(dict_data): 19 | req_obj = AccountBalanceReq() 20 | req_obj.ts = dict_data.get("ts", 0) 21 | req_obj.topic = dict_data.get("topic", 0) 22 | req_obj.cid = dict_data.get("cid", 0) 23 | data_list = dict_data.get("data", []) 24 | req_obj.data = AccountBalance.json_parse_list(data_list) 25 | return req_obj 26 | 27 | WebSocketReqClient(**kwargs).execute_subscribe_v1(subscription, 28 | parse, 29 | callback, 30 | error_handler, 31 | is_trade=True) 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/account/sub_account_update_v2.py: -------------------------------------------------------------------------------- 1 | from huobi.utils import * 2 | 3 | from huobi.connection.subscribe_client import SubscribeClient 4 | from huobi.model.account import * 5 | 6 | 7 | class SubAccountUpdateV2Service: 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def subscribe(self, callback, error_handler, **kwargs): 12 | mode = self.params["mode"] 13 | 14 | def subscription(connection): 15 | connection.send(accounts_update_channel(mode)) 16 | 17 | def parse(dict_data): 18 | account_change_event = AccountUpdateEvent() 19 | account_change_event.ch = dict_data.get("ch") 20 | data = dict_data.get("data", {}) 21 | if data and len(data): 22 | account_change_event.data = default_parse_list_dict(data, AccountUpdate) 23 | 24 | return account_change_event 25 | 26 | SubscribeClient(**kwargs).execute_subscribe_v2(subscription, 27 | parse, 28 | callback, 29 | error_handler, 30 | is_trade=True) 31 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/algo/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/new/src/collector/huobi/service/algo/__init__.py -------------------------------------------------------------------------------- /new/src/collector/huobi/service/algo/get_order_by_cid.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.utils.json_parser import * 4 | from huobi.model.algo import * 5 | 6 | 7 | class GetOrderByClientOrderIdService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/algo-orders/specific" 14 | 15 | def parse(dict_data): 16 | data = dict_data.get("data", {}) 17 | return default_parse(data, OrderHistoryItem) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 20 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/algo/get_order_history.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.utils.json_parser import * 4 | from huobi.model.algo import * 5 | 6 | 7 | class GetOrderHistoryService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/algo-orders/history" 14 | 15 | def parse(dict_data): 16 | data = dict_data.get("data", {}) 17 | return default_parse_list_dict(data, OrderHistoryItem) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 20 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/algo/post_cancel_orders.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.utils.json_parser import default_parse_fill_directly 4 | from huobi.model.algo import * 5 | 6 | 7 | class PostCancelOrderService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/algo-orders/cancellation" 14 | 15 | # {'code': 200, 'data': {'accepted': [], 'rejected': ['test001', 'test002']}} 16 | def parse(dict_data): 17 | data = dict_data.get("data", {}) 18 | return default_parse_fill_directly(data, CancelOrderResult) 19 | 20 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 21 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/algo/post_create_order.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | 4 | 5 | class PostCreateOrderService: 6 | 7 | def __init__(self, params): 8 | self.params = params 9 | 10 | def request(self, **kwargs): 11 | channel = "/v2/algo-orders" 12 | 13 | # {'code': 200, 'data': {'clientOrderId': 'test001'}} 14 | def parse(dict_data): 15 | data = dict_data.get('data') 16 | return data.get('clientOrderId') 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 19 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/etf/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/new/src/collector/huobi/service/etf/__init__.py -------------------------------------------------------------------------------- /new/src/collector/huobi/service/etf/get_etf_swap_config.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.etf import * 4 | from huobi.utils import * 5 | 6 | 7 | 8 | class GetEtfSwapConfigService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | channel = "/etf/swap/config" 15 | 16 | def parse(dict_data): 17 | data_info = dict_data.get("data", {}) 18 | return default_parse(data_info, EtfSwapConfig, UnitPrice) 19 | 20 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET, channel, self.params, parse) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/etf/get_etf_swap_list.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.etf import * 4 | 5 | class GetEtfSwapListService: 6 | 7 | def __init__(self, params): 8 | self.params = params 9 | 10 | def request(self, **kwargs): 11 | channel = "/etf/swap/list" 12 | 13 | def parse(dict_data): 14 | return EtfSwapList.json_parse_list(dict_data.get("data", [])) 15 | 16 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/etf/post_etf_swap_in.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.utils import * 4 | from huobi.model.etf import * 5 | 6 | 7 | 8 | class PostEftSwapInService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | channel = "/etf/swap/in" 15 | 16 | def parse(dict_data): 17 | return default_parse_fill_directly(dict_data, EtfSwapInOut) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/etf/post_etf_swap_out.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.utils import * 4 | from huobi.model.etf import * 5 | 6 | 7 | class PostEtfSwapOutService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/etf/swap/out" 14 | 15 | def parse(dict_data): 16 | return default_parse_fill_directly(dict_data, EtfSwapInOut) 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/generic/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/new/src/collector/huobi/service/generic/__init__.py -------------------------------------------------------------------------------- /new/src/collector/huobi/service/generic/get_exchange_currencies.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | 4 | 5 | class GetExchangeCurrenciesService: 6 | 7 | def __init__(self, params): 8 | self.params = params 9 | 10 | def request(self, **kwargs): 11 | channel = "/v1/common/currencys" 12 | 13 | def parse(dict_data): 14 | data_list = dict_data.get("data", []) 15 | return data_list if len(data_list) else [] 16 | 17 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET, channel, self.params, parse) 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/generic/get_exchange_symbols.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.generic import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetExchangeSymbolsService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v1/common/symbols" 14 | 15 | def parse(dict_data): 16 | data_list = dict_data.get("data", []) 17 | return default_parse_list_dict(data_list, Symbol, []) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET, channel, self.params, parse) 20 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/generic/get_exchange_timestamp.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.utils import * 4 | from huobi.utils.json_parser import default_parse_data_as_long 5 | 6 | 7 | class GetExchangeTimestampService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v1/common/timestamp" 14 | 15 | def parse(dict_data): 16 | return default_parse_data_as_long(dict_data, None) 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET, channel, self.params, parse) 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/generic/get_market_status.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.generic import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetMarketStatusService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/market-status" 14 | 15 | def parse(dict_data): 16 | return default_parse(dict_data.get("data", {}), MarketStatus) 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET, channel, self.params, parse) 19 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/generic/get_reference_currencies.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.generic import * 4 | from huobi.utils import * 5 | 6 | 7 | 8 | class GetReferenceCurrenciesService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | channel = "/v2/reference/currencies" 15 | 16 | def parse(dict_data): 17 | ret_list = [] 18 | data_list = dict_data.get("data", []) 19 | if data_list and len(data_list): 20 | for reference_currency in data_list: 21 | reference_currency_obj = default_parse(reference_currency, ReferenceCurrency, Chain) 22 | ret_list.append(reference_currency_obj) 23 | return ret_list 24 | 25 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET, channel, self.params, parse) 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/generic/get_system_status.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | 4 | 5 | class GetSystemStatusService: 6 | 7 | def __init__(self, params): 8 | self.params = params 9 | 10 | def request(self, **kwargs): 11 | channel = "/api/v2/summary.json" 12 | kwargs["url"] = "https://status.huobigroup.com" 13 | 14 | def parse(dict_data): 15 | return dict_data 16 | 17 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET, channel, self.params, parse) 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/margin/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/new/src/collector/huobi/service/margin/__init__.py -------------------------------------------------------------------------------- /new/src/collector/huobi/service/margin/get_cross_margin_account_balance.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.margin import * 4 | from huobi.utils import * 5 | 6 | 7 | 8 | class GetCrossMarginAccountBalanceService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | channel = "/v1/cross-margin/accounts/balance" 15 | 16 | def parse(dict_data): 17 | return CrossMarginAccountBalance.json_parse(dict_data.get("data", {})) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/margin/get_cross_margin_loan_info.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.margin import * 4 | from huobi.utils import * 5 | 6 | 7 | 8 | class GetCrossMarginLoanInfoService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | channel = "/v1/cross-margin/loan-info" 15 | 16 | def parse(dict_data): 17 | return default_parse_list_dict(dict_data.get("data", []), CrossMarginLoanInfo, []) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/margin/get_cross_margin_loan_orders.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.margin import * 4 | from huobi.utils import * 5 | 6 | 7 | 8 | class GetCrossMarginLoanOrdersService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | channel = "/v1/cross-margin/loan-orders" 15 | 16 | def parse(dict_data): 17 | data_list = dict_data.get("data", []) 18 | return default_parse_list_dict(data_list, LoanOrder, []) 19 | 20 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/margin/get_general_repayment_loan_records.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.margin.general_repay_loan_record import GeneralRepayLoanRecord 4 | from huobi.model.margin.general_repay_loan_result import GeneralRepayLoanResult 5 | from huobi.utils.json_parser import default_parse_list_dict 6 | 7 | 8 | class GetGeneralRepaymentLoanRecordsService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | 15 | def get_channel(): 16 | path = "/v2/account/repayment" 17 | return path 18 | 19 | def parse(dict_data): 20 | return default_parse_list_dict(dict_data.get("data", {}), GeneralRepayLoanRecord) 21 | 22 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, get_channel(), self.params, parse) -------------------------------------------------------------------------------- /new/src/collector/huobi/service/margin/get_margin_account_balance.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.account import Balance 4 | from huobi.model.margin import * 5 | from huobi.utils import * 6 | 7 | 8 | 9 | class GetMarginAccountBalanceService: 10 | 11 | def __init__(self, params): 12 | self.params = params 13 | 14 | def request(self, **kwargs): 15 | channel = "/v1/margin/accounts/balance" 16 | 17 | def parse(dict_data): 18 | data_list = dict_data.get("data", []) 19 | account_balance_list = [] 20 | if data_list and len(data_list): 21 | for row in data_list: 22 | account_balance = default_parse(row, MarginAccountBalance, Balance) 23 | account_balance_list.append(account_balance) 24 | return account_balance_list 25 | 26 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/margin/get_margin_loan_info.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.margin import * 4 | from huobi.utils import * 5 | 6 | 7 | 8 | class GetMarginLoanInfoService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | channel = "/v1/margin/loan-info" 15 | 16 | def parse(dict_data): 17 | return MarginLoanInfo.json_parse(dict_data.get("data", [])) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/margin/get_margin_loan_orders.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.margin import * 4 | from huobi.utils import * 5 | 6 | 7 | 8 | class GetMarginLoanOrdersService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | channel = "/v1/margin/loan-orders" 15 | 16 | def parse(dict_data): 17 | data_list = dict_data.get("data", []) 18 | return default_parse_list_dict(data_list, LoanOrder, []) 19 | 20 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/margin/post_create_margin_order.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.utils.json_parser import default_parse_data_as_long 4 | 5 | 6 | class PostCreateMarginOrderService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | channel = "/v1/margin/orders" 13 | 14 | def parse(dict_data): 15 | return default_parse_data_as_long(dict_data, None) 16 | 17 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/margin/post_cross_margin_create_loan_orders.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.utils.json_parser import default_parse_data_as_long 4 | 5 | 6 | class PostCrossMarginCreateLoanOrdersService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | channel = "/v1/cross-margin/orders" 13 | 14 | def parse(dict_data): 15 | return default_parse_data_as_long(dict_data, None) 16 | 17 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/margin/post_cross_margin_loan_order_repay.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | 4 | 5 | class PostCrossMarginLoanOrderRepayService: 6 | 7 | def __init__(self, params): 8 | self.params = params 9 | 10 | def request(self, **kwargs): 11 | channel = "/v1/cross-margin/orders/{order_id}/repay".format(order_id=self.params.get("order-id")) 12 | 13 | def parse(dict_data): 14 | return dict_data.get("status", None) 15 | 16 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/margin/post_cross_margin_transfer_in.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.utils.json_parser import default_parse_data_as_long 4 | 5 | 6 | class PostCrossMarginTransferInService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | channel = "/v1/cross-margin/transfer-in" 13 | 14 | def parse(dict_data): 15 | return default_parse_data_as_long(dict_data, None) 16 | 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/margin/post_cross_margin_transfer_out.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.utils.json_parser import default_parse_data_as_long 4 | 5 | 6 | class PostCrossMarginTransferOutService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | channel = "/v1/cross-margin/transfer-out" 13 | 14 | def parse(dict_data): 15 | transfer_id = default_parse_data_as_long(dict_data, None) 16 | return transfer_id 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/margin/post_general_repay_loan.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.margin.general_repay_loan_result import GeneralRepayLoanResult 4 | from huobi.utils.json_parser import default_parse_list_dict 5 | 6 | 7 | class PostGeneralRepayLoanService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | 14 | def get_channel(): 15 | path = "/v2/account/repayment" 16 | return path 17 | 18 | def parse(dict_data): 19 | return default_parse_list_dict(dict_data.get("data", {}), GeneralRepayLoanResult) 20 | 21 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, get_channel(), self.params, parse) -------------------------------------------------------------------------------- /new/src/collector/huobi/service/margin/post_repay_margin_order.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.utils.json_parser import default_parse_data_as_long 4 | 5 | 6 | class PostRepayMarginOrderService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | loan_id = self.params["loan_id"] 13 | def get_channel(): 14 | path = "/v1/margin/orders/{}/repay" 15 | return path.format(loan_id) 16 | 17 | def parse(dict_data): 18 | return default_parse_data_as_long(dict_data, None) 19 | 20 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, get_channel(), self.params, parse) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/margin/post_transfer_in_margin.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.utils.json_parser import default_parse_data_as_long 4 | 5 | 6 | class PostTransferInMarginService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | channel = "/v1/dw/transfer-in/margin" 13 | 14 | def parse(dict_data): 15 | return default_parse_data_as_long(dict_data, None) 16 | 17 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/margin/post_transfer_out_margin.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.utils.json_parser import default_parse_data_as_long 4 | 5 | 6 | class PostTransferOutMarginService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | channel = "/v1/dw/transfer-out/margin" 13 | 14 | def parse(dict_data): 15 | return default_parse_data_as_long(dict_data, None) 16 | 17 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/get_candlestick.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.market import * 4 | from huobi.utils import * 5 | 6 | 7 | 8 | class GetCandleStickService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | channel = "/market/history/kline" 15 | 16 | def parse(dict_data): 17 | return default_parse_list_dict(dict_data.get("data", []), Candlestick) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET, channel, self.params, parse) 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/get_history_trade.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.market import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetHistoryTradeService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/market/history/trade" 14 | 15 | def parse(dict_data): 16 | trade_list_ret = [] # two level list, list item is list too 17 | data_list_outer = dict_data.get("data", []) 18 | if len(data_list_outer): 19 | for row in data_list_outer: 20 | data_list_inner = row.get("data", []) 21 | if len(data_list_inner): 22 | for trade_info in data_list_inner: 23 | trade_obj = default_parse_list_dict(trade_info, Trade, None) # return a list 24 | if trade_obj: 25 | trade_list_ret.append(trade_obj) 26 | 27 | return trade_list_ret 28 | 29 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET, channel, self.params, parse) 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/get_market_detail.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.market import * 4 | from huobi.utils import * 5 | 6 | 7 | 8 | class GetMarketDetailService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | channel = "/market/detail" 15 | 16 | def parse(dict_data): 17 | tick = dict_data.get("tick", {}) 18 | return default_parse(tick, MarketDetail) 19 | 20 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET, channel, self.params, parse) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/get_market_detail_merged.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.market import * 4 | from huobi.utils import * 5 | 6 | 7 | 8 | class GetMarketDetailMergedService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | channel = "/market/detail/merged" 15 | 16 | def parse(dict_data): 17 | tick = dict_data.get("tick", {}) 18 | return default_parse_fill_directly(tick, MarketDetailMerged) 19 | 20 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET, channel, self.params, parse) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/get_market_tickers.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.market import * 4 | from huobi.utils import * 5 | 6 | 7 | 8 | class GetMarketTickersService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | channel = "/market/tickers" 15 | 16 | def parse(dict_data): 17 | return default_parse_list_dict(dict_data.get("data", []), MarketTicker) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET, channel, self.params, parse) 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/get_market_trade.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.market import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetMarketTradeService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/market/trade" 14 | 15 | def parse(dict_data): 16 | tick = dict_data.get("tick", {}) 17 | data = tick.get("data", []) 18 | return default_parse_list_dict(data, Trade, []) 19 | 20 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET, channel, self.params, parse) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/get_pricedepth.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.market import PriceDepth 4 | 5 | 6 | class GetPriceDepthService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | channel = "/market/depth" 13 | 14 | def parse(dict_data): 15 | tick = dict_data.get("tick", {}) 16 | return PriceDepth.json_parse(tick) 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET, channel, self.params, parse) 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/req_candlestick.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from huobi.utils import * 4 | 5 | from huobi.connection.websocket_req_client import * 6 | from huobi.model.market import * 7 | from huobi.utils.channels_request import * 8 | 9 | 10 | class ReqCandleStickService: 11 | def __init__(self, params): 12 | self.params = params 13 | 14 | def subscribe(self, callback, error_handler, **kwargs): 15 | symbol_list = self.params["symbol_list"] 16 | interval = self.params["interval"] 17 | from_ts_second = self.params.get("from_ts_second", None) 18 | end_ts_second = self.params.get("end_ts_second", None) 19 | 20 | def subscription(connection): 21 | for symbol in symbol_list: 22 | connection.send(request_kline_channel(symbol, interval, from_ts_second, end_ts_second)) 23 | time.sleep(0.01) 24 | 25 | def parse(dict_data): 26 | return default_parse(dict_data, CandlestickReq, Candlestick) 27 | 28 | WebSocketReqClient(**kwargs).execute_subscribe_v1(subscription, 29 | parse, 30 | callback, 31 | error_handler) 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/req_market_detail.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from huobi.utils import * 4 | 5 | from huobi.connection.websocket_req_client import * 6 | from huobi.model.market import * 7 | from huobi.utils.channels_request import * 8 | 9 | 10 | class ReqMarketDetailService: 11 | def __init__(self, params): 12 | self.params = params 13 | 14 | def subscribe(self, callback, error_handler, **kwargs): 15 | symbol_list = self.params["symbol_list"] 16 | 17 | def subscription(connection): 18 | for symbol in symbol_list: 19 | connection.send(request_market_detail_channel(symbol)) 20 | time.sleep(0.01) 21 | 22 | def parse(dict_data): 23 | return default_parse(dict_data, MarketDetailReq, MarketDetail) 24 | 25 | WebSocketReqClient(**kwargs).execute_subscribe_v1(subscription, 26 | parse, 27 | callback, 28 | error_handler) 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/req_mbp.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from huobi.model.market import * 4 | from huobi.utils import * 5 | from huobi.connection.websocket_req_client import WebSocketReqClient 6 | 7 | 8 | class ReqMbpService: 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def subscribe(self, callback, error_handler, **kwargs): 13 | symbol_list = self.params["symbol_list"] 14 | level = self.params["levels"] 15 | 16 | def subscription(connection): 17 | for symbol in symbol_list: 18 | connection.send(request_mbp_channel(symbol, level)) 19 | time.sleep(0.01) 20 | 21 | def parse(dict_data): 22 | return MbpReq.json_parse(dict_data) 23 | 24 | WebSocketReqClient(**kwargs).execute_subscribe_mbp(subscription, 25 | parse, 26 | callback, 27 | error_handler) 28 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/req_trade_detail.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from huobi.model.market import * 4 | from huobi.utils import * 5 | from huobi.connection.websocket_req_client import * 6 | 7 | 8 | class ReqTradeDetailService: 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def subscribe(self, callback, error_handler, **kwargs): 13 | symbol_list = self.params["symbol_list"] 14 | 15 | def subscription(connection): 16 | for symbol in symbol_list: 17 | connection.send(request_trade_detail_channel(symbol)) 18 | time.sleep(0.01) 19 | 20 | def parse(dict_data): 21 | return default_parse(dict_data, TradeDetailReq, TradeDetail) 22 | 23 | WebSocketReqClient(**kwargs).execute_subscribe_v1(subscription, 24 | parse, 25 | callback, 26 | error_handler) 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/sub_candlestick.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from huobi.utils import * 4 | 5 | from huobi.connection.subscribe_client import SubscribeClient 6 | from huobi.model.market import * 7 | 8 | 9 | 10 | class SubCandleStickService: 11 | def __init__(self, params): 12 | 13 | self.params = params 14 | 15 | def subscribe(self, callback, error_handler, **kwargs): 16 | symbol_list = self.params["symbol_list"] 17 | interval = self.params["interval"] 18 | 19 | def subscription(connection): 20 | for symbol in symbol_list: 21 | connection.send(kline_channel(symbol, interval)) 22 | time.sleep(0.01) 23 | 24 | def parse(dict_data): 25 | return default_parse(dict_data, CandlestickEvent, Candlestick) 26 | 27 | SubscribeClient(**kwargs).execute_subscribe_v1(subscription, 28 | parse, 29 | callback, 30 | error_handler) 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/sub_market_detail.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from huobi.utils import * 4 | 5 | from huobi.connection.subscribe_client import SubscribeClient 6 | from huobi.model.market import * 7 | 8 | 9 | 10 | class SubMarketDetailService: 11 | def __init__(self, params): 12 | self.params = params 13 | 14 | def subscribe(self, callback, error_handler, **kwargs): 15 | symbol_list = self.params["symbol_list"] 16 | 17 | def subscription(connection): 18 | for symbol in symbol_list: 19 | connection.send(market_detail_channel(symbol)) 20 | time.sleep(0.01) 21 | 22 | def parse(dict_data): 23 | return default_parse(dict_data, MarketDetailEvent, MarketDetail) 24 | 25 | SubscribeClient(**kwargs).execute_subscribe_v1(subscription, 26 | parse, 27 | callback, 28 | error_handler) 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/sub_mbp_full.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from huobi.model.market import * 4 | from huobi.utils import * 5 | from huobi.connection.subscribe_client import SubscribeClient 6 | 7 | 8 | class SubMbpFullService: 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def subscribe(self, callback, error_handler, **kwargs): 13 | symbol_list = self.params["symbol_list"] 14 | level = self.params["levels"] 15 | 16 | def subscription(connection): 17 | for symbol in symbol_list: 18 | connection.send(mbp_full_channel(symbol, level)) 19 | time.sleep(0.01) 20 | 21 | def parse(dict_data): 22 | return MbpFullEvent.json_parse(dict_data) 23 | 24 | SubscribeClient(**kwargs).execute_subscribe_v1(subscription, 25 | parse, 26 | callback, 27 | error_handler) 28 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/sub_mbp_increase.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from huobi.model.market import * 4 | from huobi.utils import * 5 | from huobi.connection.subscribe_client import SubscribeClient 6 | 7 | 8 | class SubMbpIncreaseService: 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def subscribe(self, callback, error_handler, **kwargs): 13 | symbol_list = self.params["symbol_list"] 14 | level = self.params["levels"] 15 | 16 | def subscription(connection): 17 | for symbol in symbol_list: 18 | connection.send(mbp_increase_channel(symbol, level)) 19 | time.sleep(0.01) 20 | 21 | def parse(dict_data): 22 | return MbpIncreaseEvent.json_parse(dict_data) 23 | 24 | SubscribeClient(**kwargs).execute_subscribe_mbp(subscription, 25 | parse, 26 | callback, 27 | error_handler) 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/sub_pricedepth.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from huobi.model.market import * 4 | from huobi.utils import * 5 | from huobi.connection.subscribe_client import SubscribeClient 6 | 7 | 8 | class SubPriceDepthService: 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def subscribe(self, callback, error_handler, **kwargs): 13 | symbol_list = self.params["symbol_list"] 14 | step = self.params["step"] 15 | 16 | def subscription(connection): 17 | for symbol in symbol_list: 18 | connection.send(price_depth_channel(symbol, step)) 19 | time.sleep(0.01) 20 | 21 | def parse(dict_data): 22 | price_depth_event_obj = PriceDepthEvent() 23 | price_depth_event_obj.ch = dict_data.get("ch", "") 24 | tick = dict_data.get("tick", "") 25 | price_depth_event_obj.tick = PriceDepth.json_parse(tick) 26 | return price_depth_event_obj 27 | 28 | SubscribeClient(**kwargs).execute_subscribe_v1(subscription, 29 | parse, 30 | callback, 31 | error_handler) 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/sub_pricedepth_bbo.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from huobi.utils import * 4 | from huobi.model.market import * 5 | from huobi.connection.subscribe_client import SubscribeClient 6 | 7 | 8 | class SubPriceDepthBboService: 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def subscribe(self, callback, error_handler, **kwargs): 13 | symbol_list = self.params["symbol_list"] 14 | 15 | def subscription(connection): 16 | for symbol in symbol_list: 17 | connection.send(price_depth_bbo_channel(symbol)) 18 | time.sleep(0.01) 19 | 20 | def parse(dict_data): 21 | return default_parse(dict_data, PriceDepthBboEvent, PriceDepthBbo) 22 | 23 | SubscribeClient(**kwargs).execute_subscribe_v1(subscription, 24 | parse, 25 | callback, 26 | error_handler) 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/market/sub_trade_detail.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from huobi.model.market import * 4 | from huobi.utils import * 5 | from huobi.connection.subscribe_client import SubscribeClient 6 | 7 | 8 | class SubTradeDetailService: 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def subscribe(self, callback, error_handler, **kwargs): 13 | symbol_list = self.params["symbol_list"] 14 | 15 | def subscription(connection): 16 | for symbol in symbol_list: 17 | connection.send(trade_detail_channel(symbol)) 18 | time.sleep(0.01) 19 | 20 | def parse(dict_data): 21 | tick = dict_data.get("tick", {}) 22 | trade_detail_event = default_parse(tick, TradeDetailEvent, TradeDetail) 23 | trade_detail_event.ch = dict_data.get("ch", "") 24 | return trade_detail_event 25 | 26 | SubscribeClient(**kwargs).execute_subscribe_v1(subscription, 27 | parse, 28 | callback, 29 | error_handler) 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/subuser/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/new/src/collector/huobi/service/subuser/__init__.py -------------------------------------------------------------------------------- /new/src/collector/huobi/service/subuser/get_uid.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.utils import * 4 | from huobi.model.subuser import * 5 | from huobi.utils.json_parser import default_parse_data_as_long 6 | 7 | 8 | 9 | class GetUidService: 10 | 11 | def __init__(self, params): 12 | self.params = params 13 | 14 | def request(self, **kwargs): 15 | channel = "/v2/user/uid" 16 | 17 | def parse(dict_data): 18 | return default_parse_data_as_long(dict_data, None) 19 | 20 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 21 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/subuser/get_user_apikey_info.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.utils import * 4 | from huobi.model.subuser import * 5 | 6 | 7 | class GetUserApikeyInfoService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/user/api-key" 14 | 15 | def parse(dict_data): 16 | return default_parse_list_dict(dict_data.get("data", {}), UserApikeyInfo) 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 19 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/subuser/post_create_subuser.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.utils import * 4 | from huobi.model.subuser import * 5 | 6 | 7 | class PostSubuserCreationService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/sub-user/creation" 14 | 15 | def parse(dict_data): 16 | return default_parse_list_dict(dict_data.get("data", {}), SubuserCreation) 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 19 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/subuser/post_set_transferability.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.utils import * 4 | from huobi.model.subuser import * 5 | 6 | 7 | class PostSetSubuserTransferability: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/sub-user/transferability" 14 | 15 | def parse(dict_data): 16 | return default_parse_list_dict(dict_data.get("data", {}), SubuserTransferability) 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 19 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/subuser/post_subuser_apikey_deletion.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | 4 | 5 | class PostSubuserApikeyDeletionService: 6 | 7 | def __init__(self, params): 8 | self.params = params 9 | 10 | def request(self, **kwargs): 11 | channel = "/v2/sub-user/api-key-deletion" 12 | 13 | # {'code': 200, 'data': None, 'ok': True} 14 | def parse(dict_data): 15 | return dict_data 16 | 17 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 18 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/subuser/post_subuser_apikey_generation.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.utils import * 4 | from huobi.model.subuser import * 5 | 6 | 7 | class PostSubuserApikeyGenerationService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/sub-user/api-key-generation" 14 | 15 | def parse(dict_data): 16 | return default_parse(dict_data.get("data", {}), SubuserApikeyGeneration) 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 19 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/subuser/post_subuser_apikey_modification.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.utils import * 4 | from huobi.model.subuser import * 5 | 6 | 7 | class PostSubuserApikeyModificationService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/sub-user/api-key-modification" 14 | 15 | def parse(dict_data): 16 | return default_parse(dict_data.get("data", {}), SubuserApikeyModification) 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 19 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/subuser/post_tradable_market.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.subuser.trade_market import TradeMarket 4 | from huobi.utils import * 5 | 6 | 7 | class PostTradableMarketService: 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | channel = "/v2/sub-user/tradable-market" 13 | 14 | def parse(dict_data): 15 | return default_parse_list_dict(dict_data.get("data", {}), TradeMarket) 16 | 17 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 18 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/new/src/collector/huobi/service/trade/__init__.py -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/get_feerate.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.trade import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetFeeRateService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v1/fee/fee-rate/get" 14 | 15 | def parse(dict_data): 16 | data_list = dict_data.get("data", []) 17 | return default_parse_list_dict(data_list, FeeRate, []) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/get_history_orders.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.trade import * 4 | 5 | 6 | class GetHistoryOrdersService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | channel = "/v1/order/history" 13 | 14 | def parse(dict_data): 15 | data_list = dict_data.get("data", []) 16 | return Order.json_parse_list(data_list) 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/get_match_results.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.trade import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetMatchResultsService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v1/order/matchresults" 14 | 15 | def parse(dict_data): 16 | data_list = dict_data.get("data", []) 17 | return default_parse_list_dict(data_list, MatchResult, []) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/get_match_results_by_order_id.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.trade import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetMatchResultsByOrderIdService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | order_id = self.params["order_id"] 14 | def get_channel(): 15 | path = "/v1/order/orders/{}/matchresults" 16 | return path.format(order_id) 17 | 18 | def parse(dict_data): 19 | data_list = dict_data.get("data", []) 20 | return default_parse_list_dict(data_list, MatchResult, []) 21 | 22 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, get_channel(), self.params, parse) 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/get_open_orders.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.trade import * 4 | 5 | 6 | class GetOpenOrdersService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | channel = "/v1/order/openOrders" 13 | 14 | def parse(dict_data): 15 | data_list = dict_data.get("data", []) 16 | return Order.json_parse_list(data_list) 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/get_order_by_client_order_id.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.trade import * 4 | 5 | 6 | class GetOrderByClientOrderIdService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | channel = "/v1/order/orders/getClientOrder" 13 | 14 | def parse(dict_data): 15 | data_dict = dict_data.get("data", {}) 16 | return Order.json_parse(data_dict) 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/get_order_by_id.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.trade import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetOrderByIdService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | order_id = self.params["order_id"] 14 | def get_channel(): 15 | path = "/v1/order/orders/{}" 16 | return path.format(order_id) 17 | 18 | def parse(dict_data): 19 | data_dict = dict_data.get("data") 20 | return Order.json_parse(data_dict) 21 | 22 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, get_channel(), self.params, parse) 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/get_orders.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.trade import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetOrdersService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v1/order/orders" 14 | 15 | def parse(dict_data): 16 | data_list = dict_data.get("data", []) 17 | return Order.json_parse_list(data_list) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/get_transact_feerate.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant.system import HttpMethod 3 | from huobi.model.trade import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetTransactFeeRateService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/reference/transact-fee-rate" 14 | 15 | def parse(dict_data): 16 | data_list = dict_data.get("data", []) 17 | return default_parse_list_dict(data_list, TransactFeeRate, []) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/post_batch_cancel_open_order.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.trade import * 4 | from huobi.utils import * 5 | 6 | 7 | class PostBatchCancelOpenOrderService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v1/order/orders/batchCancelOpenOrders" 14 | 15 | def parse(dict_data): 16 | data = dict_data.get("data", {}) 17 | return default_parse(data, BatchCancelCount) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/post_batch_cancel_order.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.utils import * 4 | from huobi.model.trade import * 5 | 6 | class PostBatchCancelOrderService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | channel = "/v1/order/orders/batchcancel" 13 | 14 | def parse(dict_data): 15 | data = dict_data.get("data", {}) 16 | return default_parse_fill_directly(data, BatchCancelResult) 17 | 18 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/post_batch_create_order.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.trade.batch_create_order import BatchCreateOrder 4 | from huobi.utils import * 5 | 6 | class PostBatchCreateOrderService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | channel = "/v1/order/batch-orders" 13 | 14 | def parse(dict_data): 15 | data = dict_data.get("data", []) 16 | return default_parse_list_dict(data, BatchCreateOrder, []) 17 | 18 | return RestApiSyncClient(**kwargs).request_process_post_batch(HttpMethod.POST_SIGN, channel, self.params, parse) 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/post_cancel_client_order.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.utils.json_parser import default_parse_data_as_long 4 | 5 | 6 | class PostCancelClientOrderService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | channel = "/v1/order/orders/submitCancelClientOrder" 13 | 14 | def parse(dict_data): 15 | return default_parse_data_as_long(dict_data, None) 16 | 17 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/post_cancel_order.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.utils.json_parser import default_parse_data_as_long 4 | 5 | 6 | class PostCancelOrderService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | order_id = self.params["order_id"] 13 | 14 | def get_channel(): 15 | path = "/v1/order/orders/{}/submitcancel" 16 | return path.format(order_id) 17 | 18 | def parse(dict_data): 19 | return default_parse_data_as_long(dict_data, None) 20 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, get_channel(), self.params, parse) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/post_create_order.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.utils.json_parser import default_parse_data_as_long 4 | 5 | 6 | class PostCreateOrderService: 7 | 8 | def __init__(self, params): 9 | self.params = params 10 | 11 | def request(self, **kwargs): 12 | channel = "/v1/order/orders/place" 13 | 14 | def parse(dict_data): 15 | return default_parse_data_as_long(dict_data, None) 16 | 17 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/post_transfer_futures_pro.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.trade import * 4 | from huobi.utils import * 5 | from huobi.utils.json_parser import default_parse_data_as_long 6 | 7 | 8 | class PostTransferFuturesProService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | channel = "/v1/futures/transfer" 15 | 16 | def parse(dict_data): 17 | return default_parse_data_as_long(dict_data, None) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/req_order_detail.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | from huobi.connection.websocket_req_client import * 4 | from huobi.model.trade import * 5 | from huobi.utils import * 6 | 7 | 8 | class ReqOrderDetailService: 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def subscribe(self, callback, error_handler, **kwargs): 13 | order_id = self.params["order-id"] 14 | client_req_id = self.params["cid"] 15 | 16 | def subscription(connection): 17 | connection.send(request_order_detail_channel(order_id, client_req_id)) 18 | 19 | def parse(dict_data): 20 | order_update_event = default_parse(dict_data, OrderDetailReq, OrderListItem) 21 | 22 | return order_update_event 23 | 24 | WebSocketReqClient(**kwargs).execute_subscribe_v1(subscription, 25 | parse, 26 | callback, 27 | error_handler, 28 | is_trade=True) 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/sub_order_update_v2.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | 4 | from huobi.connection.subscribe_client import SubscribeClient 5 | from huobi.model.trade import * 6 | from huobi.utils import * 7 | 8 | 9 | class SubOrderUpdateV2Service: 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def subscribe(self, callback, error_handler, **kwargs): 14 | symbol_list = self.params["symbol_list"] 15 | 16 | def subscription(connection): 17 | for val in symbol_list: 18 | connection.send(orders_update_channel(val)) 19 | time.sleep(0.01) 20 | 21 | def parse(dict_data): 22 | return default_parse(dict_data, OrderUpdateEvent, OrderUpdate) 23 | 24 | SubscribeClient(**kwargs).execute_subscribe_v2(subscription, 25 | parse, 26 | callback, 27 | error_handler, 28 | is_trade=True) 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/trade/sub_trade_clearing_v2.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | 4 | from huobi.connection.subscribe_client import SubscribeClient 5 | from huobi.model.trade import * 6 | from huobi.utils import * 7 | 8 | 9 | class SubTradeClearingV2Service: 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def subscribe(self, callback, error_handler, **kwargs): 14 | symbol_list = self.params["symbol_list"] 15 | 16 | def subscription(connection): 17 | for symbol in symbol_list: 18 | connection.send(trade_clearing_channel(symbol)) 19 | time.sleep(0.01) 20 | 21 | def parse(dict_data): 22 | return TradeClearingEvent.json_parse(dict_data) 23 | 24 | SubscribeClient(**kwargs).execute_subscribe_v2(subscription, 25 | parse, 26 | callback, 27 | error_handler, 28 | is_trade=True) 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/wallet/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/new/src/collector/huobi/service/wallet/__init__.py -------------------------------------------------------------------------------- /new/src/collector/huobi/service/wallet/get_account_deposit_address.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.wallet import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetAccountDepositAddressService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/account/deposit/address" 14 | 15 | def parse(dict_data): 16 | data_list = dict_data.get("data", []) 17 | return default_parse_list_dict(data_list, ChainDepositAddress) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/wallet/get_account_withdraw_address.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.wallet import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetAccountWithdrawAddressService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/account/withdraw/address" 14 | 15 | def parse(dict_data): 16 | data_list = dict_data.get("data", []) 17 | return default_parse_list_dict(data_list, ChainWithdrawAddress) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/wallet/get_account_withdraw_quota.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.wallet import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetAccountWithdrawQuotaService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/account/withdraw/quota" 14 | 15 | def parse(dict_data): 16 | data = dict_data.get("data", {}) 17 | chains = data.get("chains", []) 18 | return default_parse_list_dict(chains, WithdrawQuota) 19 | 20 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/wallet/get_deposit_withdraw.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.wallet import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetDepositWithdrawService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v1/query/deposit-withdraw" 14 | 15 | def parse(dict_data): 16 | op_type = self.params["type"] 17 | data_list = dict_data.get("data", []) 18 | if op_type == DepositWithdraw.DEPOSIT: 19 | return default_parse_list_dict(data_list, Deposit) 20 | elif op_type == DepositWithdraw.WITHDRAW: 21 | return default_parse_list_dict(data_list, Withdraw) 22 | return [] 23 | 24 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/wallet/get_sub_user_deposit_address.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.wallet import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetSubUserDepositAddressService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/sub-user/deposit-address" 14 | 15 | def parse(dict_data): 16 | json_data_list = dict_data.get("data", []) 17 | return default_parse_list_dict(json_data_list, ChainDepositAddress, []) 18 | 19 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/wallet/get_sub_user_deposit_history.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.wallet import * 4 | from huobi.utils import * 5 | 6 | 7 | class GetSubUserDepositHistoryService: 8 | 9 | def __init__(self, params): 10 | self.params = params 11 | 12 | def request(self, **kwargs): 13 | channel = "/v2/sub-user/query-deposit" 14 | 15 | def parse(dict_data): 16 | deposit_history = DepositHistory() 17 | deposit_history.nextId = dict_data.get("nextId", 0) 18 | json_data_list = dict_data.get("data", []) 19 | deposit_history_item_list = default_parse_list_dict(json_data_list, DepositHistoryItem) 20 | deposit_history.data = deposit_history_item_list 21 | return deposit_history 22 | 23 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, channel, self.params, parse) 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/wallet/post_cancel_withdraw.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.trade import * 4 | from huobi.utils import * 5 | from huobi.utils.json_parser import default_parse_data_as_long 6 | 7 | 8 | class PostCancelWithdrawService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | withdraw_id_params = self.params["withdraw-id"] 15 | def get_channel(): 16 | path = "/v1/dw/withdraw-virtual/{}/cancel" 17 | return path.format(withdraw_id_params) 18 | 19 | def parse(dict_data): 20 | return default_parse_data_as_long(dict_data, None) 21 | 22 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, get_channel(), self.params, parse) 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /new/src/collector/huobi/service/wallet/post_create_withdraw.py: -------------------------------------------------------------------------------- 1 | from huobi.connection.restapi_sync_client import RestApiSyncClient 2 | from huobi.constant import * 3 | from huobi.model.trade import * 4 | from huobi.utils import * 5 | from huobi.utils.json_parser import default_parse_data_as_long 6 | 7 | 8 | class PostCreateWithdrawService: 9 | 10 | def __init__(self, params): 11 | self.params = params 12 | 13 | def request(self, **kwargs): 14 | channel = "/v1/dw/withdraw/api/create" 15 | 16 | def parse(dict_data): 17 | # return dict_data.get("data", 0) 18 | return default_parse_data_as_long(dict_data, None) 19 | 20 | return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /new/src/collector/huobi/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from huobi.utils.print_mix_object import PrintMix, PrintBasic, PrintList 2 | from huobi.utils.channels import * 3 | from huobi.utils.channels_request import * 4 | from huobi.utils.json_parser import default_parse, default_parse_list_dict, default_parse_fill_directly 5 | from huobi.utils.api_signature import create_signature, utc_now 6 | from huobi.utils.api_signature_v2 import create_signature_v2, utc_now 7 | from huobi.utils.url_params_builder import UrlParamsBuilder 8 | from huobi.utils.time_service import get_current_timestamp, convert_cst_in_millisecond_to_utc, convert_cst_in_second_to_utc 9 | from huobi.utils.input_checker import check_symbol, check_symbol_list, check_currency, check_range, check_should_none, \ 10 | check_should_not_none, check_list, greater_or_equal, format_date 11 | from huobi.utils.log_info import LogLevel, LogInfo 12 | -------------------------------------------------------------------------------- /new/src/collector/huobi/utils/channel_parser.py: -------------------------------------------------------------------------------- 1 | class ChannelParser: 2 | def __init__(self, input): 3 | fields = input.split(".") 4 | if len(fields) >= 2: 5 | self.symbol = fields[1] 6 | -------------------------------------------------------------------------------- /new/src/collector/huobi/utils/etf_result.py: -------------------------------------------------------------------------------- 1 | def etf_result_check(code): 2 | code = int(code) 3 | if code == 200: 4 | return "" 5 | elif code == 10400: 6 | return "Invalid ETF name" 7 | elif code == 13403: 8 | return "Insufficient asset to create ETF" 9 | elif code == 13404: 10 | return "Create and redemption disabled due to system setup" 11 | elif code == 13405: 12 | return "Create and redemption disabled due to configuration issue" 13 | elif code == 13406: 14 | return "Invalid API call" 15 | elif code == 13410: 16 | return "API authentication fails" 17 | elif code == 13500: 18 | return "System error" 19 | elif code == 13601: 20 | return "Create and redemption disabled during rebalance" 21 | elif code == 13603: 22 | return "Create and redemption disabled due to other reason" 23 | elif code == 13604: 24 | return "Create suspended" 25 | elif code == 13605: 26 | return "Redemption suspended" 27 | elif code == 13606: 28 | return "Amount incorrect. For the cases when creation amount or redemption amount is not in the range of min/max amount" 29 | return "" 30 | -------------------------------------------------------------------------------- /new/src/collector/huobi/utils/log_info.py: -------------------------------------------------------------------------------- 1 | class LogLevel: 2 | DEBUG = "debug" 3 | INFO = "info" 4 | WARNINGS = "warning" 5 | ERROR = "error" 6 | FATAL = "fatal" 7 | 8 | 9 | class LogInfo: 10 | @staticmethod 11 | def output(message, log_level=LogLevel.DEBUG): 12 | # if (message and len(message)): 13 | # if log_level == LogLevel.DEBUG: 14 | # logging.debug(message) 15 | # elif log_level == LogLevel.INFO: 16 | # logging.info(message) 17 | # elif log_level == LogLevel.WARNINGS: 18 | # logging.warnings(message) 19 | # elif log_level == LogLevel.ERROR: 20 | # logging.error(message) 21 | # elif log_level == LogLevel.FATAL: 22 | # logging.fatal(message) 23 | 24 | print(message) 25 | 26 | @staticmethod 27 | def output_list(data_list, log_level=LogLevel.DEBUG): 28 | if data_list and len(data_list): 29 | for obj in data_list: 30 | obj.print_object() 31 | print() 32 | -------------------------------------------------------------------------------- /new/src/collector/huobi/utils/time_service.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | 4 | def get_current_timestamp(): 5 | return int(round(time.time() * 1000)) 6 | 7 | 8 | def convert_cst_in_second_to_utc(time_in_second): 9 | time_in_second = int(time_in_second) 10 | if time_in_second > 946656000 and time_in_second < 946656000000: 11 | return (time_in_second - 8 * 60 * 60) * 1000 12 | else: 13 | return 0 14 | 15 | 16 | def convert_cst_in_millisecond_to_utc(time_in_ms): 17 | time_in_ms = int(time_in_ms) 18 | if time_in_ms > 946656000000: 19 | return time_in_ms - 8 * 60 * 60 * 1000 20 | else: 21 | return 0 22 | 23 | -------------------------------------------------------------------------------- /new/src/collector/huobi/utils/url_params_builder.py: -------------------------------------------------------------------------------- 1 | import json 2 | import urllib.parse 3 | 4 | 5 | class UrlParamsBuilder(object): 6 | 7 | def __init__(self): 8 | self.param_map = dict() 9 | self.post_map = dict() 10 | self.post_list = list() 11 | 12 | def put_url(self, name, value): 13 | if value is not None: 14 | if isinstance(value, (list, dict)): 15 | self.param_map[name] = value 16 | else: 17 | self.param_map[name] = str(value) 18 | 19 | def put_post(self, name, value): 20 | if value is not None: 21 | if isinstance(value, (list, dict)): 22 | self.post_map[name] = value 23 | else: 24 | self.post_map[name] = str(value) 25 | 26 | def build_url(self): 27 | if len(self.param_map) == 0: 28 | return "" 29 | encoded_param = urllib.parse.urlencode(self.param_map) 30 | return "?" + encoded_param 31 | 32 | def build_url_to_json(self): 33 | return json.dumps(self.param_map) 34 | -------------------------------------------------------------------------------- /new/src/collector/log.py: -------------------------------------------------------------------------------- 1 | """ 2 | 主要用于封装日志相关 3 | @example: 4 | import log 5 | log.Init("log_name.log") 6 | """ 7 | import sys 8 | import io 9 | import os 10 | import time 11 | 12 | """ 13 | 封装一个类用于替换sys.stdout 14 | """ 15 | class _Logger(object): 16 | def __init__(self, filename="Default.log", path="./"): 17 | sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') 18 | self.terminal = sys.stdout 19 | self.log = open(os.path.join(path, filename), "a", encoding='utf8') 20 | 21 | def write(self, message): 22 | if message != "\n": 23 | self.terminal.write(self.get_local_time() + "=>" + message + "\n") 24 | self.log.write(self.get_local_time() + "=>" +message + "\n") 25 | self.terminal.flush() 26 | self.log.flush() 27 | 28 | def get_local_time(self): 29 | return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) 30 | 31 | def flush(self): 32 | pass 33 | 34 | """ 35 | 初始化整个log模块,使之能用 36 | """ 37 | def init(file_name, path="./"): 38 | sys.stdout = _Logger(file_name, path=path) 39 | print("==========================> start") 40 | 41 | if __name__=="__main__": 42 | init("out.log") 43 | print("test") -------------------------------------------------------------------------------- /new/src/collector/mysql_tools.py: -------------------------------------------------------------------------------- 1 | import pymysql 2 | from DBUtils.PooledDB import PooledDB 3 | import time 4 | db = None 5 | db_cursor = None 6 | sql_ip = "mysql" 7 | sql_user = "root" 8 | sql_passwd = "123456" 9 | sql_db = "coin" 10 | while True: 11 | time.sleep(1) 12 | try: 13 | pool = PooledDB(pymysql, 5, host=sql_ip, user=sql_user, passwd=sql_passwd, db=sql_db) # 5为连接池里的最少连接数 14 | break 15 | except: 16 | time.sleep(1) 17 | pass 18 | """ init db """ 19 | def GetDB(): 20 | conn = pool.connection() 21 | return conn -------------------------------------------------------------------------------- /new/src/collector/requirements.txt: -------------------------------------------------------------------------------- 1 | numpy==1.19.4 2 | websocket_client==0.57.0 3 | -------------------------------------------------------------------------------- /new/src/website/front_end/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { 4 | "modules": false, 5 | "targets": { 6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"] 7 | } 8 | }], 9 | "stage-2" 10 | ], 11 | "plugins": ["transform-vue-jsx", "transform-runtime"], 12 | "env": { 13 | "test": { 14 | "presets": ["env", "stage-2"], 15 | "plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /new/src/website/front_end/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /new/src/website/front_end/.eslintignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /config/ 3 | /dist/ 4 | /*.js 5 | /test/unit/coverage/ 6 | -------------------------------------------------------------------------------- /new/src/website/front_end/.eslintrc.js: -------------------------------------------------------------------------------- 1 | // https://eslint.org/docs/user-guide/configuring 2 | 3 | module.exports = { 4 | root: true, 5 | parserOptions: { 6 | parser: 'babel-eslint' 7 | }, 8 | env: { 9 | browser: true, 10 | }, 11 | extends: [ 12 | // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention 13 | // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules. 14 | 'plugin:vue/essential', 15 | // https://github.com/standard/standard/blob/master/docs/RULES-en.md 16 | 'standard' 17 | ], 18 | // required to lint *.vue files 19 | plugins: [ 20 | 'vue' 21 | ], 22 | // add your custom rules here 23 | rules: { 24 | // allow async-await 25 | 'generator-star-spacing': 'off', 26 | // allow debugger during development 27 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /new/src/website/front_end/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | /dist/ 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | /test/unit/coverage/ 8 | /test/e2e/reports/ 9 | selenium-debug.log 10 | 11 | # Editor directories and files 12 | .idea 13 | .vscode 14 | *.suo 15 | *.ntvs* 16 | *.njsproj 17 | *.sln 18 | -------------------------------------------------------------------------------- /new/src/website/front_end/.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | "postcss-import": {}, 6 | "postcss-url": {}, 7 | // to edit target browsers: use "browserslist" field in package.json 8 | "autoprefixer": {} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /new/src/website/front_end/README.md: -------------------------------------------------------------------------------- 1 | # coin_view 2 | 3 | > A Vue.js project 4 | 5 | ## Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | npm install 10 | 11 | # serve with hot reload at localhost:8080 12 | npm run dev 13 | 14 | # build for production with minification 15 | npm run build 16 | 17 | # build for production and view the bundle analyzer report 18 | npm run build --report 19 | 20 | # run unit tests 21 | npm run unit 22 | 23 | # run e2e tests 24 | npm run e2e 25 | 26 | # run all tests 27 | npm test 28 | ``` 29 | 30 | For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). 31 | -------------------------------------------------------------------------------- /new/src/website/front_end/build/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/new/src/website/front_end/build/logo.png -------------------------------------------------------------------------------- /new/src/website/front_end/build/vue-loader.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const utils = require('./utils') 3 | const config = require('../config') 4 | const isProduction = process.env.NODE_ENV === 'production' 5 | const sourceMapEnabled = isProduction 6 | ? config.build.productionSourceMap 7 | : config.dev.cssSourceMap 8 | 9 | module.exports = { 10 | loaders: utils.cssLoaders({ 11 | sourceMap: sourceMapEnabled, 12 | extract: isProduction 13 | }), 14 | cssSourceMap: sourceMapEnabled, 15 | cacheBusting: config.dev.cacheBusting, 16 | transformToRequire: { 17 | video: ['src', 'poster'], 18 | source: 'src', 19 | img: 'src', 20 | image: 'xlink:href' 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /new/src/website/front_end/config/dev.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const prodEnv = require('./prod.env') 4 | 5 | module.exports = merge(prodEnv, { 6 | NODE_ENV: '"development"' 7 | }) 8 | -------------------------------------------------------------------------------- /new/src/website/front_end/config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /new/src/website/front_end/config/test.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const devEnv = require('./dev.env') 4 | 5 | module.exports = merge(devEnv, { 6 | NODE_ENV: '"testing"' 7 | }) 8 | -------------------------------------------------------------------------------- /new/src/website/front_end/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | coin_view 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /new/src/website/front_end/src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | 21 | -------------------------------------------------------------------------------- /new/src/website/front_end/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/new/src/website/front_end/src/assets/logo.png -------------------------------------------------------------------------------- /new/src/website/front_end/src/main.js: -------------------------------------------------------------------------------- 1 | // The Vue build version to load with the `import` command 2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias. 3 | import Vue from 'vue' 4 | import ElementUI from 'element-ui' 5 | import App from './App' 6 | import router from './router' 7 | import 'element-ui/lib/theme-chalk/index.css' 8 | 9 | Vue.config.productionTip = false 10 | Vue.use(ElementUI) 11 | 12 | /* eslint-disable no-new */ 13 | new Vue({ 14 | el: '#app', 15 | router, 16 | components: { App }, 17 | template: '' 18 | }) 19 | -------------------------------------------------------------------------------- /new/src/website/front_end/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import CoinView from '@/components/CoinView' 4 | import Login from '@/components/Login' 5 | 6 | Vue.use(Router) 7 | 8 | export default new Router({ 9 | routes: [ 10 | { 11 | path: '/', 12 | name: 'CoinView', 13 | component: CoinView 14 | }, { 15 | path: '/login', 16 | name: 'Login', 17 | component: Login 18 | } 19 | ] 20 | }) 21 | -------------------------------------------------------------------------------- /new/src/website/front_end/src/script/Login.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | import md5 from 'js-md5' 3 | var echarts = require('echarts'); 4 | var _this = null; 5 | export default { 6 | name: 'HelloWorld', 7 | data () { 8 | return { 9 | username:'', 10 | password:'' 11 | } 12 | }, 13 | mounted: function () { 14 | this.get_login_status(); 15 | }, 16 | destroyed: function () { 17 | 18 | }, 19 | methods: { 20 | login(){ 21 | //alert(this.username + this.password) 22 | let that = this; 23 | axios.post("/coin_view/login.php",{username:this.username, password:md5(this.password)}).then(function(result){ 24 | console.log(result.data) 25 | if(result.data.result == 0){ 26 | that.$router.push({path:'/'}); 27 | } 28 | }) 29 | }, 30 | get_login_status(){ 31 | let that = this; 32 | axios.post("/coin_view/get_login_status.php").then(function(result){ 33 | console.log(result.data) 34 | if(result.data.result == 0){ 35 | that.$router.push({path:'/'}); 36 | } 37 | }) 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /new/src/website/front_end/src/scss/CoinView.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/new/src/website/front_end/src/scss/CoinView.scss -------------------------------------------------------------------------------- /new/src/website/front_end/src/scss/color.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/new/src/website/front_end/src/scss/color.scss -------------------------------------------------------------------------------- /new/src/website/front_end/src/scss/common.scss: -------------------------------------------------------------------------------- 1 | .clearfix { 2 | &::after { 3 | content:''; 4 | display:block; 5 | clear:both; 6 | } 7 | zoom:1; 8 | } 9 | .left{ 10 | float:left; 11 | } 12 | .right{ 13 | float:right 14 | } -------------------------------------------------------------------------------- /new/src/website/front_end/static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/new/src/website/front_end/static/.gitkeep -------------------------------------------------------------------------------- /new/src/website/front_end/test/e2e/custom-assertions/elementCount.js: -------------------------------------------------------------------------------- 1 | // A custom Nightwatch assertion. 2 | // The assertion name is the filename. 3 | // Example usage: 4 | // 5 | // browser.assert.elementCount(selector, count) 6 | // 7 | // For more information on custom assertions see: 8 | // http://nightwatchjs.org/guide#writing-custom-assertions 9 | 10 | exports.assertion = function (selector, count) { 11 | this.message = 'Testing if element <' + selector + '> has count: ' + count 12 | this.expected = count 13 | this.pass = function (val) { 14 | return val === this.expected 15 | } 16 | this.value = function (res) { 17 | return res.value 18 | } 19 | this.command = function (cb) { 20 | var self = this 21 | return this.api.execute(function (selector) { 22 | return document.querySelectorAll(selector).length 23 | }, [selector], function (res) { 24 | cb.call(self, res) 25 | }) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /new/src/website/front_end/test/e2e/nightwatch.conf.js: -------------------------------------------------------------------------------- 1 | require('babel-register') 2 | var config = require('../../config') 3 | 4 | // http://nightwatchjs.org/gettingstarted#settings-file 5 | module.exports = { 6 | src_folders: ['test/e2e/specs'], 7 | output_folder: 'test/e2e/reports', 8 | custom_assertions_path: ['test/e2e/custom-assertions'], 9 | 10 | selenium: { 11 | start_process: true, 12 | server_path: require('selenium-server').path, 13 | host: '127.0.0.1', 14 | port: 4444, 15 | cli_args: { 16 | 'webdriver.chrome.driver': require('chromedriver').path 17 | } 18 | }, 19 | 20 | test_settings: { 21 | default: { 22 | selenium_port: 4444, 23 | selenium_host: 'localhost', 24 | silent: true, 25 | globals: { 26 | devServerURL: 'http://localhost:' + (process.env.PORT || config.dev.port) 27 | } 28 | }, 29 | 30 | chrome: { 31 | desiredCapabilities: { 32 | browserName: 'chrome', 33 | javascriptEnabled: true, 34 | acceptSslCerts: true 35 | } 36 | }, 37 | 38 | firefox: { 39 | desiredCapabilities: { 40 | browserName: 'firefox', 41 | javascriptEnabled: true, 42 | acceptSslCerts: true 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /new/src/website/front_end/test/e2e/specs/test.js: -------------------------------------------------------------------------------- 1 | // For authoring Nightwatch tests, see 2 | // http://nightwatchjs.org/guide#usage 3 | 4 | module.exports = { 5 | 'default e2e tests': function (browser) { 6 | // automatically uses dev Server port from /config.index.js 7 | // default: http://localhost:8080 8 | // see nightwatch.conf.js 9 | const devServer = browser.globals.devServerURL 10 | 11 | browser 12 | .url(devServer) 13 | .waitForElementVisible('#app', 5000) 14 | .assert.elementPresent('.hello') 15 | .assert.containsText('h1', 'Welcome to Your Vue.js App') 16 | .assert.elementCount('img', 1) 17 | .end() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /new/src/website/front_end/test/unit/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "jest": true 4 | }, 5 | "globals": { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /new/src/website/front_end/test/unit/jest.conf.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = { 4 | rootDir: path.resolve(__dirname, '../../'), 5 | moduleFileExtensions: [ 6 | 'js', 7 | 'json', 8 | 'vue' 9 | ], 10 | moduleNameMapper: { 11 | '^@/(.*)$': '/src/$1' 12 | }, 13 | transform: { 14 | '^.+\\.js$': '/node_modules/babel-jest', 15 | '.*\\.(vue)$': '/node_modules/vue-jest' 16 | }, 17 | testPathIgnorePatterns: [ 18 | '/test/e2e' 19 | ], 20 | snapshotSerializers: ['/node_modules/jest-serializer-vue'], 21 | setupFiles: ['/test/unit/setup'], 22 | mapCoverage: true, 23 | coverageDirectory: '/test/unit/coverage', 24 | collectCoverageFrom: [ 25 | 'src/**/*.{js,vue}', 26 | '!src/main.js', 27 | '!src/router/index.js', 28 | '!**/node_modules/**' 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /new/src/website/front_end/test/unit/setup.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | Vue.config.productionTip = false 4 | -------------------------------------------------------------------------------- /new/src/website/front_end/test/unit/specs/HelloWorld.spec.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import HelloWorld from '@/components/HelloWorld' 3 | 4 | describe('HelloWorld.vue', () => { 5 | it('should render correct contents', () => { 6 | const Constructor = Vue.extend(HelloWorld) 7 | const vm = new Constructor().$mount() 8 | expect(vm.$el.querySelector('.hello h1').textContent) 9 | .toEqual('Welcome to Your Vue.js App') 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /new/src/website/php/coin_view/get_balance_now.php: -------------------------------------------------------------------------------- 1 | connect_error) { 11 | die("连接失败: " . $conn->connect_error); 12 | } 13 | 14 | 15 | 16 | $sql = " 17 | (select * from amount_history where tag = 'huobi_1' order by timestamp desc limit 0,1) 18 | union 19 | (select * from amount_history where tag = 'huobi_2' order by timestamp desc limit 0,1); 20 | 21 | "; 22 | $result = $conn->query($sql); 23 | 24 | $rtn = ["result"=>"ok", "data"=>[]]; 25 | if ($result->num_rows > 0) { 26 | // 输出数据 27 | while($row = $result->fetch_assoc()) { 28 | array_push($rtn["data"], $row["amount"]); 29 | } 30 | } else { 31 | //echo "0 结果"; 32 | } 33 | 34 | 35 | echo json_encode($rtn); 36 | ?> -------------------------------------------------------------------------------- /new/src/website/php/coin_view/get_login_status.php: -------------------------------------------------------------------------------- 1 | -1]; 4 | //var_dump($_SESSION); 5 | if(key_exists("username", $_SESSION) && key_exists("id", $_SESSION)){ 6 | $rtn["username"] = $_SESSION["username"]; 7 | $rtn["id"] = $_SESSION["id"]; 8 | $rtn["result"] = 0; 9 | } 10 | echo json_encode($rtn); 11 | ?> -------------------------------------------------------------------------------- /new/src/website/php/coin_view/login.php: -------------------------------------------------------------------------------- 1 | -1]; 7 | // 创建连接 8 | $conn = new mysqli($servername, $username, $password, $dbname); 9 | // Check connection 10 | if ($conn->connect_error) { 11 | die("连接失败: " . $conn->connect_error); 12 | } 13 | session_start(); 14 | $param = json_decode(file_get_contents("php://input"),true); 15 | 16 | $sql = $conn->prepare("select id,username from user where username=? and password=?"); 17 | $sql->bind_param("ss", $param["username"], $param["password"]); 18 | $result = $sql->execute(); 19 | $sql->store_result(); 20 | $sql->bind_result($id, $username); 21 | while ($sql->fetch()){ 22 | $_SESSION["id"] = $id; 23 | $_SESSION["username"] = $param["username"]; 24 | } 25 | //登录成功 26 | if($sql->num_rows == 1){ 27 | $rtn["result"] = 0; 28 | } 29 | 30 | echo json_encode($rtn); 31 | ?> -------------------------------------------------------------------------------- /new/src/website/php/coin_view/test.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /old/collect_script/.gitignore: -------------------------------------------------------------------------------- 1 | /__pycache__/ 2 | 3 | -------------------------------------------------------------------------------- /old/collect_script/config.py: -------------------------------------------------------------------------------- 1 | config = { 2 | "proxy_config":{ 3 | "proxy_use":False, 4 | "proxy_ip":"127.0.0.1", 5 | "proxy_port":1087 6 | }, 7 | "redius_config":{ 8 | "redius_ip":"localhost", 9 | "redius_port":6379 10 | } 11 | } -------------------------------------------------------------------------------- /old/collect_script/depth_crawl.py: -------------------------------------------------------------------------------- 1 | import time 2 | import depth_huobi 3 | import depth_ok 4 | import depth_binance 5 | depth_huobi.StartCrwal() 6 | depth_ok.StartCrwal() 7 | depth_binance.StartCrwal() 8 | while True: 9 | time.sleep(1) -------------------------------------------------------------------------------- /old/collect_script/depth_info.py: -------------------------------------------------------------------------------- 1 | 2 | class DepthInfo: 3 | def __init__(self): 4 | self.up_time = 0 5 | self.forbuy=[] 6 | self.forsell=[] 7 | self.order_coin='' 8 | self.base_coin='' 9 | self.market = 0 10 | def dumps(self): 11 | rtn = {} 12 | rtn["up_time"]=self.up_time 13 | rtn["forbuy"]=self.forbuy 14 | rtn["forsell"]=self.forsell 15 | rtn["order_coin"]=self.order_coin 16 | rtn["base_coin"]=self.base_coin 17 | rtn["market"]=self.market 18 | return rtn 19 | def dump(self): 20 | print('==================') 21 | print("order_coin:") 22 | print(self.order_coin) 23 | print("base_coin:") 24 | print(self.base_coin) 25 | print("time:") 26 | print(self.up_time) 27 | print("forbuy:") 28 | print(self.forbuy) 29 | print("forsell:") 30 | print(self.forsell) 31 | 32 | -------------------------------------------------------------------------------- /old/collect_script/depth_watcher.py: -------------------------------------------------------------------------------- 1 | 2 | import json 3 | import threading 4 | import time 5 | import mysql.connector 6 | import gzip 7 | import websocket 8 | import redis 9 | import pickle 10 | from depth_info import DepthInfo 11 | 12 | def run(market, order_coin, base_coin): 13 | redis_db = redis.Redis(host='localhost', port=6379) 14 | while True: 15 | str_out='' 16 | obj = pickle.loads(redis_db.get(str(market)+'_'+order_coin.upper()+'_'+base_coin.upper())) 17 | str_out += obj.order_coin+"\r\n" 18 | str_out += obj.base_coin+"\r\n" 19 | str_out+="time:"+str(obj.up_time)+"\r\n" 20 | str_out+='卖:'+"\r\n" 21 | for item in reversed(obj.forsell[0:10]): 22 | str_out+=str(item)+"\r\n" 23 | str_out+='买:'+"\r\n" 24 | for item in obj.forbuy[0:10]: 25 | str_out+=str(item)+"\r\n" 26 | print(str_out) 27 | time.sleep(0.1) 28 | import sys 29 | run(int(sys.argv[1]), sys.argv[2], sys.argv[3]) -------------------------------------------------------------------------------- /old/collect_script/market_base_common_crawl.py: -------------------------------------------------------------------------------- 1 | import time 2 | import market_base_common_ok 3 | import market_base_common_binance 4 | import market_base_common_huobi 5 | while True: 6 | print("开始抓取火币币对信息>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") 7 | market_base_common_huobi.run() 8 | print("开始抓取火币币对信息<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") 9 | print("开始抓取binance币对信息>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") 10 | market_base_common_binance.run() 11 | print("开始抓取binance币对信息<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") 12 | print("开始抓取ok币对信息>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") 13 | market_base_common_ok.run() 14 | print("开始抓取ok币对信息<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") 15 | time.sleep(60*10) 16 | 17 | 18 | 19 | ''' 20 | print(sys.argv[1]) 21 | if sys.argv[1]=='coin_crawl': 22 | import coin_crawl 23 | elif sys.argv[1]=='news_crawl': 24 | import news_crawl 25 | ''' -------------------------------------------------------------------------------- /old/collect_script/market_base_common_ok.py: -------------------------------------------------------------------------------- 1 | import urllib.request 2 | import json 3 | import _thread 4 | import threading 5 | import time 6 | import mysql.connector 7 | from pyquery import PyQuery as pq 8 | import db_base 9 | db_base.init_db() 10 | def url_open(url): 11 | #print(url) 12 | headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0'} 13 | req = urllib.request.Request(url=url, headers=headers) 14 | for i in range(10): 15 | try: 16 | response = urllib.request.urlopen(url=req, timeout=5).read().decode('utf-8') 17 | return response 18 | except : 19 | print("chainnewscrawl except:") 20 | def run(): 21 | response = url_open('https://www.okex.com/api/spot/v3/instruments') 22 | json_data = json.loads(response) 23 | for item in json_data: 24 | db_base.insert_market_base_common( 25 | item['base_currency'].upper(), 26 | item['quote_currency'].upper(), 27 | item['tick_size'].find('.'), 28 | item['size_increment'].find('.'), 29 | 0, 30 | 0 , 31 | float(item['min_size']), 32 | float(10^20), 33 | float(0), 34 | 2 35 | ) 36 | 37 | #run() 38 | -------------------------------------------------------------------------------- /old/collect_script/news_base.py: -------------------------------------------------------------------------------- 1 | class article_info: 2 | def __init__(self, author, time_utc, title, desc, content, source_addr, source_media): 3 | self.author = author 4 | self.time_utc = time_utc 5 | self.title = title 6 | self.desc = desc 7 | self.content = content 8 | self.source_addr = source_addr 9 | self.source_media = source_media 10 | def __str__(self): 11 | return("""========================== 12 | author:%s 13 | time_utc:%d 14 | title:%s 15 | desc:%s 16 | content:%s 17 | source_addr:%s 18 | source_media:%s"""%(self.author, self.time_utc, self.title, self.desc, 'self.content', self.source_addr, self.source_media)) -------------------------------------------------------------------------------- /old/collect_script/news_crawl.py: -------------------------------------------------------------------------------- 1 | import db_base 2 | import news_chainfor 3 | import news_jinse 4 | import news_8btc 5 | import news_55coin 6 | import news_chainnews 7 | import threading 8 | 9 | class myThread (threading.Thread): 10 | def __init__(self, func, arg1, arg2): 11 | threading.Thread.__init__(self) 12 | self.func = func 13 | self.arg1 = arg1 14 | self.arg2 = arg2 15 | def run(self): 16 | print ("开始线程:" + self.name) 17 | self.func(self.arg1, self.arg2) 18 | print ("退出线程:" + self.name) 19 | def run(): 20 | db_base.init_db() 21 | 22 | thread_list = [ 23 | myThread(news_55coin.get_news, 10, db_base.insert_article), 24 | myThread(news_8btc.get_news, 10, db_base.insert_article), 25 | myThread(news_jinse.get_news, 10, db_base.insert_article), 26 | myThread(news_chainfor.get_news, 10, db_base.insert_article), 27 | myThread(news_chainnews.get_news, 10, db_base.insert_article) 28 | ] 29 | for i in range(len(thread_list)): 30 | thread_list[i].start() 31 | 32 | for i in range(len(thread_list)): 33 | thread_list[i].join() 34 | 35 | #run() 36 | -------------------------------------------------------------------------------- /old/collect_script/start_news_service.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import time 3 | import article2coin_anylse 4 | import news_crawl 5 | while True: 6 | print("开始抓取新闻>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") 7 | news_crawl.run() 8 | print("完成抓取新闻<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") 9 | print("开始分析新闻>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") 10 | article2coin_anylse.run() 11 | time.sleep(60*10) 12 | print("完成分析新闻<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") 13 | 14 | 15 | ''' 16 | print(sys.argv[1]) 17 | if sys.argv[1]=='coin_crawl': 18 | import coin_crawl 19 | elif sys.argv[1]=='news_crawl': 20 | import news_crawl 21 | ''' -------------------------------------------------------------------------------- /old/collect_script/trade_detail_crawl.py: -------------------------------------------------------------------------------- 1 | 2 | import json 3 | import threading 4 | import time 5 | 6 | import trade_detail_huobi 7 | import trade_detail_ok 8 | 9 | 10 | 11 | trade_detail = {} 12 | def detail_callback(key, info_list): 13 | 14 | print("callback:") 15 | print(key) 16 | for info in info_list: 17 | info.dump() 18 | print(len(info_list)) 19 | if key not in trade_detail: 20 | trade_detail[key] = [] 21 | trade_detail[key] += info_list 22 | 23 | trade_detail_huobi.run(detail_callback) 24 | trade_detail_ok.run(detail_callback) 25 | while True: 26 | time.sleep(1) -------------------------------------------------------------------------------- /old/collect_script/trade_detail_info.py: -------------------------------------------------------------------------------- 1 | 2 | class TradeDetailInfo: 3 | def __init__(self): 4 | self.dir = 0 #0 buy 1 sell 5 | self.price=0 6 | self.amount=0 7 | self.trade_time=0 8 | def dumps(self): 9 | rtn = {} 10 | rtn["dir"]=self.dir 11 | rtn["price"]=self.price 12 | rtn["amount"]=self.amount 13 | rtn["trade_time"]=self.trade_time 14 | return rtn 15 | def dump(self): 16 | print('==================') 17 | print("dir:") 18 | print(self.dir) 19 | print("price:") 20 | print(self.price) 21 | print("amount:") 22 | print(self.amount) 23 | print("trade_time:") 24 | print(self.trade_time) 25 | 26 | -------------------------------------------------------------------------------- /old/website/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { 4 | "modules": false, 5 | "targets": { 6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"] 7 | } 8 | }], 9 | "stage-2" 10 | ], 11 | "plugins": ["transform-vue-jsx", "transform-runtime"], 12 | "env": { 13 | "test": { 14 | "presets": ["env", "stage-2"], 15 | "plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /old/website/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /old/website/.eslintignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /config/ 3 | /dist/ 4 | /*.js 5 | /test/unit/coverage/ 6 | -------------------------------------------------------------------------------- /old/website/.eslintrc.js: -------------------------------------------------------------------------------- 1 | // https://eslint.org/docs/user-guide/configuring 2 | 3 | module.exports = { 4 | root: true, 5 | parserOptions: { 6 | parser: 'babel-eslint' 7 | }, 8 | env: { 9 | browser: true, 10 | }, 11 | extends: [ 12 | // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention 13 | // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules. 14 | 'plugin:vue/essential', 15 | // https://github.com/standard/standard/blob/master/docs/RULES-en.md 16 | 'standard' 17 | ], 18 | // required to lint *.vue files 19 | plugins: [ 20 | 'vue' 21 | ], 22 | // add your custom rules here 23 | rules: { 24 | // allow async-await 25 | 'generator-star-spacing': 'off', 26 | // allow debugger during development 27 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /old/website/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | npm-debug.log* 4 | yarn-debug.log* 5 | yarn-error.log* 6 | /test/unit/coverage/ 7 | /test/e2e/reports/ 8 | selenium-debug.log 9 | 10 | # Editor directories and files 11 | .idea 12 | .vscode 13 | *.suo 14 | *.ntvs* 15 | *.njsproj 16 | *.sln 17 | -------------------------------------------------------------------------------- /old/website/.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | "postcss-import": {}, 6 | "postcss-url": {}, 7 | // to edit target browsers: use "browserslist" field in package.json 8 | "autoprefixer": {} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /old/website/README.md: -------------------------------------------------------------------------------- 1 | # nange-website 2 | 3 | > A Vue.js project 4 | 5 | ## Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | npm install 10 | 11 | # serve with hot reload at localhost:8080 12 | npm run dev 13 | 14 | # build for production with minification 15 | npm run build 16 | 17 | # build for production and view the bundle analyzer report 18 | npm run build --report 19 | 20 | # run unit tests 21 | npm run unit 22 | 23 | # run e2e tests 24 | npm run e2e 25 | 26 | # run all tests 27 | npm test 28 | ``` 29 | 30 | For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). 31 | -------------------------------------------------------------------------------- /old/website/build/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/old/website/build/logo.png -------------------------------------------------------------------------------- /old/website/build/vue-loader.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const utils = require('./utils') 3 | const config = require('../config') 4 | const isProduction = process.env.NODE_ENV === 'production' 5 | const sourceMapEnabled = isProduction 6 | ? config.build.productionSourceMap 7 | : config.dev.cssSourceMap 8 | 9 | module.exports = { 10 | loaders: utils.cssLoaders({ 11 | sourceMap: sourceMapEnabled, 12 | extract: isProduction 13 | }), 14 | cssSourceMap: sourceMapEnabled, 15 | cacheBusting: config.dev.cacheBusting, 16 | transformToRequire: { 17 | video: ['src', 'poster'], 18 | source: 'src', 19 | img: 'src', 20 | image: 'xlink:href' 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /old/website/config/dev.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const prodEnv = require('./prod.env') 4 | 5 | module.exports = merge(prodEnv, { 6 | NODE_ENV: '"development"' 7 | }) 8 | -------------------------------------------------------------------------------- /old/website/config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /old/website/config/test.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const devEnv = require('./dev.env') 4 | 5 | module.exports = merge(devEnv, { 6 | NODE_ENV: '"testing"' 7 | }) 8 | -------------------------------------------------------------------------------- /old/website/dist/back/getcoinbase.php: -------------------------------------------------------------------------------- 1 | 4 | getAllBaseInfo(intval($_GET["page_idx"]), intval($_GET['page_size'])); 13 | }else if( 14 | array_key_exists('method',$_GET) && 15 | array_key_exists('id',$_GET) && 16 | $_GET['method'] == 'get_description') 17 | { 18 | $coin_base->getCoinDescribe(intval($_GET["id"])); 19 | }else if( 20 | array_key_exists('method',$_GET) && 21 | array_key_exists('id',$_GET) && 22 | $_GET['method'] == 'get_coin_name_en') 23 | { 24 | $coin_base->getCoinNameEnByID(intval($_GET["id"])); 25 | } 26 | 27 | ?> -------------------------------------------------------------------------------- /old/website/dist/back/getnews.php: -------------------------------------------------------------------------------- 1 | 4 | getNewsInfo(intval($_GET["offset"]),intval($_GET["size"])); 7 | ?> -------------------------------------------------------------------------------- /old/website/dist/back/getnewsbycoinid.php: -------------------------------------------------------------------------------- 1 | 4 | getNewsInfoByCoinId(intval($_GET["offset"]),intval($_GET["size"]), intval($_GET['coin_id'])); 7 | ?> -------------------------------------------------------------------------------- /old/website/dist/index.html: -------------------------------------------------------------------------------- 1 | 币小站
-------------------------------------------------------------------------------- /old/website/dist/static/js/manifest.2ae2e69a05c33dfc65f8.js: -------------------------------------------------------------------------------- 1 | !function(r){var n=window.webpackJsonp;window.webpackJsonp=function(e,u,c){for(var f,i,p,a=0,l=[];a 2 | 3 | 4 | 5 | 6 | 币小站 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 21 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /old/website/src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | 22 | -------------------------------------------------------------------------------- /old/website/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/old/website/src/assets/logo.png -------------------------------------------------------------------------------- /old/website/src/components/PC/Coin/Main.vue: -------------------------------------------------------------------------------- 1 | 9 | 31 | 32 | 33 | 36 | -------------------------------------------------------------------------------- /old/website/src/components/PC/Common/ErrorBody.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 19 | 20 | 21 | 40 | -------------------------------------------------------------------------------- /old/website/src/components/PC/Common/Footer.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 17 | 18 | 19 | 25 | -------------------------------------------------------------------------------- /old/website/src/components/PC/Main/Body.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 23 | 24 | 25 | 44 | -------------------------------------------------------------------------------- /old/website/src/components/PC/Main/Main.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 26 | 27 | 28 | 31 | -------------------------------------------------------------------------------- /old/website/src/components/PC/News/Main.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 26 | 27 | 28 | 31 | -------------------------------------------------------------------------------- /old/website/src/components/PC/Stone/Main.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 26 | 27 | 28 | 31 | -------------------------------------------------------------------------------- /old/website/src/config/server_config.js: -------------------------------------------------------------------------------- 1 | var server_config = { 2 | url: '', 3 | //url: 'http://a.com', 4 | port: '80' 5 | } 6 | var websocket_url = "ws://www.bxiaozhan.com"; 7 | var websocket_config = { 8 | depth_url:websocket_url+":8000", 9 | detail_url:websocket_url+":8001", 10 | analyse_url:websocket_url+":8002" 11 | } 12 | export { 13 | server_config, 14 | websocket_config 15 | } -------------------------------------------------------------------------------- /old/website/src/main.js: -------------------------------------------------------------------------------- 1 | // The Vue build version to load with the `import` command 2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias. 3 | import Vue from 'vue' 4 | import App from './App' 5 | import router from './router' 6 | 7 | Vue.config.productionTip = false 8 | /* eslint-disable no-new */ 9 | new Vue({ 10 | el: '#app', 11 | router, 12 | components: { App }, 13 | template: '' 14 | }) 15 | -------------------------------------------------------------------------------- /old/website/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import Main from '@/components/PC/Main/Main' 4 | import Coin from '@/components/PC/Coin/Main' 5 | import CoinDescribe from '@/components/PC/Coin/CoinDescribe' 6 | import Stone from '@/components/PC/Stone/Main' 7 | import News from '@/components/PC/News/Main' 8 | 9 | Vue.use(Router) 10 | 11 | export default new Router({ 12 | routes: [ 13 | { 14 | path: '/', 15 | name: 'Main', 16 | component: Main 17 | }, 18 | { 19 | path: '/Coin', 20 | name: 'Coin', 21 | component: Coin 22 | }, 23 | { 24 | path: '/Coin/Describe/:id', 25 | name: 'coin_describe', 26 | component: CoinDescribe 27 | }, 28 | { 29 | path: '/Stone', 30 | name: 'Stone', 31 | component: Stone 32 | }, 33 | { 34 | path: '/News', 35 | name: 'News', 36 | component: News 37 | } 38 | ] 39 | }) 40 | -------------------------------------------------------------------------------- /old/website/src/style/clearfix.scss: -------------------------------------------------------------------------------- 1 | 2 | .clearfix { 3 | &::after { 4 | content:''; 5 | display:block; 6 | clear:both; 7 | } 8 | zoom:1; 9 | } 10 | .left{ 11 | float:left; 12 | } 13 | .right{ 14 | float:right 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /old/website/src/style/index.scss: -------------------------------------------------------------------------------- 1 | @import "./clearfix.scss"; 2 | $content_width: 1280px; 3 | $green:rgb(95, 188, 118); 4 | $gray-text:rgb(74, 74, 74); 5 | 6 | 7 | -------------------------------------------------------------------------------- /old/website/static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lihn1987/CoinCollector/3115be42a6bf72e969bbdc245f5bf217b33b25d9/old/website/static/.gitkeep -------------------------------------------------------------------------------- /old/website/test/e2e/custom-assertions/elementCount.js: -------------------------------------------------------------------------------- 1 | // A custom Nightwatch assertion. 2 | // The assertion name is the filename. 3 | // Example usage: 4 | // 5 | // browser.assert.elementCount(selector, count) 6 | // 7 | // For more information on custom assertions see: 8 | // http://nightwatchjs.org/guide#writing-custom-assertions 9 | 10 | exports.assertion = function (selector, count) { 11 | this.message = 'Testing if element <' + selector + '> has count: ' + count 12 | this.expected = count 13 | this.pass = function (val) { 14 | return val === this.expected 15 | } 16 | this.value = function (res) { 17 | return res.value 18 | } 19 | this.command = function (cb) { 20 | var self = this 21 | return this.api.execute(function (selector) { 22 | return document.querySelectorAll(selector).length 23 | }, [selector], function (res) { 24 | cb.call(self, res) 25 | }) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /old/website/test/e2e/nightwatch.conf.js: -------------------------------------------------------------------------------- 1 | require('babel-register') 2 | var config = require('../../config') 3 | 4 | // http://nightwatchjs.org/gettingstarted#settings-file 5 | module.exports = { 6 | src_folders: ['test/e2e/specs'], 7 | output_folder: 'test/e2e/reports', 8 | custom_assertions_path: ['test/e2e/custom-assertions'], 9 | 10 | selenium: { 11 | start_process: true, 12 | server_path: require('selenium-server').path, 13 | host: '127.0.0.1', 14 | port: 4444, 15 | cli_args: { 16 | 'webdriver.chrome.driver': require('chromedriver').path 17 | } 18 | }, 19 | 20 | test_settings: { 21 | default: { 22 | selenium_port: 4444, 23 | selenium_host: 'localhost', 24 | silent: true, 25 | globals: { 26 | devServerURL: 'http://localhost:' + (process.env.PORT || config.dev.port) 27 | } 28 | }, 29 | 30 | chrome: { 31 | desiredCapabilities: { 32 | browserName: 'chrome', 33 | javascriptEnabled: true, 34 | acceptSslCerts: true 35 | } 36 | }, 37 | 38 | firefox: { 39 | desiredCapabilities: { 40 | browserName: 'firefox', 41 | javascriptEnabled: true, 42 | acceptSslCerts: true 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /old/website/test/e2e/specs/test.js: -------------------------------------------------------------------------------- 1 | // For authoring Nightwatch tests, see 2 | // http://nightwatchjs.org/guide#usage 3 | 4 | module.exports = { 5 | 'default e2e tests': function (browser) { 6 | // automatically uses dev Server port from /config.index.js 7 | // default: http://localhost:8080 8 | // see nightwatch.conf.js 9 | const devServer = browser.globals.devServerURL 10 | 11 | browser 12 | .url(devServer) 13 | .waitForElementVisible('#app', 5000) 14 | .assert.elementPresent('.hello') 15 | .assert.containsText('h1', 'Welcome to Your Vue.js App') 16 | .assert.elementCount('img', 1) 17 | .end() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /old/website/test/unit/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "jest": true 4 | }, 5 | "globals": { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /old/website/test/unit/jest.conf.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = { 4 | rootDir: path.resolve(__dirname, '../../'), 5 | moduleFileExtensions: [ 6 | 'js', 7 | 'json', 8 | 'vue' 9 | ], 10 | moduleNameMapper: { 11 | '^@/(.*)$': '/src/$1' 12 | }, 13 | transform: { 14 | '^.+\\.js$': '/node_modules/babel-jest', 15 | '.*\\.(vue)$': '/node_modules/vue-jest' 16 | }, 17 | testPathIgnorePatterns: [ 18 | '/test/e2e' 19 | ], 20 | snapshotSerializers: ['/node_modules/jest-serializer-vue'], 21 | setupFiles: ['/test/unit/setup'], 22 | mapCoverage: true, 23 | coverageDirectory: '/test/unit/coverage', 24 | collectCoverageFrom: [ 25 | 'src/**/*.{js,vue}', 26 | '!src/main.js', 27 | '!src/router/index.js', 28 | '!**/node_modules/**' 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /old/website/test/unit/setup.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | Vue.config.productionTip = false 4 | -------------------------------------------------------------------------------- /old/website/test/unit/specs/HelloWorld.spec.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import HelloWorld from '@/components/HelloWorld' 3 | 4 | describe('HelloWorld.vue', () => { 5 | it('should render correct contents', () => { 6 | const Constructor = Vue.extend(HelloWorld) 7 | const vm = new Constructor().$mount() 8 | expect(vm.$el.querySelector('.hello h1').textContent) 9 | .toEqual('Welcome to Your Vue.js App') 10 | }) 11 | }) 12 | --------------------------------------------------------------------------------