forked from scrtlabs/catalyst
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
108 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import pytz | ||
from datetime import datetime | ||
from catalyst.api import symbol | ||
from catalyst.utils.run_algo import run_algorithm | ||
|
||
coin = 'btc' | ||
base_currency = 'usd' | ||
n_candles = 5 | ||
|
||
|
||
def initialize(context): | ||
context.symbol = symbol('%s_%s' % (coin, base_currency)) | ||
|
||
|
||
def handle_data_polo_partial_candles(context, data): | ||
history = data.history(symbol('btc_usdt'), ['volume'], | ||
bar_count=10, | ||
frequency='4H') | ||
print('\nnow: %s\n%s' % (data.current_dt, history)) | ||
if not hasattr(context, 'i'): | ||
context.i = 0 | ||
context.i += 1 | ||
if context.i > 5: | ||
raise Exception('stop') | ||
|
||
|
||
live = False | ||
|
||
if live: | ||
run_algorithm(initialize=lambda ctx: True, | ||
handle_data=handle_data_polo_partial_candles, | ||
exchange_name='poloniex', | ||
base_currency='usdt', | ||
algo_namespace='ns', | ||
live=True, | ||
data_frequency='minute', | ||
capital_base=3000) | ||
else: | ||
run_algorithm(initialize=lambda ctx: True, | ||
handle_data=handle_data_polo_partial_candles, | ||
exchange_name='poloniex', | ||
base_currency='usdt', | ||
algo_namespace='ns', | ||
live=False, | ||
data_frequency='minute', | ||
capital_base=3000, | ||
start=datetime(2018, 2, 2, 0, 0, 0, 0, pytz.utc), | ||
end=datetime(2018, 2, 20, 0, 0, 0, 0, pytz.utc) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import pytz | ||
from datetime import datetime | ||
from catalyst.api import symbol | ||
from catalyst.utils.run_algo import run_algorithm | ||
|
||
coin = 'btc' | ||
base_currency = 'usd' | ||
|
||
|
||
def initialize(context): | ||
context.symbol = symbol('%s_%s' % (coin, base_currency)) | ||
|
||
|
||
def handle_data_polo_partial_candles(context, data): | ||
history = data.history(symbol('btc_usdt'), ['volume'], | ||
bar_count=10, | ||
frequency='1D') | ||
print('\nnow: %s\n%s' % (data.current_dt, history)) | ||
if not hasattr(context, 'i'): | ||
context.i = 0 | ||
context.i += 1 | ||
if context.i > 5: | ||
raise Exception('stop') | ||
|
||
|
||
run_algorithm(initialize=lambda ctx: True, | ||
handle_data=handle_data_polo_partial_candles, | ||
exchange_name='poloniex', | ||
base_currency='usdt', | ||
algo_namespace='ns', | ||
live=False, | ||
data_frequency='minute', | ||
capital_base=3000, | ||
start=datetime(2018, 2, 2, 0, 0, 0, 0, pytz.utc), | ||
end=datetime(2018, 2, 20, 0, 0, 0, 0, pytz.utc)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters