Leo4815162342 / dukascopy-node

✨ Download historical price tick data for Crypto, Stocks, ETFs, CFDs, Forex via CLI and Node.js ✨
https://dukascopy-node.app
MIT License
350 stars 66 forks source link

[feature] Some backtesting framework not support timestamp #156

Closed groschovskiy closed 7 months ago

groschovskiy commented 1 year ago

Some backtesting framework not support timestamp and would be awesome to add ability to save dtformat=('%Y-%m-%d %H:%M:%S') for common backtesting software

acutedeveloper commented 7 months ago

I second this. I tried to download the data for forextester.com. Could not load it in dues to the date format.

Leo4815162342 commented 7 months ago

@acutedeveloper can you share the example of the price format you'd like to be added?

Leo4815162342 commented 7 months ago

@groschovskiy @acutedeveloper I've released an experimental support for formatting dates (version1.37.0-beta.0):

npm install dukascopy-node@1.37.0-beta.0 

It now accepts --date-format option in which you can specify the date-time format. It uses dayjs formatting under the hood, you can view all available formats here: https://day.js.org/docs/en/display/format#list-of-all-available-formats


Example with custom date formatting

npx dukascopy-node -i eurusd -from 2024-02-26 -to 2024-02-27 -t m1 --date-format "YYYY-MM-DD HH:mm:ss" -f csv

which outputs the following content:

Output

timestamp,open,high,low,close
2024-02-26 00:00:00,1.08188,1.08202,1.08186,1.08196
2024-02-26 00:01:00,1.08196,1.08198,1.08191,1.08191
2024-02-26 00:02:00,1.08191,1.08194,1.08185,1.08186
2024-02-26 00:03:00,1.08187,1.08191,1.08186,1.08186

Additionally you can pass iso as a value to --date-format option which will convert timestamo into a ISO based date string:

Example:

npx dukascopy-node -i eurusd -from 2024-02-26 -to 2024-02-27 -t m1 --date-format iso -f csv

output:

timestamp,open,high,low,close
2024-02-26T00:00:00.000Z,1.08188,1.08202,1.08186,1.08196
2024-02-26T00:01:00.000Z,1.08196,1.08198,1.08191,1.08191
2024-02-26T00:02:00.000Z,1.08191,1.08194,1.08185,1.08186
2024-02-26T00:03:00.000Z,1.08187,1.08191,1.08186,1.08186
Leo4815162342 commented 7 months ago

stable support for custom date formatting is now available in 1.37.0. Docs: https://www.dukascopy-node.app/custom-date-format-and-timezone-conversion