Exemple #1
0
                    strategy.order(bid[0], 'buy', qty=bid[2], limit=int(bid[1]), minute_to_expire=1)
                    restrict_range[target] = bid[2]
                else:
                    strategy.cancel(bid[0])

            logger.info(
                '%f %.1f %.1f/%.1f (%.1f)'
                % (delay, buy_vol_avg, buy_vol_std, sell_vol_avg, sell_vol_std)
            )
        else:
            strategy.cancel_order_all()
            strategy.close_position()


if __name__ == "__main__":
    from . import settings
    import logging
    import logging.config

    logging.config.dictConfig(settings.loggingConf('elephant.log'))
    logger = logging.getLogger("elephant")

    bot = elephant()
    strategy = Strategy(yourlogic=bot.loop, yoursetup=bot.setup, interval=5)
    strategy.settings.apiKey = settings.apiKey
    strategy.settings.secret = settings.secret
    strategy.settings.disable_rich_ohlcv = True
    strategy.settings.max_ohlcv_size = 10*3
    strategy.risk.max_position_size = 0.1
    strategy.start()
Exemple #2
0
                strategy.cancel('L close')
                strategy.cancel('S close')
                for size, width, suffix, period in pairs:
                    if buymax+size <= maxsize:
                        strategy.order('L'+suffix, 'buy', qty=size, limit=int(mid-width+ofs),
                            seconds_to_keep_order=period, minute_to_expire=1)
                        buymax += size
                    else:
                        strategy.cancel('L'+suffix)
                    if sellmax-size >= -maxsize:
                        strategy.order('S'+suffix, 'sell', qty=size, limit=int(mid+width+ofs),
                            seconds_to_keep_order=period, minute_to_expire=1)
                        sellmax -= size
                    else:
                        strategy.cancel('S'+suffix)
        else:
            strategy.cancel_order_all()
            strategy.close_position()


if __name__ == "__main__":
    from . import settings

    strategy = Strategy(simple_market_maker().loop, 5)
    strategy.settings.apiKey = settings.apiKey
    strategy.settings.secret = settings.secret
    strategy.settings.max_ohlcv_size = 12*20
    strategy.settings.disable_rich_ohlcv = True
    strategy.risk.max_position_size = 0.06
    strategy.start()
Exemple #3
0
                               qty=qty_lot,
                               limit=bid + 1,
                               minute_to_expire=1)
            else:
                strategy.cancel('L')
            if spr >= spr_target or strategy.position_size > 0:
                strategy.order('S',
                               'sell',
                               qty=qty_lot,
                               limit=ask - 1,
                               minute_to_expire=1)
            else:
                strategy.cancel('S')


if __name__ == "__main__":
    from . import settings
    import logging
    import logging.config

    logging.config.dictConfig(settings.loggingConf('spcatcher.log'))
    logger = logging.getLogger("spcatcher")

    strategy = Strategy(spcatcher().loop, 5)
    # strategy.settings.symbol = 'BTCJPY28DEC2018'
    strategy.settings.apiKey = settings.apiKey
    strategy.settings.secret = settings.secret
    strategy.settings.show_last_n_orders = 10
    strategy.risk.max_position_size = 0.05
    strategy.start()
Exemple #4
0
                            pnl = mid - price
                            if pnl <= loss or pnl >= profit:
                                strategy.order('C%f' % price, 'sell', qty=size)
                        else:
                            pnl = price - mid
                            if pnl <= loss or pnl >= profit:
                                strategy.order('C%f' % price, 'buy', qty=size)
            else:
                strategy.cancel_order_all()
                strategy.close_position()
        else:
            strategy.cancel_order_all()
            strategy.close_position()


if __name__ == "__main__":
    from . import settings
    import logging
    import logging.config

    logging.config.dictConfig(settings.loggingConf('fraction.log'))
    logger = logging.getLogger("fraction")

    strategy = Strategy(fraction().loop, 0.5)
    strategy.settings.apiKey = settings.apiKey
    strategy.settings.secret = settings.secret
    strategy.settings.max_ohlcv_size = 30
    strategy.settings.disable_rich_ohlcv = True
    strategy.risk.max_position_size = 0.1
    strategy.start()
Exemple #5
0
            if sell_entry and strategy.position_size >= 0:
                strategy.cancel('L exit')
                strategy.entry('S', 'sell', qty=qty_lot)
        else:
            strategy.cancel('L')
            strategy.cancel('S')
            if position.currentQty > 0:
                strategy.order('L exit suspended',
                               'sell',
                               qty=position.currentQty)
            elif position.currentQty < 0:
                strategy.order('S exit suspended',
                               'buy',
                               qty=-position.currentQty)


if __name__ == "__main__":
    from . import settings
    import argparse
    import logging
    import logging.config

    logging.basicConfig(level=logging.INFO)
    logger = logging.getLogger("volbot")

    strategy = Strategy(Volbot().loop, 1)
    strategy.settings.apiKey = settings.apiKey
    strategy.settings.secret = settings.secret
    strategy.risk.max_position_size = 0.01
    strategy.start()
Exemple #6
0
                           qty=max(0.02 * z, 0.01),
                           limit=int(buy),
                           limit_mask=rng * 0.5,
                           minute_to_expire=1)
            strategy.order('S',
                           'sell',
                           qty=max(0.02 * -z, 0.01),
                           limit=int(sell),
                           limit_mask=rng * 0.5,
                           minute_to_expire=1)
        else:
            strategy.cancel_order_all()
            strategy.close_position()


if __name__ == "__main__":
    from . import settings
    import logging
    import logging.config

    logging.config.dictConfig(settings.loggingConf('hft.log'))
    logger = logging.getLogger("hft")

    strategy = Strategy(hft().loop, 0.5)
    strategy.settings.apiKey = settings.apiKey
    strategy.settings.secret = settings.secret
    strategy.settings.disable_rich_ohlcv = True
    strategy.settings.max_ohlcv_size = 1000
    strategy.risk.max_position_size = 0.1
    strategy.start()
Exemple #7
0
            'buy/sell {bid_20pct}/{ask_20pct} bid/ask {bid}/{ask}({spr})'.
            format(**locals()))

        qty_lot = 1
        strategy.entry('L',
                       'buy',
                       qty=qty_lot,
                       limit=bid_20pct,
                       minute_to_expire=1)
        strategy.entry('S',
                       'sell',
                       qty=qty_lot,
                       limit=ask_20pct,
                       minute_to_expire=1)


if __name__ == "__main__":
    from . import settings
    import logging
    import logging.config

    logging.basicConfig(level=logging.INFO)
    logger = logging.getLogger("LossCut")

    strategy = Strategy(LossCut().loop, 60)
    strategy.settings.symbol = 'BTCJPY28DEC2018'
    strategy.settings.apiKey = settings.apiKey
    strategy.settings.secret = settings.secret
    strategy.risk.max_position_size = 1
    strategy.start()
Exemple #8
0
                                   limit=ticker.best_bid,
                                   time_in_force='FOK')
                    self.next_order_accept_time = t + self.min_order_interval
                    showlog = True

        if showlog:
            logger.info(
                '{cur_time} {fx_delay:.4f} {btc_delay:.4f}'.format(**locals()))
            logger.info(
                'SFD {sfdpct:.4f}({sfdpct_bid:.4f}/{sfdpct_ask:.4f}) '
                'FX ltp[bid/ask] {fx_ltp} {fx_exec_side:<4}({fx_exec_cnt})[{ticker[best_bid]:.0f}({ticker[best_bid_size]:6.2f})/{ticker[best_ask]:.0f}({ticker[best_ask_size]:6.2f})] '
                'BTC ltp[bid/ask] {btc_ltp:.0f}[{ticker_btcjpy[best_bid]:.0f}/{ticker_btcjpy[best_ask]:.0f}]'
                .format(**locals()))


if __name__ == "__main__":
    from . import settings
    import argparse
    import logging
    import logging.config

    logging.basicConfig(level=logging.INFO)
    logger = logging.getLogger("SFDBot")

    strategy = Strategy(SFDBot().loop, 0.0)
    strategy.settings.apiKey = settings.apiKey
    strategy.settings.secret = settings.secret
    strategy.settings.disable_ohlcv = True
    strategy.risk.max_position_size = 0.01
    strategy.start()
Exemple #9
0
                                   limit=max(limit_sell, ask + 1),
                                   minute_to_expire=1)

                # 注文キャンセル完了してから次の注文を出す
                # # if o.status == 'open':
                # #     if abs(o.price - limit_buy)>spread*0.333:
                # #         strategy.cancel('L')
                # # elif o.status == 'closed' or o.status == 'canceled':
                # #     strategy.order('L', 'buy', qty=qty_lot, limit=min(limit_buy, bid-1), minute_to_expire=1)
                # # if o.status == 'open':
                # #     if abs(o.price - limit_sell)>spread*0.333:
                # #         strategy.cancel('S')
                # # elif o.status == 'closed' or o.status == 'canceled':
                # #     strategy.order('S', 'sell', qty=qty_lot, limit=max(limit_sell, ask+1), minute_to_expire=1)

        else:
            for no in range(self.maxslots):
                strategy.cancel('L' + str(no))
                strategy.cancel('S' + str(no))
            if strategy.position_size > 0:
                strategy.order('L close', 'sell', qty=strategy.position_size)
            elif strategy.position_size < 0:
                strategy.order('S close', 'buy', qty=-strategy.position_size)


if __name__ == "__main__":
    strategy = Strategy(MMBot)
    strategy.settings.show_last_n_orders = 10
    strategy.risk.max_position_size = 0.05
    strategy.start()