def get_private(cls) -> PoloniexPrivateAPI: if cls._private is None: cls._private = PoloniexPrivateAPI( key=config.read_string('poloniex.key'), secret=config.read_string('poloniex.secret'), ) return cls._private
def get_client(cls): if cls._client is None: cls._client = _Poloniex( config.read_string('poloniex.key', default=None), config.read_string('poloniex.secret', default=None), ) return cls._client
def get_client(cls): if cls._client is None: host = config.read_string('postgres.host') port = config.read_int('postgres.port') user = config.read_string('postgres.username') pswd = config.read_string('postgres.password') dbname = config.read_string('postgres.dbname') cls._client = psycopg2.connect( host=host, port=port, dbname=dbname, user=user, password=pswd, ) return cls._client
def main(args): load_config(args.config) fiat = config.read_string('trading.fiat') strategy = strategies[args.strategy]( fiat, config.read_int('trading.interval'), ) adapter = LiveMarketAdapter(MarketHistory(), fiat) fund = Fund(strategy, adapter) fund.run_live()
def test_strategies(expected_results): ''' Strategies should produce their expected values ''' # The start and end of our test period start = '2017-05-01' end = '2017-06-01' fiat = config.read_string('trading.fiat') interval = config.read_int('trading.interval') for expected in expected_results: strategy = expected['strategy'](fiat, interval) adapter = BacktestMarketAdapter( MarketHistoryMock(), {'BTC': 1.0}, fiat, ) fund = Fund(strategy, adapter) res = list(fund.begin_backtest(start, end)) # print(res) assert res == expected['values']
def main(args): load_config(args.config) fiat = config.read_string('trading.fiat') strategy = strategies[args.strategy]( fiat, config.read_int('trading.interval'), ) # TODO: Shouldn't be necessary to provide initial balances for live trading adapter = PoloniexMarketAdapter( fiat, MarketHistory(), {}, # Actual balances will be fetched from Poloniex ) fund = Fund(strategy, adapter) if args.force_rebalance is True: confirm = input('Are you sure you want to rebalance your fund? [y/N] ') if confirm.strip().lower() == 'y': fund.force_rebalance_next_step = True fund.run_live()
def main(args): load_config(args.config) fiat = config.read_string('trading.fiat') strategy = strategies[args.strategy]( fiat, config.read_int('trading.interval'), ) adapter = BacktestMarketAdapter( fiat, MarketHistory(), {'BTC': 1.0}, ) fund = Fund(strategy, adapter) summary = evaluate( fund, '2017-01-01', '2017-06-29', duration_days=30, window_distance_days=14, ) print(summary)