Tim55667757 / PriceGenerator

PriceGenerator is the platform for generating prices similar to real stock prices, but you can control the statistics of their distribution. Use PriceGenerator to generate synthetic data to test your trading strategy.
https://tim55667757.github.io/PriceGenerator
Apache License 2.0
41 stars 5 forks source link

Create data from existing data? #23

Closed burruplambert closed 1 year ago

burruplambert commented 1 year ago

Hi,

I was hoping to use your tool to analyze existing candle stick data to create new price with similar characteristics. Is it possible?

I can see that loaded data provides statistics like, up/down candle count, max/min high/low deltas etc, but there are in input parameters for these values when using --generate.

Tim55667757 commented 1 year ago

@burruplambert Hi! Thanks for question!

Did I understand correctly that you want to load candlestick data from existing file and then analyze it?

Yes, it is possible. I wrote an example here: https://github.com/Tim55667757/PriceGenerator#statistics-and-chart-from-saved-prices

You can load prices from the file using --load-from key and then define any csv_file_name. After that you can draw the chart using --render-bokeh key. For example, you have an existing test.csv file (download it here). Run this command:

pricegenerator --load-from media/test.csv --render-bokeh index.html

PriceGenerator.py   L:485  INFO    [2023-01-30 18:17:53,058] Loading, parse and preparing input data from [./media/test.csv]...
PriceGenerator.py   L:499  INFO    [2023-01-30 18:17:54,003] It was read 30 rows
PriceGenerator.py   L:500  INFO    [2023-01-30 18:17:54,004] Showing last 5 rows as Pandas DataFrame:
PriceGenerator.py   L:502  INFO    [2023-01-30 18:17:54,112]                     datetime   open   high    low  close  volume
PriceGenerator.py   L:502  INFO    [2023-01-30 18:17:54,113] 25 2021-02-03 11:00:00+03:00  76.82  78.43  76.21  78.13   33652
PriceGenerator.py   L:502  INFO    [2023-01-30 18:17:54,113] 26 2021-02-03 12:00:00+03:00  78.13  78.37  78.12  78.36    9347
PriceGenerator.py   L:502  INFO    [2023-01-30 18:17:54,114] 27 2021-02-03 13:00:00+03:00  78.36  78.40  78.05  78.07   27250
PriceGenerator.py   L:502  INFO    [2023-01-30 18:17:54,114] 28 2021-02-03 14:00:00+03:00  78.07  78.61  75.72  76.42   22979
PriceGenerator.py   L:502  INFO    [2023-01-30 18:17:54,115] 29 2021-02-03 15:00:00+03:00  76.42  77.37  76.25  77.16   30845
PriceGenerator.py   L:928  INFO    [2023-01-30 18:17:54,116] Rendering Pandas DataFrame as Bokeh chart...
PriceGenerator.py   L:680  INFO    [2023-01-30 18:17:54,175] Some statistics:
# Summary
- Candles count: 30
- Timeframe: 0 days 01:00:00
- Precision (signs after comma): 2
- Close, first: 71.65
- Close, last: 77.16
- Close, max: 78.96
- Close, min: 71.65
- Diapason, |close_max - close_min|: 7.31
- Trend, |close_1st - close_last|: UP trend

# Statistics
- Up candles count: 18 (60.0%)
- Down candles count: 12 (40.0%)
- Max of up / down candle chains: 4 / 2
- Max delta, |high - low|: 3.08
- Min delta, |high - low|: 0.1
- Delta's std. dev.: 0.95
  - 99 percentile: ≤ 3.02
  - 95 percentile: ≤ 2.89
  - 80 percentile: ≤ 2.46
- Cumulative sum of volumes: 612774
PriceGenerator.py   L:1406 INFO    [2023-01-30 18:17:57,665] Pandas DataFrame saved as HTML-file [index.html]
PriceGenerator.py   L:1413 INFO    [2023-01-30 18:17:57,701] Statistics saved to [index.html.md]

image

Let me know if this is what you need!

burruplambert commented 1 year ago

Hi. I want to load candlestick data from existing file, analyze it, and then generate new data that is similar to the data that I loaded.

Tim55667757 commented 1 year ago

@burruplambert I understand, but, unfortunately, the concept of the "similar data" is too fuzzy. However, from the analysis of primary loaded data, you can get some parameters: the maximum of the series, the minimum, the number of candles, the direction of the general trend, visually evaluate the sequence of trends, etc. After that you will be able to override some parameters for the PriceGenerator as shown here: https://github.com/Tim55667757/PriceGenerator#Overriding-parameters