Working and relatively glitch free. Classes implemented in python and javascript. UML class diagram. roughed in for both python and javascript.Bit of sequence uml. signals ready for implementation
This commit is contained in:
parent
f6e1b848d2
commit
0a49a52383
|
|
@ -1,6 +1,8 @@
|
|||
from binance.enums import *
|
||||
import yaml
|
||||
|
||||
from indicators import Indicators
|
||||
|
||||
|
||||
class Configuration:
|
||||
def __init__(self):
|
||||
|
|
@ -19,8 +21,8 @@ class Configuration:
|
|||
# The name of the file that stores saved_data
|
||||
self.config_FN = 'config.yml'
|
||||
|
||||
# A list of all the indicators available. This is injected later.
|
||||
self.indicator_list = None
|
||||
# Call a static method from indicators that fills in a default list of indicators in config.
|
||||
self.indicator_list = Indicators.get_indicator_defaults()
|
||||
|
||||
# The data that will be saved and loaded from file .
|
||||
self.saved_data = None
|
||||
|
|
@ -23,7 +23,7 @@ class Candles:
|
|||
self.latest_vol = []
|
||||
|
||||
# Set the instance variable of candlesticks, latest_close_values, high, low, closing, volume, and last_candle
|
||||
self.set_candle_history()
|
||||
self.set_candle_history(symbol=config.trading_pair, interval=config.chart_interval)
|
||||
|
||||
def set_new_candle(self, cdata):
|
||||
self.last_candle = cdata
|
||||
|
|
@ -92,12 +92,14 @@ class Candles:
|
|||
max_data_loaded = self.max_data_loaded
|
||||
if not symbol:
|
||||
symbol = self.config.trading_pair
|
||||
print(f'set_candle_history(): No symbol provided. Using{symbol}')
|
||||
if not interval:
|
||||
interval = self.config.chart_interval
|
||||
print(f'set_candle_history(): No interval provided. Using{interval}')
|
||||
if self.candlesticks:
|
||||
print(f'set_candle_history(): Reloading candle data for :{interval}')
|
||||
print(f'set_candle_history(): Reloading {interval} candles.')
|
||||
else:
|
||||
print('set_candle_history(): Loading candle data')
|
||||
print(f'set_candle_history(): Loading {interval} candles.')
|
||||
# Load candles from file
|
||||
cdata = self.load_candle_history(symbol, interval)
|
||||
# Trim the beginning of the returned list to size of max_data_loaded of less
|
||||
|
|
|
|||
|
|
@ -0,0 +1,78 @@
|
|||
config:
|
||||
chart_interval: 1d
|
||||
trading_pair: BTCUSDT
|
||||
indicator_list:
|
||||
Bolenger:
|
||||
color_1: '#5ad858'
|
||||
color_2: '#f0f664'
|
||||
color_3: '#5ad858'
|
||||
devdn: 2
|
||||
devup: 2
|
||||
ma: 1
|
||||
period: 20
|
||||
type: BOLBands
|
||||
value: 0
|
||||
value1: '38691.58'
|
||||
value2: '38552.36'
|
||||
value3: '38413.14'
|
||||
visible: 'True'
|
||||
EMA 100:
|
||||
color: '#286006'
|
||||
period: 100
|
||||
type: EMA
|
||||
value: 0
|
||||
visible: true
|
||||
EMA 50:
|
||||
color: '#fe534c'
|
||||
period: 50
|
||||
type: EMA
|
||||
value: 0
|
||||
visible: true
|
||||
New Indicator4:
|
||||
color_1: '#2f1bc6'
|
||||
color_2: '#3e79cb'
|
||||
fast_p: 12
|
||||
hist: 0
|
||||
macd: 0
|
||||
signal: 0
|
||||
signal_p: 9
|
||||
slow_p: 26
|
||||
type: MACD
|
||||
value: 0
|
||||
visible: true
|
||||
RSI 14:
|
||||
color: '#07120c'
|
||||
period: 14
|
||||
type: RSI
|
||||
value: 0
|
||||
visible: true
|
||||
RSI 8:
|
||||
color: '#4c4fe9'
|
||||
period: 8
|
||||
type: RSI
|
||||
value: 0
|
||||
visible: true
|
||||
SMA 200:
|
||||
color: '#cdc178'
|
||||
period: 200
|
||||
type: SMA
|
||||
value: 0
|
||||
visible: true
|
||||
SMA 21:
|
||||
color: '#2847ce'
|
||||
period: 21
|
||||
type: SMA
|
||||
value: 0
|
||||
visible: true
|
||||
indicator 5:
|
||||
color: '#13cbec'
|
||||
nameww: valueww
|
||||
period: 20
|
||||
test222: 2222222
|
||||
type: LREG
|
||||
value: '30302.05'
|
||||
visible: 'True'
|
||||
vol:
|
||||
type: Volume
|
||||
value: 0
|
||||
visible: true
|
||||
14
data.py
14
data.py
|
|
@ -2,7 +2,7 @@ from binance.client import Client
|
|||
|
||||
import config
|
||||
from candles import Candles
|
||||
from config_states import Configuration
|
||||
from Configuration import Configuration
|
||||
from exchange_info import ExchangeInfo
|
||||
from indicators import Indicators
|
||||
|
||||
|
|
@ -15,8 +15,7 @@ class BrighterData:
|
|||
|
||||
# Configuration and settings for the user interface and charts
|
||||
self.config = Configuration()
|
||||
# Call a static method from indicators that fills in a default list of indicators in config.
|
||||
self.config.set_indicator_list(Indicators.get_indicator_defaults())
|
||||
|
||||
# Load any saved data from file
|
||||
self.config.config_and_states('load')
|
||||
|
||||
|
|
@ -24,7 +23,7 @@ class BrighterData:
|
|||
self.candles = Candles(self.config, self.client)
|
||||
|
||||
# Object that interacts with and maintains data from available indicators
|
||||
self.indicators = Indicators(self.candles)
|
||||
self.indicators = Indicators(self.candles, self.config)
|
||||
|
||||
# Object that maintains exchange and account data
|
||||
self.exchange_info = ExchangeInfo(self.client)
|
||||
|
|
@ -56,12 +55,11 @@ class BrighterData:
|
|||
|
||||
def received_cdata(self, cdata):
|
||||
# If this is the first candle received,
|
||||
# then just set last_candle and return.
|
||||
# then set last_candle. Then set a new candle.
|
||||
if not self.candles.last_candle:
|
||||
self.candles.last_candle = cdata
|
||||
return
|
||||
# If this candle is the same as last candle return nothing to do.
|
||||
if cdata['time']:
|
||||
elif cdata['time']:
|
||||
if cdata['time'] == self.candles.last_candle['time']:
|
||||
return
|
||||
|
||||
|
|
@ -75,6 +73,6 @@ class BrighterData:
|
|||
if 'sigName' not in data:
|
||||
return 'data.py:received_new_signal() - The new signal has no name. '
|
||||
print(data)
|
||||
|
||||
# TODO lets go!
|
||||
|
||||
app_data = BrighterData()
|
||||
|
|
|
|||
|
|
@ -4,25 +4,20 @@ import talib
|
|||
|
||||
|
||||
class Indicators:
|
||||
def __init__(self, candles):
|
||||
def __init__(self, candles, config):
|
||||
# Object containing Price and candle data.
|
||||
self.candles = candles
|
||||
# List of all available indicator types
|
||||
self.indicator_types = {}
|
||||
# todo: get rid of this use inheritance in classes instead.
|
||||
self.indicator_types = {'simple_indicators': ['RSI', 'SMA', 'EMA', 'LREG'],
|
||||
'other': ['Volume', 'BOLBands', 'MACD', 'ATR']}
|
||||
|
||||
# List of all available indicators
|
||||
self.indicator_list = None
|
||||
# Add default indicators and their default values to self.indicator_list
|
||||
self.set_indicator_defaults()
|
||||
self.indicator_list = config.indicator_list
|
||||
|
||||
# A list of values to use with bolenger bands
|
||||
self.bb_ma_val = {'SMA': 0, 'EMA': 1, 'WMA': 2, 'DEMA': 3, 'TEMA': 4, 'TRIMA': 5, 'KAMA': 6, 'MAMA': 7, 'T3': 8}
|
||||
|
||||
def set_indicator_defaults(self):
|
||||
self.indicator_list = self.get_indicator_defaults()
|
||||
# todo: get rid of this they are not needed after utilizing ingheritance in classes instead.
|
||||
self.indicator_types = {'simple_indicators': ['RSI', 'SMA', 'EMA', 'LREG'],
|
||||
'other': ['Volume', 'BOLBands', 'MACD', 'ATR']}
|
||||
|
||||
@staticmethod
|
||||
def get_indicator_defaults():
|
||||
"""Set the default settings for each indicator"""
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ class Comms {
|
|||
return id;
|
||||
}
|
||||
send_to_app(message_type, data){
|
||||
console.log( JSON.stringify({ message_type: message_type, data : data }));
|
||||
this.app_con.send( JSON.stringify({ message_type: message_type, data : data }));
|
||||
}
|
||||
set_app_con(){
|
||||
|
|
|
|||
|
|
@ -153,23 +153,18 @@ class Signals {
|
|||
var sigType = document.getElementById('select_s_type').value; // The type of signal value or indicator comparison.
|
||||
var value = document.getElementById('value').value; // The input value if it is a value comparison.
|
||||
|
||||
var sigName = {sigName : sigName}; // Name_of_signal
|
||||
var sigSource = {sigSource : sigSource}; // First_signal_indicator.
|
||||
var sigProp = {sigProp : sigProp}; // First_signal_property.
|
||||
var operator = {operator : operator}; // Operator.
|
||||
|
||||
if (sigType == 'Comparison'){
|
||||
var sig2Source = {sig2Source: sig2Source};
|
||||
var sig2Prop = {sig2Prop : sig2Prop};
|
||||
var sig2Source = sig2Source;
|
||||
var sig2Prop = sig2Prop;
|
||||
}else{
|
||||
var sig2Source = {sig2Source: value};
|
||||
var sig2Prop = {value: value};
|
||||
var sig2Source = 'value';
|
||||
var sig2Prop = value;
|
||||
}
|
||||
if (operator == "'operator' : '+/-'" ){
|
||||
if (operator == "+/-" ){
|
||||
var range = {range : range};
|
||||
var data = [sigName, sigSource, sigProp, operator, sig2Source, sig2Prop, range];
|
||||
var data = {sigName, sigSource, sigProp, operator, sig2Source, sig2Prop, range};
|
||||
}else{
|
||||
var data = [sigName, sigSource, sigProp, operator, sig2Source, sig2Prop];
|
||||
var data = {sigName, sigSource, sigProp, operator, sig2Source, sig2Prop};
|
||||
}
|
||||
/* It may be more maintainable to configure the connection inside the different classes
|
||||
than passing functions, references and callbacks around. */
|
||||
|
|
|
|||
Loading…
Reference in New Issue