0

I was trying to build a code which can manipulate Moving Averages from a closing price data. There is a method in VectorBT that allows to do that, which is :

Moving_Average = vectorbt.MA.run(price, window = 14)
print(Moving_Average)

And this is what I get as the output :

MA(**Config({
    "wrapper": "<vectorbt.base.array_wrapper.ArrayWrapper object at 0x000001D29A523640> of shape (390,)",
    "input_list": [
        "<numpy.ndarray object at 0x000001D29A7EFED0> of shape (390,)"
    ],
    "input_mapper": "<numpy.ndarray object at 0x000001D29C0E4F30> of shape (1,)",
    "in_output_list": [],
    "output_list": [
        "<numpy.ndarray object at 0x000001D29C0E4810> of shape (390, 1)"
    ],
    "param_list": [
        [
            14
        ],
        [
            false
        ]
    ],
    "mapper_list": [
        "<pandas.core.indexes.numeric.Int64Index object at 0x000001D29BA0CDC0> of shape (1,)",
        "<pandas.core.indexes.base.Index object at 0x000001D29A7F29D0> of shape (1,)"
    ],
    "short_name": "ma",
    "level_names": [
        "ma_window",
        "ma_ewm"
    ]
}))

I want to get the Moving Averages in a dataframe from this Moving_Average object. I read the documentation but was unable to find any method for this. I think that the moving averages found by this method by VectorBT module is saved in a dataframe format. But how can I access that. I need to manipulate two Moving averages of different time windows, but for that, I need Moving averages table.

If you have any idea, please suggest. Thankyou. here the prices are fetched by following method of VectorBT :

price = vbt.YFData.download( "AAPL",
                                start = start,
                                end = end,
                                missing_index='drop',
                                interval = '1m').get('Close')

1 Answers1

0

To extract the actual list of MA values, you need to add .ma to the end:

Moving_Average = vectorbt.MA.run(price, window = 14).ma
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83