ChatGPT prompt
Let's grab candle data using KuCoin API and store it in txt files located in a folder. We do this using a Python component in Rhino Grasshopper.
The component will have 4 inputs:
Input 1. A list of coin symbols such as: SUI-USDT, BTC-USDT, ADA-USDT
Input 2. A timeframe value selected from a Value List composed of 6 possible options:
1D - meaning candle data for last 1 day at 1 minute intervals
5D - meaning candle data for last 5 days at 15 minute intervals
1M - meaning candle data for last 1 month at 1 hour intervals
3M - meaning candle data for last 3 months at 6 hour intervals
6M - meaning candle data for last 6 months at 12 hour intervals
1Y - meaning candle data for last 1 year at 1 day intervals
Input 3. A folder Path for the txt files:
If non existing, a txt file should be created for each coin in the list of coins.
If the txt file exists it should be updated with new data, meaning: Keeping the values which are within the timeframe, removing the values which are no longer in the timeframe, and adding the new values which are within the timeframe. Like this we only update locally without the need of retrieving the full data from the API with each run. We retrieve only the new candle data and clean the old ones.
Input 4: a Run trigger as boolean value : if Run == 1 : run the grab script
The component will have 8 outputs, with data retrieved from the txt files only. So first update the txt files and second read them for the outputs.
Symbol - retrieved from the name of the txt file, such as SUI-USDT.
0 - Unix timestamp
1 - Opening price
2 - Closing price
3 - Highest price
4 - Lowest price
5 - Trading volume
6 - Turnover
If several symbols are input, the data will be output in several branches made of lists of values.