Files

143 lines
3.8 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-02T13:59:06.716302Z",
"start_time": "2018-03-02T13:59:06.040476Z"
}
},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
"from datetime import datetime\n",
"\n",
"import pandas as pd\n",
"\n",
"# from libcryptomarket.core import candles, latest_candles, FREQUENCY_TO_SEC_DICT"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Candles"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-02T13:59:16.182130Z",
"start_time": "2018-03-02T13:59:06.746957Z"
},
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running exchange <ccxt.poloniex.poloniex object at 0x7fe1ff38a6d8> for instrument LTC/BTC\n",
"Running exchange <ccxt.bitfinex2.bitfinex2 object at 0x7fe1d3009240> for instrument BTC/USD\n",
"Running exchange <ccxt.gdax.gdax object at 0x7fe1d3013470> for instrument BTC/USD\n"
]
}
],
"source": [
"import libcryptomarket\n",
"\n",
"for source, symbol, frequency in [\n",
" (libcryptomarket.poloniex(), \"LTC/BTC\", \"1d\"), \n",
" (libcryptomarket.bitfinex2(), \"BTC/USD\", \"1d\"),\n",
" (libcryptomarket.gdax(), \"BTC/USD\", \"1d\")]:\n",
" print(\"Running exchange {} for instrument {}\".format(source, symbol))\n",
" data = source.fetch_candles(\n",
" symbol=symbol, start_time=pd.Timestamp(\"2017-12-15\"), end_time=pd.Timestamp(\"2017-12-31\"), frequency=frequency)\n",
" assert data[\"start_time\"].iloc[0] == pd.Timestamp(\"2017-12-15\")\n",
" assert data[\"end_time\"].iloc[-1] == pd.Timestamp(\"2017-12-31\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Latest candles"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import libcryptomarket\n",
"\n",
"for source, symbols in [\n",
" (libcryptomarket.poloniex(), [\"LTC/BTC\", \"ETH/BTC\"]), \n",
" (libcryptomarket.bitfinex2(), [\"BTC/USD\", \"ETH/USD\"]),\n",
" (libcryptomarket.gdax(), [\"BTC/USD\", \"ETH/USD\"])\n",
" ]:\n",
" print(\"Running exchange {} for instrument {}\".format(source, symbols))\n",
" data = source.fetch_latest_candles(source=source, symbols=symbols, frequency=\"5m\", frequency_count=1)\n",
" assert data.shape[0] == 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Latest candles with quote_currency"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import libcryptomarket\n",
"\n",
"for source, symbols in [\n",
" (libcryptomarket.poloniex(), [\"BTC/USDT\", ]), \n",
" ]:\n",
" print(\"Running exchange {} for instrument {}\".format(source, symbols))\n",
" data = source.fetch_latest_candles(symbols=symbols, frequency=\"5m\", frequency_count=1, quote_currency=\"BTC\")\n",
" assert data.shape[0] == 1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}