Ejemplo n.º 1
0
    def __init__(self, instrument, mode, test_mode, base_path, config_name,
                 args, sendmail):
        self.sendmail = sendmail
        # trueであれば、テストモードにする
        self.test_mode = test_mode

        # rootの絶対パス
        self.base_path = base_path

        # デモもしくは本番
        account_data = account_init(mode, self.base_path)
        self.account_id = account_data["account_id"]
        self.token = account_data["token"]
        self.env = account_data["env"]

        # パラメータセット
        # configが一つだと、わかりづらいのでネーミングを変える instrument.config_timetrend, instrument.config_bollingerとかで使い分け
        self.config_name = config_name
        self.config_data = instrument_init(instrument, self.base_path,
                                           self.config_name)
        units = self.config_data["units"]
        self.instrument = instrument
        # 使うものインスタンス化
        self.oanda_wrapper = OandaWrapper(self.env, self.account_id,
                                          self.token, units)

        # 指値でいつの間にか決済されてしまったときはこれでスリープさせる
        self.stl_sleep_flag = False
        self.onfile_path = ""

        self.debug_logger = getLogger("debug")
        self.result_logger = getLogger("result")
        self.result_logger.info("#########################")
        tmp = ""
        for arg in args:
            tmp = tmp + arg + " "
        self.result_logger.info("# %s" % tmp)
        lst = sorted(self.config_data)
        for elm in lst:
            self.result_logger.info("# %s = %s" % (elm, self.config_data[elm]))
Ejemplo n.º 2
0
import os
current_path = os.path.abspath(os.path.dirname(__file__))
current_path = current_path + "/.."
sys.path.append(current_path)
sys.path.append(current_path + "/trade_algorithm")
sys.path.append(current_path + "/obj")
sys.path.append(current_path + "/lib")

from mysql_connector import MysqlConnector
from price_obj import PriceObj
from datetime import datetime, timedelta
from common import decideMarket, account_init, iso_jp, jp_utc
from get_indicator import getBollingerWrapper
import time

account_data = account_init("production", current_path)
account_id = account_data["account_id"]
token = account_data["token"]
env = account_data["env"]
import oandapyV20
import oandapyV20.endpoints.instruments as instruments

client = oandapyV20.API(access_token=token, environment=env)

# python insert_multi_table.py instrument table_type mode


def check_table(base_time, instrument, con, table_type):
    if table_type == "1m":
        base_time = base_time - timedelta(minutes=1)
    elif table_type == "5m":