From 47a104b29c4cc4a15212ab8182fb317c652ff517 Mon Sep 17 00:00:00 2001 From: reinka Date: Sat, 21 Oct 2017 11:26:34 +0200 Subject: [PATCH] [MIG] Migrated to version 0.3 to work with Poloniex exchange. --- catalyst/examples/buy_and_hodl.py | 8 ++++---- catalyst/examples/buy_low_sell_high.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/catalyst/examples/buy_and_hodl.py b/catalyst/examples/buy_and_hodl.py index b3f411f4..b2b6a7ec 100644 --- a/catalyst/examples/buy_and_hodl.py +++ b/catalyst/examples/buy_and_hodl.py @@ -24,7 +24,7 @@ from catalyst.api import ( ) def initialize(context): - context.ASSET_NAME = 'USDT_BTC' + context.ASSET_NAME = 'BTC_USDT' context.TARGET_HODL_RATIO = 0.8 context.RESERVE_RATIO = 1.0 - context.TARGET_HODL_RATIO @@ -49,14 +49,14 @@ def handle_data(context, data): orders = get_open_orders(context.asset) or [] for order in orders: cancel_order(order) - + # Stop buying after passing the reserve threshold cash = context.portfolio.cash if cash <= reserve_value: context.is_buying = False # Retrieve current asset price from pricing data - price = data[context.asset].price + price = data.current(context.asset, 'price') # Check if still buying and could (approximately) afford another purchase if context.is_buying and cash > price: @@ -70,7 +70,7 @@ def handle_data(context, data): record( price=price, - volume=data[context.asset].volume, + volume=data.current(context.asset, 'volume'), cash=cash, starting_cash=context.portfolio.starting_cash, leverage=context.account.leverage, diff --git a/catalyst/examples/buy_low_sell_high.py b/catalyst/examples/buy_low_sell_high.py index feadf49b..acf481e0 100644 --- a/catalyst/examples/buy_low_sell_high.py +++ b/catalyst/examples/buy_low_sell_high.py @@ -27,7 +27,7 @@ log = Logger(algo_namespace) def initialize(context): log.info('initializing algo') - context.ASSET_NAME = 'XRP_USD' + context.ASSET_NAME = 'XRP_USDT' context.asset = symbol(context.ASSET_NAME) context.TARGET_POSITIONS = 5000