def updated_buffered_positions(data: dataBlob, strategy_name: str,
                               system: System):
    log = data.log

    data_optimal_positions = dataOptimalPositions(data)

    list_of_instruments = system.get_instrument_list()
    for instrument_code in list_of_instruments:
        lower_buffer, upper_buffer = get_position_buffers_from_system(
            system, instrument_code)
        position_entry = construct_position_entry(
            data=data,
            system=system,
            instrument_code=instrument_code,
            lower_buffer=lower_buffer,
            upper_buffer=upper_buffer,
        )
        instrument_strategy = instrumentStrategy(
            instrument_code=instrument_code, strategy_name=strategy_name)
        data_optimal_positions.update_optimal_position_for_instrument_strategy(
            instrument_strategy=instrument_strategy,
            position_entry=position_entry)
        log.msg(
            "New buffered positions %.3f %.3f" %
            (position_entry.lower_position, position_entry.upper_position),
            instrument_code=instrument_code,
        )
예제 #2
0
def updated_optimal_positions(data: dataBlob, strategy_name: str,
                              system: System):
    log = data.log

    data_optimal_positions = dataOptimalPositions(data)

    list_of_instruments = system.get_instrument_list()
    for instrument_code in list_of_instruments:
        position_entry = construct_optimal_position_entry(
            data=data,
            system=system,
            instrument_code=instrument_code,
        )
        instrument_strategy = instrumentStrategy(
            instrument_code=instrument_code, strategy_name=strategy_name)
        data_optimal_positions.update_optimal_position_for_instrument_strategy(
            instrument_strategy=instrument_strategy,
            raw_positions=True,
            position_entry=position_entry,
        )

        log.msg("New Optimal position %s %s" %
                (str(position_entry), instrument_code))
예제 #3
0
파일: test.py 프로젝트: rlcjj/pysystemtrade
rule_variations=system.rules.trading_rules()
rule_variation_name="ewmac16"

this_stage=system.accounts
price = this_stage.get_daily_price(instrument_code)
get_daily_returns_volatility = this_stage.get_daily_returns_volatility(
    instrument_code)

forecast = this_stage.get_capped_forecast(
                                              instrument_code, rule_variation_name)

accountCurve(percentage=True, price=price, forecast=forecast, get_daily_returns_volatility=get_daily_returns_volatility)


instruments=system.get_instrument_list()

capital = this_stage.get_notional_capital()
ann_risk_target=system.positionSize.get_daily_cash_vol_target()['percentage_vol_target']/100.0

acc_list=[]
for instrument_code in instruments:
    price = this_stage.get_daily_price(instrument_code)
    positions = this_stage.get_notional_position(instrument_code)
    fx = this_stage.get_fx_rate(instrument_code)
    value_of_price_point = this_stage.get_value_of_price_move(
        instrument_code)
    

    ans2=accountCurve(percentage=True, price=price, positions=positions, fx=fx, get_daily_returns_volatility=get_daily_returns_volatility,
                      capital=capital, ann_risk_target=ann_risk_target, value_of_price_point=value_of_price_point)