Пример #1
0
import sys
sys.dont_write_bytecode = True
from datetime import datetime, timedelta
from core.data_factory import *
from core.engine import *
from core.utils import *
from pylab import plot, show
import os, time, glob
from core.logger import Logging
import config.config as config
import traceback
logger = Logging(__name__).logger


def initialize_csv(context):
    csv_fetcher(context, 'data/MSFT.csv', 'signals')


def handle_data_csv(context):
    if random.randint(0, context.A) == 3:
        order(context, 'MSFT', random.randint(-1, 2))
    if random.randint(0, context.A) == 3:
        order(context, 'AAPL', random.randint(-1, 2))


def run_csv(A):
    data = CSVDataFactory(['data/MSFT.csv', 'data/AAPL.csv'])()
    strategy = Strategy(config,
                        handle_data=handle_data_csv,
                        initialize=initialize_csv)
    strategy.context.A = A
Пример #2
0
from collections import deque
import traceback
from pylab import *
from numpy import *
from pandas import DataFrame, Series, Panel
import json
import bcolz
from core.logger import Logging
from copy import deepcopy
from datetime import datetime
# from ipdb import set_trace
from core.portfolio import *
from core.performance import Performance
from core.order import *

logger = Logging(__name__, '/tmp/slackline.log').logger


def handle_data(context):
    pass


def initialize(context):
    pass


def init_optimization(params):
    pass


def config():
Пример #3
0
# ==== wire the components together =====
env.visual_feedback.subscribe(lambda img: vis.input_image.on_next(img))
vis.output_predictions.subscribe(lambda preds: eval.input_encountered_object.on_next(preds))

eval.output_danger_level.subscribe(lambda d: cpg.input_danger.on_next(d))
eval.output_opportunity_level.subscribe(lambda o: cpg.input_opportunity.on_next(o))

eval.output_danger_level.subscribe((lambda d: rpg.input_danger.on_next(d)))
eval.output_opportunity_level.subscribe(lambda o: rpg.input_opportunity.on_next(o))
rpg.output_invert_movement.subscribe(lambda i: cpg.input_flip.on_next(i))

cpg.output_muscle_stimuli.subscribe(lambda ms: process_muscle_stimulus(ms))

# ========== configure logging ==========
log_path = "../log/demo.txt" if demo_mode else "../log/logfile.txt"
logging = Logging(log_path, 10)

logging.add_logger(Logging.Logger("vis_feedback", env.visual_feedback_label))
logging.add_logger(Logging.Logger("prediction", vis.output_prediction_label))
logging.add_logger(Logging.Logger("danger", eval.output_danger_level))
logging.add_logger(Logging.Logger("opportunity", eval.output_opportunity_level))
logging.add_logger(Logging.Logger("invert", rpg.output_invert_movement))
logging.add_logger(Logging.Logger("muscle_f_ant", cpg.output_muscle_stimuli.pipe(ops.map(lambda x: x[0]))))
logging.add_logger(Logging.Logger("muscle_f_post", cpg.output_muscle_stimuli.pipe(ops.map(lambda x: x[1]))))

logging.start_logging()

# ========= start timer ticks ===========
Timer().start()