Edit: I have answered this question below as it may be useful for others. If anyone can refine/minimise the code please provide another answer.
Summary
How do I create an OHLC dataframe using Numpy/Pandas
- which has an ATR or trading range of somewhere around
.0075to.02or range could be specified as a variable. Looking to see random price moves roughly within these boundaries. - with a
Closevalue on first row at1.1904(see example below). - and can use a seed value (i.e.
np.random.seed) so the dataframe is reproducible.
Overview
I'm trying to generate mock forex/stock data to create reproducible examples for pandas questions using Numpy/Pandas. This question covers similar data requirements but a Forex data example using Open, High, Low ,Close Data could be useful for many SO users and help avoid pasting large amounts of data into a question.
As an example of how the dataframe should look I see the euro/dollar rate on Friday was as follows:
eur = {"open" : 1.19160,
"high" : 1.19371,
"low" : 1.18739,
"close" : 1.1904}
pd.DataFrame(eur,index=['19/3/2021'])
from Generate mock forex or stock OHLC data to use in reproducible examples for pandas questions

No comments:
Post a Comment