def __init__(self): """ 初始化 """ self.strategy = config.strategy self.platform = const.COINSUPER_PRE self.account = config.accounts[0]["account"] self.access_key = config.accounts[0]["access_key"] self.secret_key = config.accounts[0]["secret_key"] self.symbol = config.symbol self.order_no = None # 创建订单的id self.create_order_price = "0.0" # 创建订单的价格 # 交易模块 cc = { "strategy": self.strategy, "platform": self.platform, "symbol": self.symbol, "account": self.account, "access_key": self.access_key, "secret_key": self.secret_key, "order_update_callback": self.on_event_order_update } self.trader = Trade(**cc) # 订阅行情 Market(const.MARKET_TYPE_ORDERBOOK, self.platform, self.symbol, self.on_event_orderbook_update)
def __init__(self): """ 初始化 """ self.strategy = config.strategy self.platform = const.OKEX self.account = config.platforms.get(self.platform, {}).get("account") self.access_key = config.platforms.get(self.platform, {}).get("access_key") self.secret_key = config.platforms.get(self.platform, {}).get("secret_key") self.passphrase = config.platforms.get(self.platform, {}).get("passphrase") self.symbol = config.symbol self.order_no = None # 创建订单的id self.create_order_price = "0.0" # 创建订单的价格 # 交易模块 cc = { "strategy": self.strategy, "platform": self.platform, "symbol": self.symbol, "account": self.account, "access_key": self.access_key, "secret_key": self.secret_key, "passphrase": self.passphrase, "order_update_callback": self.on_event_order_update } self.trader = Trade(**cc) # 订阅行情 Market(const.MARKET_TYPE_ORDERBOOK, self.platform, self.symbol, self.on_event_orderbook_update)
def __init__(self): """ 初始化 """ self.strategy = "my_strategy" self.platform = BINANCE self.account = config.platforms.get(self.platform, {}).get("account") self.access_key = config.platforms.get(self.platform, {}).get("access_key") self.secret_key = config.platforms.get(self.platform, {}).get("secret_key") self.symbol = config.symbol self.name = config.strategy self.order_no = None # 创建订单的id self.create_order_price = "0.0" # 创建订单的价格 # 交易模块 self.trader = Trade(self.strategy, self.platform, self.symbol, self.account, asset_update_callback=self.on_event_asset_update, order_update_callback=self.on_event_order_update) # 订阅行情 Market(const.MARKET_TYPE_ORDERBOOK, const.BINANCE, self.symbol, self.on_event_orderbook_update)
def __init__(self): """ 初始化 """ self.strategy = config.strategy self.platform = const.BITMEX self.account = config.platforms.get(self.platform, {}).get("account") self.access_key = config.platforms.get(self.platform, {}).get("access_key") self.secret_key = config.platforms.get(self.platform, {}).get("secret_key") self.symbol = config.symbol self.buy_open_order_no = None # 开仓做多订单号 self.buy_open_quantity = "10" # 开仓数量(USD) self.sell_close_order_no = None # 多仓平仓订单号 self.sell_close_time_down = 0 # 平仓倒计时 self.current_price = None # 当前盘口价格,为了方便,这里假设盘口价格为 卖一 和 买一 的平均值 # 交易模块 cc = { "strategy": self.strategy, "platform": self.platform, "symbol": self.symbol, "account": self.account, "access_key": self.access_key, "secret_key": self.secret_key, "order_update_callback": self.on_event_order_update, "position_update_callback": self.on_event_position_update } self.trader = Trade(**cc) # 订阅行情 Market(const.MARKET_TYPE_ORDERBOOK, self.platform, self.symbol, self.on_event_orderbook_update) # 注册系统循环回调 LoopRunTask.register(self.on_ticker, 1) # 每隔1秒执行一次回调
def __init__(self): """ 初始化 """ self.strategy = config.strategy self.platform = const.BINANCE self.account = config.accounts[0]["account"] self.access_key = config.accounts[0]["access_key"] self.secret_key = config.accounts[0]["secret_key"] self.symbol = config.symbol self.buy_open_order_no = None # 开仓做多订单号 self.buy_open_price = 0 self.buy_open_quantity = "0.003" # 开仓数量(USD) self.sell_close_order_no = None # 多仓平仓订单号 self.sell_close_time_down = 0 # 平仓倒计时 self.bsud_usdt_price = 0 self.btc_busd_relative = {} self.highest_price = 0 self.lowest_price = 999999 self.threshold = 0.001 #self.current_price = None # 当前盘口价格,为了方便,这里假设盘口价格为 卖一 和 买一 的平均值 # 交易模块 cc = { "strategy": self.strategy, "platform": self.platform, "symbol": self.symbol, "account": self.account, "access_key": self.access_key, "secret_key": self.secret_key, "order_update_callback": self.on_event_order_update, "position_update_callback": self.on_event_position_update } self.trader = Trade(**cc) # 订阅行情 Market(const.MARKET_TYPE_ORDERBOOK, 'binance', 'BTC/USDT', self.on_event_orderbook_btcusdt_update) Market(const.MARKET_TYPE_ORDERBOOK, 'binance', 'BUSD/USDT', self.on_event_orderbook_busdusdt_update) Market(const.MARKET_TYPE_ORDERBOOK, 'binance', 'BTC/BUSD', self.on_event_orderbook_update) # 注册系统循环回调 LoopRunTask.register(self.on_ticker, 1) # 每隔1秒执行一次回调
def __init__(self): """ 初始化 """ self.strategy = config.strategy self.platform = const.BINANCE self.account = config.accounts[0]["account"] self.access_key = config.accounts[0]["access_key"] self.secret_key = config.accounts[0]["secret_key"] self.symbol = config.symbol self.buy_open_order_no = None # 开仓做多订单号 self.buy_open_price = 0 self.buy_open_quantity = "0.003" # 开仓数量(USD) self.sell_close_order_no = None # 多仓平仓订单号 self.sell_close_time_down = 0 # 平仓倒计时 self.bsud_usdt_price = 0 self.btc_busd_relative = {} self.highest_price = 0 self.lowest_price = 999999 self.threshold = 1.002 self.six_price = [0, 0, 0, 0, 0, 0] self.six_amount = [0, 0, 0, 0, 0, 0] #self.six_usdt_amount = [0, 0, 0, 0, 0, 0] self.actions = [] self.limit_usdt = 10.0 self.trader = {} # self.current_price = None # 当前盘口价格,为了方便,这里假设盘口价格为 卖一 和 买一 的平均值 # 交易模块 cc = { "strategy": self.strategy, "platform": self.platform, "symbol": 'BUSD/USDT', "account": self.account, "access_key": self.access_key, "secret_key": self.secret_key, "order_update_callback": self.on_event_order_update, "position_update_callback": self.on_event_position_update } cc1 = { "strategy": self.strategy, "platform": self.platform, "symbol": 'BTC/USDT', "account": self.account, "access_key": self.access_key, "secret_key": self.secret_key, "order_update_callback": self.on_event_order_update, "position_update_callback": self.on_event_position_update } cc2 = { "strategy": self.strategy, "platform": self.platform, "symbol": 'BTC/BUSD', "account": self.account, "access_key": self.access_key, "secret_key": self.secret_key, "order_update_callback": self.on_event_order_update, "position_update_callback": self.on_event_position_update } self.trader['BUSD/USDT'] = Trade(**cc) self.trader['BTC/USDT'] = Trade(**cc1) self.trader['BTC/BUSD'] = Trade(**cc2) # 订阅行情 Market(const.MARKET_TYPE_ORDERBOOK, 'binance', 'BUSD/USDT', self.on_event_orderbook_update) Market(const.MARKET_TYPE_ORDERBOOK, 'binance', 'BTC/USDT', self.on_event_orderbook_update) Market(const.MARKET_TYPE_ORDERBOOK, 'binance', 'BTC/BUSD', self.on_event_orderbook_update)