Пример #1
0
def main(base, trade, symbol, debug, back):
    if debug or back:
        logging.basicConfig(level=logging.INFO,
                            format='%(asctime)s - %(levelname)s - %(message)s')
    else:
        logging.basicConfig(level=logging.INFO,
                            format='%(asctime)s - %(levelname)s - %(message)s',
                            filename="log_abs_strategy.log")
    from util import read_conf
    config = read_conf("./config.json")
    if base == 'binance':
        base_exchange = Binance()
    elif base == 'bitfinex':
        base_exchange = Bitfinex()
    elif base == 'gdax':
        base_exchange = Gdax()
    trade_exchange = Okex(config['apikey']['okex']['key'],
                          config['apikey']['okex']['secret'])
    if back:
        b = arrow.now().shift(hours=-1).timestamp * 1000
        #AbsDiffStrategy(config, debug).back_test(base_exchange, trade_exchange, symbol, 1517615151000 ,1517618751000)
        AbsDiffStrategy(config, debug).back_test(base_exchange, trade_exchange,
                                                 symbol, b)
    else:
        AbsDiffStrategy(config, debug).run(base_exchange, trade_exchange,
                                           symbol)
Пример #2
0
def __submit_result(ea, request_hash):
    args = util.read_conf('{}/config/YZDataRequest.json'.format(tx_home),
                          '{}/compiled'.format(tx_home))
    succ, args = __update_func_args(request_hash, args)
    if not succ:
        return
    tx = transaction(ea.host, ea.project_id)
    tx.call_and_send_transaction(args.keystore_path, submitter_passwd, args)
Пример #3
0
def main(first, second, coin, debug):
    if debug:
        logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
    else:
        logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s',
                            filename="strategy.log")
    from util import read_conf
    config = read_conf("./config.json")
    TestStrategy(config, debug).trade(first, second, coin)
Пример #4
0
def main(debug, back):
    if debug or back:
        logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
    else:
        logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s',
                            filename="log_ta_strategy.log")
    from util import read_conf
    config = read_conf("./config.json")
    if back:
        TaStrategy(config, "btc_usdt", back, debug=debug).back_test()
    else:
        TaStrategy(config, "btc_usdt", debug=debug).run()
Пример #5
0
def main(debug, back):
    if debug or back:
        logging.basicConfig(level=logging.INFO,
                            format='%(asctime)s - %(levelname)s - %(message)s')
    else:
        logging.basicConfig(level=logging.INFO,
                            format='%(asctime)s - %(levelname)s - %(message)s',
                            filename="log_ta_strategy.log")
    from util import read_conf
    config = read_conf("./config.json")
    if back:
        TaStrategy(config, "btc_usdt", back, debug=debug).back_test()
    else:
        TaStrategy(config, "btc_usdt", debug=debug).run()
def main():
    args = __parse_args()
    args = util.read_conf(args.conf, './compiled')

    tx = transaction(args.host, args.project_id)
    op_code = {
        'call':
        'tx.call_contract(args)',
        'call_and_send':
        'tx.call_and_send_transaction(args.keystore_path, passwd, args)'
    }
    if '_and_send' in args.op_type:
        passwd = getpass.getpass()
    ret = eval(op_code[args.op_type])
    print(ret)
Пример #7
0
import os
import time
import re
from slackclient import SlackClient
import subprocess

from util import read_conf, run_cmd

conf = read_conf("./config.json")
# instantiate Slack client
slack_client = SlackClient(conf['slack']['bot']['token'])
# starterbot's user ID in Slack: value is assigned after the bot starts up
starterbot_id = None

# constants
RTM_READ_DELAY = 1  # 1 second delay between reading from RTM
EXAMPLE_COMMAND = "do"
MENTION_REGEX = "^<@(|[WU].+)>(.*)"


def parse_bot_commands(slack_events):
    for event in slack_events:
        if event["type"] == "message" and not "subtype" in event:
            user_id, message = parse_direct_mention(event["text"])
            if user_id == starterbot_id:
                return message, event["channel"]
    return None, None


def parse_direct_mention(message_text):
    matches = re.search(MENTION_REGEX, message_text)
Пример #8
0
#!/usr/bin/python

from util import read_conf
import logging
from util import PROJ_BASE_PATH

CONF_FILE_PATH = '%s/conf/conf.ini' % PROJ_BASE_PATH
EXPORT_FILES_PATH = '%s/conf/model_class0.txt %s/conf/model_class1.txt' % (
    PROJ_BASE_PATH, PROJ_BASE_PATH)
STOP_FILE_PATH = '%s/data/stop_words.txt' % PROJ_BASE_PATH
# specify the encoding of non-data files
ENCODING = 'utf-8'

CONF = read_conf(CONF_FILE_PATH, ENCODING)

logging.basicConfig(stream=CONF.get('stream'),
                    level=CONF.get('log_level'),
                    datefmt=CONF.get('log_date_fmt'),
                    format=CONF.get('log_format'))
logging.info("has read the conf and set the logging successfully...")
Пример #9
0
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support import expected_conditions as EC
import unittest, time, re
import yaml
import sys, getopt
from rockstor_testcase import RockStorTestCase
from inspect import stack
from util import read_conf
from login import Login
from pools_create_raid0_2disks import PoolsCreateRaid02Disks

if __name__ == '__main__':
    conf = read_conf()
    # TODO generate screenshot dir name from timestamp and create dir
    conf['screenshot_dir'] = 'output2' 
    suite = unittest.TestSuite()
    suite.addTest(RockStorTestCase.parametrize(Login, conf=conf))
    suite.addTest(RockStorTestCase.parametrize(PoolsCreateRaid02Disks, conf=conf))
    unittest.TextTestRunner(verbosity=2).run(suite)


Пример #10
0
            status = ORDER_STATUS.SUCCESS
        return Order(od['order_id'], od['symbol'], od['price'], od['amount'],
                     od['create_date'], od['type'], status)


if __name__ == '__main__':
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

    import os, sys

    sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
    from util import read_conf

    conf = read_conf(os.path.join(os.path.dirname(__file__), "../config.json"))
    api = Okex(conf['apikey']['okex']['key'], conf['apikey']['okex']['secret'])
    # a = api.fetch_ticker('eth_usdt')
    # print api.fetch_kline("btc_usdt")
    # print api.account()
    orders = [{
        "price": 7000,
        "amount": 0.001
    }, {
        "price": 7500,
        "amount": 0.001
    }]
    print api.batch_order("btc_usdt", "buy", orders_data=orders)
    # api.batch_order()
    # print api.fetch_depth('eth_usdt')
    # print api.account()
Пример #11
0
                'name': 'diff',
                'type': 'line',
                'data': [[x.id, x.trade_ma - x.base_ma] for x in data],
            })
        else:
                
            series.append({
                'name': 'base',
                'type': 'line',
                'data': base_data
            })
            series.append({
                'name': 'price',
                'type': 'line',
                'data': t_data
            })
            series.append({
                'name': 'bid',
                'type': 'line',
                'data': [[x.id, float(x.trade_bid)] for x in data]
            })
        option['series'] = series

        self.render("abs_diff.html", option=json.dumps(option))


if __name__ == '__main__':
    from util import read_conf

    ApiApplication(True, config=read_conf()).boot(8000)
Пример #12
0
def main(debug):
    logging.basicConfig(level=logging.INFO,
                        format='%(asctime)s - %(levelname)s - %(message)s')
    from util import read_conf
    config = read_conf("./config.json")
    PriceAlarm(config, debug).run()
Пример #13
0
def main(debug):
    logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
    from util import read_conf
    config = read_conf("./config.json")
    PriceAlarm(config, debug).run()
Пример #14
0
        }

    def scan(self):
        try:
            while True:
                placed_orders = self.order_manager.list_by_status(ORDER_STATUS.PLACED)
                for order in placed_orders:
                    api = self.exchanges[order.exchange]
                    symbol = order.coin
                    order_info = api.order_info(symbol, order.ex_id)
                    if order_info.status == ORDER_STATUS.SUCCESS:
                        logging.info("update order success %s, %s, %s" % (order.exchange, order.id, order.ex_id))
                        self.order_manager.success(order['id'])
                    elif order_info.status == ORDER_STATUS.CANCELLED:
                        logging.info("update order cancel %s, %s, %s" % (order.exchange, order.id, order.ex_id))
                        self.order_manager.update_status(order['id'], ORDER_STATUS.CANCELLED)

        except:
            logging.exception("")
        time.sleep(2)
        

if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
    from skyb import MysqlEngine

    conf = read_conf()
    engine = MysqlEngine(conf['db']['url'])
    scanner = OrderScanner(conf, engine=engine)
    print scanner.scan()
Пример #15
0
def main(first, second, coin, debug):
    from util import read_conf
    config = read_conf("./config.json")
    Test(config, debug).trade(first, second, coin)
Пример #16
0
def main(first, second, coin, debug):
    from util import read_conf
    config = read_conf("./config.json")
    Test(config, debug).trade(first, second, coin)
Пример #17
0
 def __init__(self, methodName='runTest', conf=None):
     super(RockStorTestCase, self).__init__(methodName)
     if conf == None:
         self.conf = read_conf()
     else:
         self.conf = conf
 def __init__(self, methodName='runTest', conf=None):
     super(RockStorTestCase, self).__init__(methodName)
     if conf == None:
         self.conf = read_conf()
     else:
         self.conf = conf
Пример #19
0
import os
import time
import re
from slackclient import SlackClient
import subprocess

from util import read_conf, run_cmd

conf = read_conf("./config.json")
# instantiate Slack client
slack_client = SlackClient(conf['slack']['bot']['token'])
# starterbot's user ID in Slack: value is assigned after the bot starts up
starterbot_id = None

# constants
RTM_READ_DELAY = 1  # 1 second delay between reading from RTM
EXAMPLE_COMMAND = "do"
MENTION_REGEX = "^<@(|[WU].+)>(.*)"


def parse_bot_commands(slack_events):
    for event in slack_events:
        if event["type"] == "message" and not "subtype" in event:
            user_id, message = parse_direct_mention(event["text"])
            if user_id == starterbot_id:
                return message, event["channel"]
    return None, None


def parse_direct_mention(message_text):
    matches = re.search(MENTION_REGEX, message_text)
Пример #20
0
    def remove_price_monitor(self, symbol="btc_usdt", ex="okex"):
        sql = "update price_monitor_symbols set status=0 where ex=? and symbol=?"
        self.engine.execute(sql, (ex, symbol))
        return True

    def show_price_monitor(self):
        sql = "select * from price_monitor_symbols where status = 1"
        data = self.engine.execute(sql, ())
        res = []
        for x in data:
            s = "%s\t%s\t%s\t%s" % (x.exchange, x.symbol, fix_float_radix(x.low, 2), fix_float_radix(x.high, 2))
            res.append(s)
        return ' '.join(res)


tool = Tool(read_conf("./config.json"))


@click.group()
@click.pass_context
def cli(*args, **kw):
    pass


@cli.command()
def record():
    tool.record_account()


@cli.command()
@click.option("-o", is_flag=True)
Пример #21
0
        elif status_int == 1:
            status = ORDER_STATUS.PARTIAL_SUCCESS
        elif status_int == 2:
            status = ORDER_STATUS.SUCCESS
        return Order(od['order_id'], od['symbol'], od['price'], od['amount'], od['create_date'], od['type'], status)


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

    import os, sys

    sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
    from util import read_conf

    conf = read_conf(os.path.join(os.path.dirname(__file__), "../config.json"))
    api = Okex(conf['apikey']['okex']['key'], conf['apikey']['okex']['secret'])
    # a = api.fetch_ticker('eth_usdt')
    # print api.fetch_kline("btc_usdt")
    # print api.account()
    orders = [
        {"price": 7000, "amount": 0.001},
        {"price": 7500, "amount": 0.001}
    ]
    print api.batch_order("btc_usdt", "buy", orders_data=orders)
    # api.batch_order()
    # print api.fetch_depth('eth_usdt')
    # print api.account()
    # print api.order('eth_usdt', 'buy', 'limit', 0.1, 10)
    # print api.order_info('eth_usdt', 1000)
    # print api.cancel_order('eth_usdt', 1000)
Пример #22
0
                v = avg(dt[i - window:i + 1])
            if v > 0:
                t_data.append([data[i].id, v])
                data[i].trade_ma = v
        if delta > 0:
            series.append({
                'name':
                'diff',
                'type':
                'line',
                'data': [[x.id, x.trade_ma - x.base_ma] for x in data],
            })
        else:

            series.append({'name': 'base', 'type': 'line', 'data': base_data})
            series.append({'name': 'price', 'type': 'line', 'data': t_data})
            series.append({
                'name': 'bid',
                'type': 'line',
                'data': [[x.id, float(x.trade_bid)] for x in data]
            })
        option['series'] = series

        self.render("abs_diff.html", option=json.dumps(option))


if __name__ == '__main__':
    from util import read_conf

    ApiApplication(True, config=read_conf()).boot(8000)