mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-11 11:16:15 +08:00
BLD: Housekeeping
This commit is contained in:
@@ -38,8 +38,8 @@ def initialize(context):
|
||||
context.base_price = None
|
||||
context.current_day = None
|
||||
|
||||
context.RSI_OVERSOLD = 65
|
||||
context.RSI_OVERBOUGHT = 82
|
||||
context.RSI_OVERSOLD = 30
|
||||
context.RSI_OVERBOUGHT = 80
|
||||
context.CANDLE_SIZE = '5T'
|
||||
|
||||
context.start_time = time.time()
|
||||
@@ -98,9 +98,10 @@ def handle_data(context, data):
|
||||
# a parameter of the analyze() function for further analysis.
|
||||
|
||||
record(
|
||||
volume=(context.market, current['volume']),
|
||||
price_change=(context.market, price_change),
|
||||
rsi=(context.market, rsi[-1]),
|
||||
volume=current['volume'],
|
||||
price=price,
|
||||
price_change=price_change,
|
||||
rsi=rsi[-1],
|
||||
cash=cash
|
||||
)
|
||||
# We are trying to avoid over-trading by limiting our trades to
|
||||
@@ -108,6 +109,7 @@ def handle_data(context, data):
|
||||
if context.traded_today:
|
||||
return
|
||||
|
||||
# TODO: retest with open orders
|
||||
# Since we are using limit orders, some orders may not execute immediately
|
||||
# we wait until all orders are executed before considering more trades.
|
||||
orders = get_open_orders(context.market)
|
||||
|
||||
@@ -30,15 +30,17 @@ from catalyst.protocol import Account
|
||||
|
||||
# Trying to account for REST api instability
|
||||
# https://stackoverflow.com/questions/15431044/can-i-set-max-retries-for-requests-request
|
||||
from catalyst.utils.deprecate import deprecated
|
||||
|
||||
requests.adapters.DEFAULT_RETRIES = 20
|
||||
|
||||
BITFINEX_URL = 'https://api.bitfinex.com'
|
||||
|
||||
|
||||
log = Logger('Bitfinex', level=LOG_LEVEL)
|
||||
warning_logger = Logger('AlgoWarning')
|
||||
|
||||
|
||||
@deprecated
|
||||
class Bitfinex(Exchange):
|
||||
def __init__(self, key, secret, base_currency, portfolio=None):
|
||||
self.url = BITFINEX_URL
|
||||
@@ -666,11 +668,11 @@ class Bitfinex(Exchange):
|
||||
"""
|
||||
url = ('{url}/v2/candles/trade:1D:{symbol}/hist?start={start}'
|
||||
'&end={end}').format(
|
||||
url=self.url,
|
||||
symbol=symbol_v2,
|
||||
start=startmonth - 3600 * 24 * 31 * 1000,
|
||||
end=min(startmonth + 3600 * 24 * 31 * 1000,
|
||||
int(time.time() * 1000)))
|
||||
url=self.url,
|
||||
symbol=symbol_v2,
|
||||
start=startmonth - 3600 * 24 * 31 * 1000,
|
||||
end=min(startmonth + 3600 * 24 * 31 * 1000,
|
||||
int(time.time() * 1000)))
|
||||
|
||||
try:
|
||||
self.ask_request()
|
||||
|
||||
@@ -19,12 +19,14 @@ from catalyst.finance.execution import LimitOrder, StopLimitOrder
|
||||
from catalyst.finance.order import Order, ORDER_STATUS
|
||||
|
||||
# TODO: consider using this: https://github.com/mondeja/bittrex_v2
|
||||
from catalyst.utils.deprecate import deprecated
|
||||
|
||||
log = Logger('Bittrex', level=LOG_LEVEL)
|
||||
|
||||
URL2 = 'https://bittrex.com/Api/v2.0'
|
||||
|
||||
|
||||
@deprecated
|
||||
class Bittrex(Exchange):
|
||||
def __init__(self, key, secret, base_currency, portfolio=None):
|
||||
self.api = Bittrex_api(key=key, secret=secret)
|
||||
|
||||
@@ -28,10 +28,12 @@ from catalyst.exchange.poloniex.poloniex_api import Poloniex_api
|
||||
from catalyst.finance.order import Order, ORDER_STATUS
|
||||
from catalyst.finance.transaction import Transaction
|
||||
from catalyst.protocol import Account
|
||||
from catalyst.utils.deprecate import deprecated
|
||||
|
||||
log = Logger('Poloniex', level=LOG_LEVEL)
|
||||
|
||||
|
||||
@deprecated
|
||||
class Poloniex(Exchange):
|
||||
def __init__(self, key, secret, base_currency, portfolio=None):
|
||||
self.api = Poloniex_api(key=key, secret=secret)
|
||||
@@ -292,8 +294,8 @@ class Poloniex(Exchange):
|
||||
"""
|
||||
exchange_symbol = self.get_symbol(asset)
|
||||
|
||||
if(isinstance(style, ExchangeLimitOrder)
|
||||
or isinstance(style, ExchangeStopLimitOrder)):
|
||||
if (isinstance(style, ExchangeLimitOrder)
|
||||
or isinstance(style, ExchangeStopLimitOrder)):
|
||||
if isinstance(style, ExchangeStopLimitOrder):
|
||||
log.warn('{} will ignore the stop price'.format(self.name))
|
||||
|
||||
|
||||
@@ -4,10 +4,12 @@ from base import BaseExchangeTestCase
|
||||
from catalyst.exchange.bitfinex.bitfinex import Bitfinex
|
||||
from catalyst.exchange.exchange_utils import get_exchange_auth
|
||||
from catalyst.finance.execution import (LimitOrder)
|
||||
from catalyst.utils.deprecate import deprecated
|
||||
|
||||
log = Logger('test_bitfinex')
|
||||
|
||||
|
||||
@deprecated
|
||||
class TestBitfinex(BaseExchangeTestCase):
|
||||
@classmethod
|
||||
def setup(self):
|
||||
|
||||
@@ -4,10 +4,12 @@ from catalyst.finance.order import Order
|
||||
from base import BaseExchangeTestCase
|
||||
from logbook import Logger
|
||||
from catalyst.exchange.exchange_utils import get_exchange_auth
|
||||
from catalyst.utils.deprecate import deprecated
|
||||
|
||||
log = Logger('test_bittrex')
|
||||
|
||||
|
||||
@deprecated
|
||||
class TestBittrex(BaseExchangeTestCase):
|
||||
@classmethod
|
||||
def setup(self):
|
||||
|
||||
@@ -4,11 +4,14 @@ from base import BaseExchangeTestCase
|
||||
from logbook import Logger
|
||||
from catalyst.exchange.exchange_utils import get_exchange_auth
|
||||
import pandas as pd
|
||||
|
||||
from catalyst.utils.deprecate import deprecated
|
||||
from test_utils import output_df
|
||||
|
||||
log = Logger('test_poloniex')
|
||||
|
||||
|
||||
@deprecated
|
||||
class TestPoloniex(BaseExchangeTestCase):
|
||||
@classmethod
|
||||
def setup(self):
|
||||
|
||||
Reference in New Issue
Block a user