def initialize(context): """ Define algorithm""" print "Initialize..." global TRAINING_STOCK, BACKTEST_STOCK context.security = None #becomes symbol(BACKTEST_STOCK) context.benchmark = symbol('SPY') context.training_data = loadTrainingData(TRAINING_TIME, TRAINING_STOCK) context.training_data_length = len(context.training_data) - 2 context.normalized_data = Manager.normalize(context.training_data) # will have to redo every time step target = Manager.getTargets(context.normalized_data) context.training_data = context.training_data[:-2] # delete last data entry, because it won't be used context.normalized_data = context.normalized_data[:-2] # delete last data entry, because it won't be used #print target #plt.figure("Training Data") #for i in range(len(context.normalized_data[0])): # plt.plot([x[i] for x in context.normalized_data]) #plt.legend(['open', 'high', 'low', 'close', 'volume', 'price'], loc='upper left') #plt.show() print "Train..." #print len(context.training_data), len(context.normalized_data), len(target) context.strategy = STRATEGY_CLASS([context.normalized_data], [target], num_epochs=EPOCHS) print "Capital Base: " + str(context.portfolio.cash)
def run_clusters(strategy_class, clustering_tickers, cluster_num, epochs_num, training_start, training_end, backtest_start, backtest_end, is_graph, is_elbow): """ Run the test given command-line args. Cluster. For each cluster, train a strategy on that cluster. For each stock in that cluster, run a backtest. Graph results. """ print "\nGathering data..." ticker_list, raw_stock_data_list = Manager.getRawStockDataList( clustering_tickers, training_start, training_end, 252) normalized_stock_data_list = [ Manager.preprocessData(x) for x in raw_stock_data_list ] print "\nClustering..." tickers, clusters = createClusters(ticker_list, normalized_stock_data_list, cluster_num) print "# of stocks: " + str(len(normalized_stock_data_list)) print "# of clusters: " + str(len(clusters)) print "" for t, c in itertools.izip(tickers, clusters): print "\tCluster: " + str(len(c)), "stocks: ", for symbol in t: print symbol, print "" if is_graph: graphClusters(clusters) if is_elbow: graphElbowMethod(normalized_stock_data_list) for t, cluster in itertools.izip(tickers, clusters): settings.STRATEGY_OBJECT = trainStrategy(strategy_class, cluster, epochs_num) for ticker in t: print "Cluster:", t print "Stock:", ticker tmp_ticks, tmp_data = Manager.getRawStockDataList([ticker], training_start, training_end, 252) settings.BACKTEST_STOCK = ticker settings.PRE_BACKTEST_DATA = tmp_data[0] print "Create Algorithm..." algo_obj = TradingAlgorithm(initialize=initialize, handle_data=handle_data) try: backtest_data = load_bars_from_yahoo(stocks=[ticker, 'SPY'], start=backtest_start, end=backtest_end) try: perf = algo_obj.run(backtest_data) analyze([ticker], [perf]) except ValueError, e: print str(e) except IOError, e: print "Stock Error: could not load", ticker, "from Yahoo." print "Only testing one cluster for now - Done!" return
def __init__(self): self.CONFIG_FILENAME = 'config/config.ini' self._config = None self._api = None self._gpsDevice = None self._accelDevice = None self._thermoDevice = None self._voltDevice = None self._baroDevice = None self._obdDevice = None self.read_configuration_file() self.configure_obd() self.configure_gps() self.configure_thermo() self.configure_acceleromenter() self.configure_volt() self.configure_baro() self._deviceList = DeviceCollection(thermoDevice=self._thermoDevice, gpsDevice=self._gpsDevice, accelDevice=self._accelDevice, voltDevice=self._voltDevice, baroDevice=self._baroDevice, obdDevice=self._obdDevice) self._manager = Manager(self._config, self._deviceList)
def parse(self): list = [] lines = self.data.splitlines() for line in lines: info = LibraryInfo() info.manager = Requirements.MANAGER_NAME has_version = False for operator in Requirements.VERSION_OPERATORS: if operator not in line: continue else: info.name = str(line.split(operator)[0]) info.version = operator + str(line.split(operator)[1]) has_version = True if not has_version: info.name = line if Manager.needIndex(): pipy = Pypi() index_info = pipy.get_library_info(info.name) if Manager.needLicense(): info.license = index_info.get('license') if Manager.needAuthor(): info.author = index_info.get('author') if Manager.needHpUrl(): info.homepage_url = index_info.get('homepage_url') if Manager.needCodeUrl(): info.code_url = index_info.get('code_url') list.append(info) return list
def main(): parser = argparse.ArgumentParser(description="Bridge the gap between IM platforms") parser.add_argument('-l', '--loglevel', dest='loglevel', default="info", help='Set log level(Default: info)') args = parser.parse_args() log.level(args.loglevel) m = Manager() s1 = SamplePlatform(m, "p1") s2 = SamplePlatform(m, "p2") m.add_im(s1) m.add_im(s2) m.run()
def run_clusters(strategy_class, clustering_tickers, cluster_num, epochs_num, training_start, training_end, backtest_start, backtest_end, is_graph, is_elbow): """ Run the test given command-line args. Cluster. For each cluster, train a strategy on that cluster. For each stock in that cluster, run a backtest. Graph results. """ print "\nGathering data..." ticker_list, raw_stock_data_list = Manager.getRawStockDataList(clustering_tickers, training_start, training_end, 252) normalized_stock_data_list = [Manager.preprocessData(x) for x in raw_stock_data_list] print "\nClustering..." tickers, clusters = createClusters(ticker_list, normalized_stock_data_list, cluster_num) print "# of stocks: " + str(len(normalized_stock_data_list)) print "# of clusters: " + str(len(clusters)) print "" for t, c in itertools.izip(tickers, clusters): print "\tCluster: " + str(len(c)), "stocks: ", for symbol in t: print symbol, print "" if is_graph: graphClusters(clusters) if is_elbow: graphElbowMethod(normalized_stock_data_list) for t, cluster in itertools.izip(tickers, clusters): settings.STRATEGY_OBJECT = trainStrategy(strategy_class, cluster, epochs_num) for ticker in t: print "Cluster:", t print "Stock:", ticker tmp_ticks, tmp_data = Manager.getRawStockDataList([ticker], training_start, training_end, 252) settings.BACKTEST_STOCK = ticker settings.PRE_BACKTEST_DATA = tmp_data[0] print "Create Algorithm..." algo_obj = TradingAlgorithm(initialize=initialize, handle_data=handle_data) try: backtest_data = load_bars_from_yahoo(stocks=[ticker, 'SPY'], start=backtest_start, end=backtest_end) try: perf = algo_obj.run(backtest_data) analyze([ticker], [perf]) except ValueError, e: print str(e) except IOError, e: print "Stock Error: could not load", ticker, "from Yahoo." print "Only testing one cluster for now - Done!" return
def handle_data(context, data): #assert context.portfolio.cash > 0.0, "ERROR: negative context.portfolio.cash" #assert len(context.raw_data) == context.training_data_length; "ERROR: " # data stored as (open, high, low, close, volume, price) feed_data = ([ data[context.security].open, data[context.security].high, data[context.security].low, data[context.security].close #data[context.security].volume, #data[context.security].close, ]) #keep track of history. context.raw_data.pop(0) context.raw_data.append(feed_data) context.normalized_data = Manager.preprocessData(context.raw_data)[:-2] prediction = context.strategy.predict(context.normalized_data)[-1] print "Value: $%.2f Cash: $%.2f Predict: %.5f" % (context.portfolio.portfolio_value, context.portfolio.cash, prediction[0]) # Do nothing if there are open orders: if has_orders(context, data): print('has open orders - doing nothing!') # Put entire position in elif prediction > 0.5: order_target_percent(context.security, .95) # Take entire position out else: order_target_percent(context.security, 0) #order_target_percent(context.security, -.99) record(BENCH=data[context.security].price) record(SPY=data[context.benchmark].price)
def get(self, userid): cursor = self.conn.cursor() query = "SELECT id, username, password, full_name, email FROM user WHERE id = ?" cursor.execute(query, (userid,)) manager = cursor.fetchone() cursor.close() return Manager(manager[0], manager[1], manager[2], manager[3], manager[4])
def handle_data(context, data): #assert context.portfolio.cash > 0.0, "ERROR: negative context.portfolio.cash" #assert len(context.raw_data) == context.training_data_length; "ERROR: " # data stored as (open, high, low, close, volume, price) feed_data = ([ data[context.security].open, data[context.security].high, data[context.security].low, data[context.security].close #data[context.security].volume, #data[context.security].close, ]) #keep track of history. context.raw_data.pop(0) context.raw_data.append(feed_data) context.normalized_data = Manager.preprocessData(context.raw_data)[:-2] prediction = context.strategy.predict(context.normalized_data)[-1] print "Value: $%.2f Cash: $%.2f Predict: %.5f" % ( context.portfolio.portfolio_value, context.portfolio.cash, prediction[0]) # Do nothing if there are open orders: if has_orders(context, data): print('has open orders - doing nothing!') # Put entire position in elif prediction > 0.5: order_target_percent(context.security, .95) # Take entire position out else: order_target_percent(context.security, 0) #order_target_percent(context.security, -.99) record(BENCH=data[context.security].price) record(SPY=data[context.benchmark].price)
def edit(self, userid, json): if json['username'] and json['email'] and json['full_name']: user = Manager(userid, json['username'], json['email'], 0, json['full_name']) manager = ManagerDAO().edit(user) return jsonify(Manager=manager.serialize()), OK else: return jsonify(Error='Unexpected attributes in post'), BAD_REQUEST
def initialize(context): print "Initialize..." context.security = symbol(settings.BACKTEST_STOCK) context.benchmark = symbol('SPY') context.strategy = settings.STRATEGY_OBJECT context.raw_data = settings.PRE_BACKTEST_DATA context.normalized_data = Manager.preprocessData(context.raw_data)[:-2] print "Backtest symbol:", context.security print "Capital Base:", context.portfolio.cash
def getByTeamID(self, tid): cursor = self.conn.cursor() query = "SELECT user.id, username, password, full_name, email FROM (user JOIN manages ON user.id = user_id) WHERE team_id = ? ORDER BY full_name" cursor.execute(query, (tid,)) result = cursor.fetchall() managers = [Manager(manager[0], manager[1], manager[2], manager[3], manager[4]) for manager in result] cursor.close() self.conn.close() return managers
def main(): """ Allows for switching easily between different tests using a different STRATEGY_CLASS. strategy_num: Must pick a STRATEGY_CLASS from the strategy_dict. """ strategy_dict = {1: TradingNet, 2: SVM, 3: NaiveBayes, 4: DeepNet} np.random.seed(13) parser = argparse.ArgumentParser() parser.add_argument("-n", "--strategy_num", default=1, type=int, choices=[key for key in strategy_dict]) #parser.add_argument("-t", "--training_time", default=1, type=int, choices=[year for year in range(1,2)]) #TODO #parser.add_argument("-b", "--backtest_time", default=1, type=int, choices=[year for year in range(1,2)]) #TODO parser.add_argument("-e", "--epochs_num", default=2000, type=int) parser.add_argument("-c", "--cluster_num", default=20, type=int, choices=[n for n in range(1, 25)]) #parser.add_argument("-z", "--is_normalize", action='store_false', help='Turn normalization off.') #parser.add_argument("-o", "--is_overfit", action='store_false', help='Perform test over training data.') parser.add_argument("-g", "--graph_clusters", action='store_true', help='Graph clusters.') parser.add_argument("-l", "--graph_elbow", action='store_true', help='Graph elbow method for clustering.') args = parser.parse_args() training_start = datetime(2014, 1, 1, 0, 0, 0, 0, pytz.utc) training_end = datetime(2015, 1, 1, 0, 0, 0, 0, pytz.utc) backtest_start = datetime(2015, 1, 1, 0, 0, 0, 0, pytz.utc) backtest_end = datetime(2016, 1, 1, 0, 0, 0, 0, pytz.utc) #IS_NORMALIZE = args.is_normalize #IS_OVERFIT = args.is_overfit print "Using:", str(strategy_dict[args.strategy_num]) #print "Train", training_time, "year,", "Test", backtest_time, "year." clustering_tickers = Manager.get_SP500() # get_DJIA() or get_SP500() run_clusters( strategy_class=strategy_dict[args.strategy_num], clustering_tickers=clustering_tickers, cluster_num=args.cluster_num, epochs_num=args.epochs_num, #training_time=args.training_time, #backtest_time=args.backtest_time, training_start=training_start, training_end=training_end, backtest_start=backtest_start, backtest_end=backtest_end, is_graph=args.graph_clusters, is_elbow=args.graph_elbow, ) sys.exit(0)
def getByUsername(self, username): cursor = self.conn.cursor() query = "SELECT user.id, username, password, full_name, email FROM user WHERE username = ?" cursor.execute(query, (username,)) result = cursor.fetchall() if result: managers = [Manager(manager[0], manager[1], manager[2], manager[3], manager[4]) for manager in result] return managers[0] else: return None
def main(parsed_args): manager = Manager() start_input_worker(manager, parsed_args.get_domain(), parsed_args.get_resolvers_filename(), parsed_args.get_subdomains_filename(), parsed_args.include_auth_ns()) start_dns_workers(manager, parsed_args.get_workers()) start_output_worker_and_wait_for(manager, parsed_args.get_output_filename(), parsed_args.get_output_mode())
def getAll(self): cursor = self.conn.cursor() query = "SELECT id, username, password, full_name, email FROM user" cursor.execute(query) result = cursor.fetchall() manager_tupl = [manager for manager in result] manager_obj = [Manager(manager[0], manager[1], manager[2], manager[3], manager[4]) for manager in manager_tupl] cursor.close() self.conn.close() return manager_obj
def parse(self): list = [] package = json.loads(self.data) for kinds in Package.PACKAGE_KINDS: if kinds not in package.keys(): continue for lib in package[kinds]: info = LibraryInfo() info.manager = Package.MANAGER_NAME info.name = lib info.version = package[kinds][lib] if Manager.needIndex(): npmjs = Npmjs() index_info = npmjs.get_library_info(info.name) if Manager.needLicense(): info.license = index_info.get('license') if Manager.needAuthor(): info.author = index_info.get('author') if Manager.needHpUrl(): info.homepage_url = index_info.get('homepage_url') if Manager.needCodeUrl(): info.code_url = index_info.get('code_url') list.append(info) return list
def handle_data(context, data): #print "Cash: $" + str(context.portfolio.cash), "Data: ", str(len(context.training_data)) #assert context.portfolio.cash > 0.0, "ERROR: negative context.portfolio.cash" assert len(context.training_data) == context.training_data_length; "ERROR: " context.security = symbol(BACKTEST_STOCK) # data stored as (open, high, low, close, volume, price) if IS_NORMALIZE: feed_data = ([ data[context.security].open - data[context.security].open, data[context.security].high - data[context.security].open, data[context.security].low - data[context.security].open, data[context.security].close - data[context.security].open #data[context.security].volume, #data[context.security].close, ]) else: feed_data = ([ data[context.security].open, data[context.security].high, data[context.security].low, data[context.security].close #data[context.security].volume, #data[context.security].close, ]) #keep track of history. context.training_data.pop(0) context.training_data.append(feed_data) context.normalized_data = Manager.normalize(context.training_data) # will have to redo every time step #print len(context.training_data), len(context.normalized_data), len(context.normalized_data[0]) prediction = context.strategy.predict(context.training_data)[-1] print "Value: $%.2f Cash: $%.2f Predict: %.5f" % (context.portfolio.portfolio_value, context.portfolio.cash, prediction[0]) # Do nothing if there are open orders: if has_orders(context, data): print('has open orders - doing nothing!') # Put entire position in elif prediction > 0.5: order_target_percent(context.security, .98) # Take entire position out else: order_target_percent(context.security, 0) #order_target_percent(context.security, -.99) record(BENCH=data[context.security].price) record(SPY=data[context.benchmark].price)
def main(): """ Allows for switching easily between different tests using a different STRATEGY_CLASS. strategy_num: Must pick a STRATEGY_CLASS from the strategy_dict. """ strategy_dict = { 1: TradingNet, 2: SVM, 3: NaiveBayes, 4: DeepNet } np.random.seed(13) parser = argparse.ArgumentParser() parser.add_argument("-n", "--strategy_num", default=1, type=int, choices=[key for key in strategy_dict]) #parser.add_argument("-t", "--training_time", default=1, type=int, choices=[year for year in range(1,2)]) #TODO #parser.add_argument("-b", "--backtest_time", default=1, type=int, choices=[year for year in range(1,2)]) #TODO parser.add_argument("-e", "--epochs_num", default=2000, type=int) parser.add_argument("-c", "--cluster_num", default=20, type=int, choices=[n for n in range(1, 25)]) #parser.add_argument("-z", "--is_normalize", action='store_false', help='Turn normalization off.') #parser.add_argument("-o", "--is_overfit", action='store_false', help='Perform test over training data.') parser.add_argument("-g", "--graph_clusters", action='store_true', help='Graph clusters.') parser.add_argument("-l", "--graph_elbow", action='store_true', help='Graph elbow method for clustering.') args = parser.parse_args() training_start = datetime(2014, 1, 1, 0, 0, 0, 0, pytz.utc) training_end = datetime(2015, 1, 1, 0, 0, 0, 0, pytz.utc) backtest_start = datetime(2015, 1, 1, 0, 0, 0, 0, pytz.utc) backtest_end = datetime(2016, 1, 1, 0, 0, 0, 0, pytz.utc) #IS_NORMALIZE = args.is_normalize #IS_OVERFIT = args.is_overfit print "Using:", str(strategy_dict[args.strategy_num]) #print "Train", training_time, "year,", "Test", backtest_time, "year." clustering_tickers = Manager.get_SP500() # get_DJIA() or get_SP500() run_clusters( strategy_class=strategy_dict[args.strategy_num], clustering_tickers=clustering_tickers, cluster_num=args.cluster_num, epochs_num=args.epochs_num, #training_time=args.training_time, #backtest_time=args.backtest_time, training_start=training_start, training_end=training_end, backtest_start=backtest_start, backtest_end=backtest_end, is_graph=args.graph_clusters, is_elbow=args.graph_elbow, ) sys.exit(0)
def register(self, json): if json['username'] and json['email'] and json['password'] and json[ 'full_name']: if not ManagerDAO().getByUsername(json['username']): # json['password'] = sha256_crypt.hash(json['password']) print(len(json['password'])) new_manager = Manager(0, json['username'], json['password'], json['full_name'], json['email']) manager = ManagerDAO().add(new_manager) return jsonify(isAuth=True, UserID=manager.user_id, Username=manager.username), CREATED else: return jsonify(Error='Username already in use'), BAD_REQUEST else: return jsonify( Error='Unexpected attributes in post request'), BAD_REQUEST pass
#!/usr/bin/python3 from manager.manager import Manager from feeds import V4L2Feed, VideoTestFeed, SvgFeed, ImageFeed, DskFeed import gi gi.require_version('Gst', '1.0') from gi.repository import Gst if __name__ == "__main__": Gst.init(None) manager = Manager(('localhost', 9999)) manager.register_feed_type(V4L2Feed, 'v4l2') manager.register_feed_type(VideoTestFeed, 'video_test') manager.register_feed_type(DskFeed, 'dsk', play_after_create=False) manager.create_feed(0, 'v4l2', '/dev/video0') manager.create_feed(1, 'video_test') manager.create_feed(2, 'video_test').set_pattern(1) manager.create_feed(3, 'video_test').set_pattern(18) dsk = manager.create_feed(8, 'dsk') dsk.create_slide('media/lower_third.svg', {'line1': 'New Headline'}) dsk.select_slide(0) dsk = manager.create_feed(9, 'dsk') dsk.create_slide('media/live.svg') dsk.select_slide(0) manager.start()
""" ------------------------------------------------- File Name: app Description : Author : guodongqing date: 2019/11/11 ------------------------------------------------- """ from flask import Flask, render_template, request, jsonify from manager.manager import Manager from util.Logger import Logger logger = Logger.instance() sysManager = Manager() app = Flask(__name__) def start_web_server(port=5500, debug=True): app.run(host='0.0.0.0', port=port, debug=debug) @app.route('/') def index(): return render_template('index.html') @app.route('/meeting') def meeting(): meetingUsers = sysManager.getAllMeetingUsers() logger.info(request.remote_addr + " - meeting user's size:" + str(len(meetingUsers))) return render_template('meetingusers.html', meetingUsers=meetingUsers)
class App(): def __init__(self): self.CONFIG_FILENAME = 'config/config.ini' self._config = None self._api = None self._gpsDevice = None self._accelDevice = None self._thermoDevice = None self._voltDevice = None self._baroDevice = None self._obdDevice = None self.read_configuration_file() self.configure_obd() self.configure_gps() self.configure_thermo() self.configure_acceleromenter() self.configure_volt() self.configure_baro() self._deviceList = DeviceCollection(thermoDevice=self._thermoDevice, gpsDevice=self._gpsDevice, accelDevice=self._accelDevice, voltDevice=self._voltDevice, baroDevice=self._baroDevice, obdDevice=self._obdDevice) self._manager = Manager(self._config, self._deviceList) def read_configuration_file(self): self._config = Configuration() self._config.read(self.CONFIG_FILENAME) def configure_obd(self): if self._config.obd_device == "obd": self._obdDevice = OBDDevice() elif self._config.obd_device == "mock": self._obdDevice = MockOBDDevice() else: print("incorrect obd config") def configure_gps(self): if self._config.gps_device == "fixed_mock": self._gpsDevice = MockFixedGPSDevice() elif self._config.gps_device == "gps3": self._gpsDevice = GPS3Device() else: print("incorrect gps config") def configure_thermo(self): if self._config.thermo_device == 'fixed_mock': self._thermoDevice = MockFixedThermoDevice() elif self._config.thermo_device == 'rising_mock': self._thermoDevice = MockRisingThermoDevice() elif self._config.thermo_device == "mpu": self._thermoDevice = MPUThermoDevice() else: print("incorrect thermo config") def configure_acceleromenter(self): if self._config.accel_device == "fixed_mock": self._accelDevice = MockFixedAccelDevice() elif self._config.accel_device == "mpu": self._accelDevice = MPUAccelDevice() else: print("incorrect accel config") def configure_volt(self): if self._config.volt_device == 'mock': self._voltDevice = MockVoltDevice() else: print("incorrect volt config") def configure_baro(self): if self._config.baro_device == 'mock': self._baroDevice = MockBaroDevice() else: print("incorrect baro config") def run(self): self._manager.print_all_accumulator_means()
def process_task(self): """ Downloader Module :return: Result Dict """ start = time.time() try: task_url = self.task.url args = json.loads(self.task.args) project_name = self.project.name # Manager Module # localhost = socket.getfqdn(socket.gethostname()) # local_ip = socket.gethostbyname(localhost) _dict = psutil.net_if_addrs() if _dict.has_key('docker0'): del _dict['docker0'] _str = str(_dict) m1 = re.search(r".*address='(10.\d+.\d+.\d+)'.*", _str) m2 = re.search(r".*address='(192.\d+.\d+.\d+)'.*", _str) m3 = re.search(r".*address='(172.[1-3]\d.\d+.\d+)'.*", _str) if m1: local_ip = m1.group(1) elif m2: local_ip = m2.group(2) elif m3: local_ip = m3.group(3) else: local_ip = '127.0.0.1' manager = Manager(ip=local_ip, project_name=project_name) ip_tactics = manager.get_ip() print ip_tactics ip_tactics_dict = ip_tactics if ip_tactics_dict.get('is_granted', False) is False: raise IPLimitError( "IP Access is Limited, Please Wait for Access Permission.") else: if isinstance(args, basestring): args = json.loads(args) proxies_ip = ip_tactics_dict.get('proxies_ip', {}) if proxies_ip: args.update( {'proxies': { 'http': 'http://%s' % (proxies_ip) }}) args = json.dumps(args) _spider = __import__("execute.{0}_spider".format(project_name), fromlist=["*"]) reload(_spider) spider = _spider.Spider() resp = spider.start_downloader(task_url, args) result = None exec("result = spider.start_parser(resp, spider.{0})".format( self.task.callback)) end = time.time() spend_time = end - start self.storage.update_task(task=self.task, status=4, track_log="success", spend_time=str(spend_time)) if self.project.status == 1: return {"status": True, "store_result": True, "result": result} else: return { "status": True, "store_result": False, "result": result } except IPLimitError: end = time.time() spend_time = end - start self.task = self.storage.update_task( task=self.task, status=0, track_log=traceback.format_exc(), spend_time=str(spend_time), retry_times=self.task.retry_times + 1, ) return { "status": False, "store_result": False, "result": None, "reason": traceback.format_exc(), } except Exception: end = time.time() spend_time = end - start self.task = self.storage.update_task( task=self.task, status=3, track_log=traceback.format_exc(), spend_time=str(spend_time), retry_times=self.task.retry_times + 1, ) return { "status": False, "store_result": False, "result": None, "reason": traceback.format_exc(), }
class Player(Entity): id = field.PrimaryKey(storetype.Integer(), name='player_id') class Footballer(Player): name = field.Column(storetype.Text(max_length=80)) match_fk = rel.ManyToMany('Match', name='match') class Match(Entity): id = field.PrimaryKey(storetype.Integer(), name='match_id') player_fk = rel.ManyToMany('Footballer', name='player') m = Manager() conf = ConnectionConfiguration(user="******", password="******", database="postgres") m.connect(conf) m.create_tables() # EXAMPLE 1 ######################## simple insert, update, delete ################################## monkey = Monkey() monkey.animal_id = 1 monkey.mammal_type = 'humanoid' monkey.monkey_name = 'Ham' monkey.monkey_weight = 20.5 m.insert(monkey)
from manager.manager import Manager manager = Manager() manager.start()
def create_manager(): manager = Manager(('localhost', 9999)) manager.start()
class Author(Entity): # multiple many to many relation id = field.PrimaryKey(storetype.Integer(), name='id') name = field.Column(storetype.Text(max_length=30), name='name') book_fk = rel.ManyToMany('Book', name='book_fk') poem_fk = rel.ManyToMany('Poem') class Poem(Entity): # multiple many to many relation id = field.PrimaryKey(storetype.Integer(), name='id') title = field.Column(storetype.Text(max_length=30), name='title') author_fk = rel.ManyToMany('Author', name='author_fk') # CONFIGURATION m = Manager() conf = ConnectionConfiguration(user="******", password="******", database="postgres") m.connect(conf) m.create_tables() # OBJECTS p = Person() p._first_name = "person1" p._second_name = "sur1" a1 = Address() a1.id = "a" a1.person_fk = p
# 서버시간 체크 time_checker() # upbit 객체 print("클라이언트 생성") ub_client = Ub_Client(ub_access_key, ub_secret_key) # binance 객체 bn_client = Bn_Client(bn_access_key, bn_secret_key) # 주식 프로그램 객체 app = QApplication(sys.argv) #kw_client = Kw_Client() print("클라이언트 완료") # # 매니저 관리 프로그램 on print("매니저등록 시작") ub_manager = Manager(ub_client) bn_manager = Manager(bn_client) #kw_manager = Manager(kw_client) print("매니저등록 완료") print("알고리즘 등록") # 변동성전략 등록 # # 업비트 변동성돌파전략 ub_will = William(ub_manager, ["KRW-BTC", "KRW-ETH"]) # 바이낸스 변동성돌파전략 # bn_will = William(bn_manager, ["BTCUSDT", "ETHUSDT", "BNBUSDT"]) # 키움 변동성돌파전략 #kw_will = William(kw_manager, ['069500', '122630', '233740', '114800', '229200', '133690']) # 업비트 원퍼센트 전략 등록 # ub_one = One_percent(ub_manager, ["KRW-ADA", "KRW-BCH", "KRW-EOS", "KRW-ETC", "KRW-XLM", "KRW-TRX", "KRW-XRP"]) # 업비트 10분 원퍼센트 전략등록, 모든 마켓 대상 5개 매수