예제 #1
0
from module.CfEnv import config, configBase
import tokens.Token as Token
import api.OkexClientV3 as Client
import json
import threading

# init apikey,secretkey,passphrase
api_key = configBase.get("okex-v3", "API_KEY")
seceret_key = configBase.get("okex-v3", "SECRET_KEY")
passphrase = configBase.get("okex-v3", "PASSPHRASE")

if __name__ == '__main__':
    symbols = json.loads(config.get("trade", "symbol"))
    if len(symbols) > 1:
        for symbol in symbols:
            threading.Thread(target=Token.__main__,
                             args=(
                                 Client.OkexClient(api_key, seceret_key,
                                                   passphrase),
                                 symbol,
                             )).start()
    else:
        Token.__main__(Client.OkexClient(api_key, seceret_key, passphrase),
                       symbols[0])
예제 #2
0
import datetime
import hashlib
import hmac
import json
import urllib
import urllib.parse
import urllib.request
import requests
import configparser
from hashlib import sha256
from module.Socks5 import open_socks
from module.CfEnv import configBase

# 此处填写APIKEY
# init apikey,secretkey,url
ACCESS_KEY = configBase.get("huobipro", "access_key")
SECRET_KEY = configBase.get("huobipro", "secret_key")

# Need to replace with the actual value generated from below command
# openssl ecparam -name secp256k1 -genkey -noout -out secp256k1-key.pem
# PRIVATE_KEY = configBase.get("huobipro", "private_key").replace("|", "\n")

# API request URL
MARKET_URL = "https://api.huobi.pro"
TRADE_URL = "https://api.huobi.pro"
CONTRACT_URL = "https://api.hbdm.com"

# Can first request to call get_accounts()to find the target acct_id,later can just specify the actual acc_id in the api call
ACCOUNT_ID = None

# local socks5 proxy
예제 #3
0
import smtplib
from email.header import Header
from email.mime.text import MIMEText
from module.Logger import logger
from module.CfEnv import configBase

# read config
receivers = [configBase.get("email", "receiver")]


def send_email(content, _subtype='plain', _subject="bitcoinrobot"):
    # 第三方 SMTP 服务
    mail_host = "smtp.gmail.com"  # 设置服务器
    mail_user = "******"  # 用户名
    mail_pass = "******"  # 口令

    message = MIMEText(content, _subtype, 'utf-8')
    message['From'] = Header(mail_user)
    message['To'] = Header(",".join(receivers))
    message['Subject'] = Header(_subject)
    try:
        server = smtplib.SMTP_SSL(mail_host, 465)
        server.ehlo()
        server.login(mail_user, mail_pass)
        server.sendmail(mail_user, receivers, message.as_string())
        server.close()
        logger.info("邮件发送成功")
        return True
    except smtplib.SMTPException as err:
        logger.error("Error: 邮件发送失败,{}".format(err))
        return False
예제 #4
0
import json
import time
import hashlib
import hmac
import urllib.parse
import requests
from api.Result import Result
from module.CfEnv import configBase

API_KEY = configBase.get("binance", "API_KEY")
SECRET_KEY = configBase.get("binance", "SECRET_KEY")

BASE_URL = "https://api.binance.com"

headers = {
    "Accept":
    "application/json",
    'Content-Type':
    'application/json',
    'User-Agent':
    'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) '
    'Chrome/39.0.2171.71 Safari/537.36',
    "X-MBX-APIKEY":
    API_KEY
}


def common_response(response):
    try:
        if response.status_code == 200:
            return Result(200, "ok", response.json())
예제 #5
0
import requests
from module.CfEnv import configBase
from module.Logger import logger

# read config
deal_token = configBase.get("tg_tokens", "deal_token")
daily_report_token = configBase.get("tg_tokens", "report_token")
chat_id = configBase.get("tg_tokens", "chat_id")


def send_telegram(message, is_report=False):
    token = deal_token if not is_report else daily_report_token
    data = {"chat_id": chat_id, "text": message}
    url = f"https://api.telegram.org/bot{token}/sendMessage"
    try:
        if requests.post(url, data=data).json()["ok"]:
            return True
        else:
            return False
    except Exception as e:
        logger.error(f"send telegram msg exception:{str(e)}")
        return False