{"action":"closed","issue":{"url":"https://api.github.com/repos/ccxt/ccxt/issues/4035","repository_url":"https://api.github.com/repos/ccxt/ccxt","labels_url":"https://api.github.com/repos/ccxt/ccxt/issues/4035/labels{/name}","comments_url":"https://api.github.com/repos/ccxt/ccxt/issues/4035/comments","events_url":"https://api.github.com/repos/ccxt/ccxt/issues/4035/events","html_url":"https://github.com/ccxt/ccxt/issues/4035","id":373025782,"node_id":"MDU6SXNzdWUzNzMwMjU3ODI=","number":4035,"title":"get OHLCV exchange historic data","user":{"login":"moader808","id":44405425,"node_id":"MDQ6VXNlcjQ0NDA1NDI1","avatar_url":"https://avatars3.githubusercontent.com/u/44405425?v=4","gravatar_id":"","url":"https://api.github.com/users/moader808","html_url":"https://github.com/moader808","followers_url":"https://api.github.com/users/moader808/followers","following_url":"https://api.github.com/users/moader808/following{/other_user}","gists_url":"https://api.github.com/users/moader808/gists{/gist_id}","starred_url":"https://api.github.com/users/moader808/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moader808/subscriptions","organizations_url":"https://api.github.com/users/moader808/orgs","repos_url":"https://api.github.com/users/moader808/repos","events_url":"https://api.github.com/users/moader808/events{/privacy}","received_events_url":"https://api.github.com/users/moader808/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-23T14:18:12Z","updated_at":"2018-10-23T15:55:22Z","closed_at":"2018-10-23T15:55:22Z","author_association":"NONE","body":"- OS: Windows 10 Professional x64 bit\r\n- Programming Language version: Python x64 bit v3.6\r\n- CCXT version: Updated ~3 days prior\r\n- Exchange: Binance\r\n- Method: fetch_OHLCV\r\n\r\nI am rather new to this ccxt library as well as python, so please be patient with me... I made some additions to the python example code listed in the library to fetch historic candle data. I am trying to get the candles to print out concurrent times based on the from_timestamp. The from_timestamp gets the proper new value every iteration or loop of the try loop located within the while. But the candles function does not receive this same from_timestamp. In turn, the code when looking at the saved excel file just starts each candles at the same time, as opposed to its new time(s) Each set of 500 rows in excel is just the same first 500 rows.\r\nAny direction would be helpful, been trying to modify it to correctly save the candle data for compounding dates for many hours...\r\nUltimately I am trying to get the entire dataframe in one pass of the overall run function.\r\n\r\n```\r\nimport os\r\nimport sys\r\nimport time\r\nimport pandas as pd\r\nfrom pandas import ExcelWriter\r\n\r\n\r\nroot = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))\r\nsys.path.append(root + '/python')\r\n\r\nimport ccxt  # noqa: E402\r\n\r\nmsec = 1000\r\nminute = 60 * msec\r\nhold = 30\r\n\r\nexchange = ccxt.binance({\r\n    'rateLimit': 10000,\r\n    'enableRateLimit': True,\r\n    # 'verbose': True,\r\n})\r\n\r\ndef run():\r\n    from_datetime = '2017-01-01 00:00:00'\r\n    from_timestamp = exchange.parse8601(from_datetime)\r\n    data = []\r\n    now = exchange.milliseconds()\r\n\r\n    while from_timestamp < now:\r\n        writer = ExcelWriter('1min.xlsx')\r\n        try:\r\n            print(from_timestamp)\r\n            print(exchange.milliseconds(), 'Fetching candles starting from', exchange.iso8601(from_timestamp), from_timestamp)\r\n            candles = exchange.fetch_ohlcv('BTC/USDT', '1m', from_timestamp)\r\n            print(from_timestamp)\r\n            #print(candles, from_timestamp)     \r\n            print(exchange.milliseconds(), 'Fetched', len(candles), 'candles')\r\n            first = candles[0][0]\r\n            last = candles[-1][0]\r\n            print('First candle epoch', first, exchange.iso8601(first))\r\n            print('Last candle epoch', last, exchange.iso8601(last))\r\n            from_timestamp += len(candles) * minute\r\n            data += candles\r\n\r\n            df = pd.DataFrame(data, columns=['Timestamp','Open','High','Low','Close', 'Volume'])\r\n            df['Timestamp'] = pd.DataFrame(df['Timestamp'].apply(exchange.iso8601))\r\n            save_excel = df.to_excel(writer, sheet_name='2017_CURRENT')\r\n            writer.save()\r\n            print('1m candles saved')\r\n        except (ccxt.ExchangeError, ccxt.AuthenticationError, ccxt.ExchangeNotAvailable, ccxt.RequestTimeout) as error:\r\n\r\n            print('Got an error', type(error).__name__, error.args, ', retrying in', hold, 'seconds...')\r\n            time.sleep(hold)\r\nif __name__ == \"__main__\":      \r\n    run()\r\n```\r\n\r\n\r\nCurrent Output:\r\n```\r\n1483228800000\r\n1540300052830 Fetching candles starting from 2017-01-01T00:00:00.000Z 1483228800000\r\n2017-01-01T00:00:00.000Z 1483228800000\r\n1483228800000\r\n1540300063138 Fetched 500 candles\r\nFirst candle epoch 1502942400000 2017-08-17T04:00:00.000Z\r\nLast candle epoch 1502972340000 2017-08-17T12:19:00.000Z\r\n1m candles saved\r\n1483258800000\r\n1540300063437 Fetching candles starting from 2017-01-01T08:20:00.000Z 1483258800000\r\n2017-01-01T08:20:00.000Z 1483258800000\r\n1483258800000\r\n1540300073024 Fetched 500 candles\r\nFirst candle epoch 1502942400000 2017-08-17T04:00:00.000Z\r\nLast candle epoch 1502972340000 2017-08-17T12:19:00.000Z\r\n1m candles saved\r\n1483288800000\r\n1540300073490 Fetching candles starting from 2017-01-01T16:40:00.000Z 1483288800000\r\n2017-01-01T16:40:00.000Z 1483288800000\r\n1483288800000\r\n1540300083023 Fetched 500 candles\r\nFirst candle epoch 1502942400000 2017-08-17T04:00:00.000Z\r\nLast candle epoch 1502972340000 2017-08-17T12:19:00.000Z\r\n1m candles saved\r\n```"}}
{"actor":{"display_login":"moader808"}}