48 lines
1.9 KiB
Python
48 lines
1.9 KiB
Python
import json
|
|
|
|
from Configuration import Configuration
|
|
from DataCache import DataCache
|
|
from candles import Candles
|
|
from ExchangeInterface import ExchangeInterface
|
|
from indicators import Indicators
|
|
|
|
ALPACA_API_KEY = 'PKPSH7OHWH3Q5AUBZBE5'
|
|
ALPACA_API_SECRET = 'dVy0AgQBgGV52cpwenTqAQcr1IGj7whkEEjPY6HB'
|
|
|
|
|
|
def test_indicators():
|
|
# Object that interacts and maintains exchange_interface and account data
|
|
exchanges = ExchangeInterface()
|
|
# Object that interacts with the persistent data.
|
|
data = DataCache(exchanges)
|
|
|
|
# Configuration and settings for the user app and charts
|
|
config = Configuration(cache=data)
|
|
|
|
# Object that maintains candlestick and price data.
|
|
candles = Candles(config_obj=config, exchanges=exchanges, database=data)
|
|
|
|
# Object that interacts with and maintains data from available indicators
|
|
ind_obj = Indicators(candles, config)
|
|
|
|
user_name = 'guest'
|
|
exchanges.connect_exchange('alpaca', user_name=user_name, api_keys={'key': ALPACA_API_KEY,
|
|
'secret': ALPACA_API_SECRET})
|
|
|
|
ind_obj.load_indicators(user_name)
|
|
en_inds = ind_obj.get_enabled_indicators(user_name)
|
|
all_inds = ind_obj.get_indicator_list(user_name)
|
|
print(en_inds)
|
|
print(all_inds)
|
|
# volume_ind = all_inds.query("name=='EMA 5'").iloc[0]
|
|
# a = ind_obj.process_indicator(indicator=volume_ind, num_results=10)
|
|
# print(a)
|
|
source = {'user_name': 'guest_226', 'market': {'exchange': 'alpaca', 'timeframe': '5m', 'market': 'BTC/USD'}}
|
|
b = ind_obj.get_indicator_data(user_name=user_name, source=source)
|
|
print(b)
|
|
# src = {'symbol': 'BTC/USD', 'timeframe': '5m', 'exchange': 'alpaca'}
|
|
# specific_property = {'period': 8, 'visible': True, 'color': '#241571', 'value': 0}
|
|
# ind_obj.create_indicator(creator=user_name, name='RSI 8', kind='RSI', source=src, properties=specific_property)
|
|
|
|
assert not en_inds.empty and all_inds is not None
|