-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
begood
committed
Aug 11, 2023
1 parent
14b8279
commit efc2c8b
Showing
41 changed files
with
2,461 additions
and
589 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "initial_id", | ||
"metadata": { | ||
"collapsed": true, | ||
"ExecuteTime": { | ||
"end_time": "2023-08-11T06:52:01.213849587Z", | ||
"start_time": "2023-08-11T06:52:01.172112997Z" | ||
} | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"The autoreload extension is already loaded. To reload it, use:\n", | ||
" %reload_ext autoreload\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from generate import scrap_field_values\n", | ||
"import json\n", | ||
"\n", | ||
"%load_ext autoreload\n", | ||
"%autoreload 2" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"outputs": [], | ||
"source": [ | ||
"from generate import fill_filter_template, generate_filter_columns\n", | ||
"from generate import write\n", | ||
"\n", | ||
"\n", | ||
"def save_columns(url):\n", | ||
" fields_dict = scrap_field_values(url)\n", | ||
" for key, value in fields_dict.items():\n", | ||
" with open(f'data/{key.lower()}.json', 'w') as f:\n", | ||
" json.dump({key: value}, f)\n", | ||
" return fields_dict\n", | ||
" \n", | ||
"def generate_code_files(name):\n", | ||
" with open(f'data/{name.lower()}.json') as f:\n", | ||
" filters_ = json.load(f)\n", | ||
" formatted_columns = generate_filter_columns(filters_[name])\n", | ||
" template = fill_filter_template(name.replace(' ', ''), formatted_columns)\n", | ||
" write(name.replace(' ', '_').lower(), template)" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2023-08-11T06:52:03.190052866Z", | ||
"start_time": "2023-08-11T06:52:03.186114291Z" | ||
} | ||
}, | ||
"id": "d4c4d0ddb0c0119b" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[1]/div[1] ...\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[2]/div[1] ...\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[3]/div[1] ...\n", | ||
"TimeoutException on field: Primary Listing\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[4]/div[1] ...\n", | ||
"TimeoutException on field: Current trading day\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[5]/div[1] ...\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[6]/div[1] ...\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[7]/div[1] ...\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[8]/div[1] ...\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[9]/div[1] ...\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[10]/div[1] ...\n", | ||
"NoSuchElementException on field: Market Capitalization\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[11]/div[1] ...\n", | ||
"NoSuchElementException on field: Volume\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[12]/div[1] ...\n", | ||
"NoSuchElementException on field: Average Volume (10 day)\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[13]/div[1] ...\n", | ||
"NoSuchElementException on field: Average Volume (30 day)\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[14]/div[1] ...\n", | ||
"NoSuchElementException on field: Average Volume (60 day)\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[15]/div[1] ...\n", | ||
"NoSuchElementException on field: Average Volume (90 day)\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[16]/div[1] ...\n", | ||
"TimeoutException on field: Relative Volume\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[17]/div[1] ...\n", | ||
"TimeoutException on field: Relative Volume at Time\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[18]/div[1] ...\n", | ||
"TimeoutException on field: Change %\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[19]/div[1] ...\n", | ||
"TimeoutException on field: Change 1m, %\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[20]/div[1] ...\n", | ||
"TimeoutException on field: Change 5m, %\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[21]/div[1] ...\n", | ||
"TimeoutException on field: Change 15m, %\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[22]/div[1] ...\n", | ||
"TimeoutException on field: Change 1h, %\n", | ||
"Search field on xpath: /html/body/div[10]/div/div/div/div[3]/div[1]/div/div/div[23]/div[1] ...\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"stock_url = \"https://www.tradingview.com/screener/\"\n", | ||
"filters = save_columns(stock_url)" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2023-08-11T06:52:42.294915919Z", | ||
"start_time": "2023-08-11T06:52:04.108834356Z" | ||
} | ||
}, | ||
"id": "e4eabbd29fc14556" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"outputs": [], | ||
"source": [ | ||
"for key in filters.keys():\n", | ||
" generate_code_files(key)" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2023-08-11T07:05:13.158804479Z", | ||
"start_time": "2023-08-11T07:05:13.148339900Z" | ||
} | ||
}, | ||
"id": "fce7ec0c7477cb3c" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"outputs": [], | ||
"source": [], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "c8b265fdafe0ea0" | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 2 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython2", | ||
"version": "2.7.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.