mirror of
https://github.com/wassname/libcryptomarket.git
synced 2026-09-10 12:13:06 +08:00
Fix the poloniex latest candles issue
This commit is contained in:
@@ -98,7 +98,7 @@ def latest_candles(source, symbols, frequency, frequency_count, end_time=None):
|
||||
closest_end_time = pd.Timestamp(end_time).floor(
|
||||
timedelta(seconds=FREQUENCY_TO_SEC_DICT[frequency]))
|
||||
start_time = closest_end_time - timedelta(
|
||||
seconds=FREQUENCY_TO_SEC_DICT[frequency] * frequency_count)
|
||||
seconds=FREQUENCY_TO_SEC_DICT[frequency] * (frequency_count + 1))
|
||||
|
||||
all_data = []
|
||||
for symbol in symbols:
|
||||
@@ -111,6 +111,6 @@ def latest_candles(source, symbols, frequency, frequency_count, end_time=None):
|
||||
all_data.append(data.set_index(['start_time', 'end_time']))
|
||||
|
||||
if len(all_data) == 1:
|
||||
return all_data[0]
|
||||
return all_data[0].iloc[1:, :]
|
||||
else:
|
||||
return pd.concat(all_data, axis=1, keys=symbols)
|
||||
return pd.concat(all_data, axis=1, keys=symbols).iloc[1:, :]
|
||||
|
||||
+26
-20
@@ -5,8 +5,8 @@
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2018-01-27T23:56:10.234256Z",
|
||||
"start_time": "2018-01-27T23:56:09.703438Z"
|
||||
"end_time": "2018-01-31T15:32:12.633315Z",
|
||||
"start_time": "2018-01-31T15:32:11.476421Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
@@ -28,11 +28,11 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2018-01-28T00:06:20.147882Z",
|
||||
"start_time": "2018-01-28T00:06:14.812410Z"
|
||||
"end_time": "2018-01-31T15:32:18.992459Z",
|
||||
"start_time": "2018-01-31T15:32:12.637992Z"
|
||||
},
|
||||
"scrolled": true
|
||||
},
|
||||
@@ -68,13 +68,27 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2018-01-31T15:33:04.405264Z",
|
||||
"start_time": "2018-01-31T15:33:00.256283Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Running exchange poloniex for instrument ['BTC_LTC', 'BTC_ETH']\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"for source, symbols in [\n",
|
||||
" (\"poloniex\", [\"BTC_LTC\", \"BTC_ETH\"]), \n",
|
||||
" (\"bitfinex\", [\"tBTCUSD\", \"tETHUSD\"])]:\n",
|
||||
" (\"bitfinex\", [\"tBTCUSD\", \"tETHUSD\"]),\n",
|
||||
" ]:\n",
|
||||
" print(\"Running exchange {} for instrument {}\".format(source, symbols))\n",
|
||||
" data = latest_candles(source=source, symbols=symbols, frequency=\"30m\", frequency_count=1)\n",
|
||||
" assert data.shape[0] == 1"
|
||||
@@ -82,18 +96,10 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2018-01-28T00:02:19.164726Z",
|
||||
"start_time": "2018-01-28T00:02:14.937305Z"
|
||||
}
|
||||
},
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"data = candles(source=\"gdax\", symbol=\"BTC-USD\", \n",
|
||||
" start_time=pd.Timestamp(\"2017-12-15\"), end_time=pd.Timestamp(\"2017-12-31\"), frequency=\"1d\")"
|
||||
]
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
Reference in New Issue
Block a user