Пример #1
0
def get_position_buffers_from_system(system, instrument_code):
    buffers = system.portfolio.get_buffers_for_position(
        instrument_code)  ## get the upper and lower edges of the buffer
    lower_buffer = buffers.iloc[-1].bot_pos
    upper_buffer = buffers.iloc[-1].top_pos

    position_entry = bufferedOptimalPositions(lower_buffer, upper_buffer)

    return position_entry
Пример #2
0
def construct_position_entry(data, system, instrument_code, lower_buffer,
                             upper_buffer):
    diag_contracts = diagContracts(data)
    reference_price = system.rawdata.get_daily_prices(instrument_code).iloc[-1]
    reference_contract = diag_contracts.get_priced_contract_id(instrument_code)
    position_entry = bufferedOptimalPositions(lower_buffer, upper_buffer,
                                              reference_price,
                                              reference_contract)

    return position_entry