Skip to content

Commit

Permalink
base class fetcher is exported to clients to extend it
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaanerkoc committed Mar 22, 2024
1 parent f06ffac commit 1ec2887
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 61 deletions.
134 changes: 75 additions & 59 deletions example_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,93 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"from fast_binance.fast_binance import OnlinePriceFetcher"
"from fast_binance.online_fetcher import OpenInterestFetcher, OnlinePriceFetcher"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"pf = OpenInterestFetcher()\n",
"res = await pf.async_download(['FTMUSDT', 'ETHUSDT', 'BTCUSDT'], \n",
" period='1h')\n"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"812941.8017666667"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"res['ETHUSDT']['sumOpenInterest'].mean()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"An error occured while fetching SEIUSDT. Error: Length mismatch: Expected axis has 0 elements, new values have 12 elements. {'interval': '1h', 'start_str': '2023-07-01', 'end_str': '2023-08-01'}\n",
"An error occured while fetching FTTUSDT. Error: Length mismatch: Expected axis has 0 elements, new values have 12 elements. {'interval': '1h', 'start_str': '2023-07-01', 'end_str': '2023-08-01'}\n",
"{'SEIUSDT': 'Length mismatch: Expected axis has 0 elements, new values have 12 elements', 'FTTUSDT': 'Length mismatch: Expected axis has 0 elements, new values have 12 elements', 'BTCUSDT': open high low close volume \\\n",
"open_time \n",
"2023-07-01 00:00:00 30471.99 30534.74 30420.00 30469.83 1244.96393 \n",
"2023-07-01 01:00:00 30469.82 30484.31 30380.51 30447.78 1182.24313 \n",
"2023-07-01 02:00:00 30447.77 30530.64 30390.33 30420.85 871.56148 \n",
"2023-07-01 03:00:00 30420.84 30444.00 30375.85 30398.01 709.27222 \n",
"2023-07-01 04:00:00 30398.02 30417.62 30320.57 30389.15 1296.90923 \n",
"... ... ... ... ... ... \n",
"2023-07-31 20:00:00 29157.49 29257.99 29115.64 29208.27 1340.23541 \n",
"2023-07-31 21:00:00 29208.28 29295.24 29158.46 29243.31 865.68795 \n",
"2023-07-31 22:00:00 29243.32 29243.32 29201.00 29209.99 441.45067 \n",
"2023-07-31 23:00:00 29210.00 29240.50 29190.00 29232.25 437.20574 \n",
"2023-08-01 00:00:00 29232.26 29288.20 29210.99 29283.96 720.85463 \n",
"\n",
" close_time quote_volume count taker_buy_volume \\\n",
"open_time \n",
"2023-07-01 00:00:00 1688173199999 3.796122e+07 34431 583.42618 \n",
"2023-07-01 01:00:00 1688176799999 3.598583e+07 36840 548.10204 \n",
"2023-07-01 02:00:00 1688180399999 2.654183e+07 25121 439.93886 \n",
"2023-07-01 03:00:00 1688183999999 2.156691e+07 17815 248.73089 \n",
"2023-07-01 04:00:00 1688187599999 3.938632e+07 28893 529.70642 \n",
"... ... ... ... ... \n",
"2023-07-31 20:00:00 1690837199999 3.912652e+07 36089 734.27381 \n",
"2023-07-31 21:00:00 1690840799999 2.529714e+07 26473 452.09710 \n",
"2023-07-31 22:00:00 1690844399999 1.289902e+07 15041 203.78311 \n",
"2023-07-31 23:00:00 1690847999999 1.277267e+07 12755 222.21180 \n",
"2023-08-01 00:00:00 1690851599999 2.107947e+07 17954 341.10168 \n",
"\n",
" taker_buy_quote_volume ignore \n",
"open_time \n",
"2023-07-01 00:00:00 1.778958e+07 0 \n",
"2023-07-01 01:00:00 1.668316e+07 0 \n",
"2023-07-01 02:00:00 1.339703e+07 0 \n",
"2023-07-01 03:00:00 7.562857e+06 0 \n",
"2023-07-01 04:00:00 1.608618e+07 0 \n",
"... ... ... \n",
"2023-07-31 20:00:00 2.143501e+07 0 \n",
"2023-07-31 21:00:00 1.321175e+07 0 \n",
"2023-07-31 22:00:00 5.953828e+06 0 \n",
"2023-07-31 23:00:00 6.491104e+06 0 \n",
"2023-08-01 00:00:00 9.975408e+06 0 \n",
"\n",
"[745 rows x 11 columns]}\n"
]
"data": {
"text/plain": [
"timestamp\n",
"2024-03-13 17:00:00 800408.309\n",
"2024-03-13 18:00:00 802842.580\n",
"2024-03-13 19:00:00 804291.357\n",
"2024-03-13 20:00:00 803848.163\n",
"2024-03-13 21:00:00 792965.582\n",
"2024-03-13 22:00:00 793880.630\n",
"2024-03-13 23:00:00 796316.080\n",
"2024-03-14 00:00:00 795342.351\n",
"2024-03-14 01:00:00 798761.961\n",
"2024-03-14 02:00:00 806139.535\n",
"2024-03-14 03:00:00 803312.674\n",
"2024-03-14 04:00:00 802518.401\n",
"2024-03-14 05:00:00 805565.020\n",
"2024-03-14 06:00:00 812910.070\n",
"2024-03-14 07:00:00 806800.890\n",
"2024-03-14 08:00:00 809735.364\n",
"2024-03-14 09:00:00 810241.309\n",
"2024-03-14 10:00:00 807617.003\n",
"2024-03-14 11:00:00 809517.497\n",
"2024-03-14 12:00:00 818606.169\n",
"2024-03-14 13:00:00 824047.664\n",
"2024-03-14 14:00:00 831813.355\n",
"2024-03-14 15:00:00 835480.817\n",
"2024-03-14 16:00:00 839687.069\n",
"2024-03-14 17:00:00 845555.277\n",
"2024-03-14 18:00:00 845881.426\n",
"2024-03-14 19:00:00 828468.294\n",
"2024-03-14 20:00:00 816222.267\n",
"2024-03-14 21:00:00 820065.930\n",
"2024-03-14 22:00:00 819411.009\n",
"Name: sumOpenInterest, dtype: float64"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pf = OnlinePriceFetcher('spot')\n",
"res = await pf.async_download(['SEIUSDT', 'FTTUSDT', 'BTCUSDT'], \n",
" interval='1h', \n",
" start_str='2023-07-01',\n",
" end_str='2023-08-01' )\n",
"print(res)"
"res['ETHUSDT']['sumOpenInterest']"
]
},
{
Expand All @@ -99,7 +115,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.9.18"
},
"orig_nbformat": 4
},
Expand Down
5 changes: 3 additions & 2 deletions fast_binance/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
__version__ = "1.1.1"
__version__ = "1.1.2"

from fast_binance.online_fetcher import (
OnlinePriceFetcher,
OpenInterestFetcher
OpenInterestFetcher,
MultiplexFetcher,
)

from fast_binance.offline_fetcher import OfflineFileFetcher
Expand Down

0 comments on commit 1ec2887

Please sign in to comment.