From b6622751aa1e3b9ecbf531a41eeea8c4f466eb7b Mon Sep 17 00:00:00 2001 From: Glyphack Date: Sat, 7 Oct 2023 10:06:41 +0200 Subject: [PATCH 1/5] Fix slices --- parser/src/parser/parser.rs | 39 +++---- ...ser__tests__one_liners@dict.py-10.snap.new | 96 +++++++++++++++++ ...__parser__tests__one_liners@dict.py-8.snap | 4 +- ...rser__tests__one_liners@dict.py-9.snap.new | 44 ++++++++ ...er__tests__one_liners@subscript.py-10.snap | 53 +++++++++ ...er__tests__one_liners@subscript.py-11.snap | 101 ++++++++++++++++++ ...er__tests__one_liners@subscript.py-12.snap | 53 +++++++++ ...ser__tests__one_liners@subscript.py-2.snap | 84 +++++++++++++++ ...ser__tests__one_liners@subscript.py-3.snap | 41 +++++++ ...ser__tests__one_liners@subscript.py-4.snap | 63 +++++++++++ ...ser__tests__one_liners@subscript.py-5.snap | 73 +++++++++++++ ...ser__tests__one_liners@subscript.py-6.snap | 69 ++++++++++++ ...ser__tests__one_liners@subscript.py-7.snap | 91 ++++++++++++++++ ...ser__tests__one_liners@subscript.py-8.snap | 43 ++++++++ ...ser__tests__one_liners@subscript.py-9.snap | 101 ++++++++++++++++++ ...arser__tests__one_liners@subscript.py.snap | 84 +++++++++++++++ parser/test_data/inputs/one_liners/dict.py | 10 ++ .../test_data/inputs/one_liners/subscript.py | 19 ++++ 18 files changed, 1041 insertions(+), 27 deletions(-) create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-10.snap.new create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap.new create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-10.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-11.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-12.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-2.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-3.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-4.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-5.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-6.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-7.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-8.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-9.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py.snap create mode 100644 parser/test_data/inputs/one_liners/subscript.py diff --git a/parser/src/parser/parser.rs b/parser/src/parser/parser.rs index e3d1514e..ff1555b3 100644 --- a/parser/src/parser/parser.rs +++ b/parser/src/parser/parser.rs @@ -1998,6 +1998,18 @@ impl Parser { } } + fn parse_double_starred_kv_pair(&mut self) -> Result<(Option,Expression), ParsingError> { + if self.eat(Kind::Pow) { + let value = self.parse_expression_2()?; + Ok((None, value)) + } else { + let key = self.parse_expression_2()?; + self.expect(Kind::Colon)?; + let value = self.parse_expression_2()?; + Ok((Some(key), value)) + } + } + fn consume_whitespace_and_newline(&mut self) -> bool { let mut consumed = false; while matches!(self.cur_kind(), Kind::WhiteSpace | Kind::NewLine) { @@ -2611,6 +2623,7 @@ impl Parser { fn parse_slice_list(&mut self) -> Result { let node = self.start_node(); let mut elements = vec![]; + // TODO: This EOF check should not be here. while !self.at(Kind::Eof) && !self.at(Kind::RightBrace) { if self.at(Kind::Colon) { elements.push(self.parse_proper_slice(None)?); @@ -2651,7 +2664,7 @@ impl Parser { Some(Box::new(self.parse_expression_2()?)) }; let upper = if self.eat(Kind::Colon) { - if self.at(Kind::RightBrace) { + if self.at(Kind::RightBrace) || self.at(Kind::Colon) { None } else { Some(Box::new(self.parse_expression_2()?)) @@ -3309,30 +3322,6 @@ mod tests { } } - #[test] - fn test_subscript() { - for test_case in &[ - "a[b]", - "a[b:c]", - "a[b:c:d]", - "a[b, c, d]", - "a[b, c: d, e]", - "a[::]", - "a[b, c:d:e, f]", - "a[::d,]", - ] { - let mut parser = Parser::new(test_case.to_string(), String::from("")); - let program = parser.parse(); - - insta::with_settings!({ - description => test_case.to_string(), // the template source code - omit_expression => true // do not include the default expression - }, { - assert_debug_snapshot!(program); - }); - } - } - #[test] fn test_attribute_ref() { for test_case in &["a.b", "a.b.c", "a.b_c", "a.b.c.d"] { diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-10.snap.new b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-10.snap.new new file mode 100644 index 00000000..f5753c6c --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-10.snap.new @@ -0,0 +1,96 @@ +--- +source: parser/src/parser/parser.rs +assertion_line: 3706 +description: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,\n **market_watch,\n \"symbol\": symbol,\n \"name\": name,\n}" +input_file: parser/test_data/inputs/one_liners/dict.py +--- +[ + InvalidSyntax { + path: "dict.py", + msg: "Unexpected token Pow", + line: 2, + input: "aggregated_key_stats[idx_stat] = {\n **", + advice: "", + span: ( + 39, + 41, + ), + }, + InvalidSyntax { + path: "dict.py", + msg: "Unexpected token Comma", + line: 2, + input: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,", + advice: "", + span: ( + 58, + 59, + ), + }, + InvalidSyntax { + path: "dict.py", + msg: "Unexpected token Pow", + line: 4, + input: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **", + advice: "", + span: ( + 88, + 90, + ), + }, + InvalidSyntax { + path: "dict.py", + msg: "Unexpected token Comma", + line: 4, + input: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,", + advice: "", + span: ( + 102, + 103, + ), + }, + InvalidSyntax { + path: "dict.py", + msg: "Statement does not end in new line or semicolon", + line: 1, + input: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,\n **market_watch,\n \"symbol\": symbol", + advice: "Split the statements into two seperate lines or add a semicolon", + span: ( + 128, + 144, + ), + }, + InvalidSyntax { + path: "dict.py", + msg: "Unexpected token Comma", + line: 6, + input: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,\n **market_watch,\n \"symbol\": symbol,", + advice: "", + span: ( + 144, + 145, + ), + }, + InvalidSyntax { + path: "dict.py", + msg: "Unexpected token Colon", + line: 7, + input: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,\n **market_watch,\n \"symbol\": symbol,\n \"name\":", + advice: "", + span: ( + 156, + 157, + ), + }, + InvalidSyntax { + path: "dict.py", + msg: "Unexpected token Comma", + line: 7, + input: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,\n **market_watch,\n \"symbol\": symbol,\n \"name\": name,", + advice: "", + span: ( + 162, + 163, + ), + }, +] diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-8.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-8.snap index 6af46f8d..20f13444 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-8.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-8.snap @@ -1,12 +1,12 @@ --- source: parser/src/parser/parser.rs -description: "{1: \"name\" for name in get_names()\n}\n" +description: "{1: \"name\" for name in get_names()\n}" input_file: parser/test_data/inputs/one_liners/dict.py --- Module { node: Node { start: 0, - end: 37, + end: 36, }, body: [ ExpressionStatement( diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap.new b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap.new new file mode 100644 index 00000000..c78769f4 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap.new @@ -0,0 +1,44 @@ +--- +source: parser/src/parser/parser.rs +assertion_line: 3699 +description: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,\n **market_watch,\n \"symbol\": symbol,\n \"name\": name,\n}" +input_file: parser/test_data/inputs/one_liners/dict.py +--- +Module { + node: Node { + start: 0, + end: 165, + }, + body: [ + AnnAssignStatement( + AnnAssign { + node: Node { + start: 128, + end: 144, + }, + target: Constant( + Constant { + node: Node { + start: 128, + end: 136, + }, + value: Str( + "symbol", + ), + }, + ), + annotation: Name( + Name { + node: Node { + start: 138, + end: 144, + }, + id: "symbol", + }, + ), + value: None, + simple: true, + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-10.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-10.snap new file mode 100644 index 00000000..e6effe04 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-10.snap @@ -0,0 +1,53 @@ +--- +source: parser/src/parser/parser.rs +description: "a[::d,]\n" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 8, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 7, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 2, + end: 5, + }, + lower: None, + upper: Some( + Name( + Name { + node: Node { + start: 4, + end: 5, + }, + id: "d", + }, + ), + ), + step: None, + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-11.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-11.snap new file mode 100644 index 00000000..a488b6fd --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-11.snap @@ -0,0 +1,101 @@ +--- +source: parser/src/parser/parser.rs +description: "a[b, c:d:e, f]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 14, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 14, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 2, + end: 14, + }, + elements: [ + Name( + Name { + node: Node { + start: 2, + end: 3, + }, + id: "b", + }, + ), + Slice( + Slice { + node: Node { + start: 6, + end: 10, + }, + lower: Some( + Name( + Name { + node: Node { + start: 5, + end: 6, + }, + id: "c", + }, + ), + ), + upper: Some( + Name( + Name { + node: Node { + start: 7, + end: 8, + }, + id: "d", + }, + ), + ), + step: Some( + Name( + Name { + node: Node { + start: 9, + end: 10, + }, + id: "e", + }, + ), + ), + }, + ), + Name( + Name { + node: Node { + start: 12, + end: 13, + }, + id: "f", + }, + ), + ], + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-12.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-12.snap new file mode 100644 index 00000000..e6effe04 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-12.snap @@ -0,0 +1,53 @@ +--- +source: parser/src/parser/parser.rs +description: "a[::d,]\n" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 8, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 7, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 2, + end: 5, + }, + lower: None, + upper: Some( + Name( + Name { + node: Node { + start: 4, + end: 5, + }, + id: "d", + }, + ), + ), + step: None, + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-2.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-2.snap new file mode 100644 index 00000000..d19e5558 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-2.snap @@ -0,0 +1,84 @@ +--- +source: parser/src/parser/parser.rs +description: "values = list_of_key_stats[1::2]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 32, + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 0, + end: 32, + }, + targets: [ + Name( + Name { + node: Node { + start: 0, + end: 6, + }, + id: "values", + }, + ), + ], + value: Subscript( + Subscript { + node: Node { + start: 9, + end: 32, + }, + value: Name( + Name { + node: Node { + start: 9, + end: 26, + }, + id: "list_of_key_stats", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 28, + end: 31, + }, + lower: Some( + Constant( + Constant { + node: Node { + start: 27, + end: 28, + }, + value: Int( + "1", + ), + }, + ), + ), + upper: None, + step: Some( + Constant( + Constant { + node: Node { + start: 30, + end: 31, + }, + value: Int( + "2", + ), + }, + ), + ), + }, + ), + }, + ), + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-3.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-3.snap new file mode 100644 index 00000000..8302210f --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-3.snap @@ -0,0 +1,41 @@ +--- +source: parser/src/parser/parser.rs +description: "a[b]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 4, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 4, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Name( + Name { + node: Node { + start: 2, + end: 3, + }, + id: "b", + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-4.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-4.snap new file mode 100644 index 00000000..9b8cd4c2 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-4.snap @@ -0,0 +1,63 @@ +--- +source: parser/src/parser/parser.rs +description: "a[b:c]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 6, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 6, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 3, + end: 5, + }, + lower: Some( + Name( + Name { + node: Node { + start: 2, + end: 3, + }, + id: "b", + }, + ), + ), + upper: Some( + Name( + Name { + node: Node { + start: 4, + end: 5, + }, + id: "c", + }, + ), + ), + step: None, + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-5.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-5.snap new file mode 100644 index 00000000..b57c0ba9 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-5.snap @@ -0,0 +1,73 @@ +--- +source: parser/src/parser/parser.rs +description: "a[b:c:d]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 8, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 8, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 3, + end: 7, + }, + lower: Some( + Name( + Name { + node: Node { + start: 2, + end: 3, + }, + id: "b", + }, + ), + ), + upper: Some( + Name( + Name { + node: Node { + start: 4, + end: 5, + }, + id: "c", + }, + ), + ), + step: Some( + Name( + Name { + node: Node { + start: 6, + end: 7, + }, + id: "d", + }, + ), + ), + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-6.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-6.snap new file mode 100644 index 00000000..24106aee --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-6.snap @@ -0,0 +1,69 @@ +--- +source: parser/src/parser/parser.rs +description: "a[b, c, d]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 10, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 10, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 2, + end: 10, + }, + elements: [ + Name( + Name { + node: Node { + start: 2, + end: 3, + }, + id: "b", + }, + ), + Name( + Name { + node: Node { + start: 5, + end: 6, + }, + id: "c", + }, + ), + Name( + Name { + node: Node { + start: 8, + end: 9, + }, + id: "d", + }, + ), + ], + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-7.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-7.snap new file mode 100644 index 00000000..3c58f61c --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-7.snap @@ -0,0 +1,91 @@ +--- +source: parser/src/parser/parser.rs +description: "a[b, c: d, e]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 13, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 13, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 2, + end: 13, + }, + elements: [ + Name( + Name { + node: Node { + start: 2, + end: 3, + }, + id: "b", + }, + ), + Slice( + Slice { + node: Node { + start: 6, + end: 9, + }, + lower: Some( + Name( + Name { + node: Node { + start: 5, + end: 6, + }, + id: "c", + }, + ), + ), + upper: Some( + Name( + Name { + node: Node { + start: 8, + end: 9, + }, + id: "d", + }, + ), + ), + step: None, + }, + ), + Name( + Name { + node: Node { + start: 11, + end: 12, + }, + id: "e", + }, + ), + ], + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-8.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-8.snap new file mode 100644 index 00000000..097bd0b1 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-8.snap @@ -0,0 +1,43 @@ +--- +source: parser/src/parser/parser.rs +description: "a[::]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 5, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 5, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 2, + end: 4, + }, + lower: None, + upper: None, + step: None, + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-9.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-9.snap new file mode 100644 index 00000000..a488b6fd --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-9.snap @@ -0,0 +1,101 @@ +--- +source: parser/src/parser/parser.rs +description: "a[b, c:d:e, f]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 14, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 14, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 2, + end: 14, + }, + elements: [ + Name( + Name { + node: Node { + start: 2, + end: 3, + }, + id: "b", + }, + ), + Slice( + Slice { + node: Node { + start: 6, + end: 10, + }, + lower: Some( + Name( + Name { + node: Node { + start: 5, + end: 6, + }, + id: "c", + }, + ), + ), + upper: Some( + Name( + Name { + node: Node { + start: 7, + end: 8, + }, + id: "d", + }, + ), + ), + step: Some( + Name( + Name { + node: Node { + start: 9, + end: 10, + }, + id: "e", + }, + ), + ), + }, + ), + Name( + Name { + node: Node { + start: 12, + end: 13, + }, + id: "f", + }, + ), + ], + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py.snap new file mode 100644 index 00000000..20c87811 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py.snap @@ -0,0 +1,84 @@ +--- +source: parser/src/parser/parser.rs +description: "indices = list_of_key_stats[0::2]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 33, + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 0, + end: 33, + }, + targets: [ + Name( + Name { + node: Node { + start: 0, + end: 7, + }, + id: "indices", + }, + ), + ], + value: Subscript( + Subscript { + node: Node { + start: 10, + end: 33, + }, + value: Name( + Name { + node: Node { + start: 10, + end: 27, + }, + id: "list_of_key_stats", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 29, + end: 32, + }, + lower: Some( + Constant( + Constant { + node: Node { + start: 28, + end: 29, + }, + value: Int( + "0", + ), + }, + ), + ), + upper: None, + step: Some( + Constant( + Constant { + node: Node { + start: 31, + end: 32, + }, + value: Int( + "2", + ), + }, + ), + ), + }, + ), + }, + ), + }, + ), + ], +} diff --git a/parser/test_data/inputs/one_liners/dict.py b/parser/test_data/inputs/one_liners/dict.py index d4c3d54b..2ebba47d 100644 --- a/parser/test_data/inputs/one_liners/dict.py +++ b/parser/test_data/inputs/one_liners/dict.py @@ -19,3 +19,13 @@ {1: "name" for name in get_names() } + +aggregated_key_stats[idx_stat] = { + **filter_value_NONE, + **filter_key_found, + **client_types, + **market_watch, + "symbol": symbol, + "name": name, +} + diff --git a/parser/test_data/inputs/one_liners/subscript.py b/parser/test_data/inputs/one_liners/subscript.py new file mode 100644 index 00000000..c9679902 --- /dev/null +++ b/parser/test_data/inputs/one_liners/subscript.py @@ -0,0 +1,19 @@ +indices = list_of_key_stats[0::2] + +values = list_of_key_stats[1::2] + +a[b] + +a[b:c] + +a[b:c:d] + +a[b, c, d] + +a[b, c: d, e] + +a[::] + +a[b, c:d:e, f] + +a[::d,] From 75bdbe81076752c30ccfa81cc612eb6e12ff29ff Mon Sep 17 00:00:00 2001 From: Glyphack Date: Sat, 7 Oct 2023 18:51:54 +0200 Subject: [PATCH 2/5] Fix dict that starts with unpacking --- parser/src/parser/parser.rs | 48 ++++-- ...ser__tests__one_liners@dict.py-10.snap.new | 96 ------------ ...__parser__tests__one_liners@dict.py-9.snap | 137 ++++++++++++++++++ ...rser__tests__one_liners@dict.py-9.snap.new | 44 ------ parser/test_data/inputs/one_liners/dict.py | 1 - 5 files changed, 173 insertions(+), 153 deletions(-) delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-10.snap.new create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap.new diff --git a/parser/src/parser/parser.rs b/parser/src/parser/parser.rs index ff1555b3..907be6d3 100644 --- a/parser/src/parser/parser.rs +++ b/parser/src/parser/parser.rs @@ -1915,6 +1915,11 @@ impl Parser { values: vec![], }))); } + if self.at(Kind::Pow) { + // key must be None + let (key, value) = self.parse_double_starred_kv_pair()?; + return self.parse_dict(node, key, value) + } let first_key_or_element = self.parse_star_named_expression()?; if matches!( self.cur_kind(), @@ -1922,7 +1927,9 @@ impl Parser { ) { self.parse_set(node, first_key_or_element) } else { - self.parse_dict(node, first_key_or_element) + self.expect(Kind::Colon)?; + let first_value = self.parse_expression_2()?; + self.parse_dict(node, Some(first_key_or_element), first_value) } } @@ -1957,17 +1964,30 @@ impl Parser { fn parse_dict( &mut self, node: Node, - first_key: Expression, + first_key: Option, + first_value: Expression, ) -> Result { - self.expect(Kind::Colon)?; - let first_val = self.parse_expression_2()?; if self.at(Kind::For) || self.at(Kind::Async) && matches!(self.peek_kind(), Ok(Kind::For)) { + let key = if first_key.is_none() { + let err = ParsingError::InvalidSyntax { + path: Box::from(self.path.as_str()), + msg: Box::from("cannot use ** in dict comprehension"), + line: self.get_line_number_of_character_position(self.cur_token.end), + input: self.curr_line_string.clone(), + advice: "".into(), + span: (node.start, node.end), + }; + return Err(err); + } else { + first_key.unwrap() + }; + // make sure the first key is some let generators = self.parse_comp_for()?; self.expect(Kind::RightBracket)?; Ok(Expression::DictComp(Box::new(DictComp { node: self.finish_node(node), - key: Box::new(first_key), - value: Box::new(first_val), + key: Box::new(key), + value: Box::new(first_value), generators, }))) } else { @@ -1977,13 +1997,17 @@ impl Parser { self.expect(Kind::Comma)?; self.consume_whitespace_and_newline(); } - let mut keys = vec![first_key]; - let mut values = vec![first_val]; + let mut keys = match first_key { + Some(k) => vec![k], + None => vec![], + }; + let mut values = vec![first_value]; while !self.eat(Kind::RightBracket) { - let key = self.parse_expression_2()?; - self.expect(Kind::Colon)?; - let value = self.parse_expression_2()?; - keys.push(key); + let (key, value) = self.parse_double_starred_kv_pair()?; + match key { + Some(k) => keys.push(k), + None => {} + } values.push(value); if !self.at(Kind::RightBracket) { self.expect(Kind::Comma)?; diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-10.snap.new b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-10.snap.new deleted file mode 100644 index f5753c6c..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-10.snap.new +++ /dev/null @@ -1,96 +0,0 @@ ---- -source: parser/src/parser/parser.rs -assertion_line: 3706 -description: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,\n **market_watch,\n \"symbol\": symbol,\n \"name\": name,\n}" -input_file: parser/test_data/inputs/one_liners/dict.py ---- -[ - InvalidSyntax { - path: "dict.py", - msg: "Unexpected token Pow", - line: 2, - input: "aggregated_key_stats[idx_stat] = {\n **", - advice: "", - span: ( - 39, - 41, - ), - }, - InvalidSyntax { - path: "dict.py", - msg: "Unexpected token Comma", - line: 2, - input: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,", - advice: "", - span: ( - 58, - 59, - ), - }, - InvalidSyntax { - path: "dict.py", - msg: "Unexpected token Pow", - line: 4, - input: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **", - advice: "", - span: ( - 88, - 90, - ), - }, - InvalidSyntax { - path: "dict.py", - msg: "Unexpected token Comma", - line: 4, - input: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,", - advice: "", - span: ( - 102, - 103, - ), - }, - InvalidSyntax { - path: "dict.py", - msg: "Statement does not end in new line or semicolon", - line: 1, - input: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,\n **market_watch,\n \"symbol\": symbol", - advice: "Split the statements into two seperate lines or add a semicolon", - span: ( - 128, - 144, - ), - }, - InvalidSyntax { - path: "dict.py", - msg: "Unexpected token Comma", - line: 6, - input: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,\n **market_watch,\n \"symbol\": symbol,", - advice: "", - span: ( - 144, - 145, - ), - }, - InvalidSyntax { - path: "dict.py", - msg: "Unexpected token Colon", - line: 7, - input: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,\n **market_watch,\n \"symbol\": symbol,\n \"name\":", - advice: "", - span: ( - 156, - 157, - ), - }, - InvalidSyntax { - path: "dict.py", - msg: "Unexpected token Comma", - line: 7, - input: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,\n **market_watch,\n \"symbol\": symbol,\n \"name\": name,", - advice: "", - span: ( - 162, - 163, - ), - }, -] diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap new file mode 100644 index 00000000..d2fc6863 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap @@ -0,0 +1,137 @@ +--- +source: parser/src/parser/parser.rs +description: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,\n **market_watch,\n \"symbol\": symbol,\n \"name\": name,\n}\n" +input_file: parser/test_data/inputs/one_liners/dict.py +--- +Module { + node: Node { + start: 0, + end: 166, + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 0, + end: 165, + }, + targets: [ + Subscript( + Subscript { + node: Node { + start: 0, + end: 30, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 20, + }, + id: "aggregated_key_stats", + }, + ), + slice: Name( + Name { + node: Node { + start: 21, + end: 29, + }, + id: "idx_stat", + }, + ), + }, + ), + ], + value: Dict( + Dict { + node: Node { + start: 33, + end: 165, + }, + keys: [ + Constant( + Constant { + node: Node { + start: 128, + end: 136, + }, + value: Str( + "symbol", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 150, + end: 156, + }, + value: Str( + "name", + ), + }, + ), + ], + values: [ + Name( + Name { + node: Node { + start: 41, + end: 58, + }, + id: "filter_value_NONE", + }, + ), + Name( + Name { + node: Node { + start: 66, + end: 82, + }, + id: "filter_key_found", + }, + ), + Name( + Name { + node: Node { + start: 90, + end: 102, + }, + id: "client_types", + }, + ), + Name( + Name { + node: Node { + start: 110, + end: 122, + }, + id: "market_watch", + }, + ), + Name( + Name { + node: Node { + start: 138, + end: 144, + }, + id: "symbol", + }, + ), + Name( + Name { + node: Node { + start: 158, + end: 162, + }, + id: "name", + }, + ), + ], + }, + ), + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap.new b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap.new deleted file mode 100644 index c78769f4..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap.new +++ /dev/null @@ -1,44 +0,0 @@ ---- -source: parser/src/parser/parser.rs -assertion_line: 3699 -description: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,\n **market_watch,\n \"symbol\": symbol,\n \"name\": name,\n}" -input_file: parser/test_data/inputs/one_liners/dict.py ---- -Module { - node: Node { - start: 0, - end: 165, - }, - body: [ - AnnAssignStatement( - AnnAssign { - node: Node { - start: 128, - end: 144, - }, - target: Constant( - Constant { - node: Node { - start: 128, - end: 136, - }, - value: Str( - "symbol", - ), - }, - ), - annotation: Name( - Name { - node: Node { - start: 138, - end: 144, - }, - id: "symbol", - }, - ), - value: None, - simple: true, - }, - ), - ], -} diff --git a/parser/test_data/inputs/one_liners/dict.py b/parser/test_data/inputs/one_liners/dict.py index 2ebba47d..29c92570 100644 --- a/parser/test_data/inputs/one_liners/dict.py +++ b/parser/test_data/inputs/one_liners/dict.py @@ -28,4 +28,3 @@ "symbol": symbol, "name": name, } - From 4919fff2e8de279c912e68331d4ecae8740eca73 Mon Sep 17 00:00:00 2001 From: Glyphack Date: Sat, 7 Oct 2023 18:53:14 +0200 Subject: [PATCH 3/5] Add more tests --- ..._parser__tests__one_liners@dict.py-10.snap | 122 ++++++++++++++++++ ...__parser__tests__one_liners@dict.py-9.snap | 4 +- parser/test_data/inputs/one_liners/dict.py | 2 + 3 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-10.snap diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-10.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-10.snap new file mode 100644 index 00000000..f647bc3a --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-10.snap @@ -0,0 +1,122 @@ +--- +source: parser/src/parser/parser.rs +description: "di = {1: \"name\", **{2: \"name2\"}, 3: \"name3\"}\n" +input_file: parser/test_data/inputs/one_liners/dict.py +--- +Module { + node: Node { + start: 0, + end: 45, + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 0, + end: 44, + }, + targets: [ + Name( + Name { + node: Node { + start: 0, + end: 2, + }, + id: "di", + }, + ), + ], + value: Dict( + Dict { + node: Node { + start: 5, + end: 44, + }, + keys: [ + Constant( + Constant { + node: Node { + start: 6, + end: 7, + }, + value: Int( + "1", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 33, + end: 34, + }, + value: Int( + "3", + ), + }, + ), + ], + values: [ + Constant( + Constant { + node: Node { + start: 9, + end: 15, + }, + value: Str( + "name", + ), + }, + ), + Dict( + Dict { + node: Node { + start: 19, + end: 31, + }, + keys: [ + Constant( + Constant { + node: Node { + start: 20, + end: 21, + }, + value: Int( + "2", + ), + }, + ), + ], + values: [ + Constant( + Constant { + node: Node { + start: 23, + end: 30, + }, + value: Str( + "name2", + ), + }, + ), + ], + }, + ), + Constant( + Constant { + node: Node { + start: 36, + end: 43, + }, + value: Str( + "name3", + ), + }, + ), + ], + }, + ), + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap index d2fc6863..7a262209 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap @@ -1,12 +1,12 @@ --- source: parser/src/parser/parser.rs -description: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,\n **market_watch,\n \"symbol\": symbol,\n \"name\": name,\n}\n" +description: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,\n **market_watch,\n \"symbol\": symbol,\n \"name\": name,\n}" input_file: parser/test_data/inputs/one_liners/dict.py --- Module { node: Node { start: 0, - end: 166, + end: 165, }, body: [ AssignStatement( diff --git a/parser/test_data/inputs/one_liners/dict.py b/parser/test_data/inputs/one_liners/dict.py index 29c92570..8e332403 100644 --- a/parser/test_data/inputs/one_liners/dict.py +++ b/parser/test_data/inputs/one_liners/dict.py @@ -28,3 +28,5 @@ "symbol": symbol, "name": name, } + +di = {1: "name", **{2: "name2"}, 3: "name3"} From 6ce902f2401f732db03d235ce956163bcae47c08 Mon Sep 17 00:00:00 2001 From: Glyphack Date: Sat, 7 Oct 2023 19:55:13 +0200 Subject: [PATCH 4/5] Fix with statement consuming dedents --- parser/src/lexer/lexer.rs | 6 +- parser/src/parser/parser.rs | 2 - ...ser__tests__complete@input_program.py.snap | 16416 ++++++++-------- ...arser__parser__tests__complete@try.py.snap | 802 +- parser/test_data/inputs/try.py | 22 + 5 files changed, 9032 insertions(+), 8216 deletions(-) diff --git a/parser/src/lexer/lexer.rs b/parser/src/lexer/lexer.rs index 74b89f1c..f7374ff7 100644 --- a/parser/src/lexer/lexer.rs +++ b/parser/src/lexer/lexer.rs @@ -859,9 +859,11 @@ impl Lexer { } } if de_indents != 1 { - self.next_token_is_dedent += 1; + // minus 1 because the dedent with actual Indent value is already added + // This is super hacky and I don't like it + self.next_token_is_dedent += de_indents - 1; } - TokenValue::Indent(de_indents) + TokenValue::Indent(de_indents.into()) } Kind::Indent => TokenValue::Indent(1), _ => TokenValue::None, diff --git a/parser/src/parser/parser.rs b/parser/src/parser/parser.rs index 907be6d3..59fb9778 100644 --- a/parser/src/parser/parser.rs +++ b/parser/src/parser/parser.rs @@ -539,8 +539,6 @@ impl Parser { self.expect(Kind::Colon)?; let body = self.parse_suite()?; - self.bump(Kind::Dedent); - if is_async { Ok(Statement::AsyncWithStatement(AsyncWith { node: self.finish_node(node), diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap index 48419f6d..7bc38468 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap @@ -2496,7 +2496,7 @@ Module { For { node: Node { start: 1955, - end: 15273, + end: 4346, }, target: Name( Name { @@ -3092,7 +3092,7 @@ Module { For { node: Node { start: 2698, - end: 4346, + end: 4203, }, target: Name( Name { @@ -4551,676 +4551,364 @@ Module { orelse: [], }, ), - IfStatement( - If { - node: Node { - start: 4203, - end: 4309, + ], + orelse: [], + }, + ), + IfStatement( + If { + node: Node { + start: 4203, + end: 4309, + }, + test: Compare( + Compare { + node: Node { + start: 4206, + end: 4234, + }, + left: Call( + Call { + node: Node { + start: 4206, + end: 4218, + }, + func: Name( + Name { + node: Node { + start: 4206, + end: 4209, + }, + id: "len", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 4210, + end: 4217, + }, + id: "df_list", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, }, - test: Compare( - Compare { + ), + ops: [ + NotEq, + ], + comparators: [ + Call( + Call { node: Node { - start: 4206, + start: 4222, end: 4234, }, - left: Call( - Call { + func: Name( + Name { node: Node { - start: 4206, - end: 4218, + start: 4222, + end: 4225, }, - func: Name( - Name { - node: Node { - start: 4206, - end: 4209, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 4210, - end: 4217, - }, - id: "df_list", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "len", }, ), - ops: [ - NotEq, - ], - comparators: [ - Call( - Call { + args: [ + Name( + Name { node: Node { - start: 4222, - end: 4234, + start: 4226, + end: 4233, }, - func: Name( - Name { - node: Node { - start: 4222, - end: 4225, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 4226, - end: 4233, - }, - id: "symbols", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "symbols", }, ), ], + keywords: [], + starargs: None, + kwargs: None, }, ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 4244, - end: 4304, - }, - func: Name( - Name { - node: Node { - start: 4244, - end: 4249, - }, - id: "print", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 4250, - end: 4303, - }, - value: Str( - "Warning, download did not complete, re-run the code", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], - }, - ), + ], + }, + ), + body: [ ExpressionStatement( Call( Call { node: Node { - start: 4322, - end: 4324, + start: 4244, + end: 4304, }, - func: Attribute( - Attribute { + func: Name( + Name { node: Node { - start: 4309, - end: 4322, + start: 4244, + end: 4249, }, - value: Name( - Name { - node: Node { - start: 4309, - end: 4316, - }, - id: "session", - }, - ), - attr: "close", + id: "print", }, ), - args: [], + args: [ + Constant( + Constant { + node: Node { + start: 4250, + end: 4303, + }, + value: Str( + "Warning, download did not complete, re-run the code", + ), + }, + ), + ], keywords: [], starargs: None, kwargs: None, }, ), ), - Return( - Return { - node: Node { - start: 4329, - end: 4343, - }, - value: Some( - Name( - Name { - node: Node { - start: 4336, - end: 4343, - }, - id: "df_list", - }, - ), - ), - }, - ), ], orelse: [], }, ), - FunctionDef( - FunctionDef { - node: Node { - start: 4346, - end: 6805, - }, - name: "adjust_price", - args: Arguments { + ExpressionStatement( + Call( + Call { node: Node { - start: 4363, - end: 4379, + start: 4322, + end: 4324, }, - posonlyargs: [], - args: [ - Arg { + func: Attribute( + Attribute { node: Node { - start: 4363, - end: 4379, + start: 4309, + end: 4322, }, - arg: "df", - annotation: Some( - Attribute( - Attribute { - node: Node { - start: 4367, - end: 4379, - }, - value: Name( - Name { - node: Node { - start: 4367, - end: 4369, - }, - id: "pd", - }, - ), - attr: "DataFrame", + value: Name( + Name { + node: Node { + start: 4309, + end: 4316, }, - ), + id: "session", + }, ), + attr: "close", }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, }, - body: [ - ExpressionStatement( - Constant( - Constant { - node: Node { - start: 4402, - end: 5588, - }, - value: Str( - "\n Adjust historical records of stock\n\n There is a capital increase/profit sharing,\n if today \"Final Close Price\" is not equal to next day\n \"Yesterday Final Close Price\" by using this ratio,\n performance adjustment of stocks is achieved\n\n Parameters\n ----------\n df : pd.DataFrame\n DataFrame with historical records.\n\n Returns\n -------\n pd.DataFrame\n DataFrame with adjusted historical records.\n\n Notes\n -----\n DataFrame can not be empty or else it makes runtime error\n Type of DataFrame must be RangeIndex to make proper range of records\n that need to be modified\n\n diff: list\n list of indexs of the day after capital increase/profit sharing\n ratio_list: List\n List of ratios to adjust historical data of stock\n ratio: Float\n ratio = df.loc[i].adjClose / df.loc[i+1].yesterday\n\n Description\n -----------\n # Note: adjustment does not include Tenth and twentieth days\n df.index = range(0,101,1)\n # step is 1\n step = df.index.step\n diff = [10,20]\n ratio_list = [0.5, 0.8]\n df.loc[0:10-step, [open,...]] * ratio[0]\n df.loc[10:20-step, [open,...]] * ratio[1]\n ", - ), + ), + ), + Return( + Return { + node: Node { + start: 4329, + end: 4343, + }, + value: Some( + Name( + Name { + node: Node { + start: 4336, + end: 4343, }, - ), + id: "df_list", + }, ), - IfStatement( - If { + ), + }, + ), + ], + orelse: [], + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 4346, + end: 6805, + }, + name: "adjust_price", + args: Arguments { + node: Node { + start: 4363, + end: 4379, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 4363, + end: 4379, + }, + arg: "df", + annotation: Some( + Attribute( + Attribute { node: Node { - start: 5593, - end: 5691, + start: 4367, + end: 4379, }, - test: BoolOp( - BoolOperation { + value: Name( + Name { node: Node { - start: 5596, - end: 5666, + start: 4367, + end: 4369, }, - op: Or, - values: [ - Attribute( - Attribute { - node: Node { - start: 5596, - end: 5604, - }, - value: Name( - Name { - node: Node { - start: 5596, - end: 5598, - }, - id: "df", - }, - ), - attr: "empty", - }, - ), - UnaryOp( - UnaryOperation { - node: Node { - start: 5608, - end: 5666, - }, - op: Not, - operand: Call( - Call { - node: Node { - start: 5612, - end: 5666, - }, - func: Name( - Name { - node: Node { - start: 5612, - end: 5622, - }, - id: "isinstance", - }, - ), - args: [ - Attribute( - Attribute { - node: Node { - start: 5623, - end: 5631, - }, - value: Name( - Name { - node: Node { - start: 5623, - end: 5625, - }, - id: "df", - }, - ), - attr: "index", - }, - ), - Attribute( - Attribute { - node: Node { - start: 5633, - end: 5665, - }, - value: Attribute( - Attribute { - node: Node { - start: 5633, - end: 5654, - }, - value: Attribute( - Attribute { - node: Node { - start: 5633, - end: 5648, - }, - value: Attribute( - Attribute { - node: Node { - start: 5633, - end: 5640, - }, - value: Name( - Name { - node: Node { - start: 5633, - end: 5635, - }, - id: "pd", - }, - ), - attr: "core", - }, - ), - attr: "indexes", - }, - ), - attr: "range", - }, - ), - attr: "RangeIndex", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], + id: "pd", }, ), - body: [ - Return( - Return { - node: Node { - start: 5676, - end: 5685, - }, - value: Some( - Name( - Name { - node: Node { - start: 5683, - end: 5685, - }, - id: "df", - }, - ), - ), - }, - ), - ], - orelse: [], + attr: "DataFrame", }, ), - AssignStatement( - Assign { - node: Node { - start: 5691, - end: 5709, - }, - targets: [ - Name( - Name { - node: Node { - start: 5691, - end: 5697, - }, - id: "new_df", - }, - ), - ], - value: Call( - Call { + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + ExpressionStatement( + Constant( + Constant { + node: Node { + start: 4402, + end: 5588, + }, + value: Str( + "\n Adjust historical records of stock\n\n There is a capital increase/profit sharing,\n if today \"Final Close Price\" is not equal to next day\n \"Yesterday Final Close Price\" by using this ratio,\n performance adjustment of stocks is achieved\n\n Parameters\n ----------\n df : pd.DataFrame\n DataFrame with historical records.\n\n Returns\n -------\n pd.DataFrame\n DataFrame with adjusted historical records.\n\n Notes\n -----\n DataFrame can not be empty or else it makes runtime error\n Type of DataFrame must be RangeIndex to make proper range of records\n that need to be modified\n\n diff: list\n list of indexs of the day after capital increase/profit sharing\n ratio_list: List\n List of ratios to adjust historical data of stock\n ratio: Float\n ratio = df.loc[i].adjClose / df.loc[i+1].yesterday\n\n Description\n -----------\n # Note: adjustment does not include Tenth and twentieth days\n df.index = range(0,101,1)\n # step is 1\n step = df.index.step\n diff = [10,20]\n ratio_list = [0.5, 0.8]\n df.loc[0:10-step, [open,...]] * ratio[0]\n df.loc[10:20-step, [open,...]] * ratio[1]\n ", + ), + }, + ), + ), + IfStatement( + If { + node: Node { + start: 5593, + end: 5691, + }, + test: BoolOp( + BoolOperation { + node: Node { + start: 5596, + end: 5666, + }, + op: Or, + values: [ + Attribute( + Attribute { node: Node { - start: 5707, - end: 5709, + start: 5596, + end: 5604, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 5700, - end: 5707, + start: 5596, + end: 5598, }, - value: Name( - Name { - node: Node { - start: 5700, - end: 5702, - }, - id: "df", - }, - ), - attr: "copy", + id: "df", }, ), - args: [], - keywords: [], - starargs: None, - kwargs: None, + attr: "empty", }, ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 5714, - end: 5738, - }, - targets: [ - Name( - Name { - node: Node { - start: 5714, - end: 5718, - }, - id: "step", - }, - ), - ], - value: Attribute( - Attribute { + UnaryOp( + UnaryOperation { node: Node { - start: 5721, - end: 5738, + start: 5608, + end: 5666, }, - value: Attribute( - Attribute { + op: Not, + operand: Call( + Call { node: Node { - start: 5721, - end: 5733, + start: 5612, + end: 5666, }, - value: Name( + func: Name( Name { node: Node { - start: 5721, - end: 5727, + start: 5612, + end: 5622, }, - id: "new_df", + id: "isinstance", }, ), - attr: "index", - }, - ), - attr: "step", - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 5743, - end: 5814, - }, - targets: [ - Name( - Name { - node: Node { - start: 5743, - end: 5747, - }, - id: "diff", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 5750, - end: 5814, - }, - func: Name( - Name { - node: Node { - start: 5750, - end: 5754, - }, - id: "list", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 5767, - end: 5813, - }, - value: Attribute( + args: [ + Attribute( Attribute { node: Node { - start: 5755, - end: 5767, + start: 5623, + end: 5631, }, value: Name( Name { node: Node { - start: 5755, - end: 5761, + start: 5623, + end: 5625, }, - id: "new_df", + id: "df", }, ), attr: "index", }, ), - slice: Compare( - Compare { + Attribute( + Attribute { node: Node { - start: 5768, - end: 5812, + start: 5633, + end: 5665, }, - left: Attribute( + value: Attribute( Attribute { node: Node { - start: 5783, - end: 5792, + start: 5633, + end: 5654, }, - value: Call( - Call { + value: Attribute( + Attribute { node: Node { - start: 5780, - end: 5783, + start: 5633, + end: 5648, }, - func: Attribute( + value: Attribute( Attribute { node: Node { - start: 5768, - end: 5780, + start: 5633, + end: 5640, }, value: Name( Name { node: Node { - start: 5768, - end: 5774, + start: 5633, + end: 5635, }, - id: "new_df", + id: "pd", }, ), - attr: "shift", + attr: "core", }, ), - args: [ - Constant( - Constant { - node: Node { - start: 5781, - end: 5782, - }, - value: Int( - "1", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + attr: "indexes", }, ), - attr: "adjClose", + attr: "range", }, ), - ops: [ - NotEq, - ], - comparators: [ - Attribute( - Attribute { - node: Node { - start: 5796, - end: 5812, - }, - value: Name( - Name { - node: Node { - start: 5796, - end: 5802, - }, - id: "new_df", - }, - ), - attr: "yesterday", - }, - ), - ], - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 5819, - end: 5861, - }, - test: Compare( - Compare { - node: Node { - start: 5822, - end: 5835, - }, - left: Call( - Call { - node: Node { - start: 5822, - end: 5831, - }, - func: Name( - Name { - node: Node { - start: 5822, - end: 5825, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 5826, - end: 5830, - }, - id: "diff", + attr: "RangeIndex", }, ), ], @@ -5229,1233 +4917,1022 @@ Module { kwargs: None, }, ), - ops: [ - Gt, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 5834, - end: 5835, - }, - value: Int( - "0", - ), - }, - ), - ], }, ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 5853, - end: 5856, - }, - func: Attribute( - Attribute { - node: Node { - start: 5845, - end: 5853, - }, - value: Name( - Name { - node: Node { - start: 5845, - end: 5849, - }, - id: "diff", - }, - ), - attr: "pop", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 5854, - end: 5855, - }, - value: Int( - "0", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], - }, - ), - AssignStatement( - Assign { + ], + }, + ), + body: [ + Return( + Return { node: Node { - start: 5861, - end: 5870, + start: 5676, + end: 5685, }, - targets: [ + value: Some( Name( Name { node: Node { - start: 5861, - end: 5866, + start: 5683, + end: 5685, }, - id: "ratio", + id: "df", }, ), - ], - value: Constant( - Constant { - node: Node { - start: 5869, - end: 5870, - }, - value: Int( - "1", - ), - }, ), }, ), - AssignStatement( - Assign { + ], + orelse: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 5691, + end: 5709, + }, + targets: [ + Name( + Name { node: Node { - start: 5875, - end: 5890, + start: 5691, + end: 5697, }, - targets: [ - Name( + id: "new_df", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 5707, + end: 5709, + }, + func: Attribute( + Attribute { + node: Node { + start: 5700, + end: 5707, + }, + value: Name( Name { node: Node { - start: 5875, - end: 5885, + start: 5700, + end: 5702, }, - id: "ratio_list", + id: "df", }, ), - ], - value: List( - List { - node: Node { - start: 5888, - end: 5890, - }, - elements: [], - }, - ), + attr: "copy", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 5714, + end: 5738, + }, + targets: [ + Name( + Name { + node: Node { + start: 5714, + end: 5718, + }, + id: "step", }, ), - ForStatement( - For { + ], + value: Attribute( + Attribute { + node: Node { + start: 5721, + end: 5738, + }, + value: Attribute( + Attribute { + node: Node { + start: 5721, + end: 5733, + }, + value: Name( + Name { + node: Node { + start: 5721, + end: 5727, + }, + id: "new_df", + }, + ), + attr: "index", + }, + ), + attr: "step", + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 5743, + end: 5814, + }, + targets: [ + Name( + Name { node: Node { - start: 5895, - end: 6061, + start: 5743, + end: 5747, }, - target: Name( - Name { - node: Node { - start: 5899, - end: 5900, - }, - id: "i", + id: "diff", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 5750, + end: 5814, + }, + func: Name( + Name { + node: Node { + start: 5750, + end: 5754, }, - ), - iter: Subscript( + id: "list", + }, + ), + args: [ + Subscript( Subscript { node: Node { - start: 5904, - end: 5914, + start: 5767, + end: 5813, }, - value: Name( - Name { + value: Attribute( + Attribute { node: Node { - start: 5904, - end: 5908, + start: 5755, + end: 5767, }, - id: "diff", + value: Name( + Name { + node: Node { + start: 5755, + end: 5761, + }, + id: "new_df", + }, + ), + attr: "index", }, ), - slice: Slice( - Slice { + slice: Compare( + Compare { node: Node { - start: 5909, - end: 5913, + start: 5768, + end: 5812, }, - lower: None, - upper: Some( - UnaryOp( - UnaryOperation { - node: Node { - start: 5911, - end: 5913, - }, - op: USub, - operand: Constant( - Constant { - node: Node { - start: 5912, - end: 5913, + left: Attribute( + Attribute { + node: Node { + start: 5783, + end: 5792, + }, + value: Call( + Call { + node: Node { + start: 5780, + end: 5783, + }, + func: Attribute( + Attribute { + node: Node { + start: 5768, + end: 5780, + }, + value: Name( + Name { + node: Node { + start: 5768, + end: 5774, + }, + id: "new_df", + }, + ), + attr: "shift", }, - value: Int( - "1", + ), + args: [ + Constant( + Constant { + node: Node { + start: 5781, + end: 5782, + }, + value: Int( + "1", + ), + }, ), - }, - ), - }, - ), - ), - step: None, - }, - ), - }, - ), - body: [ - AugAssignStatement( - AugAssign { - node: Node { - start: 5924, - end: 6020, - }, - target: Name( - Name { - node: Node { - start: 5924, - end: 5929, - }, - id: "ratio", - }, - ), - op: Mult, - value: BinOp( - BinOp { - node: Node { - start: 5947, - end: 6010, - }, - op: Div, - left: Subscript( - Subscript { - node: Node { - start: 5957, - end: 5973, + ], + keywords: [], + starargs: None, + kwargs: None, }, - value: Attribute( - Attribute { - node: Node { - start: 5947, - end: 5957, - }, - value: Name( - Name { - node: Node { - start: 5947, - end: 5953, - }, - id: "new_df", - }, - ), - attr: "loc", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 5958, - end: 5973, - }, - elements: [ - Name( - Name { - node: Node { - start: 5958, - end: 5959, - }, - id: "i", - }, - ), - Constant( - Constant { - node: Node { - start: 5961, - end: 5972, - }, - value: Str( - "yesterday", - ), - }, - ), - ], - }, - ), - }, - ), - right: Subscript( - Subscript { + ), + attr: "adjClose", + }, + ), + ops: [ + NotEq, + ], + comparators: [ + Attribute( + Attribute { node: Node { - start: 5995, - end: 6010, + start: 5796, + end: 5812, }, - value: Attribute( - Attribute { - node: Node { - start: 5991, - end: 5995, - }, - value: Call( - Call { - node: Node { - start: 5988, - end: 5991, - }, - func: Attribute( - Attribute { - node: Node { - start: 5976, - end: 5988, - }, - value: Name( - Name { - node: Node { - start: 5976, - end: 5982, - }, - id: "new_df", - }, - ), - attr: "shift", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 5989, - end: 5990, - }, - value: Int( - "1", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "loc", - }, - ), - slice: Tuple( - Tuple { + value: Name( + Name { node: Node { - start: 5996, - end: 6010, + start: 5796, + end: 5802, }, - elements: [ - Name( - Name { - node: Node { - start: 5996, - end: 5997, - }, - id: "i", - }, - ), - Constant( - Constant { - node: Node { - start: 5999, - end: 6009, - }, - value: Str( - "adjClose", - ), - }, - ), - ], + id: "new_df", }, ), + attr: "yesterday", }, ), - }, - ), + ], + }, + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 5819, + end: 5861, + }, + test: Compare( + Compare { + node: Node { + start: 5822, + end: 5835, + }, + left: Call( + Call { + node: Node { + start: 5822, + end: 5831, + }, + func: Name( + Name { + node: Node { + start: 5822, + end: 5825, + }, + id: "len", }, ), - ExpressionStatement( - Call( - Call { + args: [ + Name( + Name { node: Node { - start: 6046, - end: 6056, + start: 5826, + end: 5830, }, - func: Attribute( - Attribute { - node: Node { - start: 6029, - end: 6046, - }, - value: Name( - Name { - node: Node { - start: 6029, - end: 6039, - }, - id: "ratio_list", - }, - ), - attr: "insert", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 6047, - end: 6048, - }, - value: Int( - "0", - ), - }, - ), - Name( - Name { - node: Node { - start: 6050, - end: 6055, - }, - id: "ratio", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "diff", }, ), - ), - ], - orelse: [], - }, - ), - ForStatement( - For { - node: Node { - start: 6061, - end: 6789, + ], + keywords: [], + starargs: None, + kwargs: None, }, - target: Tuple( - Tuple { + ), + ops: [ + Gt, + ], + comparators: [ + Constant( + Constant { node: Node { - start: 6065, - end: 6069, + start: 5834, + end: 5835, }, - elements: [ - Name( - Name { - node: Node { - start: 6065, - end: 6066, - }, - id: "i", - }, - ), - Name( + value: Int( + "0", + ), + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 5853, + end: 5856, + }, + func: Attribute( + Attribute { + node: Node { + start: 5845, + end: 5853, + }, + value: Name( Name { node: Node { - start: 6068, - end: 6069, + start: 5845, + end: 5849, }, - id: "k", + id: "diff", }, ), - ], - }, - ), - iter: Call( - Call { - node: Node { - start: 6073, - end: 6088, + attr: "pop", }, - func: Name( - Name { - node: Node { - start: 6073, - end: 6082, - }, - id: "enumerate", - }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 5854, + end: 5855, + }, + value: Int( + "0", + ), + }, ), - args: [ - Name( - Name { - node: Node { - start: 6083, - end: 6087, - }, - id: "diff", + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + orelse: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 5861, + end: 5870, + }, + targets: [ + Name( + Name { + node: Node { + start: 5861, + end: 5866, + }, + id: "ratio", + }, + ), + ], + value: Constant( + Constant { + node: Node { + start: 5869, + end: 5870, + }, + value: Int( + "1", + ), + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 5875, + end: 5890, + }, + targets: [ + Name( + Name { + node: Node { + start: 5875, + end: 5885, + }, + id: "ratio_list", + }, + ), + ], + value: List( + List { + node: Node { + start: 5888, + end: 5890, + }, + elements: [], + }, + ), + }, + ), + ForStatement( + For { + node: Node { + start: 5895, + end: 6061, + }, + target: Name( + Name { + node: Node { + start: 5899, + end: 5900, + }, + id: "i", + }, + ), + iter: Subscript( + Subscript { + node: Node { + start: 5904, + end: 5914, + }, + value: Name( + Name { + node: Node { + start: 5904, + end: 5908, + }, + id: "diff", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 5909, + end: 5913, + }, + lower: None, + upper: Some( + UnaryOp( + UnaryOperation { + node: Node { + start: 5911, + end: 5913, }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + op: USub, + operand: Constant( + Constant { + node: Node { + start: 5912, + end: 5913, + }, + value: Int( + "1", + ), + }, + ), + }, + ), + ), + step: None, + }, + ), + }, + ), + body: [ + AugAssignStatement( + AugAssign { + node: Node { + start: 5924, + end: 6020, + }, + target: Name( + Name { + node: Node { + start: 5924, + end: 5929, + }, + id: "ratio", }, ), - body: [ - IfStatement( - If { - node: Node { - start: 6098, - end: 6202, - }, - test: Compare( - Compare { - node: Node { - start: 6101, - end: 6107, - }, - left: Name( - Name { - node: Node { - start: 6101, - end: 6102, - }, - id: "i", + op: Mult, + value: BinOp( + BinOp { + node: Node { + start: 5947, + end: 6010, + }, + op: Div, + left: Subscript( + Subscript { + node: Node { + start: 5957, + end: 5973, + }, + value: Attribute( + Attribute { + node: Node { + start: 5947, + end: 5957, }, - ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { + value: Name( + Name { node: Node { - start: 6106, - end: 6107, + start: 5947, + end: 5953, }, - value: Int( - "0", - ), + id: "new_df", }, ), - ], - }, - ), - body: [ - AssignStatement( - Assign { + attr: "loc", + }, + ), + slice: Tuple( + Tuple { node: Node { - start: 6121, - end: 6147, + start: 5958, + end: 5973, }, - targets: [ + elements: [ Name( Name { node: Node { - start: 6121, - end: 6126, + start: 5958, + end: 5959, + }, + id: "i", + }, + ), + Constant( + Constant { + node: Node { + start: 5961, + end: 5972, }, - id: "start", + value: Str( + "yesterday", + ), }, ), ], - value: Attribute( - Attribute { + }, + ), + }, + ), + right: Subscript( + Subscript { + node: Node { + start: 5995, + end: 6010, + }, + value: Attribute( + Attribute { + node: Node { + start: 5991, + end: 5995, + }, + value: Call( + Call { node: Node { - start: 6129, - end: 6147, + start: 5988, + end: 5991, }, - value: Attribute( + func: Attribute( Attribute { node: Node { - start: 6129, - end: 6141, + start: 5976, + end: 5988, }, value: Name( Name { node: Node { - start: 6129, - end: 6135, + start: 5976, + end: 5982, }, id: "new_df", }, ), - attr: "index", + attr: "shift", }, ), - attr: "start", + args: [ + Constant( + Constant { + node: Node { + start: 5989, + end: 5990, + }, + value: Int( + "1", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, }, ), + attr: "loc", }, ), - ], - orelse: [ - AssignStatement( - Assign { + slice: Tuple( + Tuple { node: Node { - start: 6174, - end: 6193, + start: 5996, + end: 6010, }, - targets: [ + elements: [ Name( Name { node: Node { - start: 6174, - end: 6179, + start: 5996, + end: 5997, }, - id: "start", + id: "i", }, ), - ], - value: Subscript( - Subscript { - node: Node { - start: 6182, - end: 6193, - }, - value: Name( - Name { - node: Node { - start: 6182, - end: 6186, - }, - id: "diff", - }, - ), - slice: BinOp( - BinOp { - node: Node { - start: 6187, - end: 6192, - }, - op: Sub, - left: Name( - Name { - node: Node { - start: 6187, - end: 6188, - }, - id: "i", - }, - ), - right: Constant( - Constant { - node: Node { - start: 6191, - end: 6192, - }, - value: Int( - "1", - ), - }, - ), + Constant( + Constant { + node: Node { + start: 5999, + end: 6009, }, - ), - }, - ), + value: Str( + "adjClose", + ), + }, + ), + ], }, ), - ], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 6202, - end: 6222, }, - targets: [ - Name( + ), + }, + ), + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 6046, + end: 6056, + }, + func: Attribute( + Attribute { + node: Node { + start: 6029, + end: 6046, + }, + value: Name( + Name { + node: Node { + start: 6029, + end: 6039, + }, + id: "ratio_list", + }, + ), + attr: "insert", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 6047, + end: 6048, + }, + value: Int( + "0", + ), + }, + ), + Name( + Name { + node: Node { + start: 6050, + end: 6055, + }, + id: "ratio", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + orelse: [], + }, + ), + ForStatement( + For { + node: Node { + start: 6061, + end: 6789, + }, + target: Tuple( + Tuple { + node: Node { + start: 6065, + end: 6069, + }, + elements: [ + Name( + Name { + node: Node { + start: 6065, + end: 6066, + }, + id: "i", + }, + ), + Name( + Name { + node: Node { + start: 6068, + end: 6069, + }, + id: "k", + }, + ), + ], + }, + ), + iter: Call( + Call { + node: Node { + start: 6073, + end: 6088, + }, + func: Name( + Name { + node: Node { + start: 6073, + end: 6082, + }, + id: "enumerate", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 6083, + end: 6087, + }, + id: "diff", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + body: [ + IfStatement( + If { + node: Node { + start: 6098, + end: 6202, + }, + test: Compare( + Compare { + node: Node { + start: 6101, + end: 6107, + }, + left: Name( + Name { + node: Node { + start: 6101, + end: 6102, + }, + id: "i", + }, + ), + ops: [ + Eq, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 6106, + end: 6107, + }, + value: Int( + "0", + ), + }, + ), + ], + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 6121, + end: 6147, + }, + targets: [ + Name( Name { node: Node { - start: 6202, - end: 6205, + start: 6121, + end: 6126, }, - id: "end", + id: "start", }, ), ], - value: BinOp( - BinOp { + value: Attribute( + Attribute { node: Node { - start: 6208, - end: 6222, + start: 6129, + end: 6147, }, - op: Sub, - left: Subscript( - Subscript { + value: Attribute( + Attribute { node: Node { - start: 6208, - end: 6215, + start: 6129, + end: 6141, }, value: Name( Name { node: Node { - start: 6208, - end: 6212, - }, - id: "diff", - }, - ), - slice: Name( - Name { - node: Node { - start: 6213, - end: 6214, + start: 6129, + end: 6135, }, - id: "i", + id: "new_df", }, ), + attr: "index", }, ), - right: Name( - Name { - node: Node { - start: 6218, - end: 6222, - }, - id: "step", - }, - ), + attr: "start", }, ), }, ), + ], + orelse: [ AssignStatement( Assign { node: Node { - start: 6231, - end: 6783, + start: 6174, + end: 6193, }, targets: [ - Subscript( - Subscript { + Name( + Name { node: Node { - start: 6241, - end: 6457, + start: 6174, + end: 6179, }, - value: Attribute( - Attribute { - node: Node { - start: 6231, - end: 6241, - }, - value: Name( - Name { - node: Node { - start: 6231, - end: 6237, - }, - id: "new_df", - }, - ), - attr: "loc", + id: "start", + }, + ), + ], + value: Subscript( + Subscript { + node: Node { + start: 6182, + end: 6193, + }, + value: Name( + Name { + node: Node { + start: 6182, + end: 6186, }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 6255, - end: 6457, + id: "diff", + }, + ), + slice: BinOp( + BinOp { + node: Node { + start: 6187, + end: 6192, + }, + op: Sub, + left: Name( + Name { + node: Node { + start: 6187, + end: 6188, + }, + id: "i", }, - elements: [ - Slice( - Slice { - node: Node { - start: 6260, - end: 6264, - }, - lower: Some( - Name( - Name { - node: Node { - start: 6255, - end: 6260, - }, - id: "start", - }, - ), - ), - upper: Some( - Name( - Name { - node: Node { - start: 6261, - end: 6264, - }, - id: "end", - }, - ), - ), - step: None, - }, + ), + right: Constant( + Constant { + node: Node { + start: 6191, + end: 6192, + }, + value: Int( + "1", ), - List( - List { - node: Node { - start: 6278, - end: 6446, - }, - elements: [ - Constant( - Constant { - node: Node { - start: 6296, - end: 6302, - }, - value: Str( - "open", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6320, - end: 6326, - }, - value: Str( - "high", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6344, - end: 6349, - }, - value: Str( - "low", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6367, - end: 6374, - }, - value: Str( - "close", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6392, - end: 6402, - }, - value: Str( - "adjClose", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6420, - end: 6431, - }, - value: Str( - "yesterday", - ), - }, - ), - ], - }, - ), - ], - }, - ), - }, - ), - ], - value: Call( - Call { - node: Node { - start: 6460, - end: 6783, - }, - func: Name( - Name { - node: Node { - start: 6460, - end: 6465, - }, - id: "round", + }, + ), }, ), - args: [ - BinOp( - BinOp { - node: Node { - start: 6479, - end: 6773, - }, - op: Mult, - left: Subscript( - Subscript { - node: Node { - start: 6489, - end: 6745, - }, - value: Attribute( - Attribute { - node: Node { - start: 6479, - end: 6489, - }, - value: Name( - Name { - node: Node { - start: 6479, - end: 6485, - }, - id: "new_df", - }, - ), - attr: "loc", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 6507, - end: 6745, - }, - elements: [ - Slice( - Slice { - node: Node { - start: 6512, - end: 6516, - }, - lower: Some( - Name( - Name { - node: Node { - start: 6507, - end: 6512, - }, - id: "start", - }, - ), - ), - upper: Some( - Name( - Name { - node: Node { - start: 6513, - end: 6516, - }, - id: "end", - }, - ), - ), - step: None, - }, - ), - List( - List { - node: Node { - start: 6534, - end: 6730, - }, - elements: [ - Constant( - Constant { - node: Node { - start: 6556, - end: 6562, - }, - value: Str( - "open", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6584, - end: 6590, - }, - value: Str( - "high", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6612, - end: 6617, - }, - value: Str( - "low", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6639, - end: 6646, - }, - value: Str( - "close", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6668, - end: 6678, - }, - value: Str( - "adjClose", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6700, - end: 6711, - }, - value: Str( - "yesterday", - ), - }, - ), - ], - }, - ), - ], - }, - ), - }, - ), - right: Subscript( - Subscript { - node: Node { - start: 6760, - end: 6773, - }, - value: Name( - Name { - node: Node { - start: 6760, - end: 6770, - }, - id: "ratio_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 6771, - end: 6772, - }, - id: "i", - }, - ), - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, }, ), }, ), ], - orelse: [], - }, - ), - Return( - Return { - node: Node { - start: 6789, - end: 6802, - }, - value: Some( - Name( - Name { - node: Node { - start: 6796, - end: 6802, - }, - id: "new_df", - }, - ), - ), - }, - ), - ], - decorator_list: [], - returns: Some( - Attribute( - Attribute { - node: Node { - start: 4384, - end: 4396, - }, - value: Name( - Name { - node: Node { - start: 4384, - end: 4386, - }, - id: "pd", - }, - ), - attr: "DataFrame", }, ), - ), - type_comment: None, - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 6955, - end: 7464, - }, - name: "download_ticker_daily_record", - args: Arguments { - node: Node { - start: 6988, - end: 7023, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 6988, - end: 7005, - }, - arg: "ticker_index", - annotation: Some( - Name( - Name { - node: Node { - start: 7002, - end: 7005, - }, - id: "str", - }, - ), - ), - }, - Arg { - node: Node { - start: 7007, - end: 7023, - }, - arg: "session", - annotation: Some( - Name( - Name { - node: Node { - start: 7016, - end: 7023, - }, - id: "Session", - }, - ), - ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ AssignStatement( Assign { node: Node { - start: 7030, - end: 7100, + start: 6202, + end: 6222, }, targets: [ Name( Name { node: Node { - start: 7030, - end: 7033, + start: 6202, + end: 6205, }, - id: "url", + id: "end", }, ), ], - value: Call( - Call { + value: BinOp( + BinOp { node: Node { - start: 7086, - end: 7100, + start: 6208, + end: 6222, }, - func: Attribute( - Attribute { + op: Sub, + left: Subscript( + Subscript { node: Node { - start: 7036, - end: 7086, + start: 6208, + end: 6215, }, - value: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 7036, - end: 7079, + start: 6208, + end: 6212, }, - value: Name( - Name { - node: Node { - start: 7036, - end: 7048, - }, - id: "tse_settings", - }, - ), - attr: "TSE_TICKER_EXPORT_DATA_ADDRESS", + id: "diff", + }, + ), + slice: Name( + Name { + node: Node { + start: 6213, + end: 6214, + }, + id: "i", }, ), - attr: "format", }, ), - args: [ - Name( - Name { - node: Node { - start: 7087, - end: 7099, - }, - id: "ticker_index", + right: Name( + Name { + node: Node { + start: 6218, + end: 6222, }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "step", + }, + ), }, ), }, @@ -6463,2405 +5940,2799 @@ Module { AssignStatement( Assign { node: Node { - start: 7105, - end: 7144, + start: 6231, + end: 6783, }, targets: [ - Name( - Name { + Subscript( + Subscript { node: Node { - start: 7105, - end: 7113, - }, - id: "response", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 7127, - end: 7144, - }, - func: Attribute( - Attribute { - node: Node { - start: 7116, - end: 7127, - }, - value: Name( - Name { - node: Node { - start: 7116, - end: 7123, - }, - id: "session", - }, - ), - attr: "get", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 7128, - end: 7131, - }, - id: "url", - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 7133, - end: 7143, - }, - arg: Some( - "timeout", - ), - value: Constant( - Constant { - node: Node { - start: 7141, - end: 7143, - }, - value: Int( - "10", - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 7149, - end: 7369, - }, - test: Compare( - Compare { - node: Node { - start: 7152, - end: 7185, - }, - left: Constant( - Constant { - node: Node { - start: 7152, - end: 7155, - }, - value: Int( - "400", - ), + start: 6241, + end: 6457, }, - ), - ops: [ - LtE, - Lt, - ], - comparators: [ - Attribute( + value: Attribute( Attribute { node: Node { - start: 7159, - end: 7179, + start: 6231, + end: 6241, }, value: Name( Name { node: Node { - start: 7159, - end: 7167, + start: 6231, + end: 6237, }, - id: "response", + id: "new_df", }, ), - attr: "status_code", + attr: "loc", }, ), - Constant( - Constant { + slice: Tuple( + Tuple { node: Node { - start: 7182, - end: 7185, + start: 6255, + end: 6457, }, - value: Int( - "500", - ), - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 7207, - end: 7363, - }, - func: Attribute( - Attribute { - node: Node { - start: 7195, - end: 7207, - }, - value: Name( - Name { + elements: [ + Slice( + Slice { node: Node { - start: 7195, - end: 7201, + start: 6260, + end: 6264, }, - id: "logger", - }, - ), - attr: "error", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 7221, - end: 7275, - }, - values: [ - Constant( - Constant { - node: Node { - start: 7269, - end: 0, + lower: Some( + Name( + Name { + node: Node { + start: 6255, + end: 6260, + }, + id: "start", }, - value: Str( - "Cannot read daily trade records from the url: ", - ), - }, + ), ), - Name( - Name { - node: Node { - start: 7270, - end: 7273, + upper: Some( + Name( + Name { + node: Node { + start: 6261, + end: 6264, + }, + id: "end", }, - id: "url", - }, + ), ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 7289, - end: 7352, - }, - arg: Some( - "extra", + step: None, + }, ), - value: Dict( - Dict { + List( + List { node: Node { - start: 7295, - end: 7352, + start: 6278, + end: 6446, }, - keys: [ + elements: [ Constant( Constant { node: Node { - start: 7296, - end: 7306, + start: 6296, + end: 6302, }, value: Str( - "response", + "open", ), }, ), Constant( Constant { node: Node { - start: 7323, - end: 7329, + start: 6320, + end: 6326, }, value: Str( - "code", + "high", ), }, ), - ], - values: [ - Attribute( - Attribute { + Constant( + Constant { node: Node { - start: 7308, - end: 7321, + start: 6344, + end: 6349, }, - value: Name( - Name { - node: Node { - start: 7308, - end: 7316, - }, - id: "response", - }, + value: Str( + "low", ), - attr: "text", }, ), - Attribute( - Attribute { + Constant( + Constant { node: Node { - start: 7331, - end: 7351, + start: 6367, + end: 6374, }, - value: Name( - Name { - node: Node { - start: 7331, - end: 7339, - }, - id: "response", - }, + value: Str( + "close", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 6392, + end: 6402, + }, + value: Str( + "adjClose", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 6420, + end: 6431, + }, + value: Str( + "yesterday", ), - attr: "status_code", }, ), ], }, ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], - }, - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 7394, - end: 7396, - }, - func: Attribute( - Attribute { - node: Node { - start: 7369, - end: 7394, - }, - value: Name( - Name { - node: Node { - start: 7369, - end: 7377, - }, - id: "response", + ], }, ), - attr: "raise_for_status", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - AssignStatement( - Assign { - node: Node { - start: 7402, - end: 7432, - }, - targets: [ - Name( - Name { - node: Node { - start: 7402, - end: 7406, - }, - id: "data", }, ), ], value: Call( Call { node: Node { - start: 7409, - end: 7432, + start: 6460, + end: 6783, }, func: Name( Name { node: Node { - start: 7409, - end: 7417, + start: 6460, + end: 6465, }, - id: "StringIO", + id: "round", }, ), args: [ - Attribute( - Attribute { + BinOp( + BinOp { node: Node { - start: 7418, - end: 7431, + start: 6479, + end: 6773, }, - value: Name( - Name { + op: Mult, + left: Subscript( + Subscript { node: Node { - start: 7418, - end: 7426, + start: 6489, + end: 6745, }, - id: "response", - }, - ), - attr: "text", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - Return( - Return { - node: Node { - start: 7437, - end: 7461, - }, - value: Some( - Call( - Call { - node: Node { - start: 7455, - end: 7461, - }, - func: Attribute( - Attribute { - node: Node { - start: 7444, - end: 7455, - }, - value: Name( - Name { - node: Node { - start: 7444, - end: 7446, - }, - id: "pd", - }, - ), - attr: "read_csv", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 7456, - end: 7460, - }, - id: "data", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - }, - ), - ], - decorator_list: [ - Call( - Call { - node: Node { - start: 6806, - end: 6954, - }, - func: Name( - Name { - node: Node { - start: 6806, - end: 6811, - }, - id: "retry", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 6817, - end: 6857, - }, - arg: Some( - "retry", - ), - value: Call( - Call { - node: Node { - start: 6823, - end: 6857, - }, - func: Name( - Name { - node: Node { - start: 6823, - end: 6846, - }, - id: "retry_if_exception_type", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 6847, - end: 6856, - }, - id: "HTTPError", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - Keyword { - node: Node { - start: 6863, - end: 6893, - }, - arg: Some( - "wait", - ), - value: Call( - Call { - node: Node { - start: 6868, - end: 6893, - }, - func: Name( - Name { - node: Node { - start: 6868, - end: 6879, - }, - id: "wait_random", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 6880, - end: 6885, - }, - arg: Some( - "min", - ), - value: Constant( - Constant { - node: Node { - start: 6884, - end: 6885, + value: Attribute( + Attribute { + node: Node { + start: 6479, + end: 6489, + }, + value: Name( + Name { + node: Node { + start: 6479, + end: 6485, + }, + id: "new_df", + }, + ), + attr: "loc", }, - value: Int( - "1", - ), - }, - ), - }, - Keyword { - node: Node { - start: 6887, - end: 6892, - }, - arg: Some( - "max", - ), - value: Constant( - Constant { - node: Node { - start: 6891, - end: 6892, + ), + slice: Tuple( + Tuple { + node: Node { + start: 6507, + end: 6745, + }, + elements: [ + Slice( + Slice { + node: Node { + start: 6512, + end: 6516, + }, + lower: Some( + Name( + Name { + node: Node { + start: 6507, + end: 6512, + }, + id: "start", + }, + ), + ), + upper: Some( + Name( + Name { + node: Node { + start: 6513, + end: 6516, + }, + id: "end", + }, + ), + ), + step: None, + }, + ), + List( + List { + node: Node { + start: 6534, + end: 6730, + }, + elements: [ + Constant( + Constant { + node: Node { + start: 6556, + end: 6562, + }, + value: Str( + "open", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 6584, + end: 6590, + }, + value: Str( + "high", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 6612, + end: 6617, + }, + value: Str( + "low", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 6639, + end: 6646, + }, + value: Str( + "close", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 6668, + end: 6678, + }, + value: Str( + "adjClose", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 6700, + end: 6711, + }, + value: Str( + "yesterday", + ), + }, + ), + ], + }, + ), + ], }, - value: Int( - "4", - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - Keyword { - node: Node { - start: 6899, - end: 6951, - }, - arg: Some( - "before_sleep", - ), - value: Call( - Call { - node: Node { - start: 6912, - end: 6951, - }, - func: Name( - Name { - node: Node { - start: 6912, - end: 6928, - }, - id: "before_sleep_log", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 6929, - end: 6935, - }, - id: "logger", + ), }, ), - Attribute( - Attribute { + right: Subscript( + Subscript { node: Node { - start: 6937, - end: 6950, + start: 6760, + end: 6773, }, value: Name( Name { node: Node { - start: 6937, - end: 6944, + start: 6760, + end: 6770, }, - id: "logging", + id: "ratio_list", + }, + ), + slice: Name( + Name { + node: Node { + start: 6771, + end: 6772, + }, + id: "i", }, ), - attr: "DEBUG", }, ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, }, - ], - starargs: None, - kwargs: None, + ), }, ), ], - returns: None, - type_comment: None, + orelse: [], }, ), - FunctionDef( - FunctionDef { + Return( + Return { node: Node { - start: 7614, - end: 8358, + start: 6789, + end: 6802, }, - name: "download_fIndex_record", - args: Arguments { - node: Node { - start: 7641, - end: 7670, + value: Some( + Name( + Name { + node: Node { + start: 6796, + end: 6802, + }, + id: "new_df", + }, + ), + ), + }, + ), + ], + decorator_list: [], + returns: Some( + Attribute( + Attribute { + node: Node { + start: 4384, + end: 4396, + }, + value: Name( + Name { + node: Node { + start: 4384, + end: 4386, + }, + id: "pd", }, - posonlyargs: [], - args: [ - Arg { + ), + attr: "DataFrame", + }, + ), + ), + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 6955, + end: 7464, + }, + name: "download_ticker_daily_record", + args: Arguments { + node: Node { + start: 6988, + end: 7023, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 6988, + end: 7005, + }, + arg: "ticker_index", + annotation: Some( + Name( + Name { node: Node { - start: 7641, - end: 7652, + start: 7002, + end: 7005, }, - arg: "fIndex", - annotation: Some( - Name( - Name { - node: Node { - start: 7649, - end: 7652, - }, - id: "str", - }, - ), - ), + id: "str", }, - Arg { + ), + ), + }, + Arg { + node: Node { + start: 7007, + end: 7023, + }, + arg: "session", + annotation: Some( + Name( + Name { node: Node { - start: 7654, - end: 7670, + start: 7016, + end: 7023, }, - arg: "session", - annotation: Some( - Name( - Name { + id: "Session", + }, + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 7030, + end: 7100, + }, + targets: [ + Name( + Name { + node: Node { + start: 7030, + end: 7033, + }, + id: "url", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 7086, + end: 7100, + }, + func: Attribute( + Attribute { + node: Node { + start: 7036, + end: 7086, + }, + value: Attribute( + Attribute { node: Node { - start: 7663, - end: 7670, + start: 7036, + end: 7079, }, - id: "Session", + value: Name( + Name { + node: Node { + start: 7036, + end: 7048, + }, + id: "tse_settings", + }, + ), + attr: "TSE_TICKER_EXPORT_DATA_ADDRESS", }, ), + attr: "format", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 7087, + end: 7099, + }, + id: "ticker_index", + }, ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 7105, + end: 7144, }, - body: [ - AssignStatement( - Assign { + targets: [ + Name( + Name { node: Node { - start: 7677, - end: 7750, + start: 7105, + end: 7113, }, - targets: [ - Name( + id: "response", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 7127, + end: 7144, + }, + func: Attribute( + Attribute { + node: Node { + start: 7116, + end: 7127, + }, + value: Name( Name { node: Node { - start: 7677, - end: 7680, + start: 7116, + end: 7123, }, - id: "url", + id: "session", }, ), - ], - value: Call( - Call { + attr: "get", + }, + ), + args: [ + Name( + Name { node: Node { - start: 7742, - end: 7750, + start: 7128, + end: 7131, }, - func: Attribute( - Attribute { - node: Node { - start: 7683, - end: 7742, - }, - value: Attribute( - Attribute { - node: Node { - start: 7683, - end: 7735, - }, - value: Name( - Name { - node: Node { - start: 7683, - end: 7695, - }, - id: "tse_settings", - }, - ), - attr: "TSE_FINANCIAL_INDEX_EXPORT_DATA_ADDRESS", - }, - ), - attr: "format", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 7743, - end: 7749, - }, - id: "fIndex", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "url", }, ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 7755, - end: 7794, - }, - targets: [ - Name( - Name { + ], + keywords: [ + Keyword { + node: Node { + start: 7133, + end: 7143, + }, + arg: Some( + "timeout", + ), + value: Constant( + Constant { node: Node { - start: 7755, - end: 7763, + start: 7141, + end: 7143, }, - id: "response", + value: Int( + "10", + ), }, ), - ], - value: Call( - Call { + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 7149, + end: 7369, + }, + test: Compare( + Compare { + node: Node { + start: 7152, + end: 7185, + }, + left: Constant( + Constant { + node: Node { + start: 7152, + end: 7155, + }, + value: Int( + "400", + ), + }, + ), + ops: [ + LtE, + Lt, + ], + comparators: [ + Attribute( + Attribute { node: Node { - start: 7777, - end: 7794, + start: 7159, + end: 7179, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 7766, - end: 7777, + start: 7159, + end: 7167, }, - value: Name( - Name { - node: Node { - start: 7766, - end: 7773, - }, - id: "session", - }, - ), - attr: "get", + id: "response", }, ), - args: [ - Name( - Name { - node: Node { - start: 7778, - end: 7781, - }, - id: "url", - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 7783, - end: 7793, - }, - arg: Some( - "timeout", - ), - value: Constant( - Constant { - node: Node { - start: 7791, - end: 7793, - }, - value: Int( - "10", - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, + attr: "status_code", }, ), - }, - ), - IfStatement( - If { - node: Node { - start: 7799, - end: 8019, - }, - test: Compare( - Compare { + Constant( + Constant { node: Node { - start: 7802, - end: 7835, + start: 7182, + end: 7185, }, - left: Constant( - Constant { - node: Node { - start: 7802, - end: 7805, - }, - value: Int( - "400", - ), - }, + value: Int( + "500", ), - ops: [ - LtE, - Lt, - ], - comparators: [ - Attribute( - Attribute { + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 7207, + end: 7363, + }, + func: Attribute( + Attribute { + node: Node { + start: 7195, + end: 7207, + }, + value: Name( + Name { node: Node { - start: 7809, - end: 7829, + start: 7195, + end: 7201, }, - value: Name( + id: "logger", + }, + ), + attr: "error", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 7221, + end: 7275, + }, + values: [ + Constant( + Constant { + node: Node { + start: 7269, + end: 0, + }, + value: Str( + "Cannot read daily trade records from the url: ", + ), + }, + ), + Name( Name { node: Node { - start: 7809, - end: 7817, + start: 7270, + end: 7273, }, - id: "response", + id: "url", }, ), - attr: "status_code", - }, + ], + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 7289, + end: 7352, + }, + arg: Some( + "extra", ), - Constant( - Constant { + value: Dict( + Dict { node: Node { - start: 7832, - end: 7835, + start: 7295, + end: 7352, }, - value: Int( - "500", - ), - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 7857, - end: 8013, - }, - func: Attribute( - Attribute { - node: Node { - start: 7845, - end: 7857, - }, - value: Name( - Name { + keys: [ + Constant( + Constant { node: Node { - start: 7845, - end: 7851, + start: 7296, + end: 7306, }, - id: "logger", + value: Str( + "response", + ), }, ), - attr: "error", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 7871, - end: 7925, - }, - values: [ - Constant( - Constant { - node: Node { - start: 7919, - end: 0, - }, - value: Str( - "Cannot read daily trade records from the url: ", - ), - }, + Constant( + Constant { + node: Node { + start: 7323, + end: 7329, + }, + value: Str( + "code", ), - Name( + }, + ), + ], + values: [ + Attribute( + Attribute { + node: Node { + start: 7308, + end: 7321, + }, + value: Name( Name { node: Node { - start: 7920, - end: 7923, + start: 7308, + end: 7316, }, - id: "url", + id: "response", }, ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 7939, - end: 8002, - }, - arg: Some( - "extra", + attr: "text", + }, ), - value: Dict( - Dict { + Attribute( + Attribute { node: Node { - start: 7945, - end: 8002, + start: 7331, + end: 7351, }, - keys: [ - Constant( - Constant { - node: Node { - start: 7946, - end: 7956, - }, - value: Str( - "response", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 7973, - end: 7979, - }, - value: Str( - "code", - ), - }, - ), - ], - values: [ - Attribute( - Attribute { - node: Node { - start: 7958, - end: 7971, - }, - value: Name( - Name { - node: Node { - start: 7958, - end: 7966, - }, - id: "response", - }, - ), - attr: "text", - }, - ), - Attribute( - Attribute { - node: Node { - start: 7981, - end: 8001, - }, - value: Name( - Name { - node: Node { - start: 7981, - end: 7989, - }, - id: "response", - }, - ), - attr: "status_code", + value: Name( + Name { + node: Node { + start: 7331, + end: 7339, }, - ), - ], + id: "response", + }, + ), + attr: "status_code", }, ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], - }, - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 8044, - end: 8046, - }, - func: Attribute( - Attribute { - node: Node { - start: 8019, - end: 8044, - }, - value: Name( - Name { - node: Node { - start: 8019, - end: 8027, - }, - id: "response", + ], }, ), - attr: "raise_for_status", }, - ), - args: [], - keywords: [], + ], starargs: None, kwargs: None, }, ), ), - AssignStatement( - Assign { + ], + orelse: [], + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 7394, + end: 7396, + }, + func: Attribute( + Attribute { node: Node { - start: 8051, - end: 8071, + start: 7369, + end: 7394, }, - targets: [ - Name( - Name { - node: Node { - start: 8051, - end: 8055, - }, - id: "data", - }, - ), - ], - value: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 8058, - end: 8071, + start: 7369, + end: 7377, }, - value: Name( - Name { - node: Node { - start: 8058, - end: 8066, - }, - id: "response", - }, - ), - attr: "text", + id: "response", }, ), + attr: "raise_for_status", }, ), - IfStatement( - If { - node: Node { - start: 8076, - end: 8288, - }, - test: BoolOp( - BoolOperation { - node: Node { - start: 8079, - end: 8125, - }, - op: Or, - values: [ - UnaryOp( - UnaryOperation { - node: Node { - start: 8079, - end: 8087, - }, - op: Not, - operand: Name( - Name { - node: Node { - start: 8083, - end: 8087, - }, - id: "data", - }, - ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + AssignStatement( + Assign { + node: Node { + start: 7402, + end: 7432, + }, + targets: [ + Name( + Name { + node: Node { + start: 7402, + end: 7406, + }, + id: "data", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 7409, + end: 7432, + }, + func: Name( + Name { + node: Node { + start: 7409, + end: 7417, + }, + id: "StringIO", + }, + ), + args: [ + Attribute( + Attribute { + node: Node { + start: 7418, + end: 7431, + }, + value: Name( + Name { + node: Node { + start: 7418, + end: 7426, }, - ), - BoolOp( - BoolOperation { - node: Node { - start: 8091, - end: 8125, - }, - op: Or, - values: [ - Compare( - Compare { - node: Node { - start: 8091, - end: 8106, - }, - left: Constant( - Constant { - node: Node { - start: 8091, - end: 8094, - }, - value: Str( - ";", - ), - }, - ), - ops: [ - NotIn, - ], - comparators: [ - Name( - Name { - node: Node { - start: 8102, - end: 8106, - }, - id: "data", - }, - ), - ], - }, - ), - Compare( - Compare { - node: Node { - start: 8110, - end: 8125, - }, - left: Constant( - Constant { - node: Node { - start: 8110, - end: 8113, - }, - value: Str( - ",", - ), - }, - ), - ops: [ - NotIn, - ], - comparators: [ - Name( - Name { - node: Node { - start: 8121, - end: 8125, - }, - id: "data", - }, - ), - ], - }, - ), - ], + id: "response", + }, + ), + attr: "text", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + Return( + Return { + node: Node { + start: 7437, + end: 7461, + }, + value: Some( + Call( + Call { + node: Node { + start: 7455, + end: 7461, + }, + func: Attribute( + Attribute { + node: Node { + start: 7444, + end: 7455, + }, + value: Name( + Name { + node: Node { + start: 7444, + end: 7446, }, - ), - ], + id: "pd", + }, + ), + attr: "read_csv", }, ), - body: [ - Raise( - Raise { + args: [ + Name( + Name { node: Node { - start: 8135, - end: 8283, + start: 7456, + end: 7460, }, - exc: Some( - Call( - Call { - node: Node { - start: 8141, - end: 8283, - }, - func: Name( - Name { - node: Node { - start: 8141, - end: 8151, - }, - id: "ValueError", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 8165, - end: 8273, - }, - values: [ - Constant( - Constant { - node: Node { - start: 8200, - end: 0, - }, - value: Str( - "Invalid response from the url: ", - ), - }, - ), - Name( - Name { - node: Node { - start: 8201, - end: 8204, - }, - id: "url", - }, - ), - Constant( - Constant { - node: Node { - start: 8270, - end: 0, - }, - value: Str( - ".\n \\nExpected valid financial index data.", - ), - }, - ), - ], - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - cause: None, + id: "data", }, ), ], - orelse: [], + keywords: [], + starargs: None, + kwargs: None, }, ), - AssignStatement( - Assign { - node: Node { - start: 8288, - end: 8341, - }, - targets: [ - Name( + ), + }, + ), + ], + decorator_list: [ + Call( + Call { + node: Node { + start: 6806, + end: 6954, + }, + func: Name( + Name { + node: Node { + start: 6806, + end: 6811, + }, + id: "retry", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 6817, + end: 6857, + }, + arg: Some( + "retry", + ), + value: Call( + Call { + node: Node { + start: 6823, + end: 6857, + }, + func: Name( Name { node: Node { - start: 8288, - end: 8290, + start: 6823, + end: 6846, }, - id: "df", + id: "retry_if_exception_type", }, ), - ], - value: Call( - Call { - node: Node { - start: 8293, - end: 8341, - }, - func: Name( + args: [ + Name( Name { node: Node { - start: 8293, - end: 8335, + start: 6847, + end: 6856, }, - id: "_create_financial_index_from_text_response", + id: "HTTPError", }, ), - args: [ - Name( - Name { + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + Keyword { + node: Node { + start: 6863, + end: 6893, + }, + arg: Some( + "wait", + ), + value: Call( + Call { + node: Node { + start: 6868, + end: 6893, + }, + func: Name( + Name { + node: Node { + start: 6868, + end: 6879, + }, + id: "wait_random", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 6880, + end: 6885, + }, + arg: Some( + "min", + ), + value: Constant( + Constant { node: Node { - start: 8336, - end: 8340, + start: 6884, + end: 6885, }, - id: "data", + value: Int( + "1", + ), }, ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - Return( - Return { - node: Node { - start: 8346, - end: 8355, - }, - value: Some( - Name( - Name { + }, + Keyword { node: Node { - start: 8353, - end: 8355, + start: 6887, + end: 6892, }, - id: "df", + arg: Some( + "max", + ), + value: Constant( + Constant { + node: Node { + start: 6891, + end: 6892, + }, + value: Int( + "4", + ), + }, + ), }, - ), - ), - }, - ), - ], - decorator_list: [ - Call( - Call { - node: Node { - start: 7465, - end: 7613, + ], + starargs: None, + kwargs: None, }, - func: Name( - Name { - node: Node { - start: 7465, - end: 7470, - }, - id: "retry", + ), + }, + Keyword { + node: Node { + start: 6899, + end: 6951, + }, + arg: Some( + "before_sleep", + ), + value: Call( + Call { + node: Node { + start: 6912, + end: 6951, }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 7476, - end: 7516, - }, - arg: Some( - "retry", - ), - value: Call( - Call { - node: Node { - start: 7482, - end: 7516, - }, - func: Name( - Name { - node: Node { - start: 7482, - end: 7505, - }, - id: "retry_if_exception_type", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 7506, - end: 7515, - }, - id: "HTTPError", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + func: Name( + Name { + node: Node { + start: 6912, + end: 6928, }, - ), - }, - Keyword { - node: Node { - start: 7522, - end: 7552, + id: "before_sleep_log", }, - arg: Some( - "wait", - ), - value: Call( - Call { + ), + args: [ + Name( + Name { node: Node { - start: 7527, - end: 7552, + start: 6929, + end: 6935, }, - func: Name( - Name { - node: Node { - start: 7527, - end: 7538, - }, - id: "wait_random", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 7539, - end: 7544, - }, - arg: Some( - "min", - ), - value: Constant( - Constant { - node: Node { - start: 7543, - end: 7544, - }, - value: Int( - "1", - ), - }, - ), - }, - Keyword { - node: Node { - start: 7546, - end: 7551, - }, - arg: Some( - "max", - ), - value: Constant( - Constant { - node: Node { - start: 7550, - end: 7551, - }, - value: Int( - "4", - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, + id: "logger", }, ), - }, - Keyword { - node: Node { - start: 7558, - end: 7610, - }, - arg: Some( - "before_sleep", - ), - value: Call( - Call { + Attribute( + Attribute { node: Node { - start: 7571, - end: 7610, + start: 6937, + end: 6950, }, - func: Name( + value: Name( Name { node: Node { - start: 7571, - end: 7587, + start: 6937, + end: 6944, }, - id: "before_sleep_log", + id: "logging", }, ), - args: [ - Name( - Name { - node: Node { - start: 7588, - end: 7594, - }, - id: "logger", - }, - ), - Attribute( - Attribute { - node: Node { - start: 7596, - end: 7609, - }, - value: Name( - Name { - node: Node { - start: 7596, - end: 7603, - }, - id: "logging", - }, - ), - attr: "DEBUG", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + attr: "DEBUG", }, ), - }, - ], - starargs: None, - kwargs: None, - }, - ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, ], - returns: None, - type_comment: None, + starargs: None, + kwargs: None, }, ), - FunctionDef( - FunctionDef { + ], + returns: None, + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 7614, + end: 8358, + }, + name: "download_fIndex_record", + args: Arguments { + node: Node { + start: 7641, + end: 7670, + }, + posonlyargs: [], + args: [ + Arg { node: Node { - start: 8358, - end: 15273, + start: 7641, + end: 7652, }, - name: "download_financial_indexes", - args: Arguments { - node: Node { - start: 8394, - end: 8540, - }, - posonlyargs: [], - args: [ - Arg { + arg: "fIndex", + annotation: Some( + Name( + Name { node: Node { - start: 8394, - end: 8419, + start: 7649, + end: 7652, }, - arg: "symbols", - annotation: Some( - Subscript( - Subscript { + id: "str", + }, + ), + ), + }, + Arg { + node: Node { + start: 7654, + end: 7670, + }, + arg: "session", + annotation: Some( + Name( + Name { + node: Node { + start: 7663, + end: 7670, + }, + id: "Session", + }, + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 7677, + end: 7750, + }, + targets: [ + Name( + Name { + node: Node { + start: 7677, + end: 7680, + }, + id: "url", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 7742, + end: 7750, + }, + func: Attribute( + Attribute { + node: Node { + start: 7683, + end: 7742, + }, + value: Attribute( + Attribute { node: Node { - start: 8403, - end: 8419, + start: 7683, + end: 7735, }, value: Name( Name { node: Node { - start: 8403, - end: 8408, + start: 7683, + end: 7695, }, - id: "Union", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 8409, - end: 8419, - }, - elements: [ - Name( - Name { - node: Node { - start: 8409, - end: 8413, - }, - id: "List", - }, - ), - Name( - Name { - node: Node { - start: 8415, - end: 8418, - }, - id: "str", - }, - ), - ], + id: "tse_settings", }, ), + attr: "TSE_FINANCIAL_INDEX_EXPORT_DATA_ADDRESS", }, ), - ), - }, - Arg { - node: Node { - start: 8425, - end: 8451, + attr: "format", }, - arg: "write_to_csv", - annotation: Some( - Name( - Name { - node: Node { - start: 8439, - end: 8443, - }, - id: "bool", + ), + args: [ + Name( + Name { + node: Node { + start: 7743, + end: 7749, }, - ), + id: "fIndex", + }, ), - }, - Arg { + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 7755, + end: 7794, + }, + targets: [ + Name( + Name { node: Node { - start: 8457, - end: 8484, + start: 7755, + end: 7763, }, - arg: "include_jdate", - annotation: Some( - Name( - Name { - node: Node { - start: 8472, - end: 8476, - }, - id: "bool", - }, - ), - ), + id: "response", }, - Arg { - node: Node { - start: 8490, - end: 8539, - }, - arg: "base_path", - annotation: Some( - Name( + ), + ], + value: Call( + Call { + node: Node { + start: 7777, + end: 7794, + }, + func: Attribute( + Attribute { + node: Node { + start: 7766, + end: 7777, + }, + value: Name( Name { node: Node { - start: 8501, - end: 8504, + start: 7766, + end: 7773, }, - id: "str", + id: "session", }, ), - ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [ - Constant( - Constant { - node: Node { - start: 8446, - end: 8451, - }, - value: Bool( - false, - ), + attr: "get", }, ), - Constant( - Constant { - node: Node { - start: 8479, - end: 8484, + args: [ + Name( + Name { + node: Node { + start: 7778, + end: 7781, + }, + id: "url", }, - value: Bool( - false, - ), - }, - ), - Attribute( - Attribute { + ), + ], + keywords: [ + Keyword { node: Node { - start: 8507, - end: 8539, + start: 7783, + end: 7793, }, - value: Name( - Name { + arg: Some( + "timeout", + ), + value: Constant( + Constant { node: Node { - start: 8507, - end: 8513, + start: 7791, + end: 7793, }, - id: "config", + value: Int( + "10", + ), }, ), - attr: "FINANCIAL_INDEX_BASE_PATH", }, - ), - ], + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 7799, + end: 8019, }, - body: [ - IfStatement( - If { - node: Node { - start: 8575, - end: 8717, + test: Compare( + Compare { + node: Node { + start: 7802, + end: 7835, + }, + left: Constant( + Constant { + node: Node { + start: 7802, + end: 7805, + }, + value: Int( + "400", + ), }, - test: Compare( - Compare { + ), + ops: [ + LtE, + Lt, + ], + comparators: [ + Attribute( + Attribute { node: Node { - start: 8578, - end: 8594, + start: 7809, + end: 7829, }, - left: Name( + value: Name( Name { node: Node { - start: 8578, - end: 8585, + start: 7809, + end: 7817, }, - id: "symbols", + id: "response", }, ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 8589, - end: 8594, - }, - value: Str( - "all", - ), - }, - ), - ], + attr: "status_code", }, ), - body: [ - AssignStatement( - Assign { + Constant( + Constant { + node: Node { + start: 7832, + end: 7835, + }, + value: Int( + "500", + ), + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 7857, + end: 8013, + }, + func: Attribute( + Attribute { node: Node { - start: 8604, - end: 8648, + start: 7845, + end: 7857, }, - targets: [ - Name( - Name { - node: Node { - start: 8604, - end: 8611, - }, - id: "symbols", - }, - ), - ], - value: Call( - Call { + value: Name( + Name { node: Node { - start: 8646, - end: 8648, + start: 7845, + end: 7851, }, - func: Attribute( - Attribute { + id: "logger", + }, + ), + attr: "error", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 7871, + end: 7925, + }, + values: [ + Constant( + Constant { node: Node { - start: 8614, - end: 8646, + start: 7919, + end: 0, }, - value: Name( - Name { - node: Node { - start: 8614, - end: 8626, - }, - id: "symbols_data", - }, + value: Str( + "Cannot read daily trade records from the url: ", ), - attr: "all_financial_index", }, ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - orelse: [ - IfStatement( - If { - node: Node { - start: 8653, - end: 8717, - }, - test: Call( - Call { - node: Node { - start: 8658, - end: 8682, - }, - func: Name( + Name( Name { node: Node { - start: 8658, - end: 8668, + start: 7920, + end: 7923, }, - id: "isinstance", + id: "url", }, ), - args: [ - Name( - Name { + ], + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 7939, + end: 8002, + }, + arg: Some( + "extra", + ), + value: Dict( + Dict { + node: Node { + start: 7945, + end: 8002, + }, + keys: [ + Constant( + Constant { node: Node { - start: 8669, - end: 8676, + start: 7946, + end: 7956, }, - id: "symbols", + value: Str( + "response", + ), }, ), - Name( - Name { + Constant( + Constant { node: Node { - start: 8678, - end: 8681, + start: 7973, + end: 7979, }, - id: "str", + value: Str( + "code", + ), }, ), ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 8692, - end: 8711, - }, - targets: [ - Name( - Name { - node: Node { - start: 8692, - end: 8699, - }, - id: "symbols", + values: [ + Attribute( + Attribute { + node: Node { + start: 7958, + end: 7971, }, - ), - ], - value: List( - List { + value: Name( + Name { + node: Node { + start: 7958, + end: 7966, + }, + id: "response", + }, + ), + attr: "text", + }, + ), + Attribute( + Attribute { node: Node { - start: 8702, - end: 8711, + start: 7981, + end: 8001, }, - elements: [ - Name( - Name { - node: Node { - start: 8703, - end: 8710, - }, - id: "symbols", + value: Name( + Name { + node: Node { + start: 7981, + end: 7989, }, - ), - ], + id: "response", + }, + ), + attr: "status_code", }, ), - }, - ), - ], - orelse: [], + ], + }, + ), }, - ), - ], - }, + ], + starargs: None, + kwargs: None, + }, + ), ), - AssignStatement( - Assign { + ], + orelse: [], + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 8044, + end: 8046, + }, + func: Attribute( + Attribute { node: Node { - start: 8717, - end: 8729, + start: 8019, + end: 8044, }, - targets: [ - Name( - Name { - node: Node { - start: 8717, - end: 8724, - }, - id: "df_list", - }, - ), - ], - value: Dict( - Dict { + value: Name( + Name { node: Node { - start: 8727, - end: 8729, + start: 8019, + end: 8027, }, - keys: [], - values: [], + id: "response", }, ), + attr: "raise_for_status", }, ), - AssignStatement( - Assign { + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + AssignStatement( + Assign { + node: Node { + start: 8051, + end: 8071, + }, + targets: [ + Name( + Name { node: Node { - start: 8734, - end: 8755, + start: 8051, + end: 8055, }, - targets: [ - Name( - Name { - node: Node { - start: 8734, - end: 8750, - }, - id: "future_to_symbol", - }, - ), - ], - value: Dict( - Dict { - node: Node { - start: 8753, - end: 8755, - }, - keys: [], - values: [], - }, - ), + id: "data", }, ), - WithStatement( - With { - node: Node { - start: 8760, - end: 10374, + ], + value: Attribute( + Attribute { + node: Node { + start: 8058, + end: 8071, + }, + value: Name( + Name { + node: Node { + start: 8058, + end: 8066, + }, + id: "response", }, - items: [ - WithItem { + ), + attr: "text", + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 8076, + end: 8288, + }, + test: BoolOp( + BoolOperation { + node: Node { + start: 8079, + end: 8125, + }, + op: Or, + values: [ + UnaryOp( + UnaryOperation { node: Node { - start: 8765, - end: 8819, + start: 8079, + end: 8087, }, - context_expr: Call( - Call { + op: Not, + operand: Name( + Name { node: Node { - start: 8791, - end: 8807, + start: 8083, + end: 8087, }, - func: Attribute( - Attribute { - node: Node { - start: 8765, - end: 8791, + id: "data", + }, + ), + }, + ), + BoolOp( + BoolOperation { + node: Node { + start: 8091, + end: 8125, + }, + op: Or, + values: [ + Compare( + Compare { + node: Node { + start: 8091, + end: 8106, + }, + left: Constant( + Constant { + node: Node { + start: 8091, + end: 8094, + }, + value: Str( + ";", + ), }, - value: Name( + ), + ops: [ + NotIn, + ], + comparators: [ + Name( Name { node: Node { - start: 8765, - end: 8772, + start: 8102, + end: 8106, }, - id: "futures", + id: "data", }, ), - attr: "ThreadPoolExecutor", + ], + }, + ), + Compare( + Compare { + node: Node { + start: 8110, + end: 8125, }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 8792, - end: 8806, + left: Constant( + Constant { + node: Node { + start: 8110, + end: 8113, + }, + value: Str( + ",", + ), }, - arg: Some( - "max_workers", - ), - value: Constant( - Constant { + ), + ops: [ + NotIn, + ], + comparators: [ + Name( + Name { node: Node { - start: 8804, - end: 8806, + start: 8121, + end: 8125, }, - value: Int( - "10", - ), + id: "data", }, ), - }, - ], - starargs: None, - kwargs: None, + ], + }, + ), + ], + }, + ), + ], + }, + ), + body: [ + Raise( + Raise { + node: Node { + start: 8135, + end: 8283, + }, + exc: Some( + Call( + Call { + node: Node { + start: 8141, + end: 8283, }, - ), - optional_vars: Some( - Name( + func: Name( Name { node: Node { - start: 8811, - end: 8819, + start: 8141, + end: 8151, }, - id: "executor", + id: "ValueError", }, ), - ), - }, - ], - body: [ - AssignStatement( - Assign { - node: Node { - start: 8829, - end: 8863, - }, - targets: [ - Name( - Name { + args: [ + JoinedStr( + JoinedStr { node: Node { - start: 8829, - end: 8836, + start: 8165, + end: 8273, }, - id: "session", + values: [ + Constant( + Constant { + node: Node { + start: 8200, + end: 0, + }, + value: Str( + "Invalid response from the url: ", + ), + }, + ), + Name( + Name { + node: Node { + start: 8201, + end: 8204, + }, + id: "url", + }, + ), + Constant( + Constant { + node: Node { + start: 8270, + end: 0, + }, + value: Str( + ".\n \\nExpected valid financial index data.", + ), + }, + ), + ], }, ), ], - value: Call( - Call { + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + cause: None, + }, + ), + ], + orelse: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 8288, + end: 8341, + }, + targets: [ + Name( + Name { + node: Node { + start: 8288, + end: 8290, + }, + id: "df", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 8293, + end: 8341, + }, + func: Name( + Name { + node: Node { + start: 8293, + end: 8335, + }, + id: "_create_financial_index_from_text_response", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 8336, + end: 8340, + }, + id: "data", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + Return( + Return { + node: Node { + start: 8346, + end: 8355, + }, + value: Some( + Name( + Name { + node: Node { + start: 8353, + end: 8355, + }, + id: "df", + }, + ), + ), + }, + ), + ], + decorator_list: [ + Call( + Call { + node: Node { + start: 7465, + end: 7613, + }, + func: Name( + Name { + node: Node { + start: 7465, + end: 7470, + }, + id: "retry", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 7476, + end: 7516, + }, + arg: Some( + "retry", + ), + value: Call( + Call { + node: Node { + start: 7482, + end: 7516, + }, + func: Name( + Name { + node: Node { + start: 7482, + end: 7505, + }, + id: "retry_if_exception_type", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 7506, + end: 7515, + }, + id: "HTTPError", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + Keyword { + node: Node { + start: 7522, + end: 7552, + }, + arg: Some( + "wait", + ), + value: Call( + Call { + node: Node { + start: 7527, + end: 7552, + }, + func: Name( + Name { + node: Node { + start: 7527, + end: 7538, + }, + id: "wait_random", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 7539, + end: 7544, + }, + arg: Some( + "min", + ), + value: Constant( + Constant { node: Node { - start: 8839, - end: 8863, + start: 7543, + end: 7544, }, - func: Name( - Name { - node: Node { - start: 8839, - end: 8861, - }, - id: "requests_retry_session", - }, + value: Int( + "1", ), - args: [], - keywords: [], - starargs: None, - kwargs: None, }, ), }, - ), - ForStatement( - For { + Keyword { node: Node { - start: 8872, - end: 9506, + start: 7546, + end: 7551, }, - target: Name( + arg: Some( + "max", + ), + value: Constant( + Constant { + node: Node { + start: 7550, + end: 7551, + }, + value: Int( + "4", + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + Keyword { + node: Node { + start: 7558, + end: 7610, + }, + arg: Some( + "before_sleep", + ), + value: Call( + Call { + node: Node { + start: 7571, + end: 7610, + }, + func: Name( + Name { + node: Node { + start: 7571, + end: 7587, + }, + id: "before_sleep_log", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 7588, + end: 7594, + }, + id: "logger", + }, + ), + Attribute( + Attribute { + node: Node { + start: 7596, + end: 7609, + }, + value: Name( + Name { + node: Node { + start: 7596, + end: 7603, + }, + id: "logging", + }, + ), + attr: "DEBUG", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + ], + returns: None, + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 8358, + end: 15273, + }, + name: "download_financial_indexes", + args: Arguments { + node: Node { + start: 8394, + end: 8540, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 8394, + end: 8419, + }, + arg: "symbols", + annotation: Some( + Subscript( + Subscript { + node: Node { + start: 8403, + end: 8419, + }, + value: Name( + Name { + node: Node { + start: 8403, + end: 8408, + }, + id: "Union", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 8409, + end: 8419, + }, + elements: [ + Name( Name { node: Node { - start: 8876, - end: 8882, + start: 8409, + end: 8413, }, - id: "symbol", + id: "List", }, ), - iter: Name( + Name( Name { node: Node { - start: 8886, - end: 8893, + start: 8415, + end: 8418, }, - id: "symbols", + id: "str", }, ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 8907, - end: 8947, - }, - targets: [ - Name( - Name { - node: Node { - start: 8907, - end: 8913, + ], + }, + ), + }, + ), + ), + }, + Arg { + node: Node { + start: 8425, + end: 8451, + }, + arg: "write_to_csv", + annotation: Some( + Name( + Name { + node: Node { + start: 8439, + end: 8443, + }, + id: "bool", + }, + ), + ), + }, + Arg { + node: Node { + start: 8457, + end: 8484, + }, + arg: "include_jdate", + annotation: Some( + Name( + Name { + node: Node { + start: 8472, + end: 8476, + }, + id: "bool", + }, + ), + ), + }, + Arg { + node: Node { + start: 8490, + end: 8539, + }, + arg: "base_path", + annotation: Some( + Name( + Name { + node: Node { + start: 8501, + end: 8504, + }, + id: "str", + }, + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [ + Constant( + Constant { + node: Node { + start: 8446, + end: 8451, + }, + value: Bool( + false, + ), + }, + ), + Constant( + Constant { + node: Node { + start: 8479, + end: 8484, + }, + value: Bool( + false, + ), + }, + ), + Attribute( + Attribute { + node: Node { + start: 8507, + end: 8539, + }, + value: Name( + Name { + node: Node { + start: 8507, + end: 8513, + }, + id: "config", + }, + ), + attr: "FINANCIAL_INDEX_BASE_PATH", + }, + ), + ], + }, + body: [ + IfStatement( + If { + node: Node { + start: 8575, + end: 8717, + }, + test: Compare( + Compare { + node: Node { + start: 8578, + end: 8594, + }, + left: Name( + Name { + node: Node { + start: 8578, + end: 8585, + }, + id: "symbols", + }, + ), + ops: [ + Eq, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 8589, + end: 8594, + }, + value: Str( + "all", + ), + }, + ), + ], + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 8604, + end: 8648, + }, + targets: [ + Name( + Name { + node: Node { + start: 8604, + end: 8611, + }, + id: "symbols", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 8646, + end: 8648, + }, + func: Attribute( + Attribute { + node: Node { + start: 8614, + end: 8646, + }, + value: Name( + Name { + node: Node { + start: 8614, + end: 8626, + }, + id: "symbols_data", + }, + ), + attr: "all_financial_index", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ], + orelse: [ + IfStatement( + If { + node: Node { + start: 8653, + end: 8717, + }, + test: Call( + Call { + node: Node { + start: 8658, + end: 8682, + }, + func: Name( + Name { + node: Node { + start: 8658, + end: 8668, + }, + id: "isinstance", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 8669, + end: 8676, + }, + id: "symbols", + }, + ), + Name( + Name { + node: Node { + start: 8678, + end: 8681, + }, + id: "str", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 8692, + end: 8711, + }, + targets: [ + Name( + Name { + node: Node { + start: 8692, + end: 8699, + }, + id: "symbols", + }, + ), + ], + value: List( + List { + node: Node { + start: 8702, + end: 8711, + }, + elements: [ + Name( + Name { + node: Node { + start: 8703, + end: 8710, + }, + id: "symbols", + }, + ), + ], + }, + ), + }, + ), + ], + orelse: [], + }, + ), + ], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 8717, + end: 8729, + }, + targets: [ + Name( + Name { + node: Node { + start: 8717, + end: 8724, + }, + id: "df_list", + }, + ), + ], + value: Dict( + Dict { + node: Node { + start: 8727, + end: 8729, + }, + keys: [], + values: [], + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 8734, + end: 8755, + }, + targets: [ + Name( + Name { + node: Node { + start: 8734, + end: 8750, + }, + id: "future_to_symbol", + }, + ), + ], + value: Dict( + Dict { + node: Node { + start: 8753, + end: 8755, + }, + keys: [], + values: [], + }, + ), + }, + ), + WithStatement( + With { + node: Node { + start: 8760, + end: 10374, + }, + items: [ + WithItem { + node: Node { + start: 8765, + end: 8819, + }, + context_expr: Call( + Call { + node: Node { + start: 8791, + end: 8807, + }, + func: Attribute( + Attribute { + node: Node { + start: 8765, + end: 8791, + }, + value: Name( + Name { + node: Node { + start: 8765, + end: 8772, + }, + id: "futures", + }, + ), + attr: "ThreadPoolExecutor", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 8792, + end: 8806, + }, + arg: Some( + "max_workers", + ), + value: Constant( + Constant { + node: Node { + start: 8804, + end: 8806, + }, + value: Int( + "10", + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + optional_vars: Some( + Name( + Name { + node: Node { + start: 8811, + end: 8819, + }, + id: "executor", + }, + ), + ), + }, + ], + body: [ + AssignStatement( + Assign { + node: Node { + start: 8829, + end: 8863, + }, + targets: [ + Name( + Name { + node: Node { + start: 8829, + end: 8836, + }, + id: "session", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 8839, + end: 8863, + }, + func: Name( + Name { + node: Node { + start: 8839, + end: 8861, + }, + id: "requests_retry_session", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ForStatement( + For { + node: Node { + start: 8872, + end: 9506, + }, + target: Name( + Name { + node: Node { + start: 8876, + end: 8882, + }, + id: "symbol", + }, + ), + iter: Name( + Name { + node: Node { + start: 8886, + end: 8893, + }, + id: "symbols", + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 8907, + end: 8947, + }, + targets: [ + Name( + Name { + node: Node { + start: 8907, + end: 8913, + }, + id: "symbol", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 8939, + end: 8947, + }, + func: Attribute( + Attribute { + node: Node { + start: 8916, + end: 8939, + }, + value: Name( + Name { + node: Node { + start: 8916, + end: 8923, }, - id: "symbol", + id: "persian", }, ), - ], - value: Call( - Call { + attr: "replace_persian", + }, + ), + args: [ + Name( + Name { node: Node { - start: 8939, - end: 8947, + start: 8940, + end: 8946, }, - func: Attribute( - Attribute { - node: Node { - start: 8916, - end: 8939, - }, - value: Name( - Name { - node: Node { - start: 8916, - end: 8923, - }, - id: "persian", - }, - ), - attr: "replace_persian", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 8940, - end: 8946, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "symbol", }, ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 8960, + end: 9230, + }, + test: BoolOp( + BoolOperation { + node: Node { + start: 8981, + end: 9068, }, - ), - IfStatement( - If { - node: Node { - start: 8960, - end: 9230, - }, - test: BoolOp( - BoolOperation { + op: And, + values: [ + Call( + Call { node: Node { - start: 8981, - end: 9068, + start: 8997, + end: 8999, }, - op: And, - values: [ - Call( - Call { - node: Node { - start: 8997, - end: 8999, - }, - func: Attribute( - Attribute { - node: Node { - start: 8981, - end: 8997, - }, - value: Name( - Name { - node: Node { - start: 8981, - end: 8987, - }, - id: "symbol", - }, - ), - attr: "isnumeric", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - Compare( - Compare { - node: Node { - start: 9020, - end: 9068, - }, - left: Call( - Call { - node: Node { - start: 9052, - end: 9060, - }, - func: Attribute( - Attribute { - node: Node { - start: 9020, - end: 9052, - }, - value: Name( - Name { - node: Node { - start: 9020, - end: 9032, - }, - id: "symbols_data", - }, - ), - attr: "get_financial_index", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 9053, - end: 9059, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 9064, - end: 9068, - }, - value: None, - }, - ), - ], - }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 9100, - end: 9124, - }, - targets: [ - Name( - Name { - node: Node { - start: 9100, - end: 9115, - }, - id: "financial_index", - }, - ), - ], - value: Name( - Name { - node: Node { - start: 9118, - end: 9124, - }, - id: "symbol", + func: Attribute( + Attribute { + node: Node { + start: 8981, + end: 8997, }, - ), - }, - ), - ], - orelse: [ - AssignStatement( - Assign { - node: Node { - start: 9159, - end: 9217, - }, - targets: [ - Name( + value: Name( Name { node: Node { - start: 9159, - end: 9174, + start: 8981, + end: 8987, }, - id: "financial_index", + id: "symbol", }, ), - ], - value: Call( - Call { - node: Node { - start: 9209, - end: 9217, - }, - func: Attribute( - Attribute { - node: Node { - start: 9177, - end: 9209, - }, - value: Name( - Name { - node: Node { - start: 9177, - end: 9189, - }, - id: "symbols_data", - }, - ), - attr: "get_financial_index", + attr: "isnumeric", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + Compare( + Compare { + node: Node { + start: 9020, + end: 9068, + }, + left: Call( + Call { + node: Node { + start: 9052, + end: 9060, + }, + func: Attribute( + Attribute { + node: Node { + start: 9020, + end: 9052, }, - ), - args: [ - Name( + value: Name( Name { node: Node { - start: 9210, - end: 9216, + start: 9020, + end: 9032, }, - id: "symbol", + id: "symbols_data", }, ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - }, - ), - IfStatement( - If { - node: Node { - start: 9230, - end: 9345, - }, - test: Compare( - Compare { - node: Node { - start: 9233, - end: 9256, - }, - left: Name( - Name { - node: Node { - start: 9233, - end: 9248, - }, - id: "financial_index", + attr: "get_financial_index", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 9053, + end: 9059, + }, + id: "symbol", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, }, ), ops: [ @@ -8871,8 +8742,8 @@ Module { Constant( Constant { node: Node { - start: 9252, - end: 9256, + start: 9064, + end: 9068, }, value: None, }, @@ -8880,141 +8751,89 @@ Module { ], }, ), - body: [ - Raise( - Raise { + ], + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 9100, + end: 9124, + }, + targets: [ + Name( + Name { node: Node { - start: 9274, - end: 9331, + start: 9100, + end: 9115, }, - exc: Some( - Call( - Call { - node: Node { - start: 9280, - end: 9331, - }, - func: Name( - Name { - node: Node { - start: 9280, - end: 9289, - }, - id: "Exception", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 9290, - end: 9330, - }, - values: [ - Constant( - Constant { - node: Node { - start: 9321, - end: 0, - }, - value: Str( - "Cannot find financial index: ", - ), - }, - ), - Name( - Name { - node: Node { - start: 9322, - end: 9328, - }, - id: "symbol", - }, - ), - ], - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - cause: None, + id: "financial_index", }, ), ], - orelse: [], + value: Name( + Name { + node: Node { + start: 9118, + end: 9124, + }, + id: "symbol", + }, + ), }, ), + ], + orelse: [ AssignStatement( Assign { node: Node { - start: 9345, - end: 9449, + start: 9159, + end: 9217, }, targets: [ Name( Name { node: Node { - start: 9345, - end: 9351, + start: 9159, + end: 9174, }, - id: "future", + id: "financial_index", }, ), ], value: Call( Call { node: Node { - start: 9369, - end: 9449, + start: 9209, + end: 9217, }, func: Attribute( Attribute { node: Node { - start: 9354, - end: 9369, + start: 9177, + end: 9209, }, value: Name( Name { node: Node { - start: 9354, - end: 9362, + start: 9177, + end: 9189, }, - id: "executor", + id: "symbols_data", }, ), - attr: "submit", + attr: "get_financial_index", }, ), args: [ Name( Name { node: Node { - start: 9387, - end: 9409, - }, - id: "download_fIndex_record", - }, - ), - Name( - Name { - node: Node { - start: 9411, - end: 9426, - }, - id: "financial_index", - }, - ), - Name( - Name { - node: Node { - start: 9428, - end: 9435, + start: 9210, + end: 9216, }, - id: "session", + id: "symbol", }, ), ], @@ -9025,102 +8844,181 @@ Module { ), }, ), - AssignStatement( - Assign { + ], + }, + ), + IfStatement( + If { + node: Node { + start: 9230, + end: 9345, + }, + test: Compare( + Compare { + node: Node { + start: 9233, + end: 9256, + }, + left: Name( + Name { + node: Node { + start: 9233, + end: 9248, + }, + id: "financial_index", + }, + ), + ops: [ + Is, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 9252, + end: 9256, + }, + value: None, + }, + ), + ], + }, + ), + body: [ + Raise( + Raise { node: Node { - start: 9463, - end: 9496, + start: 9274, + end: 9331, }, - targets: [ - Subscript( - Subscript { + exc: Some( + Call( + Call { node: Node { - start: 9463, - end: 9487, + start: 9280, + end: 9331, }, - value: Name( + func: Name( Name { node: Node { - start: 9463, - end: 9479, + start: 9280, + end: 9289, }, - id: "future_to_symbol", + id: "Exception", }, ), - slice: Name( - Name { - node: Node { - start: 9480, - end: 9486, + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 9290, + end: 9330, + }, + values: [ + Constant( + Constant { + node: Node { + start: 9321, + end: 0, + }, + value: Str( + "Cannot find financial index: ", + ), + }, + ), + Name( + Name { + node: Node { + start: 9322, + end: 9328, + }, + id: "symbol", + }, + ), + ], }, - id: "future", - }, - ), + ), + ], + keywords: [], + starargs: None, + kwargs: None, }, ), - ], - value: Name( - Name { - node: Node { - start: 9490, - end: 9496, - }, - id: "symbol", - }, ), + cause: None, }, ), ], orelse: [], }, ), - ForStatement( - For { - node: Node { - start: 9506, - end: 10231, - }, - target: Name( - Name { - node: Node { - start: 9510, - end: 9516, + AssignStatement( + Assign { + node: Node { + start: 9345, + end: 9449, + }, + targets: [ + Name( + Name { + node: Node { + start: 9345, + end: 9351, + }, + id: "future", }, - id: "future", - }, - ), - iter: Call( + ), + ], + value: Call( Call { node: Node { - start: 9540, - end: 9558, + start: 9369, + end: 9449, }, func: Attribute( Attribute { node: Node { - start: 9520, - end: 9540, + start: 9354, + end: 9369, }, value: Name( Name { node: Node { - start: 9520, - end: 9527, + start: 9354, + end: 9362, }, - id: "futures", + id: "executor", }, ), - attr: "as_completed", + attr: "submit", }, ), args: [ Name( Name { node: Node { - start: 9541, - end: 9557, + start: 9387, + end: 9409, }, - id: "future_to_symbol", + id: "download_fIndex_record", + }, + ), + Name( + Name { + node: Node { + start: 9411, + end: 9426, + }, + id: "financial_index", + }, + ), + Name( + Name { + node: Node { + start: 9428, + end: 9435, + }, + id: "session", }, ), ], @@ -9129,726 +9027,707 @@ Module { kwargs: None, }, ), - body: [ - AssignStatement( - Assign { + }, + ), + AssignStatement( + Assign { + node: Node { + start: 9463, + end: 9496, + }, + targets: [ + Subscript( + Subscript { node: Node { - start: 9572, - end: 9605, + start: 9463, + end: 9487, }, - targets: [ - Name( - Name { - node: Node { - start: 9572, - end: 9578, - }, - id: "symbol", - }, - ), - ], - value: Subscript( - Subscript { + value: Name( + Name { node: Node { - start: 9581, - end: 9605, + start: 9463, + end: 9479, }, - value: Name( - Name { - node: Node { - start: 9581, - end: 9597, - }, - id: "future_to_symbol", - }, - ), - slice: Name( - Name { - node: Node { - start: 9598, - end: 9604, - }, - id: "future", - }, - ), + id: "future_to_symbol", }, ), - }, - ), - TryStatement( - Try { - node: Node { - start: 9618, - end: 9928, - }, - body: [ - AnnAssignStatement( - AnnAssign { - node: Node { - start: 9639, - end: 9673, - }, - target: Name( - Name { - node: Node { - start: 9639, - end: 9641, - }, - id: "df", - }, - ), - annotation: Attribute( - Attribute { - node: Node { - start: 9643, - end: 9655, - }, - value: Name( - Name { - node: Node { - start: 9643, - end: 9645, - }, - id: "pd", - }, - ), - attr: "DataFrame", - }, - ), - value: Some( - Call( - Call { - node: Node { - start: 9671, - end: 9673, - }, - func: Attribute( - Attribute { - node: Node { - start: 9658, - end: 9671, - }, - value: Name( - Name { - node: Node { - start: 9658, - end: 9664, - }, - id: "future", - }, - ), - attr: "result", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - simple: true, - }, - ), - ], - handlers: [ - ExceptHandler { + slice: Name( + Name { node: Node { - start: 9686, - end: 9928, + start: 9480, + end: 9486, }, - typ: Some( - Attribute( - Attribute { - node: Node { - start: 9693, - end: 9717, - }, - value: Attribute( - Attribute { - node: Node { - start: 9693, - end: 9702, - }, - value: Name( - Name { - node: Node { - start: 9693, - end: 9695, - }, - id: "pd", - }, - ), - attr: "errors", - }, - ), - attr: "EmptyDataError", - }, - ), - ), - name: Some( - "ex", - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 9753, - end: 9890, - }, - func: Attribute( - Attribute { - node: Node { - start: 9741, - end: 9753, - }, - value: Name( - Name { - node: Node { - start: 9741, - end: 9747, - }, - id: "logger", - }, - ), - attr: "error", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 9775, - end: 9830, - }, - values: [ - Constant( - Constant { - node: Node { - start: 9821, - end: 0, - }, - value: Str( - "Cannot read daily trade records for symbol: ", - ), - }, - ), - Name( - Name { - node: Node { - start: 9822, - end: 9828, - }, - id: "symbol", - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 9852, - end: 9871, - }, - arg: Some( - "extra", - ), - value: Dict( - Dict { - node: Node { - start: 9858, - end: 9871, - }, - keys: [ - Constant( - Constant { - node: Node { - start: 9859, - end: 9866, - }, - value: Str( - "Error", - ), - }, - ), - ], - values: [ - Name( - Name { - node: Node { - start: 9868, - end: 9870, - }, - id: "ex", - }, - ), - ], - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - Continue( - Continue { - node: Node { - start: 9907, - end: 9915, - }, - }, - ), - ], + id: "future", }, - ], - orelse: [], - finalbody: [], + ), + }, + ), + ], + value: Name( + Name { + node: Node { + start: 9490, + end: 9496, + }, + id: "symbol", + }, + ), + }, + ), + ], + orelse: [], + }, + ), + ForStatement( + For { + node: Node { + start: 9506, + end: 10231, + }, + target: Name( + Name { + node: Node { + start: 9510, + end: 9516, + }, + id: "future", + }, + ), + iter: Call( + Call { + node: Node { + start: 9540, + end: 9558, + }, + func: Attribute( + Attribute { + node: Node { + start: 9520, + end: 9540, + }, + value: Name( + Name { + node: Node { + start: 9520, + end: 9527, + }, + id: "futures", }, ), - ExpressionStatement( - Call( - Call { + attr: "as_completed", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 9541, + end: 9557, + }, + id: "future_to_symbol", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 9572, + end: 9605, + }, + targets: [ + Name( + Name { + node: Node { + start: 9572, + end: 9578, + }, + id: "symbol", + }, + ), + ], + value: Subscript( + Subscript { + node: Node { + start: 9581, + end: 9605, + }, + value: Name( + Name { node: Node { - start: 9928, - end: 9976, + start: 9581, + end: 9597, }, - func: Name( - Name { - node: Node { - start: 9928, - end: 9957, - }, - id: "_adjust_data_frame_for_fIndex", + id: "future_to_symbol", + }, + ), + slice: Name( + Name { + node: Node { + start: 9598, + end: 9604, + }, + id: "future", + }, + ), + }, + ), + }, + ), + TryStatement( + Try { + node: Node { + start: 9618, + end: 9928, + }, + body: [ + AnnAssignStatement( + AnnAssign { + node: Node { + start: 9639, + end: 9673, + }, + target: Name( + Name { + node: Node { + start: 9639, + end: 9641, }, - ), - args: [ - Name( - Name { - node: Node { - start: 9958, - end: 9960, - }, - id: "df", - }, - ), - Name( + id: "df", + }, + ), + annotation: Attribute( + Attribute { + node: Node { + start: 9643, + end: 9655, + }, + value: Name( Name { node: Node { - start: 9962, - end: 9975, + start: 9643, + end: 9645, }, - id: "include_jdate", + id: "pd", }, ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - AssignStatement( - Assign { - node: Node { - start: 9989, - end: 10009, - }, - targets: [ - Subscript( - Subscript { + attr: "DataFrame", + }, + ), + value: Some( + Call( + Call { node: Node { - start: 9989, - end: 10004, + start: 9671, + end: 9673, }, - value: Name( - Name { - node: Node { - start: 9989, - end: 9996, - }, - id: "df_list", - }, - ), - slice: Name( - Name { + func: Attribute( + Attribute { node: Node { - start: 9997, - end: 10003, + start: 9658, + end: 9671, }, - id: "symbol", + value: Name( + Name { + node: Node { + start: 9658, + end: 9664, + }, + id: "future", + }, + ), + attr: "result", }, ), + args: [], + keywords: [], + starargs: None, + kwargs: None, }, ), - ], - value: Name( - Name { - node: Node { - start: 10007, - end: 10009, - }, - id: "df", - }, ), + simple: true, }, ), - IfStatement( - If { - node: Node { - start: 10023, - end: 10231, - }, - test: Name( - Name { + ], + handlers: [ + ExceptHandler { + node: Node { + start: 9686, + end: 9928, + }, + typ: Some( + Attribute( + Attribute { node: Node { - start: 10026, - end: 10038, + start: 9693, + end: 9717, }, - id: "write_to_csv", - }, - ), - body: [ - ExpressionStatement( - Call( - Call { + value: Attribute( + Attribute { node: Node { - start: 10077, - end: 10106, + start: 9693, + end: 9702, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 10071, - end: 10077, + start: 9693, + end: 9695, }, - value: Call( - Call { - node: Node { - start: 10056, - end: 10071, - }, - func: Name( - Name { - node: Node { - start: 10056, - end: 10060, - }, - id: "Path", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 10061, - end: 10070, - }, - id: "base_path", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "mkdir", + id: "pd", }, ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 10078, - end: 10090, - }, - arg: Some( - "parents", - ), - value: Constant( - Constant { - node: Node { - start: 10086, - end: 10090, - }, - value: Bool( - true, - ), - }, - ), - }, - Keyword { - node: Node { - start: 10092, - end: 10105, - }, - arg: Some( - "exist_ok", - ), - value: Constant( - Constant { - node: Node { - start: 10101, - end: 10105, - }, - value: Bool( - true, - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, + attr: "errors", }, ), - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 10145, - end: 10225, + attr: "EmptyDataError", + }, + ), + ), + name: Some( + "ex", + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 9753, + end: 9890, + }, + func: Attribute( + Attribute { + node: Node { + start: 9741, + end: 9753, + }, + value: Name( + Name { + node: Node { + start: 9741, + end: 9747, + }, + id: "logger", + }, + ), + attr: "error", }, - func: Attribute( - Attribute { + ), + args: [ + JoinedStr( + JoinedStr { node: Node { - start: 10138, - end: 10145, + start: 9775, + end: 9830, }, - value: Subscript( - Subscript { - node: Node { - start: 10123, - end: 10138, - }, - value: Name( - Name { - node: Node { - start: 10123, - end: 10130, - }, - id: "df_list", + values: [ + Constant( + Constant { + node: Node { + start: 9821, + end: 0, }, - ), - slice: Name( - Name { - node: Node { - start: 10131, - end: 10137, - }, - id: "symbol", + value: Str( + "Cannot read daily trade records for symbol: ", + ), + }, + ), + Name( + Name { + node: Node { + start: 9822, + end: 9828, }, - ), - }, - ), - attr: "to_csv", + id: "symbol", + }, + ), + ], }, ), - args: [ - JoinedStr( - JoinedStr { + ], + keywords: [ + Keyword { + node: Node { + start: 9852, + end: 9871, + }, + arg: Some( + "extra", + ), + value: Dict( + Dict { node: Node { - start: 10167, - end: 10194, + start: 9858, + end: 9871, }, - values: [ - Name( - Name { - node: Node { - start: 10170, - end: 10179, - }, - id: "base_path", - }, - ), + keys: [ Constant( Constant { node: Node { - start: 10181, - end: 0, + start: 9859, + end: 9866, }, value: Str( - "/", + "Error", ), }, ), + ], + values: [ Name( Name { node: Node { - start: 10182, - end: 10188, - }, - id: "symbol", - }, - ), - Constant( - Constant { - node: Node { - start: 10193, - end: 0, + start: 9868, + end: 9870, }, - value: Str( - ".csv", - ), + id: "ex", }, ), ], }, ), - ], - keywords: [ - Keyword { - node: Node { - start: 10196, - end: 10207, - }, - arg: Some( - "index", - ), - value: Constant( - Constant { - node: Node { - start: 10202, - end: 10207, - }, - value: Bool( - false, - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), + }, + ], + starargs: None, + kwargs: None, + }, ), - ], - orelse: [], + ), + Continue( + Continue { + node: Node { + start: 9907, + end: 9915, + }, + }, + ), + ], + }, + ], + orelse: [], + finalbody: [], + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 9928, + end: 9976, + }, + func: Name( + Name { + node: Node { + start: 9928, + end: 9957, + }, + id: "_adjust_data_frame_for_fIndex", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 9958, + end: 9960, + }, + id: "df", + }, + ), + Name( + Name { + node: Node { + start: 9962, + end: 9975, + }, + id: "include_jdate", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + AssignStatement( + Assign { + node: Node { + start: 9989, + end: 10009, + }, + targets: [ + Subscript( + Subscript { + node: Node { + start: 9989, + end: 10004, + }, + value: Name( + Name { + node: Node { + start: 9989, + end: 9996, + }, + id: "df_list", + }, + ), + slice: Name( + Name { + node: Node { + start: 9997, + end: 10003, + }, + id: "symbol", + }, + ), }, ), ], - orelse: [], + value: Name( + Name { + node: Node { + start: 10007, + end: 10009, + }, + id: "df", + }, + ), }, ), IfStatement( If { node: Node { - start: 10231, - end: 10337, + start: 10023, + end: 10231, }, - test: Compare( - Compare { + test: Name( + Name { node: Node { - start: 10234, - end: 10262, + start: 10026, + end: 10038, }, - left: Call( + id: "write_to_csv", + }, + ), + body: [ + ExpressionStatement( + Call( Call { node: Node { - start: 10234, - end: 10246, + start: 10077, + end: 10106, }, - func: Name( - Name { + func: Attribute( + Attribute { node: Node { - start: 10234, - end: 10237, + start: 10071, + end: 10077, }, - id: "len", + value: Call( + Call { + node: Node { + start: 10056, + end: 10071, + }, + func: Name( + Name { + node: Node { + start: 10056, + end: 10060, + }, + id: "Path", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 10061, + end: 10070, + }, + id: "base_path", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + attr: "mkdir", }, ), - args: [ - Name( - Name { - node: Node { - start: 10238, - end: 10245, - }, - id: "df_list", + args: [], + keywords: [ + Keyword { + node: Node { + start: 10078, + end: 10090, }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - NotEq, - ], - comparators: [ - Call( - Call { - node: Node { - start: 10250, - end: 10262, - }, - func: Name( - Name { - node: Node { - start: 10250, - end: 10253, + arg: Some( + "parents", + ), + value: Constant( + Constant { + node: Node { + start: 10086, + end: 10090, + }, + value: Bool( + true, + ), }, - id: "len", + ), + }, + Keyword { + node: Node { + start: 10092, + end: 10105, }, - ), - args: [ - Name( - Name { + arg: Some( + "exist_ok", + ), + value: Constant( + Constant { node: Node { - start: 10254, - end: 10261, + start: 10101, + end: 10105, }, - id: "symbols", + value: Bool( + true, + ), }, ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ], - }, - ), - body: [ + }, + ], + starargs: None, + kwargs: None, + }, + ), + ), ExpressionStatement( Call( Call { node: Node { - start: 10272, - end: 10332, + start: 10145, + end: 10225, }, - func: Name( - Name { + func: Attribute( + Attribute { node: Node { - start: 10272, - end: 10277, + start: 10138, + end: 10145, }, - id: "print", + value: Subscript( + Subscript { + node: Node { + start: 10123, + end: 10138, + }, + value: Name( + Name { + node: Node { + start: 10123, + end: 10130, + }, + id: "df_list", + }, + ), + slice: Name( + Name { + node: Node { + start: 10131, + end: 10137, + }, + id: "symbol", + }, + ), + }, + ), + attr: "to_csv", }, ), args: [ - Constant( - Constant { + JoinedStr( + JoinedStr { node: Node { - start: 10278, - end: 10331, + start: 10167, + end: 10194, }, - value: Str( - "Warning, download did not complete, re-run the code", - ), + values: [ + Name( + Name { + node: Node { + start: 10170, + end: 10179, + }, + id: "base_path", + }, + ), + Constant( + Constant { + node: Node { + start: 10181, + end: 0, + }, + value: Str( + "/", + ), + }, + ), + Name( + Name { + node: Node { + start: 10182, + end: 10188, + }, + id: "symbol", + }, + ), + Constant( + Constant { + node: Node { + start: 10193, + end: 0, + }, + value: Str( + ".csv", + ), + }, + ), + ], }, ), ], - keywords: [], + keywords: [ + Keyword { + node: Node { + start: 10196, + end: 10207, + }, + arg: Some( + "index", + ), + value: Constant( + Constant { + node: Node { + start: 10202, + end: 10207, + }, + value: Bool( + false, + ), + }, + ), + }, + ], starargs: None, kwargs: None, }, @@ -9858,893 +9737,912 @@ Module { orelse: [], }, ), - ExpressionStatement( - Call( + ], + orelse: [], + }, + ), + IfStatement( + If { + node: Node { + start: 10231, + end: 10337, + }, + test: Compare( + Compare { + node: Node { + start: 10234, + end: 10262, + }, + left: Call( Call { node: Node { - start: 10350, - end: 10352, + start: 10234, + end: 10246, }, - func: Attribute( - Attribute { + func: Name( + Name { node: Node { - start: 10337, - end: 10350, + start: 10234, + end: 10237, }, - value: Name( + id: "len", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 10238, + end: 10245, + }, + id: "df_list", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ops: [ + NotEq, + ], + comparators: [ + Call( + Call { + node: Node { + start: 10250, + end: 10262, + }, + func: Name( + Name { + node: Node { + start: 10250, + end: 10253, + }, + id: "len", + }, + ), + args: [ + Name( Name { node: Node { - start: 10337, - end: 10344, + start: 10254, + end: 10261, }, - id: "session", + id: "symbols", }, ), - attr: "close", + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 10272, + end: 10332, + }, + func: Name( + Name { + node: Node { + start: 10272, + end: 10277, + }, + id: "print", }, ), - args: [], + args: [ + Constant( + Constant { + node: Node { + start: 10278, + end: 10331, + }, + value: Str( + "Warning, download did not complete, re-run the code", + ), + }, + ), + ], keywords: [], starargs: None, kwargs: None, }, ), ), - Return( - Return { + ], + orelse: [], + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 10350, + end: 10352, + }, + func: Attribute( + Attribute { node: Node { - start: 10357, - end: 10371, + start: 10337, + end: 10350, }, - value: Some( - Name( - Name { - node: Node { - start: 10364, - end: 10371, - }, - id: "df_list", + value: Name( + Name { + node: Node { + start: 10337, + end: 10344, }, - ), + id: "session", + }, ), + attr: "close", }, ), - ], + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + Return( + Return { + node: Node { + start: 10357, + end: 10371, + }, + value: Some( + Name( + Name { + node: Node { + start: 10364, + end: 10371, + }, + id: "df_list", + }, + ), + ), }, ), - FunctionDef( - FunctionDef { + ], + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 10374, + end: 15273, + }, + name: "download_client_types_records", + args: Arguments { + node: Node { + start: 10413, + end: 10561, + }, + posonlyargs: [], + args: [ + Arg { node: Node { - start: 10374, - end: 15273, + start: 10413, + end: 10438, }, - name: "download_client_types_records", - args: Arguments { - node: Node { - start: 10413, - end: 10561, - }, - posonlyargs: [], - args: [ - Arg { + arg: "symbols", + annotation: Some( + Subscript( + Subscript { node: Node { - start: 10413, + start: 10422, end: 10438, }, - arg: "symbols", - annotation: Some( - Subscript( - Subscript { - node: Node { - start: 10422, - end: 10438, - }, - value: Name( + value: Name( + Name { + node: Node { + start: 10422, + end: 10427, + }, + id: "Union", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 10428, + end: 10438, + }, + elements: [ + Name( Name { node: Node { - start: 10422, - end: 10427, + start: 10428, + end: 10432, }, - id: "Union", + id: "List", }, ), - slice: Tuple( - Tuple { + Name( + Name { node: Node { - start: 10428, - end: 10438, + start: 10434, + end: 10437, }, - elements: [ - Name( - Name { - node: Node { - start: 10428, - end: 10432, - }, - id: "List", - }, - ), - Name( - Name { - node: Node { - start: 10434, - end: 10437, - }, - id: "str", - }, - ), - ], + id: "str", }, ), - }, - ), + ], + }, ), }, - Arg { + ), + ), + }, + Arg { + node: Node { + start: 10444, + end: 10470, + }, + arg: "write_to_csv", + annotation: Some( + Name( + Name { node: Node { - start: 10444, - end: 10470, + start: 10458, + end: 10462, }, - arg: "write_to_csv", - annotation: Some( - Name( - Name { - node: Node { - start: 10458, - end: 10462, - }, - id: "bool", - }, - ), - ), + id: "bool", }, - Arg { + ), + ), + }, + Arg { + node: Node { + start: 10476, + end: 10503, + }, + arg: "include_jdate", + annotation: Some( + Name( + Name { node: Node { - start: 10476, - end: 10503, + start: 10491, + end: 10495, }, - arg: "include_jdate", - annotation: Some( - Name( - Name { - node: Node { - start: 10491, - end: 10495, - }, - id: "bool", - }, - ), - ), + id: "bool", }, - Arg { + ), + ), + }, + Arg { + node: Node { + start: 10509, + end: 10560, + }, + arg: "base_path", + annotation: Some( + Name( + Name { node: Node { - start: 10509, - end: 10560, + start: 10520, + end: 10523, }, - arg: "base_path", - annotation: Some( - Name( - Name { - node: Node { - start: 10520, - end: 10523, - }, - id: "str", - }, - ), - ), + id: "str", }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [ - Constant( - Constant { - node: Node { - start: 10465, - end: 10470, - }, - value: Bool( - false, - ), + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [ + Constant( + Constant { + node: Node { + start: 10465, + end: 10470, + }, + value: Bool( + false, + ), + }, + ), + Constant( + Constant { + node: Node { + start: 10498, + end: 10503, + }, + value: Bool( + false, + ), + }, + ), + Attribute( + Attribute { + node: Node { + start: 10526, + end: 10560, + }, + value: Name( + Name { + node: Node { + start: 10526, + end: 10532, }, - ), - Constant( - Constant { + id: "config", + }, + ), + attr: "CLIENT_TYPES_DATA_BASE_PATH", + }, + ), + ], + }, + body: [ + IfStatement( + If { + node: Node { + start: 10569, + end: 10703, + }, + test: Compare( + Compare { + node: Node { + start: 10572, + end: 10588, + }, + left: Name( + Name { node: Node { - start: 10498, - end: 10503, + start: 10572, + end: 10579, }, - value: Bool( - false, - ), + id: "symbols", }, ), - Attribute( - Attribute { - node: Node { - start: 10526, - end: 10560, + ops: [ + Eq, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 10583, + end: 10588, + }, + value: Str( + "all", + ), }, - value: Name( + ), + ], + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 10598, + end: 10634, + }, + targets: [ + Name( Name { node: Node { - start: 10526, - end: 10532, + start: 10598, + end: 10605, }, - id: "config", + id: "symbols", }, ), - attr: "CLIENT_TYPES_DATA_BASE_PATH", - }, - ), - ], - }, - body: [ + ], + value: Call( + Call { + node: Node { + start: 10632, + end: 10634, + }, + func: Attribute( + Attribute { + node: Node { + start: 10608, + end: 10632, + }, + value: Name( + Name { + node: Node { + start: 10608, + end: 10620, + }, + id: "symbols_data", + }, + ), + attr: "all_symbols", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ], + orelse: [ IfStatement( If { node: Node { - start: 10569, + start: 10639, end: 10703, }, - test: Compare( - Compare { + test: Call( + Call { node: Node { - start: 10572, - end: 10588, + start: 10644, + end: 10668, }, - left: Name( + func: Name( Name { node: Node { - start: 10572, - end: 10579, + start: 10644, + end: 10654, }, - id: "symbols", + id: "isinstance", }, ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { + args: [ + Name( + Name { + node: Node { + start: 10655, + end: 10662, + }, + id: "symbols", + }, + ), + Name( + Name { node: Node { - start: 10583, - end: 10588, + start: 10664, + end: 10667, }, - value: Str( - "all", - ), + id: "str", }, ), ], + keywords: [], + starargs: None, + kwargs: None, }, ), body: [ AssignStatement( Assign { node: Node { - start: 10598, - end: 10634, + start: 10678, + end: 10697, }, targets: [ Name( Name { node: Node { - start: 10598, - end: 10605, + start: 10678, + end: 10685, }, id: "symbols", }, ), ], - value: Call( - Call { - node: Node { - start: 10632, - end: 10634, - }, - func: Attribute( - Attribute { - node: Node { - start: 10608, - end: 10632, - }, - value: Name( - Name { - node: Node { - start: 10608, - end: 10620, - }, - id: "symbols_data", - }, - ), - attr: "all_symbols", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - orelse: [ - IfStatement( - If { - node: Node { - start: 10639, - end: 10703, - }, - test: Call( - Call { + value: List( + List { node: Node { - start: 10644, - end: 10668, + start: 10688, + end: 10697, }, - func: Name( - Name { - node: Node { - start: 10644, - end: 10654, - }, - id: "isinstance", - }, - ), - args: [ + elements: [ Name( Name { node: Node { - start: 10655, - end: 10662, + start: 10689, + end: 10696, }, id: "symbols", }, ), - Name( - Name { - node: Node { - start: 10664, - end: 10667, - }, - id: "str", - }, - ), ], - keywords: [], - starargs: None, - kwargs: None, }, ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 10678, - end: 10697, - }, - targets: [ - Name( - Name { - node: Node { - start: 10678, - end: 10685, - }, - id: "symbols", - }, - ), - ], - value: List( - List { - node: Node { - start: 10688, - end: 10697, - }, - elements: [ - Name( - Name { - node: Node { - start: 10689, - end: 10696, - }, - id: "symbols", - }, - ), - ], - }, - ), - }, - ), - ], - orelse: [], }, ), ], + orelse: [], }, ), - AssignStatement( - Assign { + ], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 10703, + end: 10715, + }, + targets: [ + Name( + Name { node: Node { start: 10703, - end: 10715, + end: 10710, }, - targets: [ - Name( - Name { - node: Node { - start: 10703, - end: 10710, - }, - id: "df_list", - }, - ), - ], - value: Dict( - Dict { - node: Node { - start: 10713, - end: 10715, - }, - keys: [], - values: [], - }, - ), + id: "df_list", }, ), - AssignStatement( - Assign { + ], + value: Dict( + Dict { + node: Node { + start: 10713, + end: 10715, + }, + keys: [], + values: [], + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 10720, + end: 10741, + }, + targets: [ + Name( + Name { node: Node { start: 10720, - end: 10741, + end: 10736, }, - targets: [ - Name( - Name { + id: "future_to_symbol", + }, + ), + ], + value: Dict( + Dict { + node: Node { + start: 10739, + end: 10741, + }, + keys: [], + values: [], + }, + ), + }, + ), + WithStatement( + With { + node: Node { + start: 10746, + end: 11849, + }, + items: [ + WithItem { + node: Node { + start: 10751, + end: 10805, + }, + context_expr: Call( + Call { + node: Node { + start: 10777, + end: 10793, + }, + func: Attribute( + Attribute { node: Node { - start: 10720, - end: 10736, + start: 10751, + end: 10777, }, - id: "future_to_symbol", + value: Name( + Name { + node: Node { + start: 10751, + end: 10758, + }, + id: "futures", + }, + ), + attr: "ThreadPoolExecutor", }, ), - ], - value: Dict( - Dict { + args: [], + keywords: [ + Keyword { + node: Node { + start: 10778, + end: 10792, + }, + arg: Some( + "max_workers", + ), + value: Constant( + Constant { + node: Node { + start: 10790, + end: 10792, + }, + value: Int( + "10", + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + optional_vars: Some( + Name( + Name { node: Node { - start: 10739, - end: 10741, + start: 10797, + end: 10805, }, - keys: [], - values: [], + id: "executor", }, ), - }, - ), - WithStatement( - With { + ), + }, + ], + body: [ + ForStatement( + For { node: Node { - start: 10746, - end: 11849, + start: 10815, + end: 11168, }, - items: [ - WithItem { + target: Name( + Name { node: Node { - start: 10751, - end: 10805, + start: 10819, + end: 10825, }, - context_expr: Call( - Call { - node: Node { - start: 10777, - end: 10793, - }, - func: Attribute( - Attribute { + id: "symbol", + }, + ), + iter: Name( + Name { + node: Node { + start: 10829, + end: 10836, + }, + id: "symbols", + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 10850, + end: 10893, + }, + targets: [ + Name( + Name { node: Node { - start: 10751, - end: 10777, + start: 10850, + end: 10862, }, - value: Name( - Name { - node: Node { - start: 10751, - end: 10758, - }, - id: "futures", + id: "ticker_index", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 10865, + end: 10893, + }, + func: Name( + Name { + node: Node { + start: 10865, + end: 10885, }, - ), - attr: "ThreadPoolExecutor", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 10778, - end: 10792, + id: "_handle_ticker_index", }, - arg: Some( - "max_workers", - ), - value: Constant( - Constant { + ), + args: [ + Name( + Name { node: Node { - start: 10790, - end: 10792, + start: 10886, + end: 10892, }, - value: Int( - "10", - ), + id: "symbol", }, ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - optional_vars: Some( - Name( - Name { - node: Node { - start: 10797, - end: 10805, - }, - id: "executor", + ], + keywords: [], + starargs: None, + kwargs: None, }, ), - ), - }, - ], - body: [ - ForStatement( - For { + }, + ), + IfStatement( + If { node: Node { - start: 10815, - end: 11168, + start: 10906, + end: 11008, }, - target: Name( - Name { - node: Node { - start: 10819, - end: 10825, - }, - id: "symbol", - }, - ), - iter: Name( - Name { + test: Compare( + Compare { node: Node { - start: 10829, - end: 10836, + start: 10909, + end: 10929, }, - id: "symbols", - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 10850, - end: 10893, + left: Name( + Name { + node: Node { + start: 10909, + end: 10921, + }, + id: "ticker_index", }, - targets: [ - Name( - Name { - node: Node { - start: 10850, - end: 10862, - }, - id: "ticker_index", - }, - ), - ], - value: Call( - Call { + ), + ops: [ + Is, + ], + comparators: [ + Constant( + Constant { node: Node { - start: 10865, - end: 10893, + start: 10925, + end: 10929, }, - func: Name( - Name { - node: Node { - start: 10865, - end: 10885, - }, - id: "_handle_ticker_index", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 10886, - end: 10892, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + value: None, }, ), - }, - ), - IfStatement( - If { + ], + }, + ), + body: [ + Raise( + Raise { node: Node { - start: 10906, - end: 11008, + start: 10947, + end: 10995, }, - test: Compare( - Compare { - node: Node { - start: 10909, - end: 10929, - }, - left: Name( - Name { - node: Node { - start: 10909, - end: 10921, - }, - id: "ticker_index", + exc: Some( + Call( + Call { + node: Node { + start: 10953, + end: 10995, }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { + func: Name( + Name { node: Node { - start: 10925, - end: 10929, + start: 10953, + end: 10962, }, - value: None, + id: "Exception", }, ), - ], - }, - ), - body: [ - Raise( - Raise { - node: Node { - start: 10947, - end: 10995, - }, - exc: Some( - Call( - Call { + args: [ + JoinedStr( + JoinedStr { node: Node { - start: 10953, - end: 10995, + start: 10963, + end: 10994, }, - func: Name( - Name { - node: Node { - start: 10953, - end: 10962, + values: [ + Constant( + Constant { + node: Node { + start: 10985, + end: 0, + }, + value: Str( + "Cannot find symbol: ", + ), }, - id: "Exception", - }, - ), - args: [ - JoinedStr( - JoinedStr { + ), + Name( + Name { node: Node { - start: 10963, - end: 10994, + start: 10986, + end: 10992, }, - values: [ - Constant( - Constant { - node: Node { - start: 10985, - end: 0, - }, - value: Str( - "Cannot find symbol: ", - ), - }, - ), - Name( - Name { - node: Node { - start: 10986, - end: 10992, - }, - id: "symbol", - }, - ), - ], + id: "symbol", }, ), ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - cause: None, - }, - ), - ], - orelse: [], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 11008, - end: 11113, - }, - targets: [ - Name( - Name { - node: Node { - start: 11008, - end: 11014, - }, - id: "future", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 11032, - end: 11113, - }, - func: Attribute( - Attribute { - node: Node { - start: 11017, - end: 11032, - }, - value: Name( - Name { - node: Node { - start: 11017, - end: 11025, - }, - id: "executor", }, ), - attr: "submit", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11050, - end: 11085, - }, - id: "download_ticker_client_types_record", - }, - ), - Name( - Name { - node: Node { - start: 11087, - end: 11099, - }, - id: "ticker_index", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 11126, - end: 11159, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 11126, - end: 11150, - }, - value: Name( - Name { - node: Node { - start: 11126, - end: 11142, - }, - id: "future_to_symbol", - }, - ), - slice: Name( - Name { - node: Node { - start: 11143, - end: 11149, - }, - id: "future", - }, - ), + ], + keywords: [], + starargs: None, + kwargs: None, }, ), - ], - value: Name( - Name { - node: Node { - start: 11153, - end: 11159, - }, - id: "symbol", - }, ), + cause: None, }, ), ], orelse: [], }, ), - ForStatement( - For { + AssignStatement( + Assign { node: Node { - start: 11168, - end: 11636, + start: 11008, + end: 11113, }, - target: Name( - Name { - node: Node { - start: 11172, - end: 11178, + targets: [ + Name( + Name { + node: Node { + start: 11008, + end: 11014, + }, + id: "future", }, - id: "future", - }, - ), - iter: Call( + ), + ], + value: Call( Call { node: Node { - start: 11202, - end: 11220, + start: 11032, + end: 11113, }, func: Attribute( Attribute { node: Node { - start: 11182, - end: 11202, + start: 11017, + end: 11032, }, value: Name( Name { node: Node { - start: 11182, - end: 11189, + start: 11017, + end: 11025, }, - id: "futures", + id: "executor", }, ), - attr: "as_completed", + attr: "submit", }, ), args: [ Name( Name { node: Node { - start: 11203, - end: 11219, + start: 11050, + end: 11085, }, - id: "future_to_symbol", + id: "download_ticker_client_types_record", + }, + ), + Name( + Name { + node: Node { + start: 11087, + end: 11099, + }, + id: "ticker_index", }, ), ], @@ -10753,2699 +10651,3164 @@ Module { kwargs: None, }, ), - body: [ - AssignStatement( - Assign { + }, + ), + AssignStatement( + Assign { + node: Node { + start: 11126, + end: 11159, + }, + targets: [ + Subscript( + Subscript { node: Node { - start: 11234, - end: 11267, + start: 11126, + end: 11150, }, - targets: [ - Name( - Name { - node: Node { - start: 11234, - end: 11240, - }, - id: "symbol", + value: Name( + Name { + node: Node { + start: 11126, + end: 11142, }, - ), - ], - value: Subscript( - Subscript { + id: "future_to_symbol", + }, + ), + slice: Name( + Name { + node: Node { + start: 11143, + end: 11149, + }, + id: "future", + }, + ), + }, + ), + ], + value: Name( + Name { + node: Node { + start: 11153, + end: 11159, + }, + id: "symbol", + }, + ), + }, + ), + ], + orelse: [], + }, + ), + ForStatement( + For { + node: Node { + start: 11168, + end: 11636, + }, + target: Name( + Name { + node: Node { + start: 11172, + end: 11178, + }, + id: "future", + }, + ), + iter: Call( + Call { + node: Node { + start: 11202, + end: 11220, + }, + func: Attribute( + Attribute { + node: Node { + start: 11182, + end: 11202, + }, + value: Name( + Name { + node: Node { + start: 11182, + end: 11189, + }, + id: "futures", + }, + ), + attr: "as_completed", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 11203, + end: 11219, + }, + id: "future_to_symbol", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 11234, + end: 11267, + }, + targets: [ + Name( + Name { + node: Node { + start: 11234, + end: 11240, + }, + id: "symbol", + }, + ), + ], + value: Subscript( + Subscript { + node: Node { + start: 11243, + end: 11267, + }, + value: Name( + Name { + node: Node { + start: 11243, + end: 11259, + }, + id: "future_to_symbol", + }, + ), + slice: Name( + Name { + node: Node { + start: 11260, + end: 11266, + }, + id: "future", + }, + ), + }, + ), + }, + ), + AnnAssignStatement( + AnnAssign { + node: Node { + start: 11280, + end: 11314, + }, + target: Name( + Name { + node: Node { + start: 11280, + end: 11282, + }, + id: "df", + }, + ), + annotation: Attribute( + Attribute { + node: Node { + start: 11284, + end: 11296, + }, + value: Name( + Name { + node: Node { + start: 11284, + end: 11286, + }, + id: "pd", + }, + ), + attr: "DataFrame", + }, + ), + value: Some( + Call( + Call { + node: Node { + start: 11312, + end: 11314, + }, + func: Attribute( + Attribute { node: Node { - start: 11243, - end: 11267, + start: 11299, + end: 11312, }, value: Name( Name { node: Node { - start: 11243, - end: 11259, - }, - id: "future_to_symbol", - }, - ), - slice: Name( - Name { - node: Node { - start: 11260, - end: 11266, + start: 11299, + end: 11305, }, id: "future", }, ), + attr: "result", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + simple: true, + }, + ), + IfStatement( + If { + node: Node { + start: 11357, + end: 11409, + }, + test: Compare( + Compare { + node: Node { + start: 11360, + end: 11370, + }, + left: Name( + Name { + node: Node { + start: 11360, + end: 11362, + }, + id: "df", + }, + ), + ops: [ + Is, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 11366, + end: 11370, + }, + value: None, }, ), + ], + }, + ), + body: [ + Continue( + Continue { + node: Node { + start: 11388, + end: 11396, + }, + }, + ), + ], + orelse: [], + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 11409, + end: 11446, + }, + func: Name( + Name { + node: Node { + start: 11409, + end: 11427, + }, + id: "_adjust_data_frame", }, ), - AnnAssignStatement( - AnnAssign { + args: [ + Name( + Name { + node: Node { + start: 11428, + end: 11430, + }, + id: "df", + }, + ), + Name( + Name { + node: Node { + start: 11432, + end: 11445, + }, + id: "include_jdate", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + AssignStatement( + Assign { + node: Node { + start: 11459, + end: 11479, + }, + targets: [ + Subscript( + Subscript { node: Node { - start: 11280, - end: 11314, + start: 11459, + end: 11474, }, - target: Name( + value: Name( Name { node: Node { - start: 11280, - end: 11282, + start: 11459, + end: 11466, }, - id: "df", + id: "df_list", }, ), - annotation: Attribute( - Attribute { + slice: Name( + Name { node: Node { - start: 11284, - end: 11296, + start: 11467, + end: 11473, }, - value: Name( - Name { - node: Node { - start: 11284, - end: 11286, - }, - id: "pd", - }, - ), - attr: "DataFrame", + id: "symbol", }, ), - value: Some( - Call( - Call { + }, + ), + ], + value: Name( + Name { + node: Node { + start: 11477, + end: 11479, + }, + id: "df", + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 11492, + end: 11636, + }, + test: Name( + Name { + node: Node { + start: 11495, + end: 11507, + }, + id: "write_to_csv", + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 11546, + end: 11575, + }, + func: Attribute( + Attribute { node: Node { - start: 11312, - end: 11314, + start: 11540, + end: 11546, }, - func: Attribute( - Attribute { + value: Call( + Call { node: Node { - start: 11299, - end: 11312, + start: 11525, + end: 11540, }, - value: Name( + func: Name( Name { node: Node { - start: 11299, - end: 11305, + start: 11525, + end: 11529, }, - id: "future", + id: "Path", }, ), - attr: "result", + args: [ + Name( + Name { + node: Node { + start: 11530, + end: 11539, + }, + id: "base_path", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, }, ), - args: [], - keywords: [], - starargs: None, - kwargs: None, + attr: "mkdir", }, ), - ), - simple: true, - }, - ), - IfStatement( - If { - node: Node { - start: 11357, - end: 11409, - }, - test: Compare( - Compare { - node: Node { - start: 11360, - end: 11370, - }, - left: Name( - Name { - node: Node { - start: 11360, - end: 11362, - }, - id: "df", + args: [], + keywords: [ + Keyword { + node: Node { + start: 11547, + end: 11559, }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( + arg: Some( + "parents", + ), + value: Constant( Constant { node: Node { - start: 11366, - end: 11370, + start: 11555, + end: 11559, }, - value: None, + value: Bool( + true, + ), }, ), - ], - }, - ), - body: [ - Continue( - Continue { - node: Node { - start: 11388, - end: 11396, - }, }, - ), - ], - orelse: [], - }, - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 11409, - end: 11446, - }, - func: Name( - Name { + Keyword { node: Node { - start: 11409, - end: 11427, - }, - id: "_adjust_data_frame", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11428, - end: 11430, - }, - id: "df", + start: 11561, + end: 11574, }, - ), - Name( - Name { - node: Node { - start: 11432, - end: 11445, + arg: Some( + "exist_ok", + ), + value: Constant( + Constant { + node: Node { + start: 11570, + end: 11574, + }, + value: Bool( + true, + ), }, - id: "include_jdate", - }, - ), + ), + }, ], - keywords: [], starargs: None, kwargs: None, }, ), ), - AssignStatement( - Assign { - node: Node { - start: 11459, - end: 11479, - }, - targets: [ - Subscript( - Subscript { + ExpressionStatement( + Call( + Call { + node: Node { + start: 11601, + end: 11630, + }, + func: Attribute( + Attribute { node: Node { - start: 11459, - end: 11474, + start: 11592, + end: 11601, }, value: Name( Name { node: Node { - start: 11459, - end: 11466, + start: 11592, + end: 11594, }, - id: "df_list", + id: "df", }, ), - slice: Name( - Name { - node: Node { - start: 11467, - end: 11473, - }, - id: "symbol", - }, - ), - }, - ), - ], - value: Name( - Name { - node: Node { - start: 11477, - end: 11479, - }, - id: "df", - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 11492, - end: 11636, - }, - test: Name( - Name { - node: Node { - start: 11495, - end: 11507, + attr: "to_csv", }, - id: "write_to_csv", - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 11546, - end: 11575, - }, - func: Attribute( - Attribute { - node: Node { - start: 11540, - end: 11546, - }, - value: Call( - Call { - node: Node { - start: 11525, - end: 11540, - }, - func: Name( - Name { - node: Node { - start: 11525, - end: 11529, - }, - id: "Path", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11530, - end: 11539, - }, - id: "base_path", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "mkdir", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 11547, - end: 11559, - }, - arg: Some( - "parents", - ), - value: Constant( - Constant { - node: Node { - start: 11555, - end: 11559, - }, - value: Bool( - true, - ), - }, - ), - }, - Keyword { - node: Node { - start: 11561, - end: 11574, - }, - arg: Some( - "exist_ok", - ), - value: Constant( - Constant { - node: Node { - start: 11570, - end: 11574, - }, - value: Bool( - true, - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), ), - ExpressionStatement( - Call( - Call { + args: [ + JoinedStr( + JoinedStr { node: Node { - start: 11601, - end: 11630, + start: 11602, + end: 11629, }, - func: Attribute( - Attribute { - node: Node { - start: 11592, - end: 11601, + values: [ + Name( + Name { + node: Node { + start: 11605, + end: 11614, + }, + id: "base_path", }, - value: Name( - Name { - node: Node { - start: 11592, - end: 11594, - }, - id: "df", + ), + Constant( + Constant { + node: Node { + start: 11616, + end: 0, }, - ), - attr: "to_csv", - }, - ), - args: [ - JoinedStr( - JoinedStr { + value: Str( + "/", + ), + }, + ), + Name( + Name { node: Node { - start: 11602, - end: 11629, + start: 11617, + end: 11623, }, - values: [ - Name( - Name { - node: Node { - start: 11605, - end: 11614, - }, - id: "base_path", - }, - ), - Constant( - Constant { - node: Node { - start: 11616, - end: 0, - }, - value: Str( - "/", - ), - }, - ), - Name( - Name { - node: Node { - start: 11617, - end: 11623, - }, - id: "symbol", - }, - ), - Constant( - Constant { - node: Node { - start: 11628, - end: 0, - }, - value: Str( - ".csv", - ), - }, - ), - ], + id: "symbol", + }, + ), + Constant( + Constant { + node: Node { + start: 11628, + end: 0, + }, + value: Str( + ".csv", + ), }, ), ], - keywords: [], - starargs: None, - kwargs: None, }, ), - ), - ], - orelse: [], - }, + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), ), ], orelse: [], }, ), - IfStatement( - If { - node: Node { - start: 11636, - end: 11832, + ], + orelse: [], + }, + ), + IfStatement( + If { + node: Node { + start: 11636, + end: 11832, + }, + test: Compare( + Compare { + node: Node { + start: 11639, + end: 11667, + }, + left: Call( + Call { + node: Node { + start: 11639, + end: 11651, + }, + func: Name( + Name { + node: Node { + start: 11639, + end: 11642, + }, + id: "len", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 11643, + end: 11650, + }, + id: "df_list", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ops: [ + NotEq, + ], + comparators: [ + Call( + Call { + node: Node { + start: 11655, + end: 11667, + }, + func: Name( + Name { + node: Node { + start: 11655, + end: 11658, + }, + id: "len", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 11659, + end: 11666, + }, + id: "symbols", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 11677, + end: 11827, + }, + func: Name( + Name { + node: Node { + start: 11677, + end: 11682, + }, + id: "print", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 11696, + end: 11817, + }, + value: Str( + "could not download client types for all the symbols make\n sure you have what you need or re-run the function", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + orelse: [], + }, + ), + Return( + Return { + node: Node { + start: 11832, + end: 11846, + }, + value: Some( + Name( + Name { + node: Node { + start: 11839, + end: 11846, + }, + id: "df_list", + }, + ), + ), + }, + ), + ], + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 11999, + end: 13481, + }, + name: "download_ticker_client_types_record", + args: Arguments { + node: Node { + start: 12039, + end: 12066, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 12039, + end: 12066, + }, + arg: "ticker_index", + annotation: Some( + Subscript( + Subscript { + node: Node { + start: 12053, + end: 12066, + }, + value: Name( + Name { + node: Node { + start: 12053, + end: 12061, + }, + id: "Optional", + }, + ), + slice: Name( + Name { + node: Node { + start: 12062, + end: 12065, + }, + id: "str", + }, + ), + }, + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 12073, + end: 12127, + }, + targets: [ + Name( + Name { + node: Node { + start: 12073, + end: 12077, + }, + id: "data", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 12080, + end: 12127, + }, + func: Name( + Name { + node: Node { + start: 12080, + end: 12113, + }, + id: "_extract_ticker_client_types_data", }, - test: Compare( - Compare { + ), + args: [ + Name( + Name { node: Node { - start: 11639, - end: 11667, + start: 12114, + end: 12126, }, - left: Call( - Call { + id: "ticker_index", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 12132, + end: 12367, + }, + test: Compare( + Compare { + node: Node { + start: 12135, + end: 12149, + }, + left: Call( + Call { + node: Node { + start: 12135, + end: 12144, + }, + func: Name( + Name { + node: Node { + start: 12135, + end: 12138, + }, + id: "len", + }, + ), + args: [ + Name( + Name { node: Node { - start: 11639, - end: 11651, + start: 12139, + end: 12143, }, - func: Name( - Name { - node: Node { - start: 11639, - end: 11642, - }, - id: "len", + id: "data", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ops: [ + Eq, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 12148, + end: 12149, + }, + value: Int( + "1", + ), + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 12173, + end: 12342, + }, + func: Attribute( + Attribute { + node: Node { + start: 12159, + end: 12173, + }, + value: Name( + Name { + node: Node { + start: 12159, + end: 12165, }, - ), - args: [ + id: "logger", + }, + ), + attr: "warning", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 12187, + end: 12281, + }, + values: [ + Constant( + Constant { + node: Node { + start: 12233, + end: 0, + }, + value: Str( + "Cannot create client types data for ticker", + ), + }, + ), Name( Name { node: Node { - start: 11643, - end: 11650, + start: 12234, + end: 12246, }, - id: "df_list", + id: "ticker_index", + }, + ), + Constant( + Constant { + node: Node { + start: 12272, + end: 0, + }, + value: Str( + "\n from data: ", + ), + }, + ), + Name( + Name { + node: Node { + start: 12273, + end: 12277, + }, + id: "data", }, ), ], - keywords: [], - starargs: None, - kwargs: None, }, ), - ops: [ - NotEq, - ], - comparators: [ - Call( - Call { + ], + keywords: [ + Keyword { + node: Node { + start: 12295, + end: 12331, + }, + arg: Some( + "extra", + ), + value: Dict( + Dict { node: Node { - start: 11655, - end: 11667, + start: 12301, + end: 12331, }, - func: Name( - Name { - node: Node { - start: 11655, - end: 11658, + keys: [ + Constant( + Constant { + node: Node { + start: 12302, + end: 12316, + }, + value: Str( + "ticker_index", + ), }, - id: "len", - }, - ), - args: [ + ), + ], + values: [ Name( Name { node: Node { - start: 11659, - end: 11666, + start: 12318, + end: 12330, }, - id: "symbols", + id: "ticker_index", }, ), ], - keywords: [], - starargs: None, - kwargs: None, }, ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 11677, - end: 11827, - }, - func: Name( - Name { - node: Node { - start: 11677, - end: 11682, - }, - id: "print", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 11696, - end: 11817, - }, - value: Str( - "could not download client types for all the symbols make\n sure you have what you need or re-run the function", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], - }, + }, + ], + starargs: None, + kwargs: None, + }, + ), ), Return( Return { node: Node { - start: 11832, - end: 11846, + start: 12351, + end: 12362, }, value: Some( - Name( - Name { + Constant( + Constant { node: Node { - start: 11839, - end: 11846, + start: 12358, + end: 12362, }, - id: "df_list", + value: None, }, ), ), }, ), ], + orelse: [], }, ), - FunctionDef( - FunctionDef { + AssignStatement( + Assign { node: Node { - start: 11999, - end: 13481, + start: 12367, + end: 12899, }, - name: "download_ticker_client_types_record", - args: Arguments { - node: Node { - start: 12039, - end: 12066, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 12039, - end: 12066, - }, - arg: "ticker_index", - annotation: Some( - Subscript( - Subscript { - node: Node { - start: 12053, - end: 12066, - }, - value: Name( - Name { - node: Node { - start: 12053, - end: 12061, - }, - id: "Optional", - }, - ), - slice: Name( - Name { - node: Node { - start: 12062, - end: 12065, - }, - id: "str", - }, - ), - }, - ), - ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - AssignStatement( - Assign { + targets: [ + Name( + Name { node: Node { - start: 12073, - end: 12127, + start: 12367, + end: 12390, }, - targets: [ - Name( + id: "client_types_data_frame", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 12405, + end: 12899, + }, + func: Attribute( + Attribute { + node: Node { + start: 12393, + end: 12405, + }, + value: Name( Name { node: Node { - start: 12073, - end: 12077, + start: 12393, + end: 12395, }, - id: "data", + id: "pd", }, ), - ], - value: Call( - Call { + attr: "DataFrame", + }, + ), + args: [ + Name( + Name { node: Node { - start: 12080, - end: 12127, + start: 12415, + end: 12419, }, - func: Name( - Name { - node: Node { - start: 12080, - end: 12113, - }, - id: "_extract_ticker_client_types_data", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 12114, - end: 12126, - }, - id: "ticker_index", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "data", }, ), - }, - ), - IfStatement( - If { - node: Node { - start: 12132, - end: 12367, - }, - test: Compare( - Compare { - node: Node { - start: 12135, - end: 12149, - }, - left: Call( - Call { - node: Node { - start: 12135, - end: 12144, - }, - func: Name( - Name { + ], + keywords: [ + Keyword { + node: Node { + start: 12429, + end: 12892, + }, + arg: Some( + "columns", + ), + value: List( + List { + node: Node { + start: 12437, + end: 12892, + }, + elements: [ + Constant( + Constant { node: Node { - start: 12135, - end: 12138, + start: 12451, + end: 12457, }, - id: "len", + value: Str( + "date", + ), }, ), - args: [ - Name( - Name { - node: Node { - start: 12139, - end: 12143, - }, - id: "data", + Constant( + Constant { + node: Node { + start: 12471, + end: 12493, }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 12148, - end: 12149, + value: Str( + "individual_buy_count", + ), }, - value: Int( - "1", - ), - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 12173, - end: 12342, - }, - func: Attribute( - Attribute { + ), + Constant( + Constant { node: Node { - start: 12159, - end: 12173, + start: 12507, + end: 12528, }, - value: Name( - Name { - node: Node { - start: 12159, - end: 12165, - }, - id: "logger", - }, + value: Str( + "corporate_buy_count", ), - attr: "warning", }, ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 12187, - end: 12281, - }, - values: [ - Constant( - Constant { - node: Node { - start: 12233, - end: 0, - }, - value: Str( - "Cannot create client types data for ticker", - ), - }, - ), - Name( - Name { - node: Node { - start: 12234, - end: 12246, - }, - id: "ticker_index", - }, - ), - Constant( - Constant { - node: Node { - start: 12272, - end: 0, - }, - value: Str( - "\n from data: ", - ), - }, - ), - Name( - Name { - node: Node { - start: 12273, - end: 12277, - }, - id: "data", - }, - ), - ], + Constant( + Constant { + node: Node { + start: 12542, + end: 12565, }, - ), - ], - keywords: [ - Keyword { + value: Str( + "individual_sell_count", + ), + }, + ), + Constant( + Constant { node: Node { - start: 12295, - end: 12331, + start: 12579, + end: 12601, }, - arg: Some( - "extra", + value: Str( + "corporate_sell_count", ), - value: Dict( - Dict { - node: Node { - start: 12301, - end: 12331, - }, - keys: [ - Constant( - Constant { - node: Node { - start: 12302, - end: 12316, - }, - value: Str( - "ticker_index", - ), - }, - ), - ], - values: [ - Name( - Name { - node: Node { - start: 12318, - end: 12330, - }, - id: "ticker_index", - }, - ), - ], - }, + }, + ), + Constant( + Constant { + node: Node { + start: 12615, + end: 12635, + }, + value: Str( + "individual_buy_vol", ), }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - Return( - Return { - node: Node { - start: 12351, - end: 12362, - }, - value: Some( + ), + Constant( + Constant { + node: Node { + start: 12649, + end: 12668, + }, + value: Str( + "corporate_buy_vol", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12682, + end: 12703, + }, + value: Str( + "individual_sell_vol", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12717, + end: 12737, + }, + value: Str( + "corporate_sell_vol", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12751, + end: 12773, + }, + value: Str( + "individual_buy_value", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12787, + end: 12808, + }, + value: Str( + "corporate_buy_value", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12822, + end: 12845, + }, + value: Str( + "individual_sell_value", + ), + }, + ), Constant( Constant { node: Node { - start: 12358, - end: 12362, + start: 12859, + end: 12881, }, - value: None, + value: Str( + "corporate_sell_value", + ), }, ), - ), + ], }, ), - ], - orelse: [], + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ForStatement( + For { + node: Node { + start: 12904, + end: 13210, + }, + target: Name( + Name { + node: Node { + start: 12908, + end: 12909, }, - ), + id: "i", + }, + ), + iter: List( + List { + node: Node { + start: 12913, + end: 13028, + }, + elements: [ + Constant( + Constant { + node: Node { + start: 12923, + end: 12940, + }, + value: Str( + "individual_buy_", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12950, + end: 12968, + }, + value: Str( + "individual_sell_", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12978, + end: 12994, + }, + value: Str( + "corporate_buy_", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 13004, + end: 13021, + }, + value: Str( + "corporate_sell_", + ), + }, + ), + ], + }, + ), + body: [ AssignStatement( Assign { node: Node { - start: 12367, - end: 12899, + start: 13038, + end: 13205, }, targets: [ - Name( - Name { + Subscript( + Subscript { node: Node { - start: 12367, - end: 12390, - }, - id: "client_types_data_frame", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 12405, - end: 12899, - }, - func: Attribute( - Attribute { - node: Node { - start: 12393, - end: 12405, - }, - value: Name( - Name { - node: Node { - start: 12393, - end: 12395, - }, - id: "pd", - }, - ), - attr: "DataFrame", + start: 13038, + end: 13079, }, - ), - args: [ - Name( + value: Name( Name { node: Node { - start: 12415, - end: 12419, + start: 13038, + end: 13061, }, - id: "data", + id: "client_types_data_frame", }, ), - ], - keywords: [ - Keyword { + slice: JoinedStr( + JoinedStr { + node: Node { + start: 13062, + end: 13078, + }, + values: [ + Name( + Name { + node: Node { + start: 13065, + end: 13066, + }, + id: "i", + }, + ), + Constant( + Constant { + node: Node { + start: 13077, + end: 0, + }, + value: Str( + "mean_price", + ), + }, + ), + ], + }, + ), + }, + ), + ], + value: BinOp( + BinOp { + node: Node { + start: 13082, + end: 13205, + }, + op: Div, + left: Call( + Call { node: Node { - start: 12429, - end: 12892, + start: 13147, + end: 13154, }, - arg: Some( - "columns", - ), - value: List( - List { + func: Attribute( + Attribute { node: Node { - start: 12437, - end: 12892, + start: 13140, + end: 13147, }, - elements: [ - Constant( - Constant { - node: Node { - start: 12451, - end: 12457, - }, - value: Str( - "date", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12471, - end: 12493, - }, - value: Str( - "individual_buy_count", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12507, - end: 12528, - }, - value: Str( - "corporate_buy_count", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12542, - end: 12565, - }, - value: Str( - "individual_sell_count", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12579, - end: 12601, - }, - value: Str( - "corporate_sell_count", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12615, - end: 12635, - }, - value: Str( - "individual_buy_vol", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12649, - end: 12668, - }, - value: Str( - "corporate_buy_vol", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12682, - end: 12703, - }, - value: Str( - "individual_sell_vol", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12717, - end: 12737, - }, - value: Str( - "corporate_sell_vol", - ), + value: Subscript( + Subscript { + node: Node { + start: 13082, + end: 13140, }, - ), - Constant( - Constant { - node: Node { - start: 12751, - end: 12773, + value: Name( + Name { + node: Node { + start: 13082, + end: 13105, + }, + id: "client_types_data_frame", }, - value: Str( - "individual_buy_value", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12787, - end: 12808, + ), + slice: JoinedStr( + JoinedStr { + node: Node { + start: 13119, + end: 13130, + }, + values: [ + Name( + Name { + node: Node { + start: 13122, + end: 13123, + }, + id: "i", + }, + ), + Constant( + Constant { + node: Node { + start: 13129, + end: 0, + }, + value: Str( + "value", + ), + }, + ), + ], }, - value: Str( - "corporate_buy_value", - ), + ), + }, + ), + attr: "astype", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 13148, + end: 13153, + }, + id: "float", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + right: Call( + Call { + node: Node { + start: 13198, + end: 13205, + }, + func: Attribute( + Attribute { + node: Node { + start: 13191, + end: 13198, + }, + value: Subscript( + Subscript { + node: Node { + start: 13157, + end: 13191, }, - ), - Constant( - Constant { - node: Node { - start: 12822, - end: 12845, + value: Name( + Name { + node: Node { + start: 13157, + end: 13180, + }, + id: "client_types_data_frame", }, - value: Str( - "individual_sell_value", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12859, - end: 12881, + ), + slice: JoinedStr( + JoinedStr { + node: Node { + start: 13181, + end: 13190, + }, + values: [ + Name( + Name { + node: Node { + start: 13184, + end: 13185, + }, + id: "i", + }, + ), + Constant( + Constant { + node: Node { + start: 13189, + end: 0, + }, + value: Str( + "vol", + ), + }, + ), + ], }, - value: Str( - "corporate_sell_value", - ), - }, - ), - ], + ), + }, + ), + attr: "astype", }, ), + args: [ + Name( + Name { + node: Node { + start: 13199, + end: 13204, + }, + id: "float", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, }, - ], - starargs: None, - kwargs: None, + ), }, ), }, ), - ForStatement( - For { + ], + orelse: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 13210, + end: 13443, + }, + targets: [ + Subscript( + Subscript { node: Node { - start: 12904, - end: 13210, + start: 13210, + end: 13278, }, - target: Name( + value: Name( Name { node: Node { - start: 12908, - end: 12909, + start: 13210, + end: 13233, }, - id: "i", + id: "client_types_data_frame", }, ), - iter: List( - List { + slice: Constant( + Constant { node: Node { - start: 12913, - end: 13028, + start: 13243, + end: 13272, + }, + value: Str( + "individual_ownership_change", + ), + }, + ), + }, + ), + ], + value: BinOp( + BinOp { + node: Node { + start: 13281, + end: 13443, + }, + op: Sub, + left: Call( + Call { + node: Node { + start: 13333, + end: 13354, + }, + func: Attribute( + Attribute { + node: Node { + start: 13326, + end: 13333, + }, + value: Subscript( + Subscript { + node: Node { + start: 13281, + end: 13326, + }, + value: Name( + Name { + node: Node { + start: 13281, + end: 13304, + }, + id: "client_types_data_frame", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 13305, + end: 13325, + }, + value: Str( + "corporate_sell_vol", + ), + }, + ), + }, + ), + attr: "astype", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 13343, + end: 13348, + }, + id: "float", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + right: Call( + Call { + node: Node { + start: 13422, + end: 13443, + }, + func: Attribute( + Attribute { + node: Node { + start: 13415, + end: 13422, + }, + value: Subscript( + Subscript { + node: Node { + start: 13357, + end: 13415, + }, + value: Name( + Name { + node: Node { + start: 13357, + end: 13380, + }, + id: "client_types_data_frame", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 13390, + end: 13409, + }, + value: Str( + "corporate_buy_vol", + ), + }, + ), + }, + ), + attr: "astype", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 13432, + end: 13437, + }, + id: "float", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + }, + ), + Return( + Return { + node: Node { + start: 13448, + end: 13478, + }, + value: Some( + Name( + Name { + node: Node { + start: 13455, + end: 13478, + }, + id: "client_types_data_frame", + }, + ), + ), + }, + ), + ], + decorator_list: [ + Call( + Call { + node: Node { + start: 11850, + end: 11998, + }, + func: Name( + Name { + node: Node { + start: 11850, + end: 11855, + }, + id: "retry", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 11861, + end: 11901, + }, + arg: Some( + "retry", + ), + value: Call( + Call { + node: Node { + start: 11867, + end: 11901, + }, + func: Name( + Name { + node: Node { + start: 11867, + end: 11890, + }, + id: "retry_if_exception_type", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 11891, + end: 11900, + }, + id: "HTTPError", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + Keyword { + node: Node { + start: 11907, + end: 11937, + }, + arg: Some( + "wait", + ), + value: Call( + Call { + node: Node { + start: 11912, + end: 11937, + }, + func: Name( + Name { + node: Node { + start: 11912, + end: 11923, + }, + id: "wait_random", }, - elements: [ - Constant( - Constant { - node: Node { - start: 12923, - end: 12940, - }, - value: Str( - "individual_buy_", - ), - }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 11924, + end: 11929, + }, + arg: Some( + "min", ), - Constant( + value: Constant( Constant { node: Node { - start: 12950, - end: 12968, + start: 11928, + end: 11929, }, - value: Str( - "individual_sell_", + value: Int( + "1", ), }, ), - Constant( - Constant { - node: Node { - start: 12978, - end: 12994, - }, - value: Str( - "corporate_buy_", - ), - }, + }, + Keyword { + node: Node { + start: 11931, + end: 11936, + }, + arg: Some( + "max", ), - Constant( + value: Constant( Constant { node: Node { - start: 13004, - end: 13021, + start: 11935, + end: 11936, }, - value: Str( - "corporate_sell_", + value: Int( + "4", ), }, ), - ], + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + Keyword { + node: Node { + start: 11943, + end: 11995, + }, + arg: Some( + "before_sleep", + ), + value: Call( + Call { + node: Node { + start: 11956, + end: 11995, }, - ), - body: [ - AssignStatement( - Assign { + func: Name( + Name { node: Node { - start: 13038, - end: 13205, + start: 11956, + end: 11972, }, - targets: [ - Subscript( - Subscript { + id: "before_sleep_log", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 11973, + end: 11979, + }, + id: "logger", + }, + ), + Attribute( + Attribute { + node: Node { + start: 11981, + end: 11994, + }, + value: Name( + Name { node: Node { - start: 13038, - end: 13079, + start: 11981, + end: 11988, }, - value: Name( - Name { - node: Node { - start: 13038, - end: 13061, - }, - id: "client_types_data_frame", - }, - ), - slice: JoinedStr( - JoinedStr { - node: Node { - start: 13062, - end: 13078, - }, - values: [ - Name( - Name { - node: Node { - start: 13065, - end: 13066, - }, - id: "i", - }, - ), - Constant( - Constant { - node: Node { - start: 13077, - end: 0, - }, - value: Str( - "mean_price", - ), - }, - ), - ], - }, - ), + id: "logging", }, ), - ], - value: BinOp( - BinOp { - node: Node { - start: 13082, - end: 13205, - }, - op: Div, - left: Call( - Call { - node: Node { - start: 13147, - end: 13154, - }, - func: Attribute( - Attribute { - node: Node { - start: 13140, - end: 13147, - }, - value: Subscript( - Subscript { - node: Node { - start: 13082, - end: 13140, - }, - value: Name( - Name { - node: Node { - start: 13082, - end: 13105, - }, - id: "client_types_data_frame", - }, - ), - slice: JoinedStr( - JoinedStr { - node: Node { - start: 13119, - end: 13130, - }, - values: [ - Name( - Name { - node: Node { - start: 13122, - end: 13123, - }, - id: "i", - }, - ), - Constant( - Constant { - node: Node { - start: 13129, - end: 0, - }, - value: Str( - "value", - ), - }, - ), - ], - }, - ), - }, - ), - attr: "astype", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 13148, - end: 13153, - }, - id: "float", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - right: Call( - Call { - node: Node { - start: 13198, - end: 13205, - }, - func: Attribute( - Attribute { - node: Node { - start: 13191, - end: 13198, - }, - value: Subscript( - Subscript { - node: Node { - start: 13157, - end: 13191, - }, - value: Name( - Name { - node: Node { - start: 13157, - end: 13180, - }, - id: "client_types_data_frame", - }, - ), - slice: JoinedStr( - JoinedStr { - node: Node { - start: 13181, - end: 13190, - }, - values: [ - Name( - Name { - node: Node { - start: 13184, - end: 13185, - }, - id: "i", - }, - ), - Constant( - Constant { - node: Node { - start: 13189, - end: 0, - }, - value: Str( - "vol", - ), - }, - ), - ], - }, - ), - }, - ), - attr: "astype", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 13199, - end: 13204, - }, - id: "float", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - }, - ), - ], - orelse: [], + attr: "DEBUG", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + ], + returns: None, + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 13481, + end: 13980, + }, + name: "get_symbol_id", + args: Arguments { + node: Node { + start: 13499, + end: 13515, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 13499, + end: 13515, + }, + arg: "symbol_name", + annotation: Some( + Name( + Name { + node: Node { + start: 13512, + end: 13515, + }, + id: "str", }, ), - AssignStatement( - Assign { + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 13522, + end: 13586, + }, + targets: [ + Name( + Name { node: Node { - start: 13210, - end: 13443, + start: 13522, + end: 13525, }, - targets: [ - Subscript( - Subscript { + id: "url", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 13565, + end: 13586, + }, + func: Attribute( + Attribute { + node: Node { + start: 13528, + end: 13565, + }, + value: Attribute( + Attribute { node: Node { - start: 13210, - end: 13278, + start: 13528, + end: 13558, }, value: Name( Name { node: Node { - start: 13210, - end: 13233, - }, - id: "client_types_data_frame", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13243, - end: 13272, + start: 13528, + end: 13540, }, - value: Str( - "individual_ownership_change", - ), + id: "tse_settings", }, ), + attr: "TSE_SYMBOL_ID_URL", }, ), - ], - value: BinOp( - BinOp { + attr: "format", + }, + ), + args: [ + Call( + Call { node: Node { - start: 13281, - end: 13443, + start: 13583, + end: 13585, }, - op: Sub, - left: Call( - Call { - node: Node { - start: 13333, - end: 13354, - }, - func: Attribute( - Attribute { - node: Node { - start: 13326, - end: 13333, - }, - value: Subscript( - Subscript { - node: Node { - start: 13281, - end: 13326, - }, - value: Name( - Name { - node: Node { - start: 13281, - end: 13304, - }, - id: "client_types_data_frame", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13305, - end: 13325, - }, - value: Str( - "corporate_sell_vol", - ), - }, - ), - }, - ), - attr: "astype", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 13343, - end: 13348, - }, - id: "float", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - right: Call( - Call { + func: Attribute( + Attribute { node: Node { - start: 13422, - end: 13443, + start: 13566, + end: 13583, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 13415, - end: 13422, + start: 13566, + end: 13577, }, - value: Subscript( - Subscript { - node: Node { - start: 13357, - end: 13415, - }, - value: Name( - Name { - node: Node { - start: 13357, - end: 13380, - }, - id: "client_types_data_frame", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13390, - end: 13409, - }, - value: Str( - "corporate_buy_vol", - ), - }, - ), - }, - ), - attr: "astype", + id: "symbol_name", }, ), - args: [ - Name( - Name { - node: Node { - start: 13432, - end: 13437, - }, - id: "float", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + attr: "strip", }, ), + args: [], + keywords: [], + starargs: None, + kwargs: None, }, ), - }, - ), - Return( - Return { + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 13591, + end: 13647, + }, + targets: [ + Name( + Name { node: Node { - start: 13448, - end: 13478, + start: 13591, + end: 13599, }, - value: Some( - Name( - Name { + id: "response", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 13630, + end: 13647, + }, + func: Attribute( + Attribute { + node: Node { + start: 13626, + end: 13630, + }, + value: Call( + Call { node: Node { - start: 13455, - end: 13478, + start: 13602, + end: 13626, }, - id: "client_types_data_frame", + func: Name( + Name { + node: Node { + start: 13602, + end: 13624, + }, + id: "requests_retry_session", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, }, ), - ), - }, - ), - ], - decorator_list: [ - Call( - Call { - node: Node { - start: 11850, - end: 11998, + attr: "get", }, - func: Name( + ), + args: [ + Name( Name { node: Node { - start: 11850, - end: 11855, + start: 13631, + end: 13634, }, - id: "retry", + id: "url", }, ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 11861, - end: 11901, + ], + keywords: [ + Keyword { + node: Node { + start: 13636, + end: 13646, + }, + arg: Some( + "timeout", + ), + value: Constant( + Constant { + node: Node { + start: 13644, + end: 13646, + }, + value: Int( + "10", + ), }, - arg: Some( - "retry", - ), - value: Call( - Call { - node: Node { - start: 11867, - end: 11901, - }, - func: Name( - Name { - node: Node { - start: 11867, - end: 11890, - }, - id: "retry_if_exception_type", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11891, - end: 11900, - }, - id: "HTTPError", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + TryStatement( + Try { + node: Node { + start: 13652, + end: 13781, + }, + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 13690, + end: 13692, + }, + func: Attribute( + Attribute { + node: Node { + start: 13665, + end: 13690, }, - ), + value: Name( + Name { + node: Node { + start: 13665, + end: 13673, + }, + id: "response", + }, + ), + attr: "raise_for_status", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + handlers: [ + ExceptHandler { + node: Node { + start: 13697, + end: 13781, + }, + typ: Some( + Name( + Name { + node: Node { + start: 13704, + end: 13713, + }, + id: "HTTPError", }, - Keyword { + ), + ), + name: None, + body: [ + Raise( + Raise { node: Node { - start: 11907, - end: 11937, + start: 13723, + end: 13775, }, - arg: Some( - "wait", - ), - value: Call( - Call { - node: Node { - start: 11912, - end: 11937, - }, - func: Name( - Name { - node: Node { - start: 11912, - end: 11923, - }, - id: "wait_random", + exc: Some( + Call( + Call { + node: Node { + start: 13729, + end: 13775, }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 11924, - end: 11929, - }, - arg: Some( - "min", - ), - value: Constant( - Constant { - node: Node { - start: 11928, - end: 11929, - }, - value: Int( - "1", - ), + func: Name( + Name { + node: Node { + start: 13729, + end: 13738, }, - ), - }, - Keyword { - node: Node { - start: 11931, - end: 11936, + id: "Exception", }, - arg: Some( - "max", - ), - value: Constant( + ), + args: [ + Constant( Constant { node: Node { - start: 11935, - end: 11936, + start: 13739, + end: 13774, }, - value: Int( - "4", + value: Str( + "Sorry, tse server did not respond", ), }, ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - Keyword { - node: Node { - start: 11943, - end: 11995, - }, - arg: Some( - "before_sleep", - ), - value: Call( - Call { - node: Node { - start: 11956, - end: 11995, + ], + keywords: [], + starargs: None, + kwargs: None, }, - func: Name( - Name { - node: Node { - start: 11956, - end: 11972, - }, - id: "before_sleep_log", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11973, - end: 11979, - }, - id: "logger", - }, - ), - Attribute( - Attribute { - node: Node { - start: 11981, - end: 11994, - }, - value: Name( - Name { - node: Node { - start: 11981, - end: 11988, - }, - id: "logging", - }, - ), - attr: "DEBUG", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, + ), ), + cause: None, }, - ], - starargs: None, - kwargs: None, - }, - ), + ), + ], + }, ], - returns: None, - type_comment: None, + orelse: [], + finalbody: [], }, ), - FunctionDef( - FunctionDef { + AssignStatement( + Assign { node: Node { - start: 13481, - end: 13980, + start: 13781, + end: 13838, }, - name: "get_symbol_id", - args: Arguments { - node: Node { - start: 13499, - end: 13515, - }, - posonlyargs: [], - args: [ - Arg { + targets: [ + Name( + Name { node: Node { - start: 13499, - end: 13515, + start: 13781, + end: 13797, }, - arg: "symbol_name", - annotation: Some( - Name( - Name { - node: Node { - start: 13512, - end: 13515, - }, - id: "str", - }, - ), - ), + id: "symbol_full_info", }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - AssignStatement( - Assign { - node: Node { - start: 13522, - end: 13586, - }, - targets: [ - Name( - Name { + ), + ], + value: Call( + Call { + node: Node { + start: 13833, + end: 13838, + }, + func: Attribute( + Attribute { + node: Node { + start: 13827, + end: 13833, + }, + value: Subscript( + Subscript { node: Node { - start: 13522, - end: 13525, - }, - id: "url", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 13565, - end: 13586, - }, - func: Attribute( - Attribute { - node: Node { - start: 13528, - end: 13565, - }, - value: Attribute( - Attribute { - node: Node { - start: 13528, - end: 13558, - }, - value: Name( - Name { - node: Node { - start: 13528, - end: 13540, - }, - id: "tse_settings", - }, - ), - attr: "TSE_SYMBOL_ID_URL", - }, - ), - attr: "format", + start: 13824, + end: 13827, }, - ), - args: [ - Call( + value: Call( Call { node: Node { - start: 13583, - end: 13585, + start: 13819, + end: 13824, }, func: Attribute( Attribute { node: Node { - start: 13566, - end: 13583, + start: 13800, + end: 13819, }, - value: Name( - Name { + value: Attribute( + Attribute { node: Node { - start: 13566, - end: 13577, + start: 13800, + end: 13813, }, - id: "symbol_name", + value: Name( + Name { + node: Node { + start: 13800, + end: 13808, + }, + id: "response", + }, + ), + attr: "text", }, ), - attr: "strip", + attr: "split", }, ), - args: [], + args: [ + Constant( + Constant { + node: Node { + start: 13820, + end: 13823, + }, + value: Str( + ";", + ), + }, + ), + ], keywords: [], starargs: None, kwargs: None, }, ), - ], - keywords: [], - starargs: None, - kwargs: None, + slice: Constant( + Constant { + node: Node { + start: 13825, + end: 13826, + }, + value: Int( + "0", + ), + }, + ), + }, + ), + attr: "split", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 13834, + end: 13837, + }, + value: Str( + ",", + ), }, ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 13843, + end: 13966, + }, + test: Compare( + Compare { + node: Node { + start: 13846, + end: 13912, }, - ), - AssignStatement( - Assign { - node: Node { - start: 13591, - end: 13647, - }, - targets: [ - Name( - Name { + left: Call( + Call { + node: Node { + start: 13868, + end: 13881, + }, + func: Attribute( + Attribute { node: Node { - start: 13591, - end: 13599, + start: 13846, + end: 13868, }, - id: "response", + value: Name( + Name { + node: Node { + start: 13846, + end: 13853, + }, + id: "persian", + }, + ), + attr: "replace_arabic", }, ), - ], - value: Call( + args: [ + Name( + Name { + node: Node { + start: 13869, + end: 13880, + }, + id: "symbol_name", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ops: [ + Eq, + ], + comparators: [ + Call( Call { node: Node { - start: 13630, - end: 13647, + start: 13910, + end: 13912, }, func: Attribute( Attribute { node: Node { - start: 13626, - end: 13630, + start: 13904, + end: 13910, }, - value: Call( - Call { + value: Subscript( + Subscript { node: Node { - start: 13602, - end: 13626, + start: 13885, + end: 13904, }, - func: Name( + value: Name( Name { node: Node { - start: 13602, - end: 13624, + start: 13885, + end: 13901, }, - id: "requests_retry_session", + id: "symbol_full_info", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 13902, + end: 13903, + }, + value: Int( + "0", + ), }, ), - args: [], - keywords: [], - starargs: None, - kwargs: None, }, ), - attr: "get", + attr: "strip", }, ), - args: [ - Name( + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ], + }, + ), + body: [ + Return( + Return { + node: Node { + start: 13922, + end: 13961, + }, + value: Some( + Subscript( + Subscript { + node: Node { + start: 13929, + end: 13961, + }, + value: Name( Name { node: Node { - start: 13631, - end: 13634, + start: 13929, + end: 13945, }, - id: "url", + id: "symbol_full_info", }, ), - ], - keywords: [ - Keyword { - node: Node { - start: 13636, - end: 13646, - }, - arg: Some( - "timeout", - ), - value: Constant( - Constant { - node: Node { - start: 13644, - end: 13646, - }, - value: Int( - "10", - ), + slice: Constant( + Constant { + node: Node { + start: 13946, + end: 13947, }, - ), - }, - ], - starargs: None, - kwargs: None, - }, + value: Int( + "2", + ), + }, + ), + }, + ), ), }, ), - TryStatement( - Try { + ], + orelse: [], + }, + ), + Return( + Return { + node: Node { + start: 13966, + end: 13977, + }, + value: Some( + Constant( + Constant { node: Node { - start: 13652, - end: 13781, + start: 13973, + end: 13977, }, - body: [ - ExpressionStatement( - Call( - Call { + value: None, + }, + ), + ), + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 13980, + end: 15273, + }, + name: "get_symbol_info", + args: Arguments { + node: Node { + start: 14000, + end: 14016, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 14000, + end: 14016, + }, + arg: "symbol_name", + annotation: Some( + Name( + Name { + node: Node { + start: 14013, + end: 14016, + }, + id: "str", + }, + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 14023, + end: 14087, + }, + targets: [ + Name( + Name { + node: Node { + start: 14023, + end: 14026, + }, + id: "url", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 14066, + end: 14087, + }, + func: Attribute( + Attribute { + node: Node { + start: 14029, + end: 14066, + }, + value: Attribute( + Attribute { + node: Node { + start: 14029, + end: 14059, + }, + value: Name( + Name { + node: Node { + start: 14029, + end: 14041, + }, + id: "tse_settings", + }, + ), + attr: "TSE_SYMBOL_ID_URL", + }, + ), + attr: "format", + }, + ), + args: [ + Call( + Call { + node: Node { + start: 14084, + end: 14086, + }, + func: Attribute( + Attribute { node: Node { - start: 13690, - end: 13692, + start: 14067, + end: 14084, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 13665, - end: 13690, + start: 14067, + end: 14078, }, - value: Name( - Name { - node: Node { - start: 13665, - end: 13673, - }, - id: "response", - }, - ), - attr: "raise_for_status", + id: "symbol_name", }, ), - args: [], - keywords: [], - starargs: None, - kwargs: None, + attr: "strip", }, ), - ), - ], - handlers: [ - ExceptHandler { - node: Node { - start: 13697, - end: 13781, - }, - typ: Some( - Name( - Name { - node: Node { - start: 13704, - end: 13713, - }, - id: "HTTPError", - }, - ), - ), - name: None, - body: [ - Raise( - Raise { - node: Node { - start: 13723, - end: 13775, - }, - exc: Some( - Call( - Call { - node: Node { - start: 13729, - end: 13775, - }, - func: Name( - Name { - node: Node { - start: 13729, - end: 13738, - }, - id: "Exception", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 13739, - end: 13774, - }, - value: Str( - "Sorry, tse server did not respond", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - cause: None, - }, - ), - ], + args: [], + keywords: [], + starargs: None, + kwargs: None, }, - ], - orelse: [], - finalbody: [], - }, - ), - AssignStatement( - Assign { + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 14092, + end: 14148, + }, + targets: [ + Name( + Name { node: Node { - start: 13781, - end: 13838, + start: 14092, + end: 14100, }, - targets: [ - Name( - Name { + id: "response", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 14131, + end: 14148, + }, + func: Attribute( + Attribute { + node: Node { + start: 14127, + end: 14131, + }, + value: Call( + Call { node: Node { - start: 13781, - end: 13797, + start: 14103, + end: 14127, }, - id: "symbol_full_info", + func: Name( + Name { + node: Node { + start: 14103, + end: 14125, + }, + id: "requests_retry_session", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, }, ), - ], - value: Call( - Call { + attr: "get", + }, + ), + args: [ + Name( + Name { node: Node { - start: 13833, - end: 13838, + start: 14132, + end: 14135, }, - func: Attribute( - Attribute { - node: Node { - start: 13827, - end: 13833, - }, - value: Subscript( - Subscript { - node: Node { - start: 13824, - end: 13827, - }, - value: Call( - Call { - node: Node { - start: 13819, - end: 13824, - }, - func: Attribute( - Attribute { - node: Node { - start: 13800, - end: 13819, - }, - value: Attribute( - Attribute { - node: Node { - start: 13800, - end: 13813, - }, - value: Name( - Name { - node: Node { - start: 13800, - end: 13808, - }, - id: "response", - }, - ), - attr: "text", - }, - ), - attr: "split", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 13820, - end: 13823, - }, - value: Str( - ";", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13825, - end: 13826, - }, - value: Int( - "0", - ), - }, - ), - }, - ), - attr: "split", + id: "url", + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 14137, + end: 14147, + }, + arg: Some( + "timeout", + ), + value: Constant( + Constant { + node: Node { + start: 14145, + end: 14147, }, - ), - args: [ - Constant( - Constant { + value: Int( + "10", + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + TryStatement( + Try { + node: Node { + start: 14153, + end: 14298, + }, + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 14191, + end: 14193, + }, + func: Attribute( + Attribute { + node: Node { + start: 14166, + end: 14191, + }, + value: Name( + Name { node: Node { - start: 13834, - end: 13837, + start: 14166, + end: 14174, }, - value: Str( - ",", - ), + id: "response", }, ), - ], - keywords: [], - starargs: None, - kwargs: None, + attr: "raise_for_status", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + handlers: [ + ExceptHandler { + node: Node { + start: 14198, + end: 14298, + }, + typ: Some( + Name( + Name { + node: Node { + start: 14205, + end: 14214, + }, + id: "HTTPError", }, ), - }, - ), - IfStatement( - If { - node: Node { - start: 13843, - end: 13966, - }, - test: Compare( - Compare { + ), + name: None, + body: [ + Raise( + Raise { node: Node { - start: 13846, - end: 13912, + start: 14224, + end: 14292, }, - left: Call( - Call { - node: Node { - start: 13868, - end: 13881, - }, - func: Attribute( - Attribute { - node: Node { - start: 13846, - end: 13868, - }, - value: Name( - Name { - node: Node { - start: 13846, - end: 13853, - }, - id: "persian", - }, - ), - attr: "replace_arabic", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 13869, - end: 13880, - }, - id: "symbol_name", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - Eq, - ], - comparators: [ + exc: Some( Call( Call { node: Node { - start: 13910, - end: 13912, + start: 14230, + end: 14292, }, - func: Attribute( - Attribute { + func: Name( + Name { node: Node { - start: 13904, - end: 13910, + start: 14230, + end: 14239, }, - value: Subscript( - Subscript { - node: Node { - start: 13885, - end: 13904, - }, - value: Name( + id: "Exception", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 14240, + end: 14291, + }, + values: [ + Name( Name { node: Node { - start: 13885, - end: 13901, + start: 14243, + end: 14254, }, - id: "symbol_full_info", + id: "symbol_name", }, ), - slice: Constant( + Constant( Constant { node: Node { - start: 13902, - end: 13903, + start: 14290, + end: 0, }, - value: Int( - "0", + value: Str( + ": Sorry, tse server did not respond", ), }, ), - }, - ), - attr: "strip", - }, - ), - args: [], + ], + }, + ), + ], keywords: [], starargs: None, kwargs: None, }, ), - ], + ), + cause: None, + }, + ), + ], + }, + ], + orelse: [], + finalbody: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 14298, + end: 14332, + }, + targets: [ + Name( + Name { + node: Node { + start: 14298, + end: 14305, + }, + id: "symbols", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 14327, + end: 14332, + }, + func: Attribute( + Attribute { + node: Node { + start: 14308, + end: 14327, }, - ), - body: [ - Return( - Return { + value: Attribute( + Attribute { node: Node { - start: 13922, - end: 13961, + start: 14308, + end: 14321, }, - value: Some( - Subscript( - Subscript { - node: Node { - start: 13929, - end: 13961, - }, - value: Name( - Name { - node: Node { - start: 13929, - end: 13945, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13946, - end: 13947, - }, - value: Int( - "2", - ), - }, - ), + value: Name( + Name { + node: Node { + start: 14308, + end: 14316, }, - ), + id: "response", + }, ), + attr: "text", }, ), - ], - orelse: [], - }, - ), - Return( - Return { - node: Node { - start: 13966, - end: 13977, + attr: "split", }, - value: Some( - Constant( - Constant { - node: Node { - start: 13973, - end: 13977, - }, - value: None, + ), + args: [ + Constant( + Constant { + node: Node { + start: 14328, + end: 14331, }, - ), + value: Str( + ";", + ), + }, ), - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), }, ), - FunctionDef( - FunctionDef { + AssignStatement( + Assign { node: Node { - start: 13980, - end: 15273, + start: 14337, + end: 14467, }, - name: "get_symbol_info", - args: Arguments { - node: Node { - start: 14000, - end: 14016, - }, - posonlyargs: [], - args: [ - Arg { + targets: [ + Name( + Name { node: Node { - start: 14000, - end: 14016, + start: 14337, + end: 14350, }, - arg: "symbol_name", - annotation: Some( - Name( - Name { + id: "market_symbol", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 14353, + end: 14467, + }, + func: Name( + Name { + node: Node { + start: 14353, + end: 14365, + }, + id: "MarketSymbol", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 14375, + end: 14384, + }, + arg: Some( + "code", + ), + value: Constant( + Constant { node: Node { - start: 14013, - end: 14016, + start: 14380, + end: 14384, }, - id: "str", + value: None, }, ), - ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - AssignStatement( - Assign { - node: Node { - start: 14023, - end: 14087, }, - targets: [ - Name( - Name { + Keyword { + node: Node { + start: 14394, + end: 14405, + }, + arg: Some( + "symbol", + ), + value: Constant( + Constant { node: Node { - start: 14023, - end: 14026, + start: 14401, + end: 14405, }, - id: "url", + value: None, }, ), - ], - value: Call( - Call { - node: Node { - start: 14066, - end: 14087, - }, - func: Attribute( - Attribute { - node: Node { - start: 14029, - end: 14066, - }, - value: Attribute( - Attribute { - node: Node { - start: 14029, - end: 14059, - }, - value: Name( - Name { - node: Node { - start: 14029, - end: 14041, - }, - id: "tse_settings", - }, - ), - attr: "TSE_SYMBOL_ID_URL", - }, - ), - attr: "format", - }, - ), - args: [ - Call( - Call { - node: Node { - start: 14084, - end: 14086, - }, - func: Attribute( - Attribute { - node: Node { - start: 14067, - end: 14084, - }, - value: Name( - Name { - node: Node { - start: 14067, - end: 14078, - }, - id: "symbol_name", - }, - ), - attr: "strip", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 14092, - end: 14148, }, - targets: [ - Name( - Name { + Keyword { + node: Node { + start: 14415, + end: 14425, + }, + arg: Some( + "index", + ), + value: Constant( + Constant { node: Node { - start: 14092, - end: 14100, + start: 14421, + end: 14425, }, - id: "response", + value: None, }, ), - ], - value: Call( - Call { - node: Node { - start: 14131, - end: 14148, - }, - func: Attribute( - Attribute { - node: Node { - start: 14127, - end: 14131, - }, - value: Call( - Call { - node: Node { - start: 14103, - end: 14127, - }, - func: Name( - Name { - node: Node { - start: 14103, - end: 14125, - }, - id: "requests_retry_session", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "get", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 14132, - end: 14135, - }, - id: "url", - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 14137, - end: 14147, - }, - arg: Some( - "timeout", - ), - value: Constant( - Constant { - node: Node { - start: 14145, - end: 14147, - }, - value: Int( - "10", - ), - }, - ), + }, + Keyword { + node: Node { + start: 14435, + end: 14444, + }, + arg: Some( + "name", + ), + value: Constant( + Constant { + node: Node { + start: 14440, + end: 14444, }, - ], - starargs: None, - kwargs: None, + value: None, + }, + ), + }, + Keyword { + node: Node { + start: 14454, + end: 14460, }, - ), + arg: Some( + "old", + ), + value: List( + List { + node: Node { + start: 14458, + end: 14460, + }, + elements: [], + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ForStatement( + For { + node: Node { + start: 14472, + end: 15195, + }, + target: Name( + Name { + node: Node { + start: 14476, + end: 14492, }, - ), - TryStatement( - Try { + id: "symbol_full_info", + }, + ), + iter: Name( + Name { + node: Node { + start: 14496, + end: 14503, + }, + id: "symbols", + }, + ), + body: [ + IfStatement( + If { node: Node { - start: 14153, - end: 14298, + start: 14513, + end: 14577, }, - body: [ - ExpressionStatement( - Call( + test: Compare( + Compare { + node: Node { + start: 14516, + end: 14546, + }, + left: Call( Call { node: Node { - start: 14191, - end: 14193, + start: 14538, + end: 14540, }, func: Attribute( Attribute { node: Node { - start: 14166, - end: 14191, + start: 14516, + end: 14538, }, value: Name( Name { node: Node { - start: 14166, - end: 14174, + start: 14516, + end: 14532, }, - id: "response", + id: "symbol_full_info", }, ), - attr: "raise_for_status", + attr: "strip", }, ), args: [], @@ -13454,142 +13817,73 @@ Module { kwargs: None, }, ), - ), - ], - handlers: [ - ExceptHandler { - node: Node { - start: 14198, - end: 14298, - }, - typ: Some( - Name( - Name { - node: Node { - start: 14205, - end: 14214, - }, - id: "HTTPError", - }, - ), - ), - name: None, - body: [ - Raise( - Raise { + ops: [ + Eq, + ], + comparators: [ + Constant( + Constant { node: Node { - start: 14224, - end: 14292, + start: 14544, + end: 14546, }, - exc: Some( - Call( - Call { - node: Node { - start: 14230, - end: 14292, - }, - func: Name( - Name { - node: Node { - start: 14230, - end: 14239, - }, - id: "Exception", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 14240, - end: 14291, - }, - values: [ - Name( - Name { - node: Node { - start: 14243, - end: 14254, - }, - id: "symbol_name", - }, - ), - Constant( - Constant { - node: Node { - start: 14290, - end: 0, - }, - value: Str( - ": Sorry, tse server did not respond", - ), - }, - ), - ], - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), + value: Str( + "", ), - cause: None, }, ), ], }, + ), + body: [ + Continue( + Continue { + node: Node { + start: 14560, + end: 14568, + }, + }, + ), ], orelse: [], - finalbody: [], }, ), AssignStatement( Assign { node: Node { - start: 14298, - end: 14332, + start: 14577, + end: 14623, }, targets: [ Name( Name { node: Node { - start: 14298, - end: 14305, + start: 14577, + end: 14593, }, - id: "symbols", + id: "symbol_full_info", }, ), ], value: Call( Call { node: Node { - start: 14327, - end: 14332, + start: 14618, + end: 14623, }, func: Attribute( Attribute { node: Node { - start: 14308, - end: 14327, + start: 14596, + end: 14618, }, - value: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 14308, - end: 14321, + start: 14596, + end: 14612, }, - value: Name( - Name { - node: Node { - start: 14308, - end: 14316, - }, - id: "response", - }, - ), - attr: "text", + id: "symbol_full_info", }, ), attr: "split", @@ -13599,11 +13893,11 @@ Module { Constant( Constant { node: Node { - start: 14328, - end: 14331, + start: 14619, + end: 14622, }, value: Str( - ";", + ",", ), }, ), @@ -13615,849 +13909,553 @@ Module { ), }, ), - AssignStatement( - Assign { + IfStatement( + If { node: Node { - start: 14337, - end: 14467, + start: 14632, + end: 15195, }, - targets: [ - Name( - Name { - node: Node { - start: 14337, - end: 14350, - }, - id: "market_symbol", - }, - ), - ], - value: Call( - Call { + test: Compare( + Compare { node: Node { - start: 14353, - end: 14467, + start: 14635, + end: 14693, }, - func: Name( - Name { - node: Node { - start: 14353, - end: 14365, - }, - id: "MarketSymbol", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 14375, - end: 14384, - }, - arg: Some( - "code", - ), - value: Constant( - Constant { - node: Node { - start: 14380, - end: 14384, - }, - value: None, - }, - ), - }, - Keyword { - node: Node { - start: 14394, - end: 14405, - }, - arg: Some( - "symbol", - ), - value: Constant( - Constant { - node: Node { - start: 14401, - end: 14405, - }, - value: None, - }, - ), - }, - Keyword { - node: Node { - start: 14415, - end: 14425, - }, - arg: Some( - "index", - ), - value: Constant( - Constant { - node: Node { - start: 14421, - end: 14425, - }, - value: None, - }, - ), - }, - Keyword { - node: Node { - start: 14435, - end: 14444, - }, - arg: Some( - "name", - ), - value: Constant( - Constant { - node: Node { - start: 14440, - end: 14444, - }, - value: None, - }, - ), - }, - Keyword { + left: Call( + Call { node: Node { - start: 14454, - end: 14460, + start: 14657, + end: 14678, }, - arg: Some( - "old", - ), - value: List( - List { + func: Attribute( + Attribute { node: Node { - start: 14458, - end: 14460, - }, - elements: [], - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ForStatement( - For { - node: Node { - start: 14472, - end: 15273, - }, - target: Name( - Name { - node: Node { - start: 14476, - end: 14492, - }, - id: "symbol_full_info", - }, - ), - iter: Name( - Name { - node: Node { - start: 14496, - end: 14503, - }, - id: "symbols", - }, - ), - body: [ - IfStatement( - If { - node: Node { - start: 14513, - end: 14577, - }, - test: Compare( - Compare { - node: Node { - start: 14516, - end: 14546, - }, - left: Call( - Call { - node: Node { - start: 14538, - end: 14540, - }, - func: Attribute( - Attribute { - node: Node { - start: 14516, - end: 14538, - }, - value: Name( - Name { - node: Node { - start: 14516, - end: 14532, - }, - id: "symbol_full_info", - }, - ), - attr: "strip", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, + start: 14635, + end: 14657, }, - ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { + value: Name( + Name { node: Node { - start: 14544, - end: 14546, + start: 14635, + end: 14642, }, - value: Str( - "", - ), + id: "persian", }, - ), - ], - }, - ), - body: [ - Continue( - Continue { - node: Node { - start: 14560, - end: 14568, - }, - }, - ), - ], - orelse: [], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 14577, - end: 14623, - }, - targets: [ - Name( - Name { - node: Node { - start: 14577, - end: 14593, - }, - id: "symbol_full_info", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 14618, - end: 14623, + ), + attr: "replace_arabic", }, - func: Attribute( - Attribute { + ), + args: [ + Subscript( + Subscript { node: Node { - start: 14596, - end: 14618, + start: 14658, + end: 14677, }, value: Name( Name { node: Node { - start: 14596, - end: 14612, + start: 14658, + end: 14674, }, id: "symbol_full_info", }, ), - attr: "split", + slice: Constant( + Constant { + node: Node { + start: 14675, + end: 14676, + }, + value: Int( + "0", + ), + }, + ), }, ), - args: [ - Constant( - Constant { - node: Node { - start: 14619, - end: 14622, - }, - value: Str( - ",", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ops: [ + Eq, + ], + comparators: [ + Name( + Name { + node: Node { + start: 14682, + end: 14693, + }, + id: "symbol_name", }, ), - }, - ), + ], + }, + ), + body: [ IfStatement( If { node: Node { - start: 14632, + start: 14744, end: 15195, }, test: Compare( Compare { node: Node { - start: 14635, - end: 14693, + start: 14747, + end: 14773, }, - left: Call( - Call { + left: Subscript( + Subscript { node: Node { - start: 14657, - end: 14678, + start: 14747, + end: 14766, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 14635, - end: 14657, + start: 14747, + end: 14763, }, - value: Name( - Name { - node: Node { - start: 14635, - end: 14642, - }, - id: "persian", - }, - ), - attr: "replace_arabic", + id: "symbol_full_info", }, ), - args: [ - Subscript( - Subscript { - node: Node { - start: 14658, - end: 14677, - }, - value: Name( - Name { - node: Node { - start: 14658, - end: 14674, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 14675, - end: 14676, - }, - value: Int( - "0", - ), - }, - ), + slice: Constant( + Constant { + node: Node { + start: 14764, + end: 14765, }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + value: Int( + "7", + ), + }, + ), }, ), ops: [ Eq, ], comparators: [ - Name( - Name { + Constant( + Constant { node: Node { - start: 14682, - end: 14693, + start: 14770, + end: 14773, }, - id: "symbol_name", + value: Str( + "1", + ), }, ), ], }, ), body: [ - IfStatement( - If { + AssignStatement( + Assign { node: Node { - start: 14744, - end: 15195, + start: 14791, + end: 14895, }, - test: Compare( - Compare { + targets: [ + Attribute( + Attribute { + node: Node { + start: 14791, + end: 14811, + }, + value: Name( + Name { + node: Node { + start: 14791, + end: 14804, + }, + id: "market_symbol", + }, + ), + attr: "symbol", + }, + ), + ], + value: Call( + Call { node: Node { - start: 14747, - end: 14773, + start: 14836, + end: 14895, }, - left: Subscript( - Subscript { + func: Attribute( + Attribute { node: Node { - start: 14747, - end: 14766, + start: 14814, + end: 14836, }, value: Name( Name { node: Node { - start: 14747, - end: 14763, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 14764, - end: 14765, + start: 14814, + end: 14821, }, - value: Int( - "7", - ), + id: "persian", }, ), + attr: "replace_arabic", }, ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { + args: [ + Subscript( + Subscript { node: Node { - start: 14770, - end: 14773, + start: 14858, + end: 14877, }, - value: Str( - "1", + value: Name( + Name { + node: Node { + start: 14858, + end: 14874, + }, + id: "symbol_full_info", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 14875, + end: 14876, + }, + value: Int( + "0", + ), + }, ), }, ), ], + keywords: [], + starargs: None, + kwargs: None, }, ), - body: [ - AssignStatement( - Assign { + }, + ), + AssignStatement( + Assign { + node: Node { + start: 14912, + end: 15014, + }, + targets: [ + Attribute( + Attribute { node: Node { - start: 14791, - end: 14895, + start: 14912, + end: 14930, }, - targets: [ - Attribute( - Attribute { - node: Node { - start: 14791, - end: 14811, - }, - value: Name( - Name { - node: Node { - start: 14791, - end: 14804, - }, - id: "market_symbol", - }, - ), - attr: "symbol", - }, - ), - ], - value: Call( - Call { + value: Name( + Name { node: Node { - start: 14836, - end: 14895, + start: 14912, + end: 14925, }, - func: Attribute( - Attribute { - node: Node { - start: 14814, - end: 14836, - }, - value: Name( - Name { - node: Node { - start: 14814, - end: 14821, - }, - id: "persian", - }, - ), - attr: "replace_arabic", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 14858, - end: 14877, - }, - value: Name( - Name { - node: Node { - start: 14858, - end: 14874, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 14875, - end: 14876, - }, - value: Int( - "0", - ), - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "market_symbol", }, ), + attr: "name", }, ), - AssignStatement( - Assign { - node: Node { - start: 14912, - end: 15014, - }, - targets: [ - Attribute( - Attribute { + ], + value: Call( + Call { + node: Node { + start: 14955, + end: 15014, + }, + func: Attribute( + Attribute { + node: Node { + start: 14933, + end: 14955, + }, + value: Name( + Name { node: Node { - start: 14912, - end: 14930, + start: 14933, + end: 14940, }, - value: Name( - Name { - node: Node { - start: 14912, - end: 14925, - }, - id: "market_symbol", - }, - ), - attr: "name", + id: "persian", }, ), - ], - value: Call( - Call { + attr: "replace_arabic", + }, + ), + args: [ + Subscript( + Subscript { node: Node { - start: 14955, - end: 15014, + start: 14977, + end: 14996, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 14933, - end: 14955, + start: 14977, + end: 14993, }, - value: Name( - Name { - node: Node { - start: 14933, - end: 14940, - }, - id: "persian", - }, - ), - attr: "replace_arabic", + id: "symbol_full_info", }, ), - args: [ - Subscript( - Subscript { - node: Node { - start: 14977, - end: 14996, - }, - value: Name( - Name { - node: Node { - start: 14977, - end: 14993, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 14994, - end: 14995, - }, - value: Int( - "1", - ), - }, - ), + slice: Constant( + Constant { + node: Node { + start: 14994, + end: 14995, }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + value: Int( + "1", + ), + }, + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 15031, + end: 15092, + }, + targets: [ + Attribute( + Attribute { + node: Node { + start: 15031, + end: 15050, + }, + value: Name( + Name { + node: Node { + start: 15031, + end: 15044, + }, + id: "market_symbol", }, ), + attr: "index", }, ), - AssignStatement( - Assign { + ], + value: Subscript( + Subscript { + node: Node { + start: 15053, + end: 15092, + }, + value: Name( + Name { + node: Node { + start: 15053, + end: 15069, + }, + id: "symbol_full_info", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 15070, + end: 15071, + }, + value: Int( + "2", + ), + }, + ), + }, + ), + }, + ), + ], + orelse: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 15151, + end: 15189, + }, + func: Attribute( + Attribute { node: Node { - start: 15031, - end: 15092, + start: 15127, + end: 15151, }, - targets: [ - Attribute( - Attribute { - node: Node { - start: 15031, - end: 15050, - }, - value: Name( - Name { - node: Node { - start: 15031, - end: 15044, - }, - id: "market_symbol", - }, - ), - attr: "index", - }, - ), - ], - value: Subscript( - Subscript { + value: Attribute( + Attribute { node: Node { - start: 15053, - end: 15092, + start: 15127, + end: 15144, }, value: Name( Name { node: Node { - start: 15053, - end: 15069, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 15070, - end: 15071, + start: 15127, + end: 15140, }, - value: Int( - "2", - ), + id: "market_symbol", }, ), + attr: "old", }, ), + attr: "append", }, ), - ], - orelse: [ - ExpressionStatement( - Call( - Call { + args: [ + Subscript( + Subscript { node: Node { - start: 15151, - end: 15189, + start: 15152, + end: 15171, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 15127, - end: 15151, + start: 15152, + end: 15168, }, - value: Attribute( - Attribute { - node: Node { - start: 15127, - end: 15144, - }, - value: Name( - Name { - node: Node { - start: 15127, - end: 15140, - }, - id: "market_symbol", - }, - ), - attr: "old", - }, - ), - attr: "append", + id: "symbol_full_info", }, ), - args: [ - Subscript( - Subscript { - node: Node { - start: 15152, - end: 15171, - }, - value: Name( - Name { - node: Node { - start: 15152, - end: 15168, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 15169, - end: 15170, - }, - value: Int( - "2", - ), - }, - ), + slice: Constant( + Constant { + node: Node { + start: 15169, + end: 15170, }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + value: Int( + "2", + ), + }, + ), }, ), - ), - ], - }, + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), ), ], - orelse: [], }, ), - IfStatement( - If { + ], + orelse: [], + }, + ), + ], + orelse: [], + }, + ), + IfStatement( + If { + node: Node { + start: 15195, + end: 15251, + }, + test: Compare( + Compare { + node: Node { + start: 15198, + end: 15225, + }, + left: Attribute( + Attribute { + node: Node { + start: 15198, + end: 15217, + }, + value: Name( + Name { node: Node { - start: 15195, - end: 15251, + start: 15198, + end: 15211, }, - test: Compare( - Compare { - node: Node { - start: 15198, - end: 15225, - }, - left: Attribute( - Attribute { - node: Node { - start: 15198, - end: 15217, - }, - value: Name( - Name { - node: Node { - start: 15198, - end: 15211, - }, - id: "market_symbol", - }, - ), - attr: "index", - }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 15221, - end: 15225, - }, - value: None, - }, - ), - ], - }, - ), - body: [ - Return( - Return { - node: Node { - start: 15235, - end: 15246, - }, - value: Some( - Constant( - Constant { - node: Node { - start: 15242, - end: 15246, - }, - value: None, - }, - ), - ), - }, - ), - ], - orelse: [], + id: "market_symbol", }, ), - Return( - Return { + attr: "index", + }, + ), + ops: [ + Is, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 15221, + end: 15225, + }, + value: None, + }, + ), + ], + }, + ), + body: [ + Return( + Return { + node: Node { + start: 15235, + end: 15246, + }, + value: Some( + Constant( + Constant { node: Node { - start: 15251, - end: 15271, + start: 15242, + end: 15246, }, - value: Some( - Name( - Name { - node: Node { - start: 15258, - end: 15271, - }, - id: "market_symbol", - }, - ), - ), + value: None, }, ), - ], - orelse: [], + ), }, ), ], - decorator_list: [], - returns: None, - type_comment: None, + orelse: [], + }, + ), + Return( + Return { + node: Node { + start: 15251, + end: 15271, + }, + value: Some( + Name( + Name { + node: Node { + start: 15258, + end: 15271, + }, + id: "market_symbol", + }, + ), + ), }, ), ], @@ -14468,67 +14466,69 @@ Module { ), ], decorator_list: [], - returns: Some( - Subscript( - Subscript { - node: Node { - start: 8546, - end: 8569, - }, - value: Name( + returns: None, + type_comment: None, + }, + ), + ], + decorator_list: [], + returns: Some( + Subscript( + Subscript { + node: Node { + start: 8546, + end: 8569, + }, + value: Name( + Name { + node: Node { + start: 8546, + end: 8550, + }, + id: "Dict", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 8551, + end: 8569, + }, + elements: [ + Name( Name { node: Node { - start: 8546, - end: 8550, + start: 8551, + end: 8554, }, - id: "Dict", + id: "str", }, ), - slice: Tuple( - Tuple { + Attribute( + Attribute { node: Node { - start: 8551, - end: 8569, + start: 8556, + end: 8568, }, - elements: [ - Name( - Name { - node: Node { - start: 8551, - end: 8554, - }, - id: "str", - }, - ), - Attribute( - Attribute { - node: Node { - start: 8556, - end: 8568, - }, - value: Name( - Name { - node: Node { - start: 8556, - end: 8558, - }, - id: "pd", - }, - ), - attr: "DataFrame", + value: Name( + Name { + node: Node { + start: 8556, + end: 8558, }, - ), - ], + id: "pd", + }, + ), + attr: "DataFrame", }, ), - }, - ), + ], + }, ), - type_comment: None, }, ), - ], - orelse: [], + ), + type_comment: None, }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@try.py.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@try.py.snap index 43369a02..9e4c39db 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@try.py.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@try.py.snap @@ -1,12 +1,12 @@ --- source: parser/src/parser/parser.rs -description: "# in some cases last price or adj price is undefined\ntry:\n last_price = int(price_section[2])\n# when instead of number value is `F`\nexcept (ValueError, IndexError):\n last_price = None\ntry:\n adj_close = int(price_section[3])\nexcept (ValueError, IndexError):\n adj_close = None\ntry:\n market_cap = adj_close * self.total_shares\nexcept ValueError:\n market_cap = None\n\n" +description: "# in some cases last price or adj price is undefined\ntry:\n last_price = int(price_section[2])\n# when instead of number value is `F`\nexcept (ValueError, IndexError):\n last_price = None\ntry:\n adj_close = int(price_section[3])\nexcept (ValueError, IndexError):\n adj_close = None\ntry:\n market_cap = adj_close * self.total_shares\nexcept ValueError:\n market_cap = None\n\n\ntry:\n async with session.get(\n url, headers=TRADE_DETAILS_HEADER, timeout=100\n ) as response:\n if response.status == 503:\n logger.info(\n f\"Received 503 Service Unavailable on {date_obj}. Retrying...\"\n )\n retry_count += 1\n await asyncio.sleep(1)\n else:\n response.raise_for_status()\n data = await response.json()\n logger.info(\n f\"Successfully fetched trade details on {date_obj} from tse\"\n )\n return [date_obj, pd.json_normalize(data[\"tradeHistory\"])]\nexcept (aiohttp.ClientError, asyncio.TimeoutError):\n logger.error(f\"Request failed for {date_obj}. Retrying...\")\n retry_count += 1\n await asyncio.sleep(1)\n" input_file: parser/test_data/inputs/try.py --- Module { node: Node { start: 0, - end: 381, + end: 1152, }, body: [ TryStatement( @@ -313,7 +313,7 @@ Module { Try { node: Node { start: 287, - end: 381, + end: 382, }, body: [ AssignStatement( @@ -376,7 +376,7 @@ Module { ExceptHandler { node: Node { start: 339, - end: 381, + end: 382, }, typ: Some( Name( @@ -426,5 +426,799 @@ Module { finalbody: [], }, ), + TryStatement( + Try { + node: Node { + start: 382, + end: 1152, + }, + body: [ + AsyncWithStatement( + AsyncWith { + node: Node { + start: 391, + end: 988, + }, + items: [ + WithItem { + node: Node { + start: 402, + end: 487, + }, + context_expr: Call( + Call { + node: Node { + start: 413, + end: 475, + }, + func: Attribute( + Attribute { + node: Node { + start: 402, + end: 413, + }, + value: Name( + Name { + node: Node { + start: 402, + end: 409, + }, + id: "session", + }, + ), + attr: "get", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 423, + end: 426, + }, + id: "url", + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 428, + end: 456, + }, + arg: Some( + "headers", + ), + value: Name( + Name { + node: Node { + start: 436, + end: 456, + }, + id: "TRADE_DETAILS_HEADER", + }, + ), + }, + Keyword { + node: Node { + start: 458, + end: 469, + }, + arg: Some( + "timeout", + ), + value: Constant( + Constant { + node: Node { + start: 466, + end: 469, + }, + value: Int( + "100", + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + optional_vars: Some( + Name( + Name { + node: Node { + start: 479, + end: 487, + }, + id: "response", + }, + ), + ), + }, + ], + body: [ + IfStatement( + If { + node: Node { + start: 497, + end: 988, + }, + test: Compare( + Compare { + node: Node { + start: 500, + end: 522, + }, + left: Attribute( + Attribute { + node: Node { + start: 500, + end: 515, + }, + value: Name( + Name { + node: Node { + start: 500, + end: 508, + }, + id: "response", + }, + ), + attr: "status", + }, + ), + ops: [ + Eq, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 519, + end: 522, + }, + value: Int( + "503", + ), + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 547, + end: 641, + }, + func: Attribute( + Attribute { + node: Node { + start: 536, + end: 547, + }, + value: Name( + Name { + node: Node { + start: 536, + end: 542, + }, + id: "logger", + }, + ), + attr: "info", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 565, + end: 627, + }, + values: [ + Constant( + Constant { + node: Node { + start: 603, + end: 0, + }, + value: Str( + "Received 503 Service Unavailable on ", + ), + }, + ), + Name( + Name { + node: Node { + start: 604, + end: 612, + }, + id: "date_obj", + }, + ), + Constant( + Constant { + node: Node { + start: 626, + end: 0, + }, + value: Str( + ". Retrying...", + ), + }, + ), + ], + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + AugAssignStatement( + AugAssign { + node: Node { + start: 654, + end: 670, + }, + target: Name( + Name { + node: Node { + start: 654, + end: 665, + }, + id: "retry_count", + }, + ), + op: Add, + value: Constant( + Constant { + node: Node { + start: 669, + end: 670, + }, + value: Int( + "1", + ), + }, + ), + }, + ), + ExpressionStatement( + Await( + Await { + node: Node { + start: 683, + end: 705, + }, + value: Call( + Call { + node: Node { + start: 702, + end: 705, + }, + func: Attribute( + Attribute { + node: Node { + start: 689, + end: 702, + }, + value: Name( + Name { + node: Node { + start: 689, + end: 696, + }, + id: "asyncio", + }, + ), + attr: "sleep", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 703, + end: 704, + }, + value: Int( + "1", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ), + ], + orelse: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 757, + end: 759, + }, + func: Attribute( + Attribute { + node: Node { + start: 732, + end: 757, + }, + value: Name( + Name { + node: Node { + start: 732, + end: 740, + }, + id: "response", + }, + ), + attr: "raise_for_status", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + AssignStatement( + Assign { + node: Node { + start: 772, + end: 800, + }, + targets: [ + Name( + Name { + node: Node { + start: 772, + end: 776, + }, + id: "data", + }, + ), + ], + value: Await( + Await { + node: Node { + start: 779, + end: 800, + }, + value: Call( + Call { + node: Node { + start: 798, + end: 800, + }, + func: Attribute( + Attribute { + node: Node { + start: 785, + end: 798, + }, + value: Name( + Name { + node: Node { + start: 785, + end: 793, + }, + id: "response", + }, + ), + attr: "json", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 824, + end: 916, + }, + func: Attribute( + Attribute { + node: Node { + start: 813, + end: 824, + }, + value: Name( + Name { + node: Node { + start: 813, + end: 819, + }, + id: "logger", + }, + ), + attr: "info", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 842, + end: 902, + }, + values: [ + Constant( + Constant { + node: Node { + start: 882, + end: 0, + }, + value: Str( + "Successfully fetched trade details on ", + ), + }, + ), + Name( + Name { + node: Node { + start: 883, + end: 891, + }, + id: "date_obj", + }, + ), + Constant( + Constant { + node: Node { + start: 901, + end: 0, + }, + value: Str( + " from tse", + ), + }, + ), + ], + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + Return( + Return { + node: Node { + start: 929, + end: 987, + }, + value: Some( + List( + List { + node: Node { + start: 936, + end: 987, + }, + elements: [ + Name( + Name { + node: Node { + start: 937, + end: 945, + }, + id: "date_obj", + }, + ), + Call( + Call { + node: Node { + start: 964, + end: 986, + }, + func: Attribute( + Attribute { + node: Node { + start: 947, + end: 964, + }, + value: Name( + Name { + node: Node { + start: 947, + end: 949, + }, + id: "pd", + }, + ), + attr: "json_normalize", + }, + ), + args: [ + Subscript( + Subscript { + node: Node { + start: 965, + end: 985, + }, + value: Name( + Name { + node: Node { + start: 965, + end: 969, + }, + id: "data", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 970, + end: 984, + }, + value: Str( + "tradeHistory", + ), + }, + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ], + }, + ), + ), + }, + ), + ], + }, + ), + ], + }, + ), + ], + handlers: [ + ExceptHandler { + node: Node { + start: 988, + end: 1152, + }, + typ: Some( + Tuple( + Tuple { + node: Node { + start: 995, + end: 1037, + }, + elements: [ + Attribute( + Attribute { + node: Node { + start: 996, + end: 1015, + }, + value: Name( + Name { + node: Node { + start: 996, + end: 1003, + }, + id: "aiohttp", + }, + ), + attr: "ClientError", + }, + ), + Attribute( + Attribute { + node: Node { + start: 1017, + end: 1037, + }, + value: Name( + Name { + node: Node { + start: 1017, + end: 1024, + }, + id: "asyncio", + }, + ), + attr: "TimeoutError", + }, + ), + ], + }, + ), + ), + name: None, + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 1056, + end: 1103, + }, + func: Attribute( + Attribute { + node: Node { + start: 1044, + end: 1056, + }, + value: Name( + Name { + node: Node { + start: 1044, + end: 1050, + }, + id: "logger", + }, + ), + attr: "error", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 1057, + end: 1102, + }, + values: [ + Constant( + Constant { + node: Node { + start: 1078, + end: 0, + }, + value: Str( + "Request failed for ", + ), + }, + ), + Name( + Name { + node: Node { + start: 1079, + end: 1087, + }, + id: "date_obj", + }, + ), + Constant( + Constant { + node: Node { + start: 1101, + end: 0, + }, + value: Str( + ". Retrying...", + ), + }, + ), + ], + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + AugAssignStatement( + AugAssign { + node: Node { + start: 1108, + end: 1124, + }, + target: Name( + Name { + node: Node { + start: 1108, + end: 1119, + }, + id: "retry_count", + }, + ), + op: Add, + value: Constant( + Constant { + node: Node { + start: 1123, + end: 1124, + }, + value: Int( + "1", + ), + }, + ), + }, + ), + ExpressionStatement( + Await( + Await { + node: Node { + start: 1129, + end: 1151, + }, + value: Call( + Call { + node: Node { + start: 1148, + end: 1151, + }, + func: Attribute( + Attribute { + node: Node { + start: 1135, + end: 1148, + }, + value: Name( + Name { + node: Node { + start: 1135, + end: 1142, + }, + id: "asyncio", + }, + ), + attr: "sleep", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 1149, + end: 1150, + }, + value: Int( + "1", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ), + ], + }, + ], + orelse: [], + finalbody: [], + }, + ), ], } diff --git a/parser/test_data/inputs/try.py b/parser/test_data/inputs/try.py index d6aeb892..455ceab4 100644 --- a/parser/test_data/inputs/try.py +++ b/parser/test_data/inputs/try.py @@ -13,3 +13,25 @@ except ValueError: market_cap = None + +try: + async with session.get( + url, headers=TRADE_DETAILS_HEADER, timeout=100 + ) as response: + if response.status == 503: + logger.info( + f"Received 503 Service Unavailable on {date_obj}. Retrying..." + ) + retry_count += 1 + await asyncio.sleep(1) + else: + response.raise_for_status() + data = await response.json() + logger.info( + f"Successfully fetched trade details on {date_obj} from tse" + ) + return [date_obj, pd.json_normalize(data["tradeHistory"])] +except (aiohttp.ClientError, asyncio.TimeoutError): + logger.error(f"Request failed for {date_obj}. Retrying...") + retry_count += 1 + await asyncio.sleep(1) From 5a020755c1fbf87701e4040acafe94122c0f2252 Mon Sep 17 00:00:00 2001 From: Glyphack Date: Sat, 7 Oct 2023 19:56:19 +0200 Subject: [PATCH 5/5] Remove consuming dedents in indented statements --- parser/src/parser/parser.rs | 4 - ...ser__tests__complete@input_program.py.snap | 20814 ++++++++-------- 2 files changed, 10407 insertions(+), 10411 deletions(-) diff --git a/parser/src/parser/parser.rs b/parser/src/parser/parser.rs index 59fb9778..3907dbaa 100644 --- a/parser/src/parser/parser.rs +++ b/parser/src/parser/parser.rs @@ -472,8 +472,6 @@ impl Parser { vec![] }; - self.bump(Kind::Dedent); - Ok(Statement::WhileStatement(While { node: self.finish_node(node), test, @@ -510,8 +508,6 @@ impl Parser { vec![] }; - self.bump(Kind::Dedent); - if is_async { Ok(Statement::AsyncForStatement(AsyncFor { node: self.finish_node(node), diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap index 7bc38468..6d0c29ca 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap @@ -1938,7 +1938,7 @@ Module { FunctionDef { node: Node { start: 1452, - end: 15273, + end: 4346, }, name: "download", args: Arguments { @@ -2379,7 +2379,7 @@ Module { With { node: Node { start: 1843, - end: 15273, + end: 4203, }, items: [ WithItem { @@ -2496,7 +2496,7 @@ Module { For { node: Node { start: 1955, - end: 4346, + end: 2698, }, target: Name( Name { @@ -3088,1077 +3088,1147 @@ Module { orelse: [], }, ), - ForStatement( - For { - node: Node { - start: 2698, - end: 4203, + ], + orelse: [], + }, + ), + ForStatement( + For { + node: Node { + start: 2698, + end: 4203, + }, + target: Name( + Name { + node: Node { + start: 2702, + end: 2708, + }, + id: "future", + }, + ), + iter: Call( + Call { + node: Node { + start: 2732, + end: 2750, + }, + func: Attribute( + Attribute { + node: Node { + start: 2712, + end: 2732, + }, + value: Name( + Name { + node: Node { + start: 2712, + end: 2719, + }, + id: "futures", + }, + ), + attr: "as_completed", }, - target: Name( + ), + args: [ + Name( Name { node: Node { - start: 2702, - end: 2708, + start: 2733, + end: 2749, }, - id: "future", + id: "future_to_symbol", }, ), - iter: Call( - Call { + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 2764, + end: 2797, + }, + targets: [ + Name( + Name { + node: Node { + start: 2764, + end: 2770, + }, + id: "symbol", + }, + ), + ], + value: Subscript( + Subscript { node: Node { - start: 2732, - end: 2750, + start: 2773, + end: 2797, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 2712, - end: 2732, + start: 2773, + end: 2789, }, - value: Name( - Name { - node: Node { - start: 2712, - end: 2719, - }, - id: "futures", - }, - ), - attr: "as_completed", + id: "future_to_symbol", }, ), - args: [ - Name( - Name { - node: Node { - start: 2733, - end: 2749, - }, - id: "future_to_symbol", + slice: Name( + Name { + node: Node { + start: 2790, + end: 2796, }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "future", + }, + ), }, ), + }, + ), + TryStatement( + Try { + node: Node { + start: 2810, + end: 3120, + }, body: [ - AssignStatement( - Assign { + AnnAssignStatement( + AnnAssign { node: Node { - start: 2764, - end: 2797, + start: 2831, + end: 2865, }, - targets: [ - Name( - Name { - node: Node { - start: 2764, - end: 2770, - }, - id: "symbol", + target: Name( + Name { + node: Node { + start: 2831, + end: 2833, }, - ), - ], - value: Subscript( - Subscript { + id: "df", + }, + ), + annotation: Attribute( + Attribute { node: Node { - start: 2773, - end: 2797, + start: 2835, + end: 2847, }, value: Name( Name { node: Node { - start: 2773, - end: 2789, - }, - id: "future_to_symbol", - }, - ), - slice: Name( - Name { - node: Node { - start: 2790, - end: 2796, + start: 2835, + end: 2837, }, - id: "future", + id: "pd", }, ), + attr: "DataFrame", }, ), - }, - ), - TryStatement( - Try { - node: Node { - start: 2810, - end: 3120, - }, - body: [ - AnnAssignStatement( - AnnAssign { + value: Some( + Call( + Call { node: Node { - start: 2831, + start: 2863, end: 2865, }, - target: Name( - Name { - node: Node { - start: 2831, - end: 2833, - }, - id: "df", - }, - ), - annotation: Attribute( + func: Attribute( Attribute { node: Node { - start: 2835, - end: 2847, + start: 2850, + end: 2863, }, value: Name( Name { node: Node { - start: 2835, - end: 2837, + start: 2850, + end: 2856, }, - id: "pd", + id: "future", }, ), - attr: "DataFrame", + attr: "result", }, ), - value: Some( - Call( - Call { - node: Node { - start: 2863, - end: 2865, - }, - func: Attribute( - Attribute { - node: Node { - start: 2850, - end: 2863, - }, - value: Name( - Name { - node: Node { - start: 2850, - end: 2856, - }, - id: "future", - }, - ), - attr: "result", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - simple: true, + args: [], + keywords: [], + starargs: None, + kwargs: None, }, ), - ], - handlers: [ - ExceptHandler { + ), + simple: true, + }, + ), + ], + handlers: [ + ExceptHandler { + node: Node { + start: 2878, + end: 3120, + }, + typ: Some( + Attribute( + Attribute { node: Node { - start: 2878, - end: 3120, + start: 2885, + end: 2909, }, - typ: Some( - Attribute( + value: Attribute( + Attribute { + node: Node { + start: 2885, + end: 2894, + }, + value: Name( + Name { + node: Node { + start: 2885, + end: 2887, + }, + id: "pd", + }, + ), + attr: "errors", + }, + ), + attr: "EmptyDataError", + }, + ), + ), + name: Some( + "ex", + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 2945, + end: 3082, + }, + func: Attribute( Attribute { node: Node { - start: 2885, - end: 2909, + start: 2933, + end: 2945, }, - value: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 2885, - end: 2894, + start: 2933, + end: 2939, }, - value: Name( - Name { - node: Node { - start: 2885, - end: 2887, - }, - id: "pd", - }, - ), - attr: "errors", + id: "logger", }, ), - attr: "EmptyDataError", + attr: "error", }, ), - ), - name: Some( - "ex", - ), - body: [ - ExpressionStatement( - Call( - Call { + args: [ + JoinedStr( + JoinedStr { node: Node { - start: 2945, - end: 3082, + start: 2967, + end: 3022, }, - func: Attribute( - Attribute { - node: Node { - start: 2933, - end: 2945, - }, - value: Name( - Name { - node: Node { - start: 2933, - end: 2939, - }, - id: "logger", + values: [ + Constant( + Constant { + node: Node { + start: 3013, + end: 0, }, - ), - attr: "error", - }, - ), - args: [ - JoinedStr( - JoinedStr { + value: Str( + "Cannot read daily trade records for symbol: ", + ), + }, + ), + Name( + Name { node: Node { - start: 2967, - end: 3022, + start: 3014, + end: 3020, }, - values: [ - Constant( - Constant { - node: Node { - start: 3013, - end: 0, - }, - value: Str( - "Cannot read daily trade records for symbol: ", - ), - }, - ), - Name( - Name { - node: Node { - start: 3014, - end: 3020, - }, - id: "symbol", - }, - ), - ], + id: "symbol", }, ), ], - keywords: [ - Keyword { - node: Node { - start: 3044, - end: 3063, - }, - arg: Some( - "extra", - ), - value: Dict( - Dict { - node: Node { - start: 3050, - end: 3063, - }, - keys: [ - Constant( - Constant { - node: Node { - start: 3051, - end: 3058, - }, - value: Str( - "Error", - ), - }, - ), - ], - values: [ - Name( - Name { - node: Node { - start: 3060, - end: 3062, - }, - id: "ex", - }, - ), - ], - }, - ), - }, - ], - starargs: None, - kwargs: None, }, ), - ), - Continue( - Continue { + ], + keywords: [ + Keyword { node: Node { - start: 3099, - end: 3107, + start: 3044, + end: 3063, }, + arg: Some( + "extra", + ), + value: Dict( + Dict { + node: Node { + start: 3050, + end: 3063, + }, + keys: [ + Constant( + Constant { + node: Node { + start: 3051, + end: 3058, + }, + value: Str( + "Error", + ), + }, + ), + ], + values: [ + Name( + Name { + node: Node { + start: 3060, + end: 3062, + }, + id: "ex", + }, + ), + ], + }, + ), }, - ), - ], + ], + starargs: None, + kwargs: None, + }, + ), + ), + Continue( + Continue { + node: Node { + start: 3099, + end: 3107, + }, }, - ], - orelse: [], - finalbody: [], - }, - ), - AssignStatement( - Assign { + ), + ], + }, + ], + orelse: [], + finalbody: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 3120, + end: 3161, + }, + targets: [ + Name( + Name { node: Node { start: 3120, - end: 3161, + end: 3122, }, - targets: [ - Name( - Name { + id: "df", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 3150, + end: 3161, + }, + func: Attribute( + Attribute { + node: Node { + start: 3138, + end: 3150, + }, + value: Subscript( + Subscript { node: Node { - start: 3120, - end: 3122, + start: 3132, + end: 3138, }, - id: "df", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 3150, - end: 3161, - }, - func: Attribute( - Attribute { - node: Node { - start: 3138, - end: 3150, - }, - value: Subscript( - Subscript { - node: Node { - start: 3132, - end: 3138, + value: Attribute( + Attribute { + node: Node { + start: 3125, + end: 3132, + }, + value: Name( + Name { + node: Node { + start: 3125, + end: 3127, + }, + id: "df", }, - value: Attribute( - Attribute { + ), + attr: "iloc", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 3133, + end: 3137, + }, + lower: None, + upper: Some( + UnaryOp( + UnaryOperation { node: Node { - start: 3125, - end: 3132, + start: 3135, + end: 3137, }, - value: Name( - Name { + op: USub, + operand: Constant( + Constant { node: Node { - start: 3125, - end: 3127, + start: 3136, + end: 3137, }, - id: "df", + value: Int( + "1", + ), }, ), - attr: "iloc", - }, - ), - slice: Slice( - Slice { - node: Node { - start: 3133, - end: 3137, - }, - lower: None, - upper: Some( - UnaryOp( - UnaryOperation { - node: Node { - start: 3135, - end: 3137, - }, - op: USub, - operand: Constant( - Constant { - node: Node { - start: 3136, - end: 3137, - }, - value: Int( - "1", - ), - }, - ), - }, - ), - ), - step: None, }, ), - }, - ), - attr: "reset_index", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 3151, - end: 3160, + ), + step: None, }, - arg: Some( - "drop", - ), - value: Constant( - Constant { - node: Node { - start: 3156, - end: 3160, - }, - value: Bool( - true, - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, + ), + }, + ), + attr: "reset_index", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 3151, + end: 3160, }, - ), - }, - ), - AssignStatement( - Assign { + arg: Some( + "drop", + ), + value: Constant( + Constant { + node: Node { + start: 3156, + end: 3160, + }, + value: Bool( + true, + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 3174, + end: 3233, + }, + targets: [ + Name( + Name { node: Node { start: 3174, - end: 3233, + end: 3176, }, - targets: [ - Name( + id: "df", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 3188, + end: 3233, + }, + func: Attribute( + Attribute { + node: Node { + start: 3179, + end: 3188, + }, + value: Name( Name { node: Node { - start: 3174, - end: 3176, + start: 3179, + end: 3181, }, id: "df", }, ), - ], - value: Call( - Call { - node: Node { - start: 3188, - end: 3233, - }, - func: Attribute( - Attribute { - node: Node { - start: 3179, - end: 3188, - }, - value: Name( - Name { - node: Node { - start: 3179, - end: 3181, - }, - id: "df", - }, - ), - attr: "rename", + attr: "rename", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 3189, + end: 3232, + }, + arg: Some( + "columns", + ), + value: Attribute( + Attribute { + node: Node { + start: 3197, + end: 3232, }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 3189, - end: 3232, - }, - arg: Some( - "columns", - ), - value: Attribute( - Attribute { - node: Node { - start: 3197, - end: 3232, - }, - value: Name( - Name { - node: Node { - start: 3197, - end: 3209, - }, - id: "translations", - }, - ), - attr: "HISTORY_FIELD_MAPPINGS", + value: Name( + Name { + node: Node { + start: 3197, + end: 3209, }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { + id: "translations", + }, + ), + attr: "HISTORY_FIELD_MAPPINGS", + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 3246, + end: 3289, + }, + targets: [ + Name( + Name { node: Node { start: 3246, - end: 3289, + end: 3248, }, - targets: [ - Name( + id: "df", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 3258, + end: 3289, + }, + func: Attribute( + Attribute { + node: Node { + start: 3251, + end: 3258, + }, + value: Name( Name { node: Node { - start: 3246, - end: 3248, + start: 3251, + end: 3253, }, id: "df", }, ), - ], - value: Call( - Call { - node: Node { - start: 3258, - end: 3289, - }, - func: Attribute( - Attribute { - node: Node { - start: 3251, - end: 3258, - }, - value: Name( - Name { + attr: "drop", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 3259, + end: 3288, + }, + arg: Some( + "columns", + ), + value: List( + List { + node: Node { + start: 3267, + end: 3288, + }, + elements: [ + Constant( + Constant { node: Node { - start: 3251, - end: 3253, + start: 3268, + end: 3275, }, - id: "df", + value: Str( + "", + ), }, ), - attr: "drop", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 3259, - end: 3288, - }, - arg: Some( - "columns", - ), - value: List( - List { + Constant( + Constant { node: Node { - start: 3267, - end: 3288, + start: 3277, + end: 3287, }, - elements: [ - Constant( - Constant { - node: Node { - start: 3268, - end: 3275, - }, - value: Str( - "", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 3277, - end: 3287, - }, - value: Str( - "", - ), - }, - ), - ], + value: Str( + "", + ), }, ), - }, - ], - starargs: None, - kwargs: None, - }, - ), + ], + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 3302, + end: 3339, + }, + func: Name( + Name { + node: Node { + start: 3302, + end: 3320, + }, + id: "_adjust_data_frame", }, ), - ExpressionStatement( - Call( - Call { + args: [ + Name( + Name { node: Node { - start: 3302, - end: 3339, + start: 3321, + end: 3323, }, - func: Name( - Name { - node: Node { - start: 3302, - end: 3320, - }, - id: "_adjust_data_frame", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 3321, - end: 3323, - }, - id: "df", - }, - ), - Name( - Name { - node: Node { - start: 3325, - end: 3338, - }, - id: "include_jdate", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "df", }, ), - ), - IfStatement( - If { - node: Node { - start: 3353, - end: 3712, + Name( + Name { + node: Node { + start: 3325, + end: 3338, + }, + id: "include_jdate", }, - test: Compare( - Compare { + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + IfStatement( + If { + node: Node { + start: 3353, + end: 3712, + }, + test: Compare( + Compare { + node: Node { + start: 3356, + end: 3373, + }, + left: Name( + Name { + node: Node { + start: 3356, + end: 3362, + }, + id: "symbol", + }, + ), + ops: [ + In, + ], + comparators: [ + Name( + Name { node: Node { - start: 3356, + start: 3366, end: 3373, }, - left: Name( - Name { - node: Node { - start: 3356, - end: 3362, - }, - id: "symbol", + id: "df_list", + }, + ), + ], + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 3391, + end: 3643, + }, + targets: [ + Subscript( + Subscript { + node: Node { + start: 3391, + end: 3406, }, - ), - ops: [ - In, - ], - comparators: [ - Name( + value: Name( Name { node: Node { - start: 3366, - end: 3373, + start: 3391, + end: 3398, }, id: "df_list", }, ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 3391, - end: 3643, - }, - targets: [ - Subscript( - Subscript { + slice: Name( + Name { + node: Node { + start: 3399, + end: 3405, + }, + id: "symbol", + }, + ), + }, + ), + ], + value: Call( + Call { + node: Node { + start: 3614, + end: 3625, + }, + func: Attribute( + Attribute { + node: Node { + start: 3602, + end: 3614, + }, + value: Call( + Call { node: Node { - start: 3391, - end: 3406, + start: 3573, + end: 3581, }, - value: Name( - Name { - node: Node { - start: 3391, - end: 3398, - }, - id: "df_list", - }, - ), - slice: Name( - Name { + func: Attribute( + Attribute { node: Node { - start: 3399, - end: 3405, + start: 3561, + end: 3573, }, - id: "symbol", - }, - ), - }, - ), - ], - value: Call( - Call { - node: Node { - start: 3614, - end: 3625, - }, - func: Attribute( - Attribute { - node: Node { - start: 3602, - end: 3614, - }, - value: Call( - Call { - node: Node { - start: 3573, - end: 3581, - }, - func: Attribute( - Attribute { - node: Node { - start: 3561, - end: 3573, + value: Call( + Call { + node: Node { + start: 3440, + end: 3540, + }, + func: Attribute( + Attribute { + node: Node { + start: 3431, + end: 3440, + }, + value: Name( + Name { + node: Node { + start: 3431, + end: 3433, + }, + id: "pd", + }, + ), + attr: "concat", }, - value: Call( - Call { + ), + args: [ + List( + List { node: Node { - start: 3440, - end: 3540, + start: 3466, + end: 3487, }, - func: Attribute( - Attribute { - node: Node { - start: 3431, - end: 3440, - }, - value: Name( - Name { - node: Node { - start: 3431, - end: 3433, - }, - id: "pd", - }, - ), - attr: "concat", - }, - ), - args: [ - List( - List { + elements: [ + Subscript( + Subscript { node: Node { - start: 3466, - end: 3487, + start: 3467, + end: 3482, }, - elements: [ - Subscript( - Subscript { - node: Node { - start: 3467, - end: 3482, - }, - value: Name( - Name { - node: Node { - start: 3467, - end: 3474, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 3475, - end: 3481, - }, - id: "symbol", - }, - ), + value: Name( + Name { + node: Node { + start: 3467, + end: 3474, }, - ), - Name( - Name { - node: Node { - start: 3484, - end: 3486, - }, - id: "df", + id: "df_list", + }, + ), + slice: Name( + Name { + node: Node { + start: 3475, + end: 3481, }, - ), - ], + id: "symbol", + }, + ), }, ), - ], - keywords: [ - Keyword { - node: Node { - start: 3489, - end: 3506, - }, - arg: Some( - "ignore_index", - ), - value: Constant( - Constant { - node: Node { - start: 3502, - end: 3506, - }, - value: Bool( - true, - ), + Name( + Name { + node: Node { + start: 3484, + end: 3486, }, - ), - }, - Keyword { - node: Node { - start: 3508, - end: 3518, + id: "df", }, - arg: Some( - "sort", - ), - value: Constant( - Constant { - node: Node { - start: 3513, - end: 3518, - }, - value: Bool( - false, - ), - }, - ), - }, + ), ], - starargs: None, - kwargs: None, }, ), - attr: "sort_values", - }, - ), - args: [ - Constant( - Constant { + ], + keywords: [ + Keyword { node: Node { - start: 3574, - end: 3580, + start: 3489, + end: 3506, }, - value: Str( - "date", + arg: Some( + "ignore_index", + ), + value: Constant( + Constant { + node: Node { + start: 3502, + end: 3506, + }, + value: Bool( + true, + ), + }, ), }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "reset_index", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 3615, - end: 3624, + Keyword { + node: Node { + start: 3508, + end: 3518, + }, + arg: Some( + "sort", + ), + value: Constant( + Constant { + node: Node { + start: 3513, + end: 3518, + }, + value: Bool( + false, + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + attr: "sort_values", }, - arg: Some( - "drop", - ), - value: Constant( + ), + args: [ + Constant( Constant { node: Node { - start: 3620, - end: 3624, + start: 3574, + end: 3580, }, - value: Bool( - true, + value: Str( + "date", ), }, ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - orelse: [ - AssignStatement( - Assign { - node: Node { - start: 3678, - end: 3698, + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + attr: "reset_index", }, - targets: [ - Subscript( - Subscript { + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 3615, + end: 3624, + }, + arg: Some( + "drop", + ), + value: Constant( + Constant { node: Node { - start: 3678, - end: 3693, + start: 3620, + end: 3624, }, - value: Name( - Name { - node: Node { - start: 3678, - end: 3685, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 3686, - end: 3692, - }, - id: "symbol", - }, + value: Bool( + true, ), }, ), - ], + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ], + orelse: [ + AssignStatement( + Assign { + node: Node { + start: 3678, + end: 3698, + }, + targets: [ + Subscript( + Subscript { + node: Node { + start: 3678, + end: 3693, + }, value: Name( Name { node: Node { - start: 3696, - end: 3698, + start: 3678, + end: 3685, }, - id: "df", + id: "df_list", + }, + ), + slice: Name( + Name { + node: Node { + start: 3686, + end: 3692, + }, + id: "symbol", }, ), }, ), ], - }, - ), - IfStatement( - If { - node: Node { - start: 3712, - end: 3800, - }, - test: Name( + value: Name( Name { node: Node { - start: 3715, - end: 3721, + start: 3696, + end: 3698, }, - id: "adjust", + id: "df", }, ), - body: [ - AssignStatement( - Assign { + }, + ), + ], + }, + ), + IfStatement( + If { + node: Node { + start: 3712, + end: 3800, + }, + test: Name( + Name { + node: Node { + start: 3715, + end: 3721, + }, + id: "adjust", + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 3739, + end: 3786, + }, + targets: [ + Subscript( + Subscript { node: Node { start: 3739, - end: 3786, + end: 3754, }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 3739, - end: 3754, - }, - value: Name( - Name { - node: Node { - start: 3739, - end: 3746, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 3747, - end: 3753, - }, - id: "symbol", - }, - ), + value: Name( + Name { + node: Node { + start: 3739, + end: 3746, }, - ), - ], - value: Call( - Call { + id: "df_list", + }, + ), + slice: Name( + Name { node: Node { - start: 3757, - end: 3786, + start: 3747, + end: 3753, }, - func: Name( + id: "symbol", + }, + ), + }, + ), + ], + value: Call( + Call { + node: Node { + start: 3757, + end: 3786, + }, + func: Name( + Name { + node: Node { + start: 3757, + end: 3769, + }, + id: "adjust_price", + }, + ), + args: [ + Subscript( + Subscript { + node: Node { + start: 3770, + end: 3785, + }, + value: Name( Name { node: Node { - start: 3757, - end: 3769, + start: 3770, + end: 3777, }, - id: "adjust_price", + id: "df_list", }, ), - args: [ - Subscript( - Subscript { - node: Node { - start: 3770, - end: 3785, + slice: Name( + Name { + node: Node { + start: 3778, + end: 3784, + }, + id: "symbol", + }, + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ], + orelse: [], + }, + ), + IfStatement( + If { + node: Node { + start: 3800, + end: 4203, + }, + test: Name( + Name { + node: Node { + start: 3803, + end: 3815, + }, + id: "write_to_csv", + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 3854, + end: 3883, + }, + func: Attribute( + Attribute { + node: Node { + start: 3848, + end: 3854, + }, + value: Call( + Call { + node: Node { + start: 3833, + end: 3848, + }, + func: Name( + Name { + node: Node { + start: 3833, + end: 3837, + }, + id: "Path", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 3838, + end: 3847, }, - value: Name( - Name { - node: Node { - start: 3770, - end: 3777, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 3778, - end: 3784, - }, - id: "symbol", - }, - ), + id: "base_path", }, ), ], @@ -4167,25 +4237,70 @@ Module { kwargs: None, }, ), + attr: "mkdir", }, ), - ], - orelse: [], - }, + args: [], + keywords: [ + Keyword { + node: Node { + start: 3855, + end: 3867, + }, + arg: Some( + "parents", + ), + value: Constant( + Constant { + node: Node { + start: 3863, + end: 3867, + }, + value: Bool( + true, + ), + }, + ), + }, + Keyword { + node: Node { + start: 3869, + end: 3882, + }, + arg: Some( + "exist_ok", + ), + value: Constant( + Constant { + node: Node { + start: 3878, + end: 3882, + }, + value: Bool( + true, + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), ), IfStatement( If { node: Node { - start: 3800, + start: 3900, end: 4203, }, test: Name( Name { node: Node { - start: 3803, - end: 3815, + start: 3903, + end: 3909, }, - id: "write_to_csv", + id: "adjust", }, ), body: [ @@ -4193,87 +4308,236 @@ Module { Call( Call { node: Node { - start: 3854, - end: 3883, + start: 3953, + end: 4044, }, func: Attribute( Attribute { node: Node { - start: 3848, - end: 3854, + start: 3946, + end: 3953, }, - value: Call( - Call { + value: Subscript( + Subscript { node: Node { - start: 3833, - end: 3848, + start: 3931, + end: 3946, }, - func: Name( + value: Name( Name { node: Node { - start: 3833, - end: 3837, + start: 3931, + end: 3938, }, - id: "Path", + id: "df_list", }, ), - args: [ - Name( - Name { - node: Node { - start: 3838, - end: 3847, - }, - id: "base_path", + slice: Name( + Name { + node: Node { + start: 3939, + end: 3945, }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "symbol", + }, + ), }, ), - attr: "mkdir", + attr: "to_csv", }, ), - args: [], + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 3979, + end: 4009, + }, + values: [ + Name( + Name { + node: Node { + start: 3982, + end: 3991, + }, + id: "base_path", + }, + ), + Constant( + Constant { + node: Node { + start: 3993, + end: 0, + }, + value: Str( + "/", + ), + }, + ), + Name( + Name { + node: Node { + start: 3994, + end: 4000, + }, + id: "symbol", + }, + ), + Constant( + Constant { + node: Node { + start: 4008, + end: 0, + }, + value: Str( + "-ت.csv", + ), + }, + ), + ], + }, + ), + ], keywords: [ Keyword { node: Node { - start: 3855, - end: 3867, + start: 4011, + end: 4022, }, arg: Some( - "parents", + "index", ), value: Constant( Constant { node: Node { - start: 3863, - end: 3867, + start: 4017, + end: 4022, }, value: Bool( - true, + false, + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + ), + ], + orelse: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 4109, + end: 4197, + }, + func: Attribute( + Attribute { + node: Node { + start: 4102, + end: 4109, + }, + value: Subscript( + Subscript { + node: Node { + start: 4087, + end: 4102, + }, + value: Name( + Name { + node: Node { + start: 4087, + end: 4094, + }, + id: "df_list", + }, + ), + slice: Name( + Name { + node: Node { + start: 4095, + end: 4101, + }, + id: "symbol", + }, ), }, ), + attr: "to_csv", }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 4135, + end: 4162, + }, + values: [ + Name( + Name { + node: Node { + start: 4138, + end: 4147, + }, + id: "base_path", + }, + ), + Constant( + Constant { + node: Node { + start: 4149, + end: 0, + }, + value: Str( + "/", + ), + }, + ), + Name( + Name { + node: Node { + start: 4150, + end: 4156, + }, + id: "symbol", + }, + ), + Constant( + Constant { + node: Node { + start: 4161, + end: 0, + }, + value: Str( + ".csv", + ), + }, + ), + ], + }, + ), + ], + keywords: [ Keyword { node: Node { - start: 3869, - end: 3882, + start: 4164, + end: 4175, }, arg: Some( - "exist_ok", + "index", ), value: Constant( Constant { node: Node { - start: 3878, - end: 3882, + start: 4170, + end: 4175, }, value: Bool( - true, + false, ), }, ), @@ -4284,10314 +4548,10050 @@ Module { }, ), ), - IfStatement( - If { - node: Node { - start: 3900, - end: 4203, - }, - test: Name( - Name { - node: Node { - start: 3903, - end: 3909, - }, - id: "adjust", - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 3953, - end: 4044, - }, - func: Attribute( - Attribute { - node: Node { - start: 3946, - end: 3953, - }, - value: Subscript( - Subscript { - node: Node { - start: 3931, - end: 3946, - }, - value: Name( - Name { - node: Node { - start: 3931, - end: 3938, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 3939, - end: 3945, - }, - id: "symbol", - }, - ), - }, - ), - attr: "to_csv", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 3979, - end: 4009, - }, - values: [ - Name( - Name { - node: Node { - start: 3982, - end: 3991, - }, - id: "base_path", - }, - ), - Constant( - Constant { - node: Node { - start: 3993, - end: 0, - }, - value: Str( - "/", - ), - }, - ), - Name( - Name { - node: Node { - start: 3994, - end: 4000, - }, - id: "symbol", - }, - ), - Constant( - Constant { - node: Node { - start: 4008, - end: 0, - }, - value: Str( - "-ت.csv", - ), - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 4011, - end: 4022, - }, - arg: Some( - "index", - ), - value: Constant( - Constant { - node: Node { - start: 4017, - end: 4022, - }, - value: Bool( - false, - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 4109, - end: 4197, - }, - func: Attribute( - Attribute { - node: Node { - start: 4102, - end: 4109, - }, - value: Subscript( - Subscript { - node: Node { - start: 4087, - end: 4102, - }, - value: Name( - Name { - node: Node { - start: 4087, - end: 4094, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 4095, - end: 4101, - }, - id: "symbol", - }, - ), - }, - ), - attr: "to_csv", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 4135, - end: 4162, - }, - values: [ - Name( - Name { - node: Node { - start: 4138, - end: 4147, - }, - id: "base_path", - }, - ), - Constant( - Constant { - node: Node { - start: 4149, - end: 0, - }, - value: Str( - "/", - ), - }, - ), - Name( - Name { - node: Node { - start: 4150, - end: 4156, - }, - id: "symbol", - }, - ), - Constant( - Constant { - node: Node { - start: 4161, - end: 0, - }, - value: Str( - ".csv", - ), - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 4164, - end: 4175, - }, - arg: Some( - "index", - ), - value: Constant( - Constant { - node: Node { - start: 4170, - end: 4175, - }, - value: Bool( - false, - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - ], - }, - ), ], - orelse: [], - }, - ), - ], - orelse: [], - }, - ), - IfStatement( - If { - node: Node { - start: 4203, - end: 4309, - }, - test: Compare( - Compare { - node: Node { - start: 4206, - end: 4234, }, - left: Call( - Call { - node: Node { - start: 4206, - end: 4218, - }, - func: Name( - Name { - node: Node { - start: 4206, - end: 4209, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 4210, - end: 4217, - }, - id: "df_list", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - NotEq, - ], - comparators: [ - Call( - Call { - node: Node { - start: 4222, - end: 4234, - }, - func: Name( - Name { - node: Node { - start: 4222, - end: 4225, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 4226, - end: 4233, - }, - id: "symbols", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 4244, - end: 4304, - }, - func: Name( - Name { - node: Node { - start: 4244, - end: 4249, - }, - id: "print", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 4250, - end: 4303, - }, - value: Str( - "Warning, download did not complete, re-run the code", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), ), ], orelse: [], }, ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 4322, - end: 4324, - }, - func: Attribute( - Attribute { - node: Node { - start: 4309, - end: 4322, - }, - value: Name( - Name { - node: Node { - start: 4309, - end: 4316, - }, - id: "session", - }, - ), - attr: "close", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - Return( - Return { - node: Node { - start: 4329, - end: 4343, - }, - value: Some( - Name( - Name { - node: Node { - start: 4336, - end: 4343, - }, - id: "df_list", - }, - ), - ), - }, - ), ], orelse: [], }, ), - FunctionDef( - FunctionDef { - node: Node { - start: 4346, - end: 6805, - }, - name: "adjust_price", - args: Arguments { + ], + }, + ), + IfStatement( + If { + node: Node { + start: 4203, + end: 4309, + }, + test: Compare( + Compare { + node: Node { + start: 4206, + end: 4234, + }, + left: Call( + Call { node: Node { - start: 4363, - end: 4379, + start: 4206, + end: 4218, }, - posonlyargs: [], - args: [ - Arg { + func: Name( + Name { node: Node { - start: 4363, - end: 4379, + start: 4206, + end: 4209, }, - arg: "df", - annotation: Some( - Attribute( - Attribute { - node: Node { - start: 4367, - end: 4379, - }, - value: Name( - Name { - node: Node { - start: 4367, - end: 4369, - }, - id: "pd", - }, - ), - attr: "DataFrame", - }, - ), - ), + id: "len", }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - ExpressionStatement( - Constant( - Constant { + ), + args: [ + Name( + Name { node: Node { - start: 4402, - end: 5588, + start: 4210, + end: 4217, }, - value: Str( - "\n Adjust historical records of stock\n\n There is a capital increase/profit sharing,\n if today \"Final Close Price\" is not equal to next day\n \"Yesterday Final Close Price\" by using this ratio,\n performance adjustment of stocks is achieved\n\n Parameters\n ----------\n df : pd.DataFrame\n DataFrame with historical records.\n\n Returns\n -------\n pd.DataFrame\n DataFrame with adjusted historical records.\n\n Notes\n -----\n DataFrame can not be empty or else it makes runtime error\n Type of DataFrame must be RangeIndex to make proper range of records\n that need to be modified\n\n diff: list\n list of indexs of the day after capital increase/profit sharing\n ratio_list: List\n List of ratios to adjust historical data of stock\n ratio: Float\n ratio = df.loc[i].adjClose / df.loc[i+1].yesterday\n\n Description\n -----------\n # Note: adjustment does not include Tenth and twentieth days\n df.index = range(0,101,1)\n # step is 1\n step = df.index.step\n diff = [10,20]\n ratio_list = [0.5, 0.8]\n df.loc[0:10-step, [open,...]] * ratio[0]\n df.loc[10:20-step, [open,...]] * ratio[1]\n ", - ), + id: "df_list", }, ), - ), - IfStatement( - If { - node: Node { - start: 5593, - end: 5691, - }, - test: BoolOp( - BoolOperation { - node: Node { - start: 5596, - end: 5666, - }, - op: Or, - values: [ - Attribute( - Attribute { - node: Node { - start: 5596, - end: 5604, - }, - value: Name( - Name { - node: Node { - start: 5596, - end: 5598, - }, - id: "df", - }, - ), - attr: "empty", - }, - ), - UnaryOp( - UnaryOperation { - node: Node { - start: 5608, - end: 5666, - }, - op: Not, - operand: Call( - Call { - node: Node { - start: 5612, - end: 5666, - }, - func: Name( - Name { - node: Node { - start: 5612, - end: 5622, - }, - id: "isinstance", - }, - ), - args: [ - Attribute( - Attribute { - node: Node { - start: 5623, - end: 5631, - }, - value: Name( - Name { - node: Node { - start: 5623, - end: 5625, - }, - id: "df", - }, - ), - attr: "index", - }, - ), - Attribute( - Attribute { - node: Node { - start: 5633, - end: 5665, - }, - value: Attribute( - Attribute { - node: Node { - start: 5633, - end: 5654, - }, - value: Attribute( - Attribute { - node: Node { - start: 5633, - end: 5648, - }, - value: Attribute( - Attribute { - node: Node { - start: 5633, - end: 5640, - }, - value: Name( - Name { - node: Node { - start: 5633, - end: 5635, - }, - id: "pd", - }, - ), - attr: "core", - }, - ), - attr: "indexes", - }, - ), - attr: "range", - }, - ), - attr: "RangeIndex", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - }, - ), - body: [ - Return( - Return { - node: Node { - start: 5676, - end: 5685, - }, - value: Some( - Name( - Name { - node: Node { - start: 5683, - end: 5685, - }, - id: "df", - }, - ), - ), - }, - ), - ], - orelse: [], + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ops: [ + NotEq, + ], + comparators: [ + Call( + Call { + node: Node { + start: 4222, + end: 4234, }, - ), - AssignStatement( - Assign { - node: Node { - start: 5691, - end: 5709, + func: Name( + Name { + node: Node { + start: 4222, + end: 4225, + }, + id: "len", }, - targets: [ - Name( - Name { - node: Node { - start: 5691, - end: 5697, - }, - id: "new_df", - }, - ), - ], - value: Call( - Call { + ), + args: [ + Name( + Name { node: Node { - start: 5707, - end: 5709, + start: 4226, + end: 4233, }, - func: Attribute( - Attribute { - node: Node { - start: 5700, - end: 5707, - }, - value: Name( - Name { - node: Node { - start: 5700, - end: 5702, - }, - id: "df", - }, - ), - attr: "copy", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, + id: "symbols", }, ), - }, - ), - AssignStatement( - Assign { + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 4244, + end: 4304, + }, + func: Name( + Name { node: Node { - start: 5714, - end: 5738, + start: 4244, + end: 4249, }, - targets: [ - Name( - Name { - node: Node { - start: 5714, - end: 5718, - }, - id: "step", - }, - ), - ], - value: Attribute( - Attribute { - node: Node { - start: 5721, - end: 5738, - }, - value: Attribute( - Attribute { - node: Node { - start: 5721, - end: 5733, - }, - value: Name( - Name { - node: Node { - start: 5721, - end: 5727, - }, - id: "new_df", - }, - ), - attr: "index", - }, - ), - attr: "step", - }, - ), + id: "print", }, ), - AssignStatement( - Assign { - node: Node { - start: 5743, - end: 5814, - }, - targets: [ - Name( - Name { - node: Node { - start: 5743, - end: 5747, - }, - id: "diff", - }, + args: [ + Constant( + Constant { + node: Node { + start: 4250, + end: 4303, + }, + value: Str( + "Warning, download did not complete, re-run the code", ), - ], - value: Call( - Call { - node: Node { - start: 5750, - end: 5814, - }, - func: Name( - Name { - node: Node { - start: 5750, - end: 5754, - }, - id: "list", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 5767, - end: 5813, - }, - value: Attribute( - Attribute { - node: Node { - start: 5755, - end: 5767, - }, - value: Name( - Name { - node: Node { - start: 5755, - end: 5761, - }, - id: "new_df", - }, - ), - attr: "index", - }, - ), - slice: Compare( - Compare { - node: Node { - start: 5768, - end: 5812, - }, - left: Attribute( - Attribute { - node: Node { - start: 5783, - end: 5792, - }, - value: Call( - Call { - node: Node { - start: 5780, - end: 5783, - }, - func: Attribute( - Attribute { - node: Node { - start: 5768, - end: 5780, - }, - value: Name( - Name { - node: Node { - start: 5768, - end: 5774, - }, - id: "new_df", - }, - ), - attr: "shift", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 5781, - end: 5782, - }, - value: Int( - "1", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "adjClose", - }, - ), - ops: [ - NotEq, - ], - comparators: [ - Attribute( - Attribute { - node: Node { - start: 5796, - end: 5812, - }, - value: Name( - Name { - node: Node { - start: 5796, - end: 5802, - }, - id: "new_df", - }, - ), - attr: "yesterday", - }, - ), - ], - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + orelse: [], + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 4322, + end: 4324, + }, + func: Attribute( + Attribute { + node: Node { + start: 4309, + end: 4322, + }, + value: Name( + Name { + node: Node { + start: 4309, + end: 4316, + }, + id: "session", + }, + ), + attr: "close", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + Return( + Return { + node: Node { + start: 4329, + end: 4343, + }, + value: Some( + Name( + Name { + node: Node { + start: 4336, + end: 4343, + }, + id: "df_list", + }, + ), + ), + }, + ), + ], + decorator_list: [], + returns: Some( + Subscript( + Subscript { + node: Node { + start: 1637, + end: 1660, + }, + value: Name( + Name { + node: Node { + start: 1637, + end: 1641, + }, + id: "Dict", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 1642, + end: 1660, + }, + elements: [ + Name( + Name { + node: Node { + start: 1642, + end: 1645, + }, + id: "str", + }, + ), + Attribute( + Attribute { + node: Node { + start: 1647, + end: 1659, + }, + value: Name( + Name { + node: Node { + start: 1647, + end: 1649, }, - ), + id: "pd", + }, + ), + attr: "DataFrame", + }, + ), + ], + }, + ), + }, + ), + ), + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 4346, + end: 6805, + }, + name: "adjust_price", + args: Arguments { + node: Node { + start: 4363, + end: 4379, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 4363, + end: 4379, + }, + arg: "df", + annotation: Some( + Attribute( + Attribute { + node: Node { + start: 4367, + end: 4379, + }, + value: Name( + Name { + node: Node { + start: 4367, + end: 4369, }, - ), - IfStatement( - If { - node: Node { - start: 5819, - end: 5861, + id: "pd", + }, + ), + attr: "DataFrame", + }, + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + ExpressionStatement( + Constant( + Constant { + node: Node { + start: 4402, + end: 5588, + }, + value: Str( + "\n Adjust historical records of stock\n\n There is a capital increase/profit sharing,\n if today \"Final Close Price\" is not equal to next day\n \"Yesterday Final Close Price\" by using this ratio,\n performance adjustment of stocks is achieved\n\n Parameters\n ----------\n df : pd.DataFrame\n DataFrame with historical records.\n\n Returns\n -------\n pd.DataFrame\n DataFrame with adjusted historical records.\n\n Notes\n -----\n DataFrame can not be empty or else it makes runtime error\n Type of DataFrame must be RangeIndex to make proper range of records\n that need to be modified\n\n diff: list\n list of indexs of the day after capital increase/profit sharing\n ratio_list: List\n List of ratios to adjust historical data of stock\n ratio: Float\n ratio = df.loc[i].adjClose / df.loc[i+1].yesterday\n\n Description\n -----------\n # Note: adjustment does not include Tenth and twentieth days\n df.index = range(0,101,1)\n # step is 1\n step = df.index.step\n diff = [10,20]\n ratio_list = [0.5, 0.8]\n df.loc[0:10-step, [open,...]] * ratio[0]\n df.loc[10:20-step, [open,...]] * ratio[1]\n ", + ), + }, + ), + ), + IfStatement( + If { + node: Node { + start: 5593, + end: 5691, + }, + test: BoolOp( + BoolOperation { + node: Node { + start: 5596, + end: 5666, + }, + op: Or, + values: [ + Attribute( + Attribute { + node: Node { + start: 5596, + end: 5604, + }, + value: Name( + Name { + node: Node { + start: 5596, + end: 5598, + }, + id: "df", }, - test: Compare( - Compare { - node: Node { - start: 5822, - end: 5835, + ), + attr: "empty", + }, + ), + UnaryOp( + UnaryOperation { + node: Node { + start: 5608, + end: 5666, + }, + op: Not, + operand: Call( + Call { + node: Node { + start: 5612, + end: 5666, + }, + func: Name( + Name { + node: Node { + start: 5612, + end: 5622, + }, + id: "isinstance", }, - left: Call( - Call { + ), + args: [ + Attribute( + Attribute { node: Node { - start: 5822, - end: 5831, + start: 5623, + end: 5631, }, - func: Name( + value: Name( Name { node: Node { - start: 5822, - end: 5825, + start: 5623, + end: 5625, }, - id: "len", + id: "df", }, ), - args: [ - Name( - Name { - node: Node { - start: 5826, - end: 5830, - }, - id: "diff", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + attr: "index", }, ), - ops: [ - Gt, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 5834, - end: 5835, - }, - value: Int( - "0", - ), - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { + Attribute( + Attribute { node: Node { - start: 5853, - end: 5856, + start: 5633, + end: 5665, }, - func: Attribute( + value: Attribute( Attribute { node: Node { - start: 5845, - end: 5853, + start: 5633, + end: 5654, }, - value: Name( - Name { + value: Attribute( + Attribute { node: Node { - start: 5845, - end: 5849, + start: 5633, + end: 5648, }, - id: "diff", - }, - ), - attr: "pop", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 5854, - end: 5855, + value: Attribute( + Attribute { + node: Node { + start: 5633, + end: 5640, + }, + value: Name( + Name { + node: Node { + start: 5633, + end: 5635, + }, + id: "pd", + }, + ), + attr: "core", + }, + ), + attr: "indexes", }, - value: Int( - "0", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + ), + attr: "range", + }, + ), + attr: "RangeIndex", }, ), - ), - ], - orelse: [], + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ], + }, + ), + body: [ + Return( + Return { + node: Node { + start: 5676, + end: 5685, + }, + value: Some( + Name( + Name { + node: Node { + start: 5683, + end: 5685, + }, + id: "df", }, ), - AssignStatement( - Assign { + ), + }, + ), + ], + orelse: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 5691, + end: 5709, + }, + targets: [ + Name( + Name { + node: Node { + start: 5691, + end: 5697, + }, + id: "new_df", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 5707, + end: 5709, + }, + func: Attribute( + Attribute { + node: Node { + start: 5700, + end: 5707, + }, + value: Name( + Name { node: Node { - start: 5861, - end: 5870, + start: 5700, + end: 5702, }, - targets: [ - Name( - Name { - node: Node { - start: 5861, - end: 5866, - }, - id: "ratio", - }, - ), - ], - value: Constant( - Constant { - node: Node { - start: 5869, - end: 5870, - }, - value: Int( - "1", - ), - }, - ), + id: "df", }, ), - AssignStatement( - Assign { + attr: "copy", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 5714, + end: 5738, + }, + targets: [ + Name( + Name { + node: Node { + start: 5714, + end: 5718, + }, + id: "step", + }, + ), + ], + value: Attribute( + Attribute { + node: Node { + start: 5721, + end: 5738, + }, + value: Attribute( + Attribute { + node: Node { + start: 5721, + end: 5733, + }, + value: Name( + Name { node: Node { - start: 5875, - end: 5890, + start: 5721, + end: 5727, }, - targets: [ - Name( + id: "new_df", + }, + ), + attr: "index", + }, + ), + attr: "step", + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 5743, + end: 5814, + }, + targets: [ + Name( + Name { + node: Node { + start: 5743, + end: 5747, + }, + id: "diff", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 5750, + end: 5814, + }, + func: Name( + Name { + node: Node { + start: 5750, + end: 5754, + }, + id: "list", + }, + ), + args: [ + Subscript( + Subscript { + node: Node { + start: 5767, + end: 5813, + }, + value: Attribute( + Attribute { + node: Node { + start: 5755, + end: 5767, + }, + value: Name( Name { node: Node { - start: 5875, - end: 5885, + start: 5755, + end: 5761, }, - id: "ratio_list", + id: "new_df", }, ), - ], - value: List( - List { - node: Node { - start: 5888, - end: 5890, - }, - elements: [], - }, - ), - }, - ), - ForStatement( - For { - node: Node { - start: 5895, - end: 6061, + attr: "index", }, - target: Name( - Name { - node: Node { - start: 5899, - end: 5900, - }, - id: "i", + ), + slice: Compare( + Compare { + node: Node { + start: 5768, + end: 5812, }, - ), - iter: Subscript( - Subscript { - node: Node { - start: 5904, - end: 5914, - }, - value: Name( - Name { - node: Node { - start: 5904, - end: 5908, - }, - id: "diff", + left: Attribute( + Attribute { + node: Node { + start: 5783, + end: 5792, }, - ), - slice: Slice( - Slice { - node: Node { - start: 5909, - end: 5913, - }, - lower: None, - upper: Some( - UnaryOp( - UnaryOperation { + value: Call( + Call { + node: Node { + start: 5780, + end: 5783, + }, + func: Attribute( + Attribute { node: Node { - start: 5911, - end: 5913, + start: 5768, + end: 5780, }, - op: USub, - operand: Constant( - Constant { + value: Name( + Name { node: Node { - start: 5912, - end: 5913, + start: 5768, + end: 5774, }, - value: Int( - "1", - ), + id: "new_df", }, ), + attr: "shift", }, ), - ), - step: None, - }, - ), - }, - ), - body: [ - AugAssignStatement( - AugAssign { - node: Node { - start: 5924, - end: 6020, - }, - target: Name( - Name { - node: Node { - start: 5924, - end: 5929, - }, - id: "ratio", + args: [ + Constant( + Constant { + node: Node { + start: 5781, + end: 5782, + }, + value: Int( + "1", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, }, ), - op: Mult, - value: BinOp( - BinOp { - node: Node { - start: 5947, - end: 6010, - }, - op: Div, - left: Subscript( - Subscript { - node: Node { - start: 5957, - end: 5973, - }, - value: Attribute( - Attribute { - node: Node { - start: 5947, - end: 5957, - }, - value: Name( - Name { - node: Node { - start: 5947, - end: 5953, - }, - id: "new_df", - }, - ), - attr: "loc", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 5958, - end: 5973, - }, - elements: [ - Name( - Name { - node: Node { - start: 5958, - end: 5959, - }, - id: "i", - }, - ), - Constant( - Constant { - node: Node { - start: 5961, - end: 5972, - }, - value: Str( - "yesterday", - ), - }, - ), - ], - }, - ), - }, - ), - right: Subscript( - Subscript { - node: Node { - start: 5995, - end: 6010, - }, - value: Attribute( - Attribute { - node: Node { - start: 5991, - end: 5995, - }, - value: Call( - Call { - node: Node { - start: 5988, - end: 5991, - }, - func: Attribute( - Attribute { - node: Node { - start: 5976, - end: 5988, - }, - value: Name( - Name { - node: Node { - start: 5976, - end: 5982, - }, - id: "new_df", - }, - ), - attr: "shift", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 5989, - end: 5990, - }, - value: Int( - "1", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "loc", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 5996, - end: 6010, - }, - elements: [ - Name( - Name { - node: Node { - start: 5996, - end: 5997, - }, - id: "i", - }, - ), - Constant( - Constant { - node: Node { - start: 5999, - end: 6009, - }, - value: Str( - "adjClose", - ), - }, - ), - ], - }, - ), - }, - ), - }, - ), - }, - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 6046, - end: 6056, - }, - func: Attribute( - Attribute { - node: Node { - start: 6029, - end: 6046, - }, - value: Name( - Name { - node: Node { - start: 6029, - end: 6039, - }, - id: "ratio_list", - }, - ), - attr: "insert", + attr: "adjClose", + }, + ), + ops: [ + NotEq, + ], + comparators: [ + Attribute( + Attribute { + node: Node { + start: 5796, + end: 5812, + }, + value: Name( + Name { + node: Node { + start: 5796, + end: 5802, + }, + id: "new_df", }, ), - args: [ - Constant( - Constant { - node: Node { - start: 6047, - end: 6048, - }, - value: Int( - "0", - ), - }, - ), - Name( - Name { - node: Node { - start: 6050, - end: 6055, - }, - id: "ratio", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + attr: "yesterday", }, ), - ), - ], - orelse: [], + ], + }, + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 5819, + end: 5861, + }, + test: Compare( + Compare { + node: Node { + start: 5822, + end: 5835, + }, + left: Call( + Call { + node: Node { + start: 5822, + end: 5831, + }, + func: Name( + Name { + node: Node { + start: 5822, + end: 5825, + }, + id: "len", }, ), - ForStatement( - For { + args: [ + Name( + Name { + node: Node { + start: 5826, + end: 5830, + }, + id: "diff", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ops: [ + Gt, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 5834, + end: 5835, + }, + value: Int( + "0", + ), + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 5853, + end: 5856, + }, + func: Attribute( + Attribute { node: Node { - start: 6061, - end: 6789, + start: 5845, + end: 5853, }, - target: Tuple( - Tuple { + value: Name( + Name { node: Node { - start: 6065, - end: 6069, + start: 5845, + end: 5849, }, - elements: [ - Name( - Name { - node: Node { - start: 6065, - end: 6066, - }, - id: "i", - }, - ), - Name( - Name { - node: Node { - start: 6068, - end: 6069, - }, - id: "k", - }, - ), - ], + id: "diff", }, ), - iter: Call( - Call { - node: Node { - start: 6073, - end: 6088, - }, - func: Name( - Name { - node: Node { - start: 6073, - end: 6082, - }, - id: "enumerate", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 6083, - end: 6087, - }, - id: "diff", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + attr: "pop", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 5854, + end: 5855, }, - ), - body: [ - IfStatement( - If { - node: Node { - start: 6098, - end: 6202, - }, - test: Compare( - Compare { - node: Node { - start: 6101, - end: 6107, - }, - left: Name( - Name { - node: Node { - start: 6101, - end: 6102, - }, - id: "i", - }, - ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 6106, - end: 6107, - }, - value: Int( - "0", - ), - }, - ), - ], + value: Int( + "0", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + orelse: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 5861, + end: 5870, + }, + targets: [ + Name( + Name { + node: Node { + start: 5861, + end: 5866, + }, + id: "ratio", + }, + ), + ], + value: Constant( + Constant { + node: Node { + start: 5869, + end: 5870, + }, + value: Int( + "1", + ), + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 5875, + end: 5890, + }, + targets: [ + Name( + Name { + node: Node { + start: 5875, + end: 5885, + }, + id: "ratio_list", + }, + ), + ], + value: List( + List { + node: Node { + start: 5888, + end: 5890, + }, + elements: [], + }, + ), + }, + ), + ForStatement( + For { + node: Node { + start: 5895, + end: 6061, + }, + target: Name( + Name { + node: Node { + start: 5899, + end: 5900, + }, + id: "i", + }, + ), + iter: Subscript( + Subscript { + node: Node { + start: 5904, + end: 5914, + }, + value: Name( + Name { + node: Node { + start: 5904, + end: 5908, + }, + id: "diff", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 5909, + end: 5913, + }, + lower: None, + upper: Some( + UnaryOp( + UnaryOperation { + node: Node { + start: 5911, + end: 5913, + }, + op: USub, + operand: Constant( + Constant { + node: Node { + start: 5912, + end: 5913, + }, + value: Int( + "1", + ), + }, + ), + }, + ), + ), + step: None, + }, + ), + }, + ), + body: [ + AugAssignStatement( + AugAssign { + node: Node { + start: 5924, + end: 6020, + }, + target: Name( + Name { + node: Node { + start: 5924, + end: 5929, + }, + id: "ratio", + }, + ), + op: Mult, + value: BinOp( + BinOp { + node: Node { + start: 5947, + end: 6010, + }, + op: Div, + left: Subscript( + Subscript { + node: Node { + start: 5957, + end: 5973, + }, + value: Attribute( + Attribute { + node: Node { + start: 5947, + end: 5957, + }, + value: Name( + Name { + node: Node { + start: 5947, + end: 5953, + }, + id: "new_df", }, ), - body: [ - AssignStatement( - Assign { + attr: "loc", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 5958, + end: 5973, + }, + elements: [ + Name( + Name { node: Node { - start: 6121, - end: 6147, + start: 5958, + end: 5959, }, - targets: [ - Name( - Name { - node: Node { - start: 6121, - end: 6126, - }, - id: "start", - }, - ), - ], - value: Attribute( - Attribute { - node: Node { - start: 6129, - end: 6147, - }, - value: Attribute( - Attribute { - node: Node { - start: 6129, - end: 6141, - }, - value: Name( - Name { - node: Node { - start: 6129, - end: 6135, - }, - id: "new_df", - }, - ), - attr: "index", - }, - ), - attr: "start", - }, - ), + id: "i", }, ), - ], - orelse: [ - AssignStatement( - Assign { + Constant( + Constant { node: Node { - start: 6174, - end: 6193, + start: 5961, + end: 5972, }, - targets: [ - Name( - Name { - node: Node { - start: 6174, - end: 6179, - }, - id: "start", - }, - ), - ], - value: Subscript( - Subscript { - node: Node { - start: 6182, - end: 6193, - }, - value: Name( - Name { - node: Node { - start: 6182, - end: 6186, - }, - id: "diff", - }, - ), - slice: BinOp( - BinOp { - node: Node { - start: 6187, - end: 6192, - }, - op: Sub, - left: Name( - Name { - node: Node { - start: 6187, - end: 6188, - }, - id: "i", - }, - ), - right: Constant( - Constant { - node: Node { - start: 6191, - end: 6192, - }, - value: Int( - "1", - ), - }, - ), - }, - ), - }, + value: Str( + "yesterday", ), }, ), ], }, ), - AssignStatement( - Assign { + }, + ), + right: Subscript( + Subscript { + node: Node { + start: 5995, + end: 6010, + }, + value: Attribute( + Attribute { node: Node { - start: 6202, - end: 6222, + start: 5991, + end: 5995, }, - targets: [ - Name( - Name { - node: Node { - start: 6202, - end: 6205, - }, - id: "end", - }, - ), - ], - value: BinOp( - BinOp { + value: Call( + Call { node: Node { - start: 6208, - end: 6222, + start: 5988, + end: 5991, }, - op: Sub, - left: Subscript( - Subscript { + func: Attribute( + Attribute { node: Node { - start: 6208, - end: 6215, + start: 5976, + end: 5988, }, value: Name( Name { node: Node { - start: 6208, - end: 6212, - }, - id: "diff", - }, - ), - slice: Name( - Name { - node: Node { - start: 6213, - end: 6214, + start: 5976, + end: 5982, }, - id: "i", + id: "new_df", }, ), + attr: "shift", }, ), - right: Name( - Name { - node: Node { - start: 6218, - end: 6222, + args: [ + Constant( + Constant { + node: Node { + start: 5989, + end: 5990, + }, + value: Int( + "1", + ), }, - id: "step", - }, - ), + ), + ], + keywords: [], + starargs: None, + kwargs: None, }, ), + attr: "loc", }, ), - AssignStatement( - Assign { + slice: Tuple( + Tuple { node: Node { - start: 6231, - end: 6783, + start: 5996, + end: 6010, }, - targets: [ - Subscript( - Subscript { + elements: [ + Name( + Name { node: Node { - start: 6241, - end: 6457, + start: 5996, + end: 5997, }, - value: Attribute( - Attribute { - node: Node { - start: 6231, - end: 6241, - }, - value: Name( - Name { - node: Node { - start: 6231, - end: 6237, - }, - id: "new_df", - }, - ), - attr: "loc", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 6255, - end: 6457, - }, - elements: [ - Slice( - Slice { - node: Node { - start: 6260, - end: 6264, - }, - lower: Some( - Name( - Name { - node: Node { - start: 6255, - end: 6260, - }, - id: "start", - }, - ), - ), - upper: Some( - Name( - Name { - node: Node { - start: 6261, - end: 6264, - }, - id: "end", - }, - ), - ), - step: None, - }, - ), - List( - List { - node: Node { - start: 6278, - end: 6446, - }, - elements: [ - Constant( - Constant { - node: Node { - start: 6296, - end: 6302, - }, - value: Str( - "open", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6320, - end: 6326, - }, - value: Str( - "high", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6344, - end: 6349, - }, - value: Str( - "low", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6367, - end: 6374, - }, - value: Str( - "close", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6392, - end: 6402, - }, - value: Str( - "adjClose", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6420, - end: 6431, - }, - value: Str( - "yesterday", - ), - }, - ), - ], - }, - ), - ], - }, + id: "i", + }, + ), + Constant( + Constant { + node: Node { + start: 5999, + end: 6009, + }, + value: Str( + "adjClose", ), }, ), ], - value: Call( - Call { - node: Node { - start: 6460, - end: 6783, - }, - func: Name( - Name { - node: Node { - start: 6460, - end: 6465, - }, - id: "round", - }, - ), - args: [ - BinOp( - BinOp { - node: Node { - start: 6479, - end: 6773, - }, - op: Mult, - left: Subscript( - Subscript { - node: Node { - start: 6489, - end: 6745, - }, - value: Attribute( - Attribute { - node: Node { - start: 6479, - end: 6489, - }, - value: Name( - Name { - node: Node { - start: 6479, - end: 6485, - }, - id: "new_df", - }, - ), - attr: "loc", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 6507, - end: 6745, - }, - elements: [ - Slice( - Slice { - node: Node { - start: 6512, - end: 6516, - }, - lower: Some( - Name( - Name { - node: Node { - start: 6507, - end: 6512, - }, - id: "start", - }, - ), - ), - upper: Some( - Name( - Name { - node: Node { - start: 6513, - end: 6516, - }, - id: "end", - }, - ), - ), - step: None, - }, - ), - List( - List { - node: Node { - start: 6534, - end: 6730, - }, - elements: [ - Constant( - Constant { - node: Node { - start: 6556, - end: 6562, - }, - value: Str( - "open", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6584, - end: 6590, - }, - value: Str( - "high", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6612, - end: 6617, - }, - value: Str( - "low", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6639, - end: 6646, - }, - value: Str( - "close", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6668, - end: 6678, - }, - value: Str( - "adjClose", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 6700, - end: 6711, - }, - value: Str( - "yesterday", - ), - }, - ), - ], - }, - ), - ], - }, - ), - }, - ), - right: Subscript( - Subscript { - node: Node { - start: 6760, - end: 6773, - }, - value: Name( - Name { - node: Node { - start: 6760, - end: 6770, - }, - id: "ratio_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 6771, - end: 6772, - }, - id: "i", - }, - ), - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), }, ), - ], - orelse: [], - }, - ), - Return( - Return { - node: Node { - start: 6789, - end: 6802, }, - value: Some( - Name( - Name { - node: Node { - start: 6796, - end: 6802, - }, - id: "new_df", - }, - ), - ), - }, - ), - ], - decorator_list: [], - returns: Some( - Attribute( + ), + }, + ), + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 6046, + end: 6056, + }, + func: Attribute( Attribute { node: Node { - start: 4384, - end: 4396, + start: 6029, + end: 6046, }, value: Name( Name { node: Node { - start: 4384, - end: 4386, + start: 6029, + end: 6039, }, - id: "pd", + id: "ratio_list", }, ), - attr: "DataFrame", + attr: "insert", }, ), + args: [ + Constant( + Constant { + node: Node { + start: 6047, + end: 6048, + }, + value: Int( + "0", + ), + }, + ), + Name( + Name { + node: Node { + start: 6050, + end: 6055, + }, + id: "ratio", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + orelse: [], + }, + ), + ForStatement( + For { + node: Node { + start: 6061, + end: 6789, + }, + target: Tuple( + Tuple { + node: Node { + start: 6065, + end: 6069, + }, + elements: [ + Name( + Name { + node: Node { + start: 6065, + end: 6066, + }, + id: "i", + }, + ), + Name( + Name { + node: Node { + start: 6068, + end: 6069, + }, + id: "k", + }, ), - type_comment: None, + ], + }, + ), + iter: Call( + Call { + node: Node { + start: 6073, + end: 6088, }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 6955, - end: 7464, - }, - name: "download_ticker_daily_record", - args: Arguments { + func: Name( + Name { node: Node { - start: 6988, - end: 7023, + start: 6073, + end: 6082, }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 6988, - end: 7005, - }, - arg: "ticker_index", - annotation: Some( - Name( - Name { - node: Node { - start: 7002, - end: 7005, - }, - id: "str", - }, - ), - ), + id: "enumerate", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 6083, + end: 6087, }, - Arg { - node: Node { - start: 7007, - end: 7023, + id: "diff", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + body: [ + IfStatement( + If { + node: Node { + start: 6098, + end: 6202, + }, + test: Compare( + Compare { + node: Node { + start: 6101, + end: 6107, + }, + left: Name( + Name { + node: Node { + start: 6101, + end: 6102, + }, + id: "i", }, - arg: "session", - annotation: Some( - Name( - Name { - node: Node { - start: 7016, - end: 7023, - }, - id: "Session", + ), + ops: [ + Eq, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 6106, + end: 6107, }, - ), + value: Int( + "0", + ), + }, ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, + ], + }, + ), body: [ AssignStatement( Assign { node: Node { - start: 7030, - end: 7100, + start: 6121, + end: 6147, }, targets: [ Name( Name { node: Node { - start: 7030, - end: 7033, + start: 6121, + end: 6126, }, - id: "url", + id: "start", }, ), ], - value: Call( - Call { + value: Attribute( + Attribute { node: Node { - start: 7086, - end: 7100, + start: 6129, + end: 6147, }, - func: Attribute( + value: Attribute( Attribute { node: Node { - start: 7036, - end: 7086, + start: 6129, + end: 6141, }, - value: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 7036, - end: 7079, + start: 6129, + end: 6135, }, - value: Name( - Name { - node: Node { - start: 7036, - end: 7048, - }, - id: "tse_settings", - }, - ), - attr: "TSE_TICKER_EXPORT_DATA_ADDRESS", + id: "new_df", }, ), - attr: "format", + attr: "index", }, ), - args: [ - Name( - Name { - node: Node { - start: 7087, - end: 7099, - }, - id: "ticker_index", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + attr: "start", }, ), }, ), + ], + orelse: [ AssignStatement( Assign { node: Node { - start: 7105, - end: 7144, + start: 6174, + end: 6193, }, targets: [ Name( Name { node: Node { - start: 7105, - end: 7113, + start: 6174, + end: 6179, }, - id: "response", + id: "start", }, ), ], - value: Call( - Call { + value: Subscript( + Subscript { node: Node { - start: 7127, - end: 7144, + start: 6182, + end: 6193, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 7116, - end: 7127, + start: 6182, + end: 6186, }, - value: Name( - Name { - node: Node { - start: 7116, - end: 7123, - }, - id: "session", - }, - ), - attr: "get", + id: "diff", }, ), - args: [ - Name( - Name { - node: Node { - start: 7128, - end: 7131, - }, - id: "url", - }, - ), - ], - keywords: [ - Keyword { + slice: BinOp( + BinOp { node: Node { - start: 7133, - end: 7143, + start: 6187, + end: 6192, }, - arg: Some( - "timeout", + op: Sub, + left: Name( + Name { + node: Node { + start: 6187, + end: 6188, + }, + id: "i", + }, ), - value: Constant( + right: Constant( Constant { node: Node { - start: 7141, - end: 7143, + start: 6191, + end: 6192, }, value: Int( - "10", + "1", ), }, ), }, - ], - starargs: None, - kwargs: None, + ), }, ), }, ), - IfStatement( - If { + ], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 6202, + end: 6222, + }, + targets: [ + Name( + Name { node: Node { - start: 7149, - end: 7369, + start: 6202, + end: 6205, }, - test: Compare( - Compare { + id: "end", + }, + ), + ], + value: BinOp( + BinOp { + node: Node { + start: 6208, + end: 6222, + }, + op: Sub, + left: Subscript( + Subscript { + node: Node { + start: 6208, + end: 6215, + }, + value: Name( + Name { + node: Node { + start: 6208, + end: 6212, + }, + id: "diff", + }, + ), + slice: Name( + Name { + node: Node { + start: 6213, + end: 6214, + }, + id: "i", + }, + ), + }, + ), + right: Name( + Name { + node: Node { + start: 6218, + end: 6222, + }, + id: "step", + }, + ), + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 6231, + end: 6783, + }, + targets: [ + Subscript( + Subscript { + node: Node { + start: 6241, + end: 6457, + }, + value: Attribute( + Attribute { node: Node { - start: 7152, - end: 7185, + start: 6231, + end: 6241, }, - left: Constant( - Constant { + value: Name( + Name { node: Node { - start: 7152, - end: 7155, + start: 6231, + end: 6237, }, - value: Int( - "400", - ), + id: "new_df", }, ), - ops: [ - LtE, - Lt, - ], - comparators: [ - Attribute( - Attribute { + attr: "loc", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 6255, + end: 6457, + }, + elements: [ + Slice( + Slice { node: Node { - start: 7159, - end: 7179, + start: 6260, + end: 6264, }, - value: Name( - Name { - node: Node { - start: 7159, - end: 7167, + lower: Some( + Name( + Name { + node: Node { + start: 6255, + end: 6260, + }, + id: "start", }, - id: "response", - }, + ), ), - attr: "status_code", + upper: Some( + Name( + Name { + node: Node { + start: 6261, + end: 6264, + }, + id: "end", + }, + ), + ), + step: None, }, ), - Constant( - Constant { + List( + List { node: Node { - start: 7182, - end: 7185, + start: 6278, + end: 6446, }, - value: Int( - "500", - ), + elements: [ + Constant( + Constant { + node: Node { + start: 6296, + end: 6302, + }, + value: Str( + "open", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 6320, + end: 6326, + }, + value: Str( + "high", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 6344, + end: 6349, + }, + value: Str( + "low", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 6367, + end: 6374, + }, + value: Str( + "close", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 6392, + end: 6402, + }, + value: Str( + "adjClose", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 6420, + end: 6431, + }, + value: Str( + "yesterday", + ), + }, + ), + ], }, ), ], }, ), - body: [ - ExpressionStatement( - Call( - Call { + }, + ), + ], + value: Call( + Call { + node: Node { + start: 6460, + end: 6783, + }, + func: Name( + Name { + node: Node { + start: 6460, + end: 6465, + }, + id: "round", + }, + ), + args: [ + BinOp( + BinOp { + node: Node { + start: 6479, + end: 6773, + }, + op: Mult, + left: Subscript( + Subscript { node: Node { - start: 7207, - end: 7363, + start: 6489, + end: 6745, }, - func: Attribute( + value: Attribute( Attribute { node: Node { - start: 7195, - end: 7207, + start: 6479, + end: 6489, }, value: Name( Name { node: Node { - start: 7195, - end: 7201, + start: 6479, + end: 6485, }, - id: "logger", + id: "new_df", }, ), - attr: "error", + attr: "loc", }, ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 7221, - end: 7275, - }, - values: [ - Constant( - Constant { - node: Node { - start: 7269, - end: 0, - }, - value: Str( - "Cannot read daily trade records from the url: ", - ), - }, - ), - Name( - Name { - node: Node { - start: 7270, - end: 7273, - }, - id: "url", - }, - ), - ], + slice: Tuple( + Tuple { + node: Node { + start: 6507, + end: 6745, }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 7289, - end: 7352, - }, - arg: Some( - "extra", - ), - value: Dict( - Dict { - node: Node { - start: 7295, - end: 7352, - }, - keys: [ - Constant( - Constant { - node: Node { - start: 7296, - end: 7306, + elements: [ + Slice( + Slice { + node: Node { + start: 6512, + end: 6516, + }, + lower: Some( + Name( + Name { + node: Node { + start: 6507, + end: 6512, + }, + id: "start", }, - value: Str( - "response", - ), - }, + ), ), - Constant( - Constant { - node: Node { - start: 7323, - end: 7329, + upper: Some( + Name( + Name { + node: Node { + start: 6513, + end: 6516, + }, + id: "end", }, - value: Str( - "code", - ), - }, + ), ), - ], - values: [ - Attribute( - Attribute { - node: Node { - start: 7308, - end: 7321, + step: None, + }, + ), + List( + List { + node: Node { + start: 6534, + end: 6730, + }, + elements: [ + Constant( + Constant { + node: Node { + start: 6556, + end: 6562, + }, + value: Str( + "open", + ), }, - value: Name( - Name { - node: Node { - start: 7308, - end: 7316, - }, - id: "response", + ), + Constant( + Constant { + node: Node { + start: 6584, + end: 6590, }, - ), - attr: "text", - }, - ), - Attribute( - Attribute { - node: Node { - start: 7331, - end: 7351, + value: Str( + "high", + ), }, - value: Name( - Name { - node: Node { - start: 7331, - end: 7339, - }, - id: "response", + ), + Constant( + Constant { + node: Node { + start: 6612, + end: 6617, }, - ), - attr: "status_code", - }, - ), - ], - }, - ), + value: Str( + "low", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 6639, + end: 6646, + }, + value: Str( + "close", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 6668, + end: 6678, + }, + value: Str( + "adjClose", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 6700, + end: 6711, + }, + value: Str( + "yesterday", + ), + }, + ), + ], + }, + ), + ], }, - ], - starargs: None, - kwargs: None, + ), }, ), - ), - ], - orelse: [], - }, - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 7394, - end: 7396, - }, - func: Attribute( - Attribute { - node: Node { - start: 7369, - end: 7394, - }, - value: Name( - Name { - node: Node { - start: 7369, - end: 7377, - }, - id: "response", - }, - ), - attr: "raise_for_status", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - AssignStatement( - Assign { - node: Node { - start: 7402, - end: 7432, - }, - targets: [ - Name( - Name { - node: Node { - start: 7402, - end: 7406, - }, - id: "data", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 7409, - end: 7432, - }, - func: Name( - Name { + right: Subscript( + Subscript { node: Node { - start: 7409, - end: 7417, - }, - id: "StringIO", - }, - ), - args: [ - Attribute( - Attribute { - node: Node { - start: 7418, - end: 7431, - }, - value: Name( - Name { - node: Node { - start: 7418, - end: 7426, - }, - id: "response", - }, - ), - attr: "text", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - Return( - Return { - node: Node { - start: 7437, - end: 7461, - }, - value: Some( - Call( - Call { - node: Node { - start: 7455, - end: 7461, - }, - func: Attribute( - Attribute { - node: Node { - start: 7444, - end: 7455, - }, - value: Name( - Name { - node: Node { - start: 7444, - end: 7446, - }, - id: "pd", - }, - ), - attr: "read_csv", + start: 6760, + end: 6773, }, - ), - args: [ - Name( + value: Name( Name { node: Node { - start: 7456, - end: 7460, + start: 6760, + end: 6770, }, - id: "data", + id: "ratio_list", }, ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - }, - ), - ], - decorator_list: [ - Call( - Call { - node: Node { - start: 6806, - end: 6954, - }, - func: Name( - Name { - node: Node { - start: 6806, - end: 6811, - }, - id: "retry", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 6817, - end: 6857, - }, - arg: Some( - "retry", - ), - value: Call( - Call { - node: Node { - start: 6823, - end: 6857, - }, - func: Name( + slice: Name( Name { node: Node { - start: 6823, - end: 6846, + start: 6771, + end: 6772, }, - id: "retry_if_exception_type", + id: "i", }, ), - args: [ - Name( - Name { - node: Node { - start: 6847, - end: 6856, - }, - id: "HTTPError", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, }, ), }, - Keyword { - node: Node { - start: 6863, - end: 6893, - }, - arg: Some( - "wait", - ), - value: Call( - Call { - node: Node { - start: 6868, - end: 6893, - }, - func: Name( - Name { - node: Node { - start: 6868, - end: 6879, - }, - id: "wait_random", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 6880, - end: 6885, - }, - arg: Some( - "min", - ), - value: Constant( - Constant { - node: Node { - start: 6884, - end: 6885, - }, - value: Int( - "1", - ), - }, - ), - }, - Keyword { - node: Node { - start: 6887, - end: 6892, - }, - arg: Some( - "max", - ), - value: Constant( - Constant { - node: Node { - start: 6891, - end: 6892, - }, - value: Int( - "4", - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - Keyword { - node: Node { - start: 6899, - end: 6951, - }, - arg: Some( - "before_sleep", - ), - value: Call( - Call { - node: Node { - start: 6912, - end: 6951, - }, - func: Name( - Name { - node: Node { - start: 6912, - end: 6928, - }, - id: "before_sleep_log", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 6929, - end: 6935, - }, - id: "logger", - }, - ), - Attribute( - Attribute { - node: Node { - start: 6937, - end: 6950, - }, - value: Name( - Name { - node: Node { - start: 6937, - end: 6944, - }, - id: "logging", - }, - ), - attr: "DEBUG", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ], - returns: None, - type_comment: None, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ], + orelse: [], + }, + ), + Return( + Return { + node: Node { + start: 6789, + end: 6802, + }, + value: Some( + Name( + Name { + node: Node { + start: 6796, + end: 6802, + }, + id: "new_df", + }, + ), + ), + }, + ), + ], + decorator_list: [], + returns: Some( + Attribute( + Attribute { + node: Node { + start: 4384, + end: 4396, + }, + value: Name( + Name { + node: Node { + start: 4384, + end: 4386, + }, + id: "pd", + }, + ), + attr: "DataFrame", + }, + ), + ), + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 6955, + end: 7464, + }, + name: "download_ticker_daily_record", + args: Arguments { + node: Node { + start: 6988, + end: 7023, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 6988, + end: 7005, + }, + arg: "ticker_index", + annotation: Some( + Name( + Name { + node: Node { + start: 7002, + end: 7005, + }, + id: "str", + }, + ), + ), + }, + Arg { + node: Node { + start: 7007, + end: 7023, + }, + arg: "session", + annotation: Some( + Name( + Name { + node: Node { + start: 7016, + end: 7023, + }, + id: "Session", }, ), - FunctionDef( - FunctionDef { + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 7030, + end: 7100, + }, + targets: [ + Name( + Name { node: Node { - start: 7614, - end: 8358, + start: 7030, + end: 7033, }, - name: "download_fIndex_record", - args: Arguments { + id: "url", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 7086, + end: 7100, + }, + func: Attribute( + Attribute { node: Node { - start: 7641, - end: 7670, + start: 7036, + end: 7086, }, - posonlyargs: [], - args: [ - Arg { + value: Attribute( + Attribute { node: Node { - start: 7641, - end: 7652, + start: 7036, + end: 7079, }, - arg: "fIndex", - annotation: Some( - Name( - Name { - node: Node { - start: 7649, - end: 7652, - }, - id: "str", + value: Name( + Name { + node: Node { + start: 7036, + end: 7048, }, - ), + id: "tse_settings", + }, ), + attr: "TSE_TICKER_EXPORT_DATA_ADDRESS", }, - Arg { - node: Node { - start: 7654, - end: 7670, - }, - arg: "session", - annotation: Some( - Name( - Name { - node: Node { - start: 7663, - end: 7670, - }, - id: "Session", - }, - ), - ), + ), + attr: "format", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 7087, + end: 7099, }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], + id: "ticker_index", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 7105, + end: 7144, + }, + targets: [ + Name( + Name { + node: Node { + start: 7105, + end: 7113, }, - body: [ - AssignStatement( - Assign { + id: "response", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 7127, + end: 7144, + }, + func: Attribute( + Attribute { + node: Node { + start: 7116, + end: 7127, + }, + value: Name( + Name { node: Node { - start: 7677, - end: 7750, + start: 7116, + end: 7123, }, - targets: [ - Name( - Name { - node: Node { - start: 7677, - end: 7680, - }, - id: "url", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 7742, - end: 7750, - }, - func: Attribute( - Attribute { - node: Node { - start: 7683, - end: 7742, - }, - value: Attribute( - Attribute { - node: Node { - start: 7683, - end: 7735, - }, - value: Name( - Name { - node: Node { - start: 7683, - end: 7695, - }, - id: "tse_settings", - }, - ), - attr: "TSE_FINANCIAL_INDEX_EXPORT_DATA_ADDRESS", - }, - ), - attr: "format", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 7743, - end: 7749, - }, - id: "fIndex", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, + id: "session", + }, + ), + attr: "get", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 7128, + end: 7131, + }, + id: "url", + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 7133, + end: 7143, + }, + arg: Some( + "timeout", + ), + value: Constant( + Constant { + node: Node { + start: 7141, + end: 7143, + }, + value: Int( + "10", ), }, ), - AssignStatement( - Assign { + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 7149, + end: 7369, + }, + test: Compare( + Compare { + node: Node { + start: 7152, + end: 7185, + }, + left: Constant( + Constant { + node: Node { + start: 7152, + end: 7155, + }, + value: Int( + "400", + ), + }, + ), + ops: [ + LtE, + Lt, + ], + comparators: [ + Attribute( + Attribute { + node: Node { + start: 7159, + end: 7179, + }, + value: Name( + Name { + node: Node { + start: 7159, + end: 7167, + }, + id: "response", + }, + ), + attr: "status_code", + }, + ), + Constant( + Constant { + node: Node { + start: 7182, + end: 7185, + }, + value: Int( + "500", + ), + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 7207, + end: 7363, + }, + func: Attribute( + Attribute { node: Node { - start: 7755, - end: 7794, + start: 7195, + end: 7207, }, - targets: [ - Name( - Name { - node: Node { - start: 7755, - end: 7763, - }, - id: "response", - }, - ), - ], - value: Call( - Call { + value: Name( + Name { node: Node { - start: 7777, - end: 7794, + start: 7195, + end: 7201, }, - func: Attribute( - Attribute { + id: "logger", + }, + ), + attr: "error", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 7221, + end: 7275, + }, + values: [ + Constant( + Constant { node: Node { - start: 7766, - end: 7777, + start: 7269, + end: 0, }, - value: Name( - Name { - node: Node { - start: 7766, - end: 7773, - }, - id: "session", - }, + value: Str( + "Cannot read daily trade records from the url: ", ), - attr: "get", }, ), - args: [ - Name( - Name { - node: Node { - start: 7778, - end: 7781, - }, - id: "url", - }, - ), - ], - keywords: [ - Keyword { + Name( + Name { node: Node { - start: 7783, - end: 7793, + start: 7270, + end: 7273, }, - arg: Some( - "timeout", - ), - value: Constant( - Constant { - node: Node { - start: 7791, - end: 7793, - }, - value: Int( - "10", - ), - }, - ), + id: "url", }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { + ), + ], + }, + ), + ], + keywords: [ + Keyword { node: Node { - start: 7799, - end: 8019, + start: 7289, + end: 7352, }, - test: Compare( - Compare { + arg: Some( + "extra", + ), + value: Dict( + Dict { node: Node { - start: 7802, - end: 7835, + start: 7295, + end: 7352, }, - left: Constant( - Constant { - node: Node { - start: 7802, - end: 7805, + keys: [ + Constant( + Constant { + node: Node { + start: 7296, + end: 7306, + }, + value: Str( + "response", + ), }, - value: Int( - "400", - ), - }, - ), - ops: [ - LtE, - Lt, + ), + Constant( + Constant { + node: Node { + start: 7323, + end: 7329, + }, + value: Str( + "code", + ), + }, + ), ], - comparators: [ + values: [ Attribute( Attribute { node: Node { - start: 7809, - end: 7829, + start: 7308, + end: 7321, }, value: Name( Name { node: Node { - start: 7809, - end: 7817, + start: 7308, + end: 7316, }, id: "response", }, ), - attr: "status_code", + attr: "text", }, ), - Constant( - Constant { + Attribute( + Attribute { node: Node { - start: 7832, - end: 7835, + start: 7331, + end: 7351, }, - value: Int( - "500", + value: Name( + Name { + node: Node { + start: 7331, + end: 7339, + }, + id: "response", + }, ), + attr: "status_code", }, ), ], }, ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 7857, - end: 8013, - }, - func: Attribute( - Attribute { - node: Node { - start: 7845, - end: 7857, - }, - value: Name( - Name { - node: Node { - start: 7845, - end: 7851, - }, - id: "logger", - }, - ), - attr: "error", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 7871, - end: 7925, - }, - values: [ - Constant( - Constant { - node: Node { - start: 7919, - end: 0, - }, - value: Str( - "Cannot read daily trade records from the url: ", - ), - }, - ), - Name( - Name { - node: Node { - start: 7920, - end: 7923, - }, - id: "url", - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 7939, - end: 8002, - }, - arg: Some( - "extra", - ), - value: Dict( - Dict { - node: Node { - start: 7945, - end: 8002, - }, - keys: [ - Constant( - Constant { - node: Node { - start: 7946, - end: 7956, - }, - value: Str( - "response", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 7973, - end: 7979, - }, - value: Str( - "code", - ), - }, - ), - ], - values: [ - Attribute( - Attribute { - node: Node { - start: 7958, - end: 7971, - }, - value: Name( - Name { - node: Node { - start: 7958, - end: 7966, - }, - id: "response", - }, - ), - attr: "text", - }, - ), - Attribute( - Attribute { - node: Node { - start: 7981, - end: 8001, - }, - value: Name( - Name { - node: Node { - start: 7981, - end: 7989, - }, - id: "response", - }, - ), - attr: "status_code", - }, - ), - ], - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], + }, + ], + starargs: None, + kwargs: None, + }, + ), + ), + ], + orelse: [], + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 7394, + end: 7396, + }, + func: Attribute( + Attribute { + node: Node { + start: 7369, + end: 7394, + }, + value: Name( + Name { + node: Node { + start: 7369, + end: 7377, + }, + id: "response", + }, + ), + attr: "raise_for_status", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + AssignStatement( + Assign { + node: Node { + start: 7402, + end: 7432, + }, + targets: [ + Name( + Name { + node: Node { + start: 7402, + end: 7406, + }, + id: "data", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 7409, + end: 7432, + }, + func: Name( + Name { + node: Node { + start: 7409, + end: 7417, + }, + id: "StringIO", + }, + ), + args: [ + Attribute( + Attribute { + node: Node { + start: 7418, + end: 7431, + }, + value: Name( + Name { + node: Node { + start: 7418, + end: 7426, + }, + id: "response", + }, + ), + attr: "text", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + Return( + Return { + node: Node { + start: 7437, + end: 7461, + }, + value: Some( + Call( + Call { + node: Node { + start: 7455, + end: 7461, + }, + func: Attribute( + Attribute { + node: Node { + start: 7444, + end: 7455, + }, + value: Name( + Name { + node: Node { + start: 7444, + end: 7446, + }, + id: "pd", + }, + ), + attr: "read_csv", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 7456, + end: 7460, + }, + id: "data", }, ), - ExpressionStatement( - Call( - Call { + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + }, + ), + ], + decorator_list: [ + Call( + Call { + node: Node { + start: 6806, + end: 6954, + }, + func: Name( + Name { + node: Node { + start: 6806, + end: 6811, + }, + id: "retry", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 6817, + end: 6857, + }, + arg: Some( + "retry", + ), + value: Call( + Call { + node: Node { + start: 6823, + end: 6857, + }, + func: Name( + Name { + node: Node { + start: 6823, + end: 6846, + }, + id: "retry_if_exception_type", + }, + ), + args: [ + Name( + Name { node: Node { - start: 8044, - end: 8046, + start: 6847, + end: 6856, }, - func: Attribute( - Attribute { - node: Node { - start: 8019, - end: 8044, - }, - value: Name( - Name { - node: Node { - start: 8019, - end: 8027, - }, - id: "response", - }, - ), - attr: "raise_for_status", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, + id: "HTTPError", }, ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + Keyword { + node: Node { + start: 6863, + end: 6893, + }, + arg: Some( + "wait", + ), + value: Call( + Call { + node: Node { + start: 6868, + end: 6893, + }, + func: Name( + Name { + node: Node { + start: 6868, + end: 6879, + }, + id: "wait_random", + }, ), - AssignStatement( - Assign { + args: [], + keywords: [ + Keyword { node: Node { - start: 8051, - end: 8071, + start: 6880, + end: 6885, }, - targets: [ - Name( - Name { - node: Node { - start: 8051, - end: 8055, - }, - id: "data", - }, - ), - ], - value: Attribute( - Attribute { + arg: Some( + "min", + ), + value: Constant( + Constant { node: Node { - start: 8058, - end: 8071, + start: 6884, + end: 6885, }, - value: Name( - Name { - node: Node { - start: 8058, - end: 8066, - }, - id: "response", - }, + value: Int( + "1", ), - attr: "text", }, ), }, - ), - IfStatement( - If { + Keyword { node: Node { - start: 8076, - end: 8288, + start: 6887, + end: 6892, }, - test: BoolOp( - BoolOperation { + arg: Some( + "max", + ), + value: Constant( + Constant { node: Node { - start: 8079, - end: 8125, + start: 6891, + end: 6892, }, - op: Or, - values: [ - UnaryOp( - UnaryOperation { - node: Node { - start: 8079, - end: 8087, - }, - op: Not, - operand: Name( - Name { - node: Node { - start: 8083, - end: 8087, - }, - id: "data", - }, - ), - }, - ), - BoolOp( - BoolOperation { - node: Node { - start: 8091, - end: 8125, - }, - op: Or, - values: [ - Compare( - Compare { - node: Node { - start: 8091, - end: 8106, - }, - left: Constant( - Constant { - node: Node { - start: 8091, - end: 8094, - }, - value: Str( - ";", - ), - }, - ), - ops: [ - NotIn, - ], - comparators: [ - Name( - Name { - node: Node { - start: 8102, - end: 8106, - }, - id: "data", - }, - ), - ], - }, - ), - Compare( - Compare { - node: Node { - start: 8110, - end: 8125, - }, - left: Constant( - Constant { - node: Node { - start: 8110, - end: 8113, - }, - value: Str( - ",", - ), - }, - ), - ops: [ - NotIn, - ], - comparators: [ - Name( - Name { - node: Node { - start: 8121, - end: 8125, - }, - id: "data", - }, - ), - ], - }, - ), - ], - }, - ), - ], + value: Int( + "4", + ), }, ), - body: [ - Raise( - Raise { - node: Node { - start: 8135, - end: 8283, - }, - exc: Some( - Call( - Call { - node: Node { - start: 8141, - end: 8283, - }, - func: Name( - Name { - node: Node { - start: 8141, - end: 8151, - }, - id: "ValueError", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 8165, - end: 8273, - }, - values: [ - Constant( - Constant { - node: Node { - start: 8200, - end: 0, - }, - value: Str( - "Invalid response from the url: ", - ), - }, - ), - Name( - Name { - node: Node { - start: 8201, - end: 8204, - }, - id: "url", - }, - ), - Constant( - Constant { - node: Node { - start: 8270, - end: 0, - }, - value: Str( - ".\n \\nExpected valid financial index data.", - ), - }, - ), - ], - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - cause: None, - }, - ), - ], - orelse: [], }, - ), - AssignStatement( - Assign { + ], + starargs: None, + kwargs: None, + }, + ), + }, + Keyword { + node: Node { + start: 6899, + end: 6951, + }, + arg: Some( + "before_sleep", + ), + value: Call( + Call { + node: Node { + start: 6912, + end: 6951, + }, + func: Name( + Name { node: Node { - start: 8288, - end: 8341, + start: 6912, + end: 6928, }, - targets: [ - Name( - Name { - node: Node { - start: 8288, - end: 8290, - }, - id: "df", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 8293, - end: 8341, - }, - func: Name( - Name { - node: Node { - start: 8293, - end: 8335, - }, - id: "_create_financial_index_from_text_response", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 8336, - end: 8340, - }, - id: "data", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), + id: "before_sleep_log", }, ), - Return( - Return { - node: Node { - start: 8346, - end: 8355, + args: [ + Name( + Name { + node: Node { + start: 6929, + end: 6935, + }, + id: "logger", }, - value: Some( - Name( + ), + Attribute( + Attribute { + node: Node { + start: 6937, + end: 6950, + }, + value: Name( Name { node: Node { - start: 8353, - end: 8355, + start: 6937, + end: 6944, }, - id: "df", + id: "logging", }, ), - ), - }, - ), - ], - decorator_list: [ - Call( - Call { - node: Node { - start: 7465, - end: 7613, + attr: "DEBUG", }, - func: Name( - Name { - node: Node { - start: 7465, - end: 7470, - }, - id: "retry", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 7476, - end: 7516, - }, - arg: Some( - "retry", - ), - value: Call( - Call { - node: Node { - start: 7482, - end: 7516, - }, - func: Name( - Name { - node: Node { - start: 7482, - end: 7505, - }, - id: "retry_if_exception_type", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 7506, - end: 7515, - }, - id: "HTTPError", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - Keyword { - node: Node { - start: 7522, - end: 7552, - }, - arg: Some( - "wait", - ), - value: Call( - Call { - node: Node { - start: 7527, - end: 7552, - }, - func: Name( - Name { - node: Node { - start: 7527, - end: 7538, - }, - id: "wait_random", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 7539, - end: 7544, - }, - arg: Some( - "min", - ), - value: Constant( - Constant { - node: Node { - start: 7543, - end: 7544, - }, - value: Int( - "1", - ), - }, - ), - }, - Keyword { - node: Node { - start: 7546, - end: 7551, - }, - arg: Some( - "max", - ), - value: Constant( - Constant { - node: Node { - start: 7550, - end: 7551, - }, - value: Int( - "4", - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - Keyword { - node: Node { - start: 7558, - end: 7610, - }, - arg: Some( - "before_sleep", - ), - value: Call( - Call { - node: Node { - start: 7571, - end: 7610, - }, - func: Name( - Name { - node: Node { - start: 7571, - end: 7587, - }, - id: "before_sleep_log", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 7588, - end: 7594, - }, - id: "logger", - }, - ), - Attribute( - Attribute { - node: Node { - start: 7596, - end: 7609, - }, - value: Name( - Name { - node: Node { - start: 7596, - end: 7603, - }, - id: "logging", - }, - ), - attr: "DEBUG", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ], - returns: None, - type_comment: None, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + ], + returns: None, + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 7614, + end: 8358, + }, + name: "download_fIndex_record", + args: Arguments { + node: Node { + start: 7641, + end: 7670, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 7641, + end: 7652, + }, + arg: "fIndex", + annotation: Some( + Name( + Name { + node: Node { + start: 7649, + end: 7652, + }, + id: "str", + }, + ), + ), + }, + Arg { + node: Node { + start: 7654, + end: 7670, + }, + arg: "session", + annotation: Some( + Name( + Name { + node: Node { + start: 7663, + end: 7670, + }, + id: "Session", }, ), - FunctionDef( - FunctionDef { + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 7677, + end: 7750, + }, + targets: [ + Name( + Name { node: Node { - start: 8358, - end: 15273, + start: 7677, + end: 7680, }, - name: "download_financial_indexes", - args: Arguments { + id: "url", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 7742, + end: 7750, + }, + func: Attribute( + Attribute { node: Node { - start: 8394, - end: 8540, + start: 7683, + end: 7742, }, - posonlyargs: [], - args: [ - Arg { + value: Attribute( + Attribute { node: Node { - start: 8394, - end: 8419, + start: 7683, + end: 7735, }, - arg: "symbols", - annotation: Some( - Subscript( - Subscript { - node: Node { - start: 8403, - end: 8419, - }, - value: Name( - Name { - node: Node { - start: 8403, - end: 8408, - }, - id: "Union", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 8409, - end: 8419, - }, - elements: [ - Name( - Name { - node: Node { - start: 8409, - end: 8413, - }, - id: "List", - }, - ), - Name( - Name { - node: Node { - start: 8415, - end: 8418, - }, - id: "str", - }, - ), - ], - }, - ), + value: Name( + Name { + node: Node { + start: 7683, + end: 7695, }, - ), + id: "tse_settings", + }, ), + attr: "TSE_FINANCIAL_INDEX_EXPORT_DATA_ADDRESS", }, - Arg { - node: Node { - start: 8425, - end: 8451, - }, - arg: "write_to_csv", - annotation: Some( - Name( - Name { - node: Node { - start: 8439, - end: 8443, - }, - id: "bool", - }, - ), - ), + ), + attr: "format", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 7743, + end: 7749, }, - Arg { + id: "fIndex", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 7755, + end: 7794, + }, + targets: [ + Name( + Name { + node: Node { + start: 7755, + end: 7763, + }, + id: "response", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 7777, + end: 7794, + }, + func: Attribute( + Attribute { + node: Node { + start: 7766, + end: 7777, + }, + value: Name( + Name { node: Node { - start: 8457, - end: 8484, + start: 7766, + end: 7773, }, - arg: "include_jdate", - annotation: Some( - Name( - Name { - node: Node { - start: 8472, - end: 8476, - }, - id: "bool", - }, - ), - ), + id: "session", + }, + ), + attr: "get", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 7778, + end: 7781, }, - Arg { + id: "url", + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 7783, + end: 7793, + }, + arg: Some( + "timeout", + ), + value: Constant( + Constant { node: Node { - start: 8490, - end: 8539, + start: 7791, + end: 7793, }, - arg: "base_path", - annotation: Some( - Name( - Name { - node: Node { - start: 8501, - end: 8504, - }, - id: "str", - }, - ), + value: Int( + "10", ), }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [ - Constant( - Constant { + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 7799, + end: 8019, + }, + test: Compare( + Compare { + node: Node { + start: 7802, + end: 7835, + }, + left: Constant( + Constant { + node: Node { + start: 7802, + end: 7805, + }, + value: Int( + "400", + ), + }, + ), + ops: [ + LtE, + Lt, + ], + comparators: [ + Attribute( + Attribute { + node: Node { + start: 7809, + end: 7829, + }, + value: Name( + Name { node: Node { - start: 8446, - end: 8451, + start: 7809, + end: 7817, }, - value: Bool( - false, - ), + id: "response", }, ), - Constant( - Constant { - node: Node { - start: 8479, - end: 8484, - }, - value: Bool( - false, - ), - }, + attr: "status_code", + }, + ), + Constant( + Constant { + node: Node { + start: 7832, + end: 7835, + }, + value: Int( + "500", ), - Attribute( - Attribute { + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 7857, + end: 8013, + }, + func: Attribute( + Attribute { + node: Node { + start: 7845, + end: 7857, + }, + value: Name( + Name { + node: Node { + start: 7845, + end: 7851, + }, + id: "logger", + }, + ), + attr: "error", + }, + ), + args: [ + JoinedStr( + JoinedStr { node: Node { - start: 8507, - end: 8539, + start: 7871, + end: 7925, }, - value: Name( - Name { - node: Node { - start: 8507, - end: 8513, + values: [ + Constant( + Constant { + node: Node { + start: 7919, + end: 0, + }, + value: Str( + "Cannot read daily trade records from the url: ", + ), }, - id: "config", - }, - ), - attr: "FINANCIAL_INDEX_BASE_PATH", + ), + Name( + Name { + node: Node { + start: 7920, + end: 7923, + }, + id: "url", + }, + ), + ], }, ), ], - }, - body: [ - IfStatement( - If { + keywords: [ + Keyword { node: Node { - start: 8575, - end: 8717, + start: 7939, + end: 8002, }, - test: Compare( - Compare { + arg: Some( + "extra", + ), + value: Dict( + Dict { node: Node { - start: 8578, - end: 8594, + start: 7945, + end: 8002, }, - left: Name( - Name { - node: Node { - start: 8578, - end: 8585, + keys: [ + Constant( + Constant { + node: Node { + start: 7946, + end: 7956, + }, + value: Str( + "response", + ), }, - id: "symbols", - }, - ), - ops: [ - Eq, - ], - comparators: [ + ), Constant( Constant { node: Node { - start: 8589, - end: 8594, + start: 7973, + end: 7979, }, value: Str( - "all", + "code", ), }, ), ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 8604, - end: 8648, - }, - targets: [ - Name( - Name { - node: Node { - start: 8604, - end: 8611, - }, - id: "symbols", - }, - ), - ], - value: Call( - Call { + values: [ + Attribute( + Attribute { node: Node { - start: 8646, - end: 8648, + start: 7958, + end: 7971, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 8614, - end: 8646, + start: 7958, + end: 7966, }, - value: Name( - Name { - node: Node { - start: 8614, - end: 8626, - }, - id: "symbols_data", - }, - ), - attr: "all_financial_index", + id: "response", }, ), - args: [], - keywords: [], - starargs: None, - kwargs: None, + attr: "text", }, ), - }, - ), - ], - orelse: [ - IfStatement( - If { - node: Node { - start: 8653, - end: 8717, - }, - test: Call( - Call { + Attribute( + Attribute { node: Node { - start: 8658, - end: 8682, + start: 7981, + end: 8001, }, - func: Name( + value: Name( Name { node: Node { - start: 8658, - end: 8668, + start: 7981, + end: 7989, }, - id: "isinstance", + id: "response", }, ), - args: [ - Name( - Name { - node: Node { - start: 8669, - end: 8676, - }, - id: "symbols", - }, - ), - Name( - Name { - node: Node { - start: 8678, - end: 8681, - }, - id: "str", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + attr: "status_code", }, ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 8692, - end: 8711, - }, - targets: [ - Name( - Name { - node: Node { - start: 8692, - end: 8699, - }, - id: "symbols", - }, - ), - ], - value: List( - List { - node: Node { - start: 8702, - end: 8711, - }, - elements: [ - Name( - Name { - node: Node { - start: 8703, - end: 8710, - }, - id: "symbols", - }, - ), - ], - }, - ), - }, - ), - ], - orelse: [], - }, - ), - ], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 8717, - end: 8729, - }, - targets: [ - Name( - Name { - node: Node { - start: 8717, - end: 8724, - }, - id: "df_list", - }, - ), - ], - value: Dict( - Dict { - node: Node { - start: 8727, - end: 8729, - }, - keys: [], - values: [], - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 8734, - end: 8755, - }, - targets: [ - Name( - Name { - node: Node { - start: 8734, - end: 8750, - }, - id: "future_to_symbol", - }, - ), - ], - value: Dict( - Dict { - node: Node { - start: 8753, - end: 8755, - }, - keys: [], - values: [], + ], }, ), }, - ), - WithStatement( - With { - node: Node { - start: 8760, - end: 10374, - }, - items: [ - WithItem { - node: Node { - start: 8765, - end: 8819, + ], + starargs: None, + kwargs: None, + }, + ), + ), + ], + orelse: [], + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 8044, + end: 8046, + }, + func: Attribute( + Attribute { + node: Node { + start: 8019, + end: 8044, + }, + value: Name( + Name { + node: Node { + start: 8019, + end: 8027, + }, + id: "response", + }, + ), + attr: "raise_for_status", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + AssignStatement( + Assign { + node: Node { + start: 8051, + end: 8071, + }, + targets: [ + Name( + Name { + node: Node { + start: 8051, + end: 8055, + }, + id: "data", + }, + ), + ], + value: Attribute( + Attribute { + node: Node { + start: 8058, + end: 8071, + }, + value: Name( + Name { + node: Node { + start: 8058, + end: 8066, + }, + id: "response", + }, + ), + attr: "text", + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 8076, + end: 8288, + }, + test: BoolOp( + BoolOperation { + node: Node { + start: 8079, + end: 8125, + }, + op: Or, + values: [ + UnaryOp( + UnaryOperation { + node: Node { + start: 8079, + end: 8087, + }, + op: Not, + operand: Name( + Name { + node: Node { + start: 8083, + end: 8087, + }, + id: "data", + }, + ), + }, + ), + BoolOp( + BoolOperation { + node: Node { + start: 8091, + end: 8125, + }, + op: Or, + values: [ + Compare( + Compare { + node: Node { + start: 8091, + end: 8106, }, - context_expr: Call( - Call { + left: Constant( + Constant { node: Node { - start: 8791, - end: 8807, + start: 8091, + end: 8094, }, - func: Attribute( - Attribute { - node: Node { - start: 8765, - end: 8791, - }, - value: Name( - Name { - node: Node { - start: 8765, - end: 8772, - }, - id: "futures", - }, - ), - attr: "ThreadPoolExecutor", - }, + value: Str( + ";", ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 8792, - end: 8806, - }, - arg: Some( - "max_workers", - ), - value: Constant( - Constant { - node: Node { - start: 8804, - end: 8806, - }, - value: Int( - "10", - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, }, ), - optional_vars: Some( + ops: [ + NotIn, + ], + comparators: [ Name( Name { node: Node { - start: 8811, - end: 8819, + start: 8102, + end: 8106, }, - id: "executor", + id: "data", }, ), - ), + ], }, - ], - body: [ - AssignStatement( - Assign { - node: Node { - start: 8829, - end: 8863, - }, - targets: [ - Name( - Name { - node: Node { - start: 8829, - end: 8836, - }, - id: "session", - }, + ), + Compare( + Compare { + node: Node { + start: 8110, + end: 8125, + }, + left: Constant( + Constant { + node: Node { + start: 8110, + end: 8113, + }, + value: Str( + ",", ), - ], - value: Call( - Call { + }, + ), + ops: [ + NotIn, + ], + comparators: [ + Name( + Name { node: Node { - start: 8839, - end: 8863, + start: 8121, + end: 8125, }, - func: Name( - Name { - node: Node { - start: 8839, - end: 8861, - }, - id: "requests_retry_session", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, + id: "data", }, ), + ], + }, + ), + ], + }, + ), + ], + }, + ), + body: [ + Raise( + Raise { + node: Node { + start: 8135, + end: 8283, + }, + exc: Some( + Call( + Call { + node: Node { + start: 8141, + end: 8283, + }, + func: Name( + Name { + node: Node { + start: 8141, + end: 8151, }, - ), - ForStatement( - For { + id: "ValueError", + }, + ), + args: [ + JoinedStr( + JoinedStr { node: Node { - start: 8872, - end: 9506, + start: 8165, + end: 8273, }, - target: Name( - Name { - node: Node { - start: 8876, - end: 8882, - }, - id: "symbol", - }, - ), - iter: Name( - Name { - node: Node { - start: 8886, - end: 8893, - }, - id: "symbols", - }, - ), - body: [ - AssignStatement( - Assign { + values: [ + Constant( + Constant { node: Node { - start: 8907, - end: 8947, + start: 8200, + end: 0, }, - targets: [ - Name( - Name { - node: Node { - start: 8907, - end: 8913, - }, - id: "symbol", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 8939, - end: 8947, - }, - func: Attribute( - Attribute { - node: Node { - start: 8916, - end: 8939, - }, - value: Name( - Name { - node: Node { - start: 8916, - end: 8923, - }, - id: "persian", - }, - ), - attr: "replace_persian", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 8940, - end: 8946, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, + value: Str( + "Invalid response from the url: ", ), }, ), - IfStatement( - If { + Name( + Name { node: Node { - start: 8960, - end: 9230, + start: 8201, + end: 8204, }, - test: BoolOp( - BoolOperation { - node: Node { - start: 8981, - end: 9068, - }, - op: And, - values: [ - Call( - Call { - node: Node { - start: 8997, - end: 8999, - }, - func: Attribute( - Attribute { - node: Node { - start: 8981, - end: 8997, - }, - value: Name( - Name { - node: Node { - start: 8981, - end: 8987, - }, - id: "symbol", - }, - ), - attr: "isnumeric", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - Compare( - Compare { - node: Node { - start: 9020, - end: 9068, - }, - left: Call( - Call { - node: Node { - start: 9052, - end: 9060, - }, - func: Attribute( - Attribute { - node: Node { - start: 9020, - end: 9052, - }, - value: Name( - Name { - node: Node { - start: 9020, - end: 9032, - }, - id: "symbols_data", - }, - ), - attr: "get_financial_index", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 9053, - end: 9059, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 9064, - end: 9068, - }, - value: None, - }, - ), - ], - }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 9100, - end: 9124, - }, - targets: [ - Name( - Name { - node: Node { - start: 9100, - end: 9115, - }, - id: "financial_index", - }, - ), - ], - value: Name( - Name { - node: Node { - start: 9118, - end: 9124, - }, - id: "symbol", - }, - ), - }, - ), - ], - orelse: [ - AssignStatement( - Assign { - node: Node { - start: 9159, - end: 9217, - }, - targets: [ - Name( - Name { - node: Node { - start: 9159, - end: 9174, - }, - id: "financial_index", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 9209, - end: 9217, - }, - func: Attribute( - Attribute { - node: Node { - start: 9177, - end: 9209, - }, - value: Name( - Name { - node: Node { - start: 9177, - end: 9189, - }, - id: "symbols_data", - }, - ), - attr: "get_financial_index", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 9210, - end: 9216, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - }, - ), - IfStatement( - If { - node: Node { - start: 9230, - end: 9345, - }, - test: Compare( - Compare { - node: Node { - start: 9233, - end: 9256, - }, - left: Name( - Name { - node: Node { - start: 9233, - end: 9248, - }, - id: "financial_index", - }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 9252, - end: 9256, - }, - value: None, - }, - ), - ], - }, - ), - body: [ - Raise( - Raise { - node: Node { - start: 9274, - end: 9331, - }, - exc: Some( - Call( - Call { - node: Node { - start: 9280, - end: 9331, - }, - func: Name( - Name { - node: Node { - start: 9280, - end: 9289, - }, - id: "Exception", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 9290, - end: 9330, - }, - values: [ - Constant( - Constant { - node: Node { - start: 9321, - end: 0, - }, - value: Str( - "Cannot find financial index: ", - ), - }, - ), - Name( - Name { - node: Node { - start: 9322, - end: 9328, - }, - id: "symbol", - }, - ), - ], - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - cause: None, - }, - ), - ], - orelse: [], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 9345, - end: 9449, - }, - targets: [ - Name( - Name { - node: Node { - start: 9345, - end: 9351, - }, - id: "future", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 9369, - end: 9449, - }, - func: Attribute( - Attribute { - node: Node { - start: 9354, - end: 9369, - }, - value: Name( - Name { - node: Node { - start: 9354, - end: 9362, - }, - id: "executor", - }, - ), - attr: "submit", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 9387, - end: 9409, - }, - id: "download_fIndex_record", - }, - ), - Name( - Name { - node: Node { - start: 9411, - end: 9426, - }, - id: "financial_index", - }, - ), - Name( - Name { - node: Node { - start: 9428, - end: 9435, - }, - id: "session", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), + id: "url", }, ), - AssignStatement( - Assign { + Constant( + Constant { node: Node { - start: 9463, - end: 9496, + start: 8270, + end: 0, }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 9463, - end: 9487, - }, - value: Name( - Name { - node: Node { - start: 9463, - end: 9479, - }, - id: "future_to_symbol", - }, - ), - slice: Name( - Name { - node: Node { - start: 9480, - end: 9486, - }, - id: "future", - }, - ), - }, - ), - ], - value: Name( - Name { - node: Node { - start: 9490, - end: 9496, - }, - id: "symbol", - }, + value: Str( + ".\n \\nExpected valid financial index data.", ), }, ), ], - orelse: [], }, ), - ForStatement( - For { - node: Node { - start: 9506, - end: 10231, - }, - target: Name( - Name { - node: Node { - start: 9510, - end: 9516, - }, - id: "future", - }, - ), - iter: Call( - Call { - node: Node { - start: 9540, - end: 9558, - }, - func: Attribute( - Attribute { - node: Node { - start: 9520, - end: 9540, - }, - value: Name( - Name { - node: Node { - start: 9520, - end: 9527, - }, - id: "futures", - }, - ), - attr: "as_completed", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 9541, - end: 9557, - }, - id: "future_to_symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 9572, - end: 9605, - }, - targets: [ - Name( - Name { - node: Node { - start: 9572, - end: 9578, - }, - id: "symbol", - }, - ), - ], - value: Subscript( - Subscript { - node: Node { - start: 9581, - end: 9605, - }, - value: Name( - Name { - node: Node { - start: 9581, - end: 9597, - }, - id: "future_to_symbol", - }, - ), - slice: Name( - Name { - node: Node { - start: 9598, - end: 9604, - }, - id: "future", - }, - ), - }, - ), - }, - ), - TryStatement( - Try { - node: Node { - start: 9618, - end: 9928, - }, - body: [ - AnnAssignStatement( - AnnAssign { - node: Node { - start: 9639, - end: 9673, - }, - target: Name( - Name { - node: Node { - start: 9639, - end: 9641, - }, - id: "df", - }, - ), - annotation: Attribute( - Attribute { - node: Node { - start: 9643, - end: 9655, - }, - value: Name( - Name { - node: Node { - start: 9643, - end: 9645, - }, - id: "pd", - }, - ), - attr: "DataFrame", - }, - ), - value: Some( - Call( - Call { - node: Node { - start: 9671, - end: 9673, - }, - func: Attribute( - Attribute { - node: Node { - start: 9658, - end: 9671, - }, - value: Name( - Name { - node: Node { - start: 9658, - end: 9664, - }, - id: "future", - }, - ), - attr: "result", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - simple: true, - }, - ), - ], - handlers: [ - ExceptHandler { - node: Node { - start: 9686, - end: 9928, - }, - typ: Some( - Attribute( - Attribute { - node: Node { - start: 9693, - end: 9717, - }, - value: Attribute( - Attribute { - node: Node { - start: 9693, - end: 9702, - }, - value: Name( - Name { - node: Node { - start: 9693, - end: 9695, - }, - id: "pd", - }, - ), - attr: "errors", - }, - ), - attr: "EmptyDataError", - }, - ), - ), - name: Some( - "ex", - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 9753, - end: 9890, - }, - func: Attribute( - Attribute { - node: Node { - start: 9741, - end: 9753, - }, - value: Name( - Name { - node: Node { - start: 9741, - end: 9747, - }, - id: "logger", - }, - ), - attr: "error", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 9775, - end: 9830, - }, - values: [ - Constant( - Constant { - node: Node { - start: 9821, - end: 0, - }, - value: Str( - "Cannot read daily trade records for symbol: ", - ), - }, - ), - Name( - Name { - node: Node { - start: 9822, - end: 9828, - }, - id: "symbol", - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 9852, - end: 9871, - }, - arg: Some( - "extra", - ), - value: Dict( - Dict { - node: Node { - start: 9858, - end: 9871, - }, - keys: [ - Constant( - Constant { - node: Node { - start: 9859, - end: 9866, - }, - value: Str( - "Error", - ), - }, - ), - ], - values: [ - Name( - Name { - node: Node { - start: 9868, - end: 9870, - }, - id: "ex", - }, - ), - ], - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - Continue( - Continue { - node: Node { - start: 9907, - end: 9915, - }, - }, - ), - ], - }, - ], - orelse: [], - finalbody: [], - }, - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 9928, - end: 9976, - }, - func: Name( - Name { - node: Node { - start: 9928, - end: 9957, - }, - id: "_adjust_data_frame_for_fIndex", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 9958, - end: 9960, - }, - id: "df", - }, - ), - Name( - Name { - node: Node { - start: 9962, - end: 9975, - }, - id: "include_jdate", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - AssignStatement( - Assign { - node: Node { - start: 9989, - end: 10009, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 9989, - end: 10004, - }, - value: Name( - Name { - node: Node { - start: 9989, - end: 9996, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 9997, - end: 10003, - }, - id: "symbol", - }, - ), - }, - ), - ], - value: Name( - Name { - node: Node { - start: 10007, - end: 10009, - }, - id: "df", - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 10023, - end: 10231, - }, - test: Name( - Name { - node: Node { - start: 10026, - end: 10038, - }, - id: "write_to_csv", - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 10077, - end: 10106, - }, - func: Attribute( - Attribute { - node: Node { - start: 10071, - end: 10077, - }, - value: Call( - Call { - node: Node { - start: 10056, - end: 10071, - }, - func: Name( - Name { - node: Node { - start: 10056, - end: 10060, - }, - id: "Path", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 10061, - end: 10070, - }, - id: "base_path", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "mkdir", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 10078, - end: 10090, - }, - arg: Some( - "parents", - ), - value: Constant( - Constant { - node: Node { - start: 10086, - end: 10090, - }, - value: Bool( - true, - ), - }, - ), - }, - Keyword { - node: Node { - start: 10092, - end: 10105, - }, - arg: Some( - "exist_ok", - ), - value: Constant( - Constant { - node: Node { - start: 10101, - end: 10105, - }, - value: Bool( - true, - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 10145, - end: 10225, - }, - func: Attribute( - Attribute { - node: Node { - start: 10138, - end: 10145, - }, - value: Subscript( - Subscript { - node: Node { - start: 10123, - end: 10138, - }, - value: Name( - Name { - node: Node { - start: 10123, - end: 10130, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 10131, - end: 10137, - }, - id: "symbol", - }, - ), - }, - ), - attr: "to_csv", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 10167, - end: 10194, - }, - values: [ - Name( - Name { - node: Node { - start: 10170, - end: 10179, - }, - id: "base_path", - }, - ), - Constant( - Constant { - node: Node { - start: 10181, - end: 0, - }, - value: Str( - "/", - ), - }, - ), - Name( - Name { - node: Node { - start: 10182, - end: 10188, - }, - id: "symbol", - }, - ), - Constant( - Constant { - node: Node { - start: 10193, - end: 0, - }, - value: Str( - ".csv", - ), - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 10196, - end: 10207, - }, - arg: Some( - "index", - ), - value: Constant( - Constant { - node: Node { - start: 10202, - end: 10207, - }, - value: Bool( - false, - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], - }, - ), - ], - orelse: [], + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + cause: None, + }, + ), + ], + orelse: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 8288, + end: 8341, + }, + targets: [ + Name( + Name { + node: Node { + start: 8288, + end: 8290, + }, + id: "df", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 8293, + end: 8341, + }, + func: Name( + Name { + node: Node { + start: 8293, + end: 8335, + }, + id: "_create_financial_index_from_text_response", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 8336, + end: 8340, + }, + id: "data", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + Return( + Return { + node: Node { + start: 8346, + end: 8355, + }, + value: Some( + Name( + Name { + node: Node { + start: 8353, + end: 8355, + }, + id: "df", + }, + ), + ), + }, + ), + ], + decorator_list: [ + Call( + Call { + node: Node { + start: 7465, + end: 7613, + }, + func: Name( + Name { + node: Node { + start: 7465, + end: 7470, + }, + id: "retry", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 7476, + end: 7516, + }, + arg: Some( + "retry", + ), + value: Call( + Call { + node: Node { + start: 7482, + end: 7516, + }, + func: Name( + Name { + node: Node { + start: 7482, + end: 7505, + }, + id: "retry_if_exception_type", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 7506, + end: 7515, + }, + id: "HTTPError", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + Keyword { + node: Node { + start: 7522, + end: 7552, + }, + arg: Some( + "wait", + ), + value: Call( + Call { + node: Node { + start: 7527, + end: 7552, + }, + func: Name( + Name { + node: Node { + start: 7527, + end: 7538, + }, + id: "wait_random", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 7539, + end: 7544, + }, + arg: Some( + "min", + ), + value: Constant( + Constant { + node: Node { + start: 7543, + end: 7544, + }, + value: Int( + "1", + ), + }, + ), + }, + Keyword { + node: Node { + start: 7546, + end: 7551, + }, + arg: Some( + "max", + ), + value: Constant( + Constant { + node: Node { + start: 7550, + end: 7551, + }, + value: Int( + "4", + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + Keyword { + node: Node { + start: 7558, + end: 7610, + }, + arg: Some( + "before_sleep", + ), + value: Call( + Call { + node: Node { + start: 7571, + end: 7610, + }, + func: Name( + Name { + node: Node { + start: 7571, + end: 7587, + }, + id: "before_sleep_log", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 7588, + end: 7594, + }, + id: "logger", + }, + ), + Attribute( + Attribute { + node: Node { + start: 7596, + end: 7609, + }, + value: Name( + Name { + node: Node { + start: 7596, + end: 7603, + }, + id: "logging", + }, + ), + attr: "DEBUG", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + ], + returns: None, + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 8358, + end: 10374, + }, + name: "download_financial_indexes", + args: Arguments { + node: Node { + start: 8394, + end: 8540, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 8394, + end: 8419, + }, + arg: "symbols", + annotation: Some( + Subscript( + Subscript { + node: Node { + start: 8403, + end: 8419, + }, + value: Name( + Name { + node: Node { + start: 8403, + end: 8408, + }, + id: "Union", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 8409, + end: 8419, + }, + elements: [ + Name( + Name { + node: Node { + start: 8409, + end: 8413, + }, + id: "List", + }, + ), + Name( + Name { + node: Node { + start: 8415, + end: 8418, + }, + id: "str", + }, + ), + ], + }, + ), + }, + ), + ), + }, + Arg { + node: Node { + start: 8425, + end: 8451, + }, + arg: "write_to_csv", + annotation: Some( + Name( + Name { + node: Node { + start: 8439, + end: 8443, + }, + id: "bool", + }, + ), + ), + }, + Arg { + node: Node { + start: 8457, + end: 8484, + }, + arg: "include_jdate", + annotation: Some( + Name( + Name { + node: Node { + start: 8472, + end: 8476, + }, + id: "bool", + }, + ), + ), + }, + Arg { + node: Node { + start: 8490, + end: 8539, + }, + arg: "base_path", + annotation: Some( + Name( + Name { + node: Node { + start: 8501, + end: 8504, + }, + id: "str", + }, + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [ + Constant( + Constant { + node: Node { + start: 8446, + end: 8451, + }, + value: Bool( + false, + ), + }, + ), + Constant( + Constant { + node: Node { + start: 8479, + end: 8484, + }, + value: Bool( + false, + ), + }, + ), + Attribute( + Attribute { + node: Node { + start: 8507, + end: 8539, + }, + value: Name( + Name { + node: Node { + start: 8507, + end: 8513, + }, + id: "config", + }, + ), + attr: "FINANCIAL_INDEX_BASE_PATH", + }, + ), + ], + }, + body: [ + IfStatement( + If { + node: Node { + start: 8575, + end: 8717, + }, + test: Compare( + Compare { + node: Node { + start: 8578, + end: 8594, + }, + left: Name( + Name { + node: Node { + start: 8578, + end: 8585, + }, + id: "symbols", + }, + ), + ops: [ + Eq, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 8589, + end: 8594, + }, + value: Str( + "all", + ), + }, + ), + ], + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 8604, + end: 8648, + }, + targets: [ + Name( + Name { + node: Node { + start: 8604, + end: 8611, + }, + id: "symbols", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 8646, + end: 8648, + }, + func: Attribute( + Attribute { + node: Node { + start: 8614, + end: 8646, + }, + value: Name( + Name { + node: Node { + start: 8614, + end: 8626, + }, + id: "symbols_data", }, ), - IfStatement( - If { + attr: "all_financial_index", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ], + orelse: [ + IfStatement( + If { + node: Node { + start: 8653, + end: 8717, + }, + test: Call( + Call { + node: Node { + start: 8658, + end: 8682, + }, + func: Name( + Name { + node: Node { + start: 8658, + end: 8668, + }, + id: "isinstance", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 8669, + end: 8676, + }, + id: "symbols", + }, + ), + Name( + Name { + node: Node { + start: 8678, + end: 8681, + }, + id: "str", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 8692, + end: 8711, + }, + targets: [ + Name( + Name { + node: Node { + start: 8692, + end: 8699, + }, + id: "symbols", + }, + ), + ], + value: List( + List { + node: Node { + start: 8702, + end: 8711, + }, + elements: [ + Name( + Name { + node: Node { + start: 8703, + end: 8710, + }, + id: "symbols", + }, + ), + ], + }, + ), + }, + ), + ], + orelse: [], + }, + ), + ], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 8717, + end: 8729, + }, + targets: [ + Name( + Name { + node: Node { + start: 8717, + end: 8724, + }, + id: "df_list", + }, + ), + ], + value: Dict( + Dict { + node: Node { + start: 8727, + end: 8729, + }, + keys: [], + values: [], + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 8734, + end: 8755, + }, + targets: [ + Name( + Name { + node: Node { + start: 8734, + end: 8750, + }, + id: "future_to_symbol", + }, + ), + ], + value: Dict( + Dict { + node: Node { + start: 8753, + end: 8755, + }, + keys: [], + values: [], + }, + ), + }, + ), + WithStatement( + With { + node: Node { + start: 8760, + end: 10231, + }, + items: [ + WithItem { + node: Node { + start: 8765, + end: 8819, + }, + context_expr: Call( + Call { + node: Node { + start: 8791, + end: 8807, + }, + func: Attribute( + Attribute { + node: Node { + start: 8765, + end: 8791, + }, + value: Name( + Name { + node: Node { + start: 8765, + end: 8772, + }, + id: "futures", + }, + ), + attr: "ThreadPoolExecutor", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 8792, + end: 8806, + }, + arg: Some( + "max_workers", + ), + value: Constant( + Constant { + node: Node { + start: 8804, + end: 8806, + }, + value: Int( + "10", + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + optional_vars: Some( + Name( + Name { + node: Node { + start: 8811, + end: 8819, + }, + id: "executor", + }, + ), + ), + }, + ], + body: [ + AssignStatement( + Assign { + node: Node { + start: 8829, + end: 8863, + }, + targets: [ + Name( + Name { + node: Node { + start: 8829, + end: 8836, + }, + id: "session", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 8839, + end: 8863, + }, + func: Name( + Name { + node: Node { + start: 8839, + end: 8861, + }, + id: "requests_retry_session", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ForStatement( + For { + node: Node { + start: 8872, + end: 9506, + }, + target: Name( + Name { + node: Node { + start: 8876, + end: 8882, + }, + id: "symbol", + }, + ), + iter: Name( + Name { + node: Node { + start: 8886, + end: 8893, + }, + id: "symbols", + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 8907, + end: 8947, + }, + targets: [ + Name( + Name { node: Node { - start: 10231, - end: 10337, + start: 8907, + end: 8913, }, - test: Compare( - Compare { - node: Node { - start: 10234, - end: 10262, - }, - left: Call( - Call { - node: Node { - start: 10234, - end: 10246, - }, - func: Name( - Name { - node: Node { - start: 10234, - end: 10237, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 10238, - end: 10245, - }, - id: "df_list", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - NotEq, - ], - comparators: [ - Call( - Call { - node: Node { - start: 10250, - end: 10262, - }, - func: Name( - Name { - node: Node { - start: 10250, - end: 10253, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 10254, - end: 10261, - }, - id: "symbols", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 10272, - end: 10332, - }, - func: Name( - Name { - node: Node { - start: 10272, - end: 10277, - }, - id: "print", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 10278, - end: 10331, - }, - value: Str( - "Warning, download did not complete, re-run the code", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], + id: "symbol", }, ), - ExpressionStatement( - Call( - Call { + ], + value: Call( + Call { + node: Node { + start: 8939, + end: 8947, + }, + func: Attribute( + Attribute { node: Node { - start: 10350, - end: 10352, + start: 8916, + end: 8939, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 10337, - end: 10350, + start: 8916, + end: 8923, }, - value: Name( - Name { - node: Node { - start: 10337, - end: 10344, - }, - id: "session", - }, - ), - attr: "close", + id: "persian", }, ), - args: [], - keywords: [], - starargs: None, - kwargs: None, + attr: "replace_persian", }, ), - ), - Return( - Return { - node: Node { - start: 10357, - end: 10371, - }, - value: Some( - Name( - Name { - node: Node { - start: 10364, - end: 10371, - }, - id: "df_list", + args: [ + Name( + Name { + node: Node { + start: 8940, + end: 8946, }, - ), + id: "symbol", + }, ), - }, - ), - ], + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), }, ), - FunctionDef( - FunctionDef { + IfStatement( + If { node: Node { - start: 10374, - end: 15273, + start: 8960, + end: 9230, }, - name: "download_client_types_records", - args: Arguments { - node: Node { - start: 10413, - end: 10561, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 10413, - end: 10438, - }, - arg: "symbols", - annotation: Some( - Subscript( - Subscript { - node: Node { - start: 10422, - end: 10438, - }, - value: Name( - Name { - node: Node { - start: 10422, - end: 10427, - }, - id: "Union", + test: BoolOp( + BoolOperation { + node: Node { + start: 8981, + end: 9068, + }, + op: And, + values: [ + Call( + Call { + node: Node { + start: 8997, + end: 8999, + }, + func: Attribute( + Attribute { + node: Node { + start: 8981, + end: 8997, }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 10428, - end: 10438, + value: Name( + Name { + node: Node { + start: 8981, + end: 8987, + }, + id: "symbol", }, - elements: [ - Name( + ), + attr: "isnumeric", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + Compare( + Compare { + node: Node { + start: 9020, + end: 9068, + }, + left: Call( + Call { + node: Node { + start: 9052, + end: 9060, + }, + func: Attribute( + Attribute { + node: Node { + start: 9020, + end: 9052, + }, + value: Name( Name { node: Node { - start: 10428, - end: 10432, + start: 9020, + end: 9032, }, - id: "List", + id: "symbols_data", }, ), - Name( - Name { - node: Node { - start: 10434, - end: 10437, - }, - id: "str", + attr: "get_financial_index", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 9053, + end: 9059, }, - ), - ], + id: "symbol", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ops: [ + Is, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 9064, + end: 9068, + }, + value: None, }, ), - }, - ), + ], + }, ), - }, - Arg { + ], + }, + ), + body: [ + AssignStatement( + Assign { node: Node { - start: 10444, - end: 10470, + start: 9100, + end: 9124, }, - arg: "write_to_csv", - annotation: Some( + targets: [ Name( Name { node: Node { - start: 10458, - end: 10462, + start: 9100, + end: 9115, }, - id: "bool", + id: "financial_index", }, ), - ), - }, - Arg { - node: Node { - start: 10476, - end: 10503, - }, - arg: "include_jdate", - annotation: Some( - Name( - Name { - node: Node { - start: 10491, - end: 10495, - }, - id: "bool", + ], + value: Name( + Name { + node: Node { + start: 9118, + end: 9124, }, - ), + id: "symbol", + }, ), }, - Arg { + ), + ], + orelse: [ + AssignStatement( + Assign { node: Node { - start: 10509, - end: 10560, + start: 9159, + end: 9217, }, - arg: "base_path", - annotation: Some( + targets: [ Name( Name { node: Node { - start: 10520, - end: 10523, - }, - id: "str", - }, - ), - ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [ - Constant( - Constant { - node: Node { - start: 10465, - end: 10470, - }, - value: Bool( - false, - ), - }, - ), - Constant( - Constant { - node: Node { - start: 10498, - end: 10503, - }, - value: Bool( - false, - ), - }, - ), - Attribute( - Attribute { - node: Node { - start: 10526, - end: 10560, - }, - value: Name( - Name { - node: Node { - start: 10526, - end: 10532, + start: 9159, + end: 9174, }, - id: "config", + id: "financial_index", }, ), - attr: "CLIENT_TYPES_DATA_BASE_PATH", - }, - ), - ], - }, - body: [ - IfStatement( - If { - node: Node { - start: 10569, - end: 10703, - }, - test: Compare( - Compare { + ], + value: Call( + Call { node: Node { - start: 10572, - end: 10588, + start: 9209, + end: 9217, }, - left: Name( - Name { + func: Attribute( + Attribute { node: Node { - start: 10572, - end: 10579, - }, - id: "symbols", - }, - ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 10583, - end: 10588, - }, - value: Str( - "all", - ), + start: 9177, + end: 9209, }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 10598, - end: 10634, - }, - targets: [ - Name( + value: Name( Name { node: Node { - start: 10598, - end: 10605, + start: 9177, + end: 9189, }, - id: "symbols", + id: "symbols_data", }, ), - ], - value: Call( - Call { + attr: "get_financial_index", + }, + ), + args: [ + Name( + Name { node: Node { - start: 10632, - end: 10634, + start: 9210, + end: 9216, }, - func: Attribute( - Attribute { - node: Node { - start: 10608, - end: 10632, - }, - value: Name( - Name { - node: Node { - start: 10608, - end: 10620, - }, - id: "symbols_data", - }, - ), - attr: "all_symbols", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, + id: "symbol", }, ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ], + }, + ), + IfStatement( + If { + node: Node { + start: 9230, + end: 9345, + }, + test: Compare( + Compare { + node: Node { + start: 9233, + end: 9256, + }, + left: Name( + Name { + node: Node { + start: 9233, + end: 9248, + }, + id: "financial_index", + }, + ), + ops: [ + Is, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 9252, + end: 9256, }, - ), - ], - orelse: [ - IfStatement( - If { + value: None, + }, + ), + ], + }, + ), + body: [ + Raise( + Raise { + node: Node { + start: 9274, + end: 9331, + }, + exc: Some( + Call( + Call { node: Node { - start: 10639, - end: 10703, + start: 9280, + end: 9331, }, - test: Call( - Call { + func: Name( + Name { node: Node { - start: 10644, - end: 10668, + start: 9280, + end: 9289, }, - func: Name( - Name { - node: Node { - start: 10644, - end: 10654, - }, - id: "isinstance", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 10655, - end: 10662, - }, - id: "symbols", - }, - ), - Name( - Name { - node: Node { - start: 10664, - end: 10667, - }, - id: "str", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "Exception", }, ), - body: [ - AssignStatement( - Assign { + args: [ + JoinedStr( + JoinedStr { node: Node { - start: 10678, - end: 10697, + start: 9290, + end: 9330, }, - targets: [ - Name( - Name { + values: [ + Constant( + Constant { node: Node { - start: 10678, - end: 10685, + start: 9321, + end: 0, }, - id: "symbols", + value: Str( + "Cannot find financial index: ", + ), }, ), - ], - value: List( - List { - node: Node { - start: 10688, - end: 10697, + Name( + Name { + node: Node { + start: 9322, + end: 9328, + }, + id: "symbol", }, - elements: [ - Name( - Name { - node: Node { - start: 10689, - end: 10696, - }, - id: "symbols", - }, - ), - ], - }, - ), + ), + ], }, ), ], - orelse: [], + keywords: [], + starargs: None, + kwargs: None, }, ), - ], + ), + cause: None, }, ), - AssignStatement( - Assign { + ], + orelse: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 9345, + end: 9449, + }, + targets: [ + Name( + Name { node: Node { - start: 10703, - end: 10715, + start: 9345, + end: 9351, }, - targets: [ - Name( + id: "future", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 9369, + end: 9449, + }, + func: Attribute( + Attribute { + node: Node { + start: 9354, + end: 9369, + }, + value: Name( Name { node: Node { - start: 10703, - end: 10710, + start: 9354, + end: 9362, }, - id: "df_list", + id: "executor", }, ), - ], - value: Dict( - Dict { + attr: "submit", + }, + ), + args: [ + Name( + Name { node: Node { - start: 10713, - end: 10715, + start: 9387, + end: 9409, }, - keys: [], - values: [], + id: "download_fIndex_record", }, ), - }, - ), - AssignStatement( - Assign { + Name( + Name { + node: Node { + start: 9411, + end: 9426, + }, + id: "financial_index", + }, + ), + Name( + Name { + node: Node { + start: 9428, + end: 9435, + }, + id: "session", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 9463, + end: 9496, + }, + targets: [ + Subscript( + Subscript { node: Node { - start: 10720, - end: 10741, + start: 9463, + end: 9487, }, - targets: [ - Name( - Name { - node: Node { - start: 10720, - end: 10736, - }, - id: "future_to_symbol", + value: Name( + Name { + node: Node { + start: 9463, + end: 9479, }, - ), - ], - value: Dict( - Dict { + id: "future_to_symbol", + }, + ), + slice: Name( + Name { node: Node { - start: 10739, - end: 10741, + start: 9480, + end: 9486, }, - keys: [], - values: [], + id: "future", }, ), }, ), - WithStatement( - With { + ], + value: Name( + Name { + node: Node { + start: 9490, + end: 9496, + }, + id: "symbol", + }, + ), + }, + ), + ], + orelse: [], + }, + ), + ForStatement( + For { + node: Node { + start: 9506, + end: 10231, + }, + target: Name( + Name { + node: Node { + start: 9510, + end: 9516, + }, + id: "future", + }, + ), + iter: Call( + Call { + node: Node { + start: 9540, + end: 9558, + }, + func: Attribute( + Attribute { + node: Node { + start: 9520, + end: 9540, + }, + value: Name( + Name { + node: Node { + start: 9520, + end: 9527, + }, + id: "futures", + }, + ), + attr: "as_completed", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 9541, + end: 9557, + }, + id: "future_to_symbol", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 9572, + end: 9605, + }, + targets: [ + Name( + Name { + node: Node { + start: 9572, + end: 9578, + }, + id: "symbol", + }, + ), + ], + value: Subscript( + Subscript { + node: Node { + start: 9581, + end: 9605, + }, + value: Name( + Name { + node: Node { + start: 9581, + end: 9597, + }, + id: "future_to_symbol", + }, + ), + slice: Name( + Name { + node: Node { + start: 9598, + end: 9604, + }, + id: "future", + }, + ), + }, + ), + }, + ), + TryStatement( + Try { + node: Node { + start: 9618, + end: 9928, + }, + body: [ + AnnAssignStatement( + AnnAssign { node: Node { - start: 10746, - end: 11849, + start: 9639, + end: 9673, }, - items: [ - WithItem { + target: Name( + Name { node: Node { - start: 10751, - end: 10805, + start: 9639, + end: 9641, }, - context_expr: Call( - Call { - node: Node { - start: 10777, - end: 10793, - }, - func: Attribute( - Attribute { - node: Node { - start: 10751, - end: 10777, - }, - value: Name( - Name { - node: Node { - start: 10751, - end: 10758, - }, - id: "futures", - }, - ), - attr: "ThreadPoolExecutor", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 10778, - end: 10792, - }, - arg: Some( - "max_workers", - ), - value: Constant( - Constant { - node: Node { - start: 10790, - end: 10792, - }, - value: Int( - "10", - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - optional_vars: Some( - Name( - Name { - node: Node { - start: 10797, - end: 10805, - }, - id: "executor", - }, - ), - ), + id: "df", }, - ], - body: [ - ForStatement( - For { - node: Node { - start: 10815, - end: 11168, - }, - target: Name( - Name { - node: Node { - start: 10819, - end: 10825, - }, - id: "symbol", - }, - ), - iter: Name( - Name { - node: Node { - start: 10829, - end: 10836, - }, - id: "symbols", - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 10850, - end: 10893, - }, - targets: [ - Name( - Name { - node: Node { - start: 10850, - end: 10862, - }, - id: "ticker_index", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 10865, - end: 10893, - }, - func: Name( - Name { - node: Node { - start: 10865, - end: 10885, - }, - id: "_handle_ticker_index", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 10886, - end: 10892, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), + ), + annotation: Attribute( + Attribute { + node: Node { + start: 9643, + end: 9655, + }, + value: Name( + Name { + node: Node { + start: 9643, + end: 9645, + }, + id: "pd", + }, + ), + attr: "DataFrame", + }, + ), + value: Some( + Call( + Call { + node: Node { + start: 9671, + end: 9673, + }, + func: Attribute( + Attribute { + node: Node { + start: 9658, + end: 9671, }, - ), - IfStatement( - If { - node: Node { - start: 10906, - end: 11008, - }, - test: Compare( - Compare { - node: Node { - start: 10909, - end: 10929, - }, - left: Name( - Name { - node: Node { - start: 10909, - end: 10921, - }, - id: "ticker_index", - }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 10925, - end: 10929, - }, - value: None, - }, - ), - ], + value: Name( + Name { + node: Node { + start: 9658, + end: 9664, }, - ), - body: [ - Raise( - Raise { - node: Node { - start: 10947, - end: 10995, - }, - exc: Some( - Call( - Call { - node: Node { - start: 10953, - end: 10995, - }, - func: Name( - Name { - node: Node { - start: 10953, - end: 10962, - }, - id: "Exception", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 10963, - end: 10994, - }, - values: [ - Constant( - Constant { - node: Node { - start: 10985, - end: 0, - }, - value: Str( - "Cannot find symbol: ", - ), - }, - ), - Name( - Name { - node: Node { - start: 10986, - end: 10992, - }, - id: "symbol", - }, - ), - ], - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - cause: None, - }, - ), - ], - orelse: [], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 11008, - end: 11113, + id: "future", }, - targets: [ - Name( - Name { - node: Node { - start: 11008, - end: 11014, - }, - id: "future", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 11032, - end: 11113, - }, - func: Attribute( - Attribute { - node: Node { - start: 11017, - end: 11032, - }, - value: Name( - Name { - node: Node { - start: 11017, - end: 11025, - }, - id: "executor", - }, - ), - attr: "submit", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11050, - end: 11085, - }, - id: "download_ticker_client_types_record", - }, - ), - Name( - Name { - node: Node { - start: 11087, - end: 11099, - }, - id: "ticker_index", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { + ), + attr: "result", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + simple: true, + }, + ), + ], + handlers: [ + ExceptHandler { + node: Node { + start: 9686, + end: 9928, + }, + typ: Some( + Attribute( + Attribute { + node: Node { + start: 9693, + end: 9717, + }, + value: Attribute( + Attribute { + node: Node { + start: 9693, + end: 9702, + }, + value: Name( + Name { node: Node { - start: 11126, - end: 11159, + start: 9693, + end: 9695, }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 11126, - end: 11150, - }, - value: Name( - Name { - node: Node { - start: 11126, - end: 11142, - }, - id: "future_to_symbol", - }, - ), - slice: Name( - Name { - node: Node { - start: 11143, - end: 11149, - }, - id: "future", - }, - ), - }, - ), - ], - value: Name( - Name { - node: Node { - start: 11153, - end: 11159, - }, - id: "symbol", - }, - ), + id: "pd", }, ), - ], - orelse: [], - }, - ), - ForStatement( - For { + attr: "errors", + }, + ), + attr: "EmptyDataError", + }, + ), + ), + name: Some( + "ex", + ), + body: [ + ExpressionStatement( + Call( + Call { node: Node { - start: 11168, - end: 11636, + start: 9753, + end: 9890, }, - target: Name( - Name { - node: Node { - start: 11172, - end: 11178, - }, - id: "future", - }, - ), - iter: Call( - Call { + func: Attribute( + Attribute { node: Node { - start: 11202, - end: 11220, + start: 9741, + end: 9753, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 11182, - end: 11202, + start: 9741, + end: 9747, }, - value: Name( - Name { - node: Node { - start: 11182, - end: 11189, - }, - id: "futures", - }, - ), - attr: "as_completed", + id: "logger", }, ), - args: [ - Name( - Name { - node: Node { - start: 11203, - end: 11219, - }, - id: "future_to_symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + attr: "error", }, ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 11234, - end: 11267, - }, - targets: [ - Name( - Name { - node: Node { - start: 11234, - end: 11240, - }, - id: "symbol", - }, - ), - ], - value: Subscript( - Subscript { - node: Node { - start: 11243, - end: 11267, - }, - value: Name( - Name { - node: Node { - start: 11243, - end: 11259, - }, - id: "future_to_symbol", - }, - ), - slice: Name( - Name { - node: Node { - start: 11260, - end: 11266, - }, - id: "future", - }, - ), - }, - ), - }, - ), - AnnAssignStatement( - AnnAssign { + args: [ + JoinedStr( + JoinedStr { node: Node { - start: 11280, - end: 11314, + start: 9775, + end: 9830, }, - target: Name( - Name { - node: Node { - start: 11280, - end: 11282, - }, - id: "df", - }, - ), - annotation: Attribute( - Attribute { - node: Node { - start: 11284, - end: 11296, - }, - value: Name( - Name { - node: Node { - start: 11284, - end: 11286, - }, - id: "pd", - }, - ), - attr: "DataFrame", - }, - ), - value: Some( - Call( - Call { + values: [ + Constant( + Constant { node: Node { - start: 11312, - end: 11314, + start: 9821, + end: 0, }, - func: Attribute( - Attribute { - node: Node { - start: 11299, - end: 11312, - }, - value: Name( - Name { - node: Node { - start: 11299, - end: 11305, - }, - id: "future", - }, - ), - attr: "result", - }, + value: Str( + "Cannot read daily trade records for symbol: ", ), - args: [], - keywords: [], - starargs: None, - kwargs: None, }, ), - ), - simple: true, - }, - ), - IfStatement( - If { - node: Node { - start: 11357, - end: 11409, - }, - test: Compare( - Compare { - node: Node { - start: 11360, - end: 11370, - }, - left: Name( - Name { - node: Node { - start: 11360, - end: 11362, - }, - id: "df", - }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 11366, - end: 11370, - }, - value: None, - }, - ), - ], - }, - ), - body: [ - Continue( - Continue { + Name( + Name { node: Node { - start: 11388, - end: 11396, + start: 9822, + end: 9828, }, + id: "symbol", }, ), ], - orelse: [], }, ), - ExpressionStatement( - Call( - Call { + ], + keywords: [ + Keyword { + node: Node { + start: 9852, + end: 9871, + }, + arg: Some( + "extra", + ), + value: Dict( + Dict { node: Node { - start: 11409, - end: 11446, + start: 9858, + end: 9871, }, - func: Name( - Name { - node: Node { - start: 11409, - end: 11427, - }, - id: "_adjust_data_frame", - }, - ), - args: [ - Name( - Name { + keys: [ + Constant( + Constant { node: Node { - start: 11428, - end: 11430, + start: 9859, + end: 9866, }, - id: "df", + value: Str( + "Error", + ), }, ), + ], + values: [ Name( Name { node: Node { - start: 11432, - end: 11445, + start: 9868, + end: 9870, }, - id: "include_jdate", + id: "ex", }, ), ], - keywords: [], - starargs: None, - kwargs: None, }, ), - ), - AssignStatement( - Assign { - node: Node { - start: 11459, - end: 11479, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 11459, - end: 11474, - }, - value: Name( - Name { - node: Node { - start: 11459, - end: 11466, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 11467, - end: 11473, - }, - id: "symbol", - }, - ), - }, - ), - ], - value: Name( - Name { - node: Node { - start: 11477, - end: 11479, - }, - id: "df", - }, - ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + ), + Continue( + Continue { + node: Node { + start: 9907, + end: 9915, + }, + }, + ), + ], + }, + ], + orelse: [], + finalbody: [], + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 9928, + end: 9976, + }, + func: Name( + Name { + node: Node { + start: 9928, + end: 9957, + }, + id: "_adjust_data_frame_for_fIndex", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 9958, + end: 9960, + }, + id: "df", + }, + ), + Name( + Name { + node: Node { + start: 9962, + end: 9975, + }, + id: "include_jdate", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + AssignStatement( + Assign { + node: Node { + start: 9989, + end: 10009, + }, + targets: [ + Subscript( + Subscript { + node: Node { + start: 9989, + end: 10004, + }, + value: Name( + Name { + node: Node { + start: 9989, + end: 9996, + }, + id: "df_list", + }, + ), + slice: Name( + Name { + node: Node { + start: 9997, + end: 10003, + }, + id: "symbol", + }, + ), + }, + ), + ], + value: Name( + Name { + node: Node { + start: 10007, + end: 10009, + }, + id: "df", + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 10023, + end: 10231, + }, + test: Name( + Name { + node: Node { + start: 10026, + end: 10038, + }, + id: "write_to_csv", + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 10077, + end: 10106, + }, + func: Attribute( + Attribute { + node: Node { + start: 10071, + end: 10077, + }, + value: Call( + Call { + node: Node { + start: 10056, + end: 10071, }, - ), - IfStatement( - If { - node: Node { - start: 11492, - end: 11636, + func: Name( + Name { + node: Node { + start: 10056, + end: 10060, + }, + id: "Path", }, - test: Name( + ), + args: [ + Name( Name { node: Node { - start: 11495, - end: 11507, + start: 10061, + end: 10070, }, - id: "write_to_csv", + id: "base_path", }, ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 11546, - end: 11575, - }, - func: Attribute( - Attribute { - node: Node { - start: 11540, - end: 11546, - }, - value: Call( - Call { - node: Node { - start: 11525, - end: 11540, - }, - func: Name( - Name { - node: Node { - start: 11525, - end: 11529, - }, - id: "Path", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11530, - end: 11539, - }, - id: "base_path", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "mkdir", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 11547, - end: 11559, - }, - arg: Some( - "parents", - ), - value: Constant( - Constant { - node: Node { - start: 11555, - end: 11559, - }, - value: Bool( - true, - ), - }, - ), - }, - Keyword { - node: Node { - start: 11561, - end: 11574, - }, - arg: Some( - "exist_ok", - ), - value: Constant( - Constant { - node: Node { - start: 11570, - end: 11574, - }, - value: Bool( - true, - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + attr: "mkdir", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 10078, + end: 10090, + }, + arg: Some( + "parents", + ), + value: Constant( + Constant { + node: Node { + start: 10086, + end: 10090, + }, + value: Bool( + true, + ), + }, + ), + }, + Keyword { + node: Node { + start: 10092, + end: 10105, + }, + arg: Some( + "exist_ok", + ), + value: Constant( + Constant { + node: Node { + start: 10101, + end: 10105, + }, + value: Bool( + true, + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 10145, + end: 10225, + }, + func: Attribute( + Attribute { + node: Node { + start: 10138, + end: 10145, + }, + value: Subscript( + Subscript { + node: Node { + start: 10123, + end: 10138, + }, + value: Name( + Name { + node: Node { + start: 10123, + end: 10130, + }, + id: "df_list", + }, + ), + slice: Name( + Name { + node: Node { + start: 10131, + end: 10137, + }, + id: "symbol", + }, + ), + }, + ), + attr: "to_csv", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 10167, + end: 10194, + }, + values: [ + Name( + Name { + node: Node { + start: 10170, + end: 10179, + }, + id: "base_path", + }, + ), + Constant( + Constant { + node: Node { + start: 10181, + end: 0, + }, + value: Str( + "/", ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 11601, - end: 11630, - }, - func: Attribute( - Attribute { - node: Node { - start: 11592, - end: 11601, - }, - value: Name( - Name { - node: Node { - start: 11592, - end: 11594, - }, - id: "df", - }, - ), - attr: "to_csv", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 11602, - end: 11629, - }, - values: [ - Name( - Name { - node: Node { - start: 11605, - end: 11614, - }, - id: "base_path", - }, - ), - Constant( - Constant { - node: Node { - start: 11616, - end: 0, - }, - value: Str( - "/", - ), - }, - ), - Name( - Name { - node: Node { - start: 11617, - end: 11623, - }, - id: "symbol", - }, - ), - Constant( - Constant { - node: Node { - start: 11628, - end: 0, - }, - value: Str( - ".csv", - ), - }, - ), - ], - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), + }, + ), + Name( + Name { + node: Node { + start: 10182, + end: 10188, + }, + id: "symbol", + }, + ), + Constant( + Constant { + node: Node { + start: 10193, + end: 0, + }, + value: Str( + ".csv", ), - ], - orelse: [], + }, + ), + ], + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 10196, + end: 10207, + }, + arg: Some( + "index", + ), + value: Constant( + Constant { + node: Node { + start: 10202, + end: 10207, }, - ), - ], - orelse: [], + value: Bool( + false, + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + ), + ], + orelse: [], + }, + ), + ], + orelse: [], + }, + ), + ], + }, + ), + IfStatement( + If { + node: Node { + start: 10231, + end: 10337, + }, + test: Compare( + Compare { + node: Node { + start: 10234, + end: 10262, + }, + left: Call( + Call { + node: Node { + start: 10234, + end: 10246, + }, + func: Name( + Name { + node: Node { + start: 10234, + end: 10237, + }, + id: "len", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 10238, + end: 10245, + }, + id: "df_list", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ops: [ + NotEq, + ], + comparators: [ + Call( + Call { + node: Node { + start: 10250, + end: 10262, + }, + func: Name( + Name { + node: Node { + start: 10250, + end: 10253, + }, + id: "len", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 10254, + end: 10261, + }, + id: "symbols", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 10272, + end: 10332, + }, + func: Name( + Name { + node: Node { + start: 10272, + end: 10277, + }, + id: "print", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 10278, + end: 10331, + }, + value: Str( + "Warning, download did not complete, re-run the code", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + orelse: [], + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 10350, + end: 10352, + }, + func: Attribute( + Attribute { + node: Node { + start: 10337, + end: 10350, + }, + value: Name( + Name { + node: Node { + start: 10337, + end: 10344, + }, + id: "session", + }, + ), + attr: "close", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + Return( + Return { + node: Node { + start: 10357, + end: 10371, + }, + value: Some( + Name( + Name { + node: Node { + start: 10364, + end: 10371, + }, + id: "df_list", + }, + ), + ), + }, + ), + ], + decorator_list: [], + returns: Some( + Subscript( + Subscript { + node: Node { + start: 8546, + end: 8569, + }, + value: Name( + Name { + node: Node { + start: 8546, + end: 8550, + }, + id: "Dict", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 8551, + end: 8569, + }, + elements: [ + Name( + Name { + node: Node { + start: 8551, + end: 8554, + }, + id: "str", + }, + ), + Attribute( + Attribute { + node: Node { + start: 8556, + end: 8568, + }, + value: Name( + Name { + node: Node { + start: 8556, + end: 8558, + }, + id: "pd", + }, + ), + attr: "DataFrame", + }, + ), + ], + }, + ), + }, + ), + ), + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 10374, + end: 11849, + }, + name: "download_client_types_records", + args: Arguments { + node: Node { + start: 10413, + end: 10561, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 10413, + end: 10438, + }, + arg: "symbols", + annotation: Some( + Subscript( + Subscript { + node: Node { + start: 10422, + end: 10438, + }, + value: Name( + Name { + node: Node { + start: 10422, + end: 10427, + }, + id: "Union", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 10428, + end: 10438, + }, + elements: [ + Name( + Name { + node: Node { + start: 10428, + end: 10432, + }, + id: "List", + }, + ), + Name( + Name { + node: Node { + start: 10434, + end: 10437, + }, + id: "str", + }, + ), + ], + }, + ), + }, + ), + ), + }, + Arg { + node: Node { + start: 10444, + end: 10470, + }, + arg: "write_to_csv", + annotation: Some( + Name( + Name { + node: Node { + start: 10458, + end: 10462, + }, + id: "bool", + }, + ), + ), + }, + Arg { + node: Node { + start: 10476, + end: 10503, + }, + arg: "include_jdate", + annotation: Some( + Name( + Name { + node: Node { + start: 10491, + end: 10495, + }, + id: "bool", + }, + ), + ), + }, + Arg { + node: Node { + start: 10509, + end: 10560, + }, + arg: "base_path", + annotation: Some( + Name( + Name { + node: Node { + start: 10520, + end: 10523, + }, + id: "str", + }, + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [ + Constant( + Constant { + node: Node { + start: 10465, + end: 10470, + }, + value: Bool( + false, + ), + }, + ), + Constant( + Constant { + node: Node { + start: 10498, + end: 10503, + }, + value: Bool( + false, + ), + }, + ), + Attribute( + Attribute { + node: Node { + start: 10526, + end: 10560, + }, + value: Name( + Name { + node: Node { + start: 10526, + end: 10532, + }, + id: "config", + }, + ), + attr: "CLIENT_TYPES_DATA_BASE_PATH", + }, + ), + ], + }, + body: [ + IfStatement( + If { + node: Node { + start: 10569, + end: 10703, + }, + test: Compare( + Compare { + node: Node { + start: 10572, + end: 10588, + }, + left: Name( + Name { + node: Node { + start: 10572, + end: 10579, + }, + id: "symbols", + }, + ), + ops: [ + Eq, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 10583, + end: 10588, + }, + value: Str( + "all", + ), + }, + ), + ], + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 10598, + end: 10634, + }, + targets: [ + Name( + Name { + node: Node { + start: 10598, + end: 10605, + }, + id: "symbols", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 10632, + end: 10634, + }, + func: Attribute( + Attribute { + node: Node { + start: 10608, + end: 10632, + }, + value: Name( + Name { + node: Node { + start: 10608, + end: 10620, + }, + id: "symbols_data", + }, + ), + attr: "all_symbols", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ], + orelse: [ + IfStatement( + If { + node: Node { + start: 10639, + end: 10703, + }, + test: Call( + Call { + node: Node { + start: 10644, + end: 10668, + }, + func: Name( + Name { + node: Node { + start: 10644, + end: 10654, + }, + id: "isinstance", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 10655, + end: 10662, + }, + id: "symbols", + }, + ), + Name( + Name { + node: Node { + start: 10664, + end: 10667, + }, + id: "str", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 10678, + end: 10697, + }, + targets: [ + Name( + Name { + node: Node { + start: 10678, + end: 10685, + }, + id: "symbols", + }, + ), + ], + value: List( + List { + node: Node { + start: 10688, + end: 10697, + }, + elements: [ + Name( + Name { + node: Node { + start: 10689, + end: 10696, + }, + id: "symbols", + }, + ), + ], + }, + ), + }, + ), + ], + orelse: [], + }, + ), + ], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 10703, + end: 10715, + }, + targets: [ + Name( + Name { + node: Node { + start: 10703, + end: 10710, + }, + id: "df_list", + }, + ), + ], + value: Dict( + Dict { + node: Node { + start: 10713, + end: 10715, + }, + keys: [], + values: [], + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 10720, + end: 10741, + }, + targets: [ + Name( + Name { + node: Node { + start: 10720, + end: 10736, + }, + id: "future_to_symbol", + }, + ), + ], + value: Dict( + Dict { + node: Node { + start: 10739, + end: 10741, + }, + keys: [], + values: [], + }, + ), + }, + ), + WithStatement( + With { + node: Node { + start: 10746, + end: 11636, + }, + items: [ + WithItem { + node: Node { + start: 10751, + end: 10805, + }, + context_expr: Call( + Call { + node: Node { + start: 10777, + end: 10793, + }, + func: Attribute( + Attribute { + node: Node { + start: 10751, + end: 10777, + }, + value: Name( + Name { + node: Node { + start: 10751, + end: 10758, + }, + id: "futures", + }, + ), + attr: "ThreadPoolExecutor", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 10778, + end: 10792, + }, + arg: Some( + "max_workers", + ), + value: Constant( + Constant { + node: Node { + start: 10790, + end: 10792, + }, + value: Int( + "10", + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + optional_vars: Some( + Name( + Name { + node: Node { + start: 10797, + end: 10805, + }, + id: "executor", + }, + ), + ), + }, + ], + body: [ + ForStatement( + For { + node: Node { + start: 10815, + end: 11168, + }, + target: Name( + Name { + node: Node { + start: 10819, + end: 10825, + }, + id: "symbol", + }, + ), + iter: Name( + Name { + node: Node { + start: 10829, + end: 10836, + }, + id: "symbols", + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 10850, + end: 10893, + }, + targets: [ + Name( + Name { + node: Node { + start: 10850, + end: 10862, + }, + id: "ticker_index", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 10865, + end: 10893, + }, + func: Name( + Name { + node: Node { + start: 10865, + end: 10885, + }, + id: "_handle_ticker_index", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 10886, + end: 10892, + }, + id: "symbol", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 10906, + end: 11008, + }, + test: Compare( + Compare { + node: Node { + start: 10909, + end: 10929, + }, + left: Name( + Name { + node: Node { + start: 10909, + end: 10921, + }, + id: "ticker_index", + }, + ), + ops: [ + Is, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 10925, + end: 10929, }, - ), - IfStatement( - If { + value: None, + }, + ), + ], + }, + ), + body: [ + Raise( + Raise { + node: Node { + start: 10947, + end: 10995, + }, + exc: Some( + Call( + Call { node: Node { - start: 11636, - end: 11832, + start: 10953, + end: 10995, }, - test: Compare( - Compare { + func: Name( + Name { node: Node { - start: 11639, - end: 11667, + start: 10953, + end: 10962, }, - left: Call( - Call { - node: Node { - start: 11639, - end: 11651, - }, - func: Name( - Name { + id: "Exception", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 10963, + end: 10994, + }, + values: [ + Constant( + Constant { node: Node { - start: 11639, - end: 11642, + start: 10985, + end: 0, }, - id: "len", + value: Str( + "Cannot find symbol: ", + ), }, ), - args: [ - Name( - Name { - node: Node { - start: 11643, - end: 11650, - }, - id: "df_list", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - NotEq, - ], - comparators: [ - Call( - Call { - node: Node { - start: 11655, - end: 11667, - }, - func: Name( - Name { - node: Node { - start: 11655, - end: 11658, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11659, - end: 11666, - }, - id: "symbols", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 11677, - end: 11827, - }, - func: Name( + Name( Name { node: Node { - start: 11677, - end: 11682, + start: 10986, + end: 10992, }, - id: "print", + id: "symbol", }, ), - args: [ - Constant( - Constant { - node: Node { - start: 11696, - end: 11817, - }, - value: Str( - "could not download client types for all the symbols make\n sure you have what you need or re-run the function", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), + ], + }, ), ], - orelse: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + cause: None, + }, + ), + ], + orelse: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 11008, + end: 11113, + }, + targets: [ + Name( + Name { + node: Node { + start: 11008, + end: 11014, + }, + id: "future", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 11032, + end: 11113, + }, + func: Attribute( + Attribute { + node: Node { + start: 11017, + end: 11032, + }, + value: Name( + Name { + node: Node { + start: 11017, + end: 11025, + }, + id: "executor", + }, + ), + attr: "submit", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 11050, + end: 11085, + }, + id: "download_ticker_client_types_record", + }, + ), + Name( + Name { + node: Node { + start: 11087, + end: 11099, + }, + id: "ticker_index", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 11126, + end: 11159, + }, + targets: [ + Subscript( + Subscript { + node: Node { + start: 11126, + end: 11150, + }, + value: Name( + Name { + node: Node { + start: 11126, + end: 11142, + }, + id: "future_to_symbol", + }, + ), + slice: Name( + Name { + node: Node { + start: 11143, + end: 11149, + }, + id: "future", + }, + ), + }, + ), + ], + value: Name( + Name { + node: Node { + start: 11153, + end: 11159, + }, + id: "symbol", + }, + ), + }, + ), + ], + orelse: [], + }, + ), + ForStatement( + For { + node: Node { + start: 11168, + end: 11636, + }, + target: Name( + Name { + node: Node { + start: 11172, + end: 11178, + }, + id: "future", + }, + ), + iter: Call( + Call { + node: Node { + start: 11202, + end: 11220, + }, + func: Attribute( + Attribute { + node: Node { + start: 11182, + end: 11202, + }, + value: Name( + Name { + node: Node { + start: 11182, + end: 11189, + }, + id: "futures", + }, + ), + attr: "as_completed", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 11203, + end: 11219, + }, + id: "future_to_symbol", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 11234, + end: 11267, + }, + targets: [ + Name( + Name { + node: Node { + start: 11234, + end: 11240, + }, + id: "symbol", + }, + ), + ], + value: Subscript( + Subscript { + node: Node { + start: 11243, + end: 11267, + }, + value: Name( + Name { + node: Node { + start: 11243, + end: 11259, + }, + id: "future_to_symbol", + }, + ), + slice: Name( + Name { + node: Node { + start: 11260, + end: 11266, + }, + id: "future", + }, + ), + }, + ), + }, + ), + AnnAssignStatement( + AnnAssign { + node: Node { + start: 11280, + end: 11314, + }, + target: Name( + Name { + node: Node { + start: 11280, + end: 11282, + }, + id: "df", + }, + ), + annotation: Attribute( + Attribute { + node: Node { + start: 11284, + end: 11296, + }, + value: Name( + Name { + node: Node { + start: 11284, + end: 11286, + }, + id: "pd", + }, + ), + attr: "DataFrame", + }, + ), + value: Some( + Call( + Call { + node: Node { + start: 11312, + end: 11314, + }, + func: Attribute( + Attribute { + node: Node { + start: 11299, + end: 11312, }, - ), - Return( - Return { - node: Node { - start: 11832, - end: 11846, + value: Name( + Name { + node: Node { + start: 11299, + end: 11305, + }, + id: "future", }, - value: Some( - Name( - Name { - node: Node { - start: 11839, - end: 11846, - }, - id: "df_list", - }, - ), - ), + ), + attr: "result", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + simple: true, + }, + ), + IfStatement( + If { + node: Node { + start: 11357, + end: 11409, + }, + test: Compare( + Compare { + node: Node { + start: 11360, + end: 11370, + }, + left: Name( + Name { + node: Node { + start: 11360, + end: 11362, + }, + id: "df", + }, + ), + ops: [ + Is, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 11366, + end: 11370, }, - ), - ], + value: None, + }, + ), + ], + }, + ), + body: [ + Continue( + Continue { + node: Node { + start: 11388, + end: 11396, + }, }, ), - FunctionDef( - FunctionDef { + ], + orelse: [], + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 11409, + end: 11446, + }, + func: Name( + Name { node: Node { - start: 11999, - end: 13481, + start: 11409, + end: 11427, }, - name: "download_ticker_client_types_record", - args: Arguments { + id: "_adjust_data_frame", + }, + ), + args: [ + Name( + Name { node: Node { - start: 12039, - end: 12066, + start: 11428, + end: 11430, }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 12039, - end: 12066, - }, - arg: "ticker_index", - annotation: Some( - Subscript( - Subscript { - node: Node { - start: 12053, - end: 12066, - }, - value: Name( - Name { - node: Node { - start: 12053, - end: 12061, - }, - id: "Optional", - }, - ), - slice: Name( - Name { - node: Node { - start: 12062, - end: 12065, - }, - id: "str", - }, - ), - }, - ), - ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], + id: "df", }, - body: [ - AssignStatement( - Assign { - node: Node { - start: 12073, - end: 12127, - }, - targets: [ - Name( - Name { - node: Node { - start: 12073, - end: 12077, - }, - id: "data", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 12080, - end: 12127, - }, - func: Name( - Name { - node: Node { - start: 12080, - end: 12113, - }, - id: "_extract_ticker_client_types_data", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 12114, - end: 12126, - }, - id: "ticker_index", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 12132, - end: 12367, - }, - test: Compare( - Compare { - node: Node { - start: 12135, - end: 12149, - }, - left: Call( - Call { - node: Node { - start: 12135, - end: 12144, - }, - func: Name( - Name { - node: Node { - start: 12135, - end: 12138, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 12139, - end: 12143, - }, - id: "data", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 12148, - end: 12149, - }, - value: Int( - "1", - ), - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 12173, - end: 12342, - }, - func: Attribute( - Attribute { - node: Node { - start: 12159, - end: 12173, - }, - value: Name( - Name { - node: Node { - start: 12159, - end: 12165, - }, - id: "logger", - }, - ), - attr: "warning", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 12187, - end: 12281, - }, - values: [ - Constant( - Constant { - node: Node { - start: 12233, - end: 0, - }, - value: Str( - "Cannot create client types data for ticker", - ), - }, - ), - Name( - Name { - node: Node { - start: 12234, - end: 12246, - }, - id: "ticker_index", - }, - ), - Constant( - Constant { - node: Node { - start: 12272, - end: 0, - }, - value: Str( - "\n from data: ", - ), - }, - ), - Name( - Name { - node: Node { - start: 12273, - end: 12277, - }, - id: "data", - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 12295, - end: 12331, - }, - arg: Some( - "extra", - ), - value: Dict( - Dict { - node: Node { - start: 12301, - end: 12331, - }, - keys: [ - Constant( - Constant { - node: Node { - start: 12302, - end: 12316, - }, - value: Str( - "ticker_index", - ), - }, - ), - ], - values: [ - Name( - Name { - node: Node { - start: 12318, - end: 12330, - }, - id: "ticker_index", - }, - ), - ], - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - Return( - Return { - node: Node { - start: 12351, - end: 12362, - }, - value: Some( - Constant( - Constant { - node: Node { - start: 12358, - end: 12362, - }, - value: None, - }, - ), - ), - }, - ), - ], - orelse: [], + ), + Name( + Name { + node: Node { + start: 11432, + end: 11445, + }, + id: "include_jdate", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + AssignStatement( + Assign { + node: Node { + start: 11459, + end: 11479, + }, + targets: [ + Subscript( + Subscript { + node: Node { + start: 11459, + end: 11474, + }, + value: Name( + Name { + node: Node { + start: 11459, + end: 11466, }, - ), - AssignStatement( - Assign { + id: "df_list", + }, + ), + slice: Name( + Name { + node: Node { + start: 11467, + end: 11473, + }, + id: "symbol", + }, + ), + }, + ), + ], + value: Name( + Name { + node: Node { + start: 11477, + end: 11479, + }, + id: "df", + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 11492, + end: 11636, + }, + test: Name( + Name { + node: Node { + start: 11495, + end: 11507, + }, + id: "write_to_csv", + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 11546, + end: 11575, + }, + func: Attribute( + Attribute { node: Node { - start: 12367, - end: 12899, + start: 11540, + end: 11546, }, - targets: [ - Name( - Name { - node: Node { - start: 12367, - end: 12390, - }, - id: "client_types_data_frame", - }, - ), - ], value: Call( Call { node: Node { - start: 12405, - end: 12899, + start: 11525, + end: 11540, }, - func: Attribute( - Attribute { + func: Name( + Name { node: Node { - start: 12393, - end: 12405, + start: 11525, + end: 11529, }, - value: Name( - Name { - node: Node { - start: 12393, - end: 12395, - }, - id: "pd", - }, - ), - attr: "DataFrame", + id: "Path", }, ), args: [ Name( Name { node: Node { - start: 12415, - end: 12419, + start: 11530, + end: 11539, }, - id: "data", + id: "base_path", }, ), ], - keywords: [ - Keyword { + keywords: [], + starargs: None, + kwargs: None, + }, + ), + attr: "mkdir", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 11547, + end: 11559, + }, + arg: Some( + "parents", + ), + value: Constant( + Constant { + node: Node { + start: 11555, + end: 11559, + }, + value: Bool( + true, + ), + }, + ), + }, + Keyword { + node: Node { + start: 11561, + end: 11574, + }, + arg: Some( + "exist_ok", + ), + value: Constant( + Constant { + node: Node { + start: 11570, + end: 11574, + }, + value: Bool( + true, + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 11601, + end: 11630, + }, + func: Attribute( + Attribute { + node: Node { + start: 11592, + end: 11601, + }, + value: Name( + Name { + node: Node { + start: 11592, + end: 11594, + }, + id: "df", + }, + ), + attr: "to_csv", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 11602, + end: 11629, + }, + values: [ + Name( + Name { + node: Node { + start: 11605, + end: 11614, + }, + id: "base_path", + }, + ), + Constant( + Constant { node: Node { - start: 12429, - end: 12892, + start: 11616, + end: 0, }, - arg: Some( - "columns", + value: Str( + "/", ), - value: List( - List { - node: Node { - start: 12437, - end: 12892, - }, - elements: [ - Constant( - Constant { - node: Node { - start: 12451, - end: 12457, - }, - value: Str( - "date", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12471, - end: 12493, - }, - value: Str( - "individual_buy_count", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12507, - end: 12528, - }, - value: Str( - "corporate_buy_count", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12542, - end: 12565, - }, - value: Str( - "individual_sell_count", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12579, - end: 12601, - }, - value: Str( - "corporate_sell_count", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12615, - end: 12635, - }, - value: Str( - "individual_buy_vol", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12649, - end: 12668, - }, - value: Str( - "corporate_buy_vol", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12682, - end: 12703, - }, - value: Str( - "individual_sell_vol", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12717, - end: 12737, - }, - value: Str( - "corporate_sell_vol", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12751, - end: 12773, - }, - value: Str( - "individual_buy_value", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12787, - end: 12808, - }, - value: Str( - "corporate_buy_value", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12822, - end: 12845, - }, - value: Str( - "individual_sell_value", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12859, - end: 12881, - }, - value: Str( - "corporate_sell_value", - ), - }, - ), - ], - }, + }, + ), + Name( + Name { + node: Node { + start: 11617, + end: 11623, + }, + id: "symbol", + }, + ), + Constant( + Constant { + node: Node { + start: 11628, + end: 0, + }, + value: Str( + ".csv", ), }, - ], - starargs: None, - kwargs: None, - }, - ), + ), + ], + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + orelse: [], + }, + ), + ], + orelse: [], + }, + ), + ], + }, + ), + IfStatement( + If { + node: Node { + start: 11636, + end: 11832, + }, + test: Compare( + Compare { + node: Node { + start: 11639, + end: 11667, + }, + left: Call( + Call { + node: Node { + start: 11639, + end: 11651, + }, + func: Name( + Name { + node: Node { + start: 11639, + end: 11642, + }, + id: "len", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 11643, + end: 11650, + }, + id: "df_list", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ops: [ + NotEq, + ], + comparators: [ + Call( + Call { + node: Node { + start: 11655, + end: 11667, + }, + func: Name( + Name { + node: Node { + start: 11655, + end: 11658, + }, + id: "len", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 11659, + end: 11666, + }, + id: "symbols", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 11677, + end: 11827, + }, + func: Name( + Name { + node: Node { + start: 11677, + end: 11682, + }, + id: "print", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 11696, + end: 11817, + }, + value: Str( + "could not download client types for all the symbols make\n sure you have what you need or re-run the function", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + orelse: [], + }, + ), + Return( + Return { + node: Node { + start: 11832, + end: 11846, + }, + value: Some( + Name( + Name { + node: Node { + start: 11839, + end: 11846, + }, + id: "df_list", + }, + ), + ), + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 11999, + end: 13481, + }, + name: "download_ticker_client_types_record", + args: Arguments { + node: Node { + start: 12039, + end: 12066, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 12039, + end: 12066, + }, + arg: "ticker_index", + annotation: Some( + Subscript( + Subscript { + node: Node { + start: 12053, + end: 12066, + }, + value: Name( + Name { + node: Node { + start: 12053, + end: 12061, + }, + id: "Optional", + }, + ), + slice: Name( + Name { + node: Node { + start: 12062, + end: 12065, + }, + id: "str", + }, + ), + }, + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 12073, + end: 12127, + }, + targets: [ + Name( + Name { + node: Node { + start: 12073, + end: 12077, + }, + id: "data", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 12080, + end: 12127, + }, + func: Name( + Name { + node: Node { + start: 12080, + end: 12113, + }, + id: "_extract_ticker_client_types_data", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 12114, + end: 12126, + }, + id: "ticker_index", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 12132, + end: 12367, + }, + test: Compare( + Compare { + node: Node { + start: 12135, + end: 12149, + }, + left: Call( + Call { + node: Node { + start: 12135, + end: 12144, + }, + func: Name( + Name { + node: Node { + start: 12135, + end: 12138, + }, + id: "len", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 12139, + end: 12143, + }, + id: "data", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ops: [ + Eq, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 12148, + end: 12149, + }, + value: Int( + "1", + ), + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 12173, + end: 12342, + }, + func: Attribute( + Attribute { + node: Node { + start: 12159, + end: 12173, + }, + value: Name( + Name { + node: Node { + start: 12159, + end: 12165, + }, + id: "logger", + }, + ), + attr: "warning", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 12187, + end: 12281, + }, + values: [ + Constant( + Constant { + node: Node { + start: 12233, + end: 0, + }, + value: Str( + "Cannot create client types data for ticker", + ), + }, + ), + Name( + Name { + node: Node { + start: 12234, + end: 12246, + }, + id: "ticker_index", + }, + ), + Constant( + Constant { + node: Node { + start: 12272, + end: 0, + }, + value: Str( + "\n from data: ", + ), + }, + ), + Name( + Name { + node: Node { + start: 12273, + end: 12277, + }, + id: "data", + }, + ), + ], + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 12295, + end: 12331, + }, + arg: Some( + "extra", + ), + value: Dict( + Dict { + node: Node { + start: 12301, + end: 12331, + }, + keys: [ + Constant( + Constant { + node: Node { + start: 12302, + end: 12316, + }, + value: Str( + "ticker_index", + ), + }, + ), + ], + values: [ + Name( + Name { + node: Node { + start: 12318, + end: 12330, + }, + id: "ticker_index", + }, + ), + ], + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + ), + Return( + Return { + node: Node { + start: 12351, + end: 12362, + }, + value: Some( + Constant( + Constant { + node: Node { + start: 12358, + end: 12362, + }, + value: None, + }, + ), + ), + }, + ), + ], + orelse: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 12367, + end: 12899, + }, + targets: [ + Name( + Name { + node: Node { + start: 12367, + end: 12390, + }, + id: "client_types_data_frame", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 12405, + end: 12899, + }, + func: Attribute( + Attribute { + node: Node { + start: 12393, + end: 12405, + }, + value: Name( + Name { + node: Node { + start: 12393, + end: 12395, + }, + id: "pd", + }, + ), + attr: "DataFrame", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 12415, + end: 12419, + }, + id: "data", + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 12429, + end: 12892, + }, + arg: Some( + "columns", + ), + value: List( + List { + node: Node { + start: 12437, + end: 12892, + }, + elements: [ + Constant( + Constant { + node: Node { + start: 12451, + end: 12457, + }, + value: Str( + "date", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12471, + end: 12493, + }, + value: Str( + "individual_buy_count", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12507, + end: 12528, + }, + value: Str( + "corporate_buy_count", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12542, + end: 12565, + }, + value: Str( + "individual_sell_count", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12579, + end: 12601, + }, + value: Str( + "corporate_sell_count", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12615, + end: 12635, + }, + value: Str( + "individual_buy_vol", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12649, + end: 12668, + }, + value: Str( + "corporate_buy_vol", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12682, + end: 12703, + }, + value: Str( + "individual_sell_vol", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12717, + end: 12737, + }, + value: Str( + "corporate_sell_vol", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12751, + end: 12773, + }, + value: Str( + "individual_buy_value", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12787, + end: 12808, + }, + value: Str( + "corporate_buy_value", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12822, + end: 12845, + }, + value: Str( + "individual_sell_value", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12859, + end: 12881, + }, + value: Str( + "corporate_sell_value", + ), + }, + ), + ], + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ForStatement( + For { + node: Node { + start: 12904, + end: 13210, + }, + target: Name( + Name { + node: Node { + start: 12908, + end: 12909, + }, + id: "i", + }, + ), + iter: List( + List { + node: Node { + start: 12913, + end: 13028, + }, + elements: [ + Constant( + Constant { + node: Node { + start: 12923, + end: 12940, + }, + value: Str( + "individual_buy_", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12950, + end: 12968, + }, + value: Str( + "individual_sell_", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12978, + end: 12994, + }, + value: Str( + "corporate_buy_", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 13004, + end: 13021, + }, + value: Str( + "corporate_sell_", + ), + }, + ), + ], + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 13038, + end: 13205, + }, + targets: [ + Subscript( + Subscript { + node: Node { + start: 13038, + end: 13079, + }, + value: Name( + Name { + node: Node { + start: 13038, + end: 13061, + }, + id: "client_types_data_frame", + }, + ), + slice: JoinedStr( + JoinedStr { + node: Node { + start: 13062, + end: 13078, + }, + values: [ + Name( + Name { + node: Node { + start: 13065, + end: 13066, }, - ), - ForStatement( - For { - node: Node { - start: 12904, - end: 13210, - }, - target: Name( - Name { - node: Node { - start: 12908, - end: 12909, - }, - id: "i", - }, - ), - iter: List( - List { - node: Node { - start: 12913, - end: 13028, - }, - elements: [ - Constant( - Constant { - node: Node { - start: 12923, - end: 12940, - }, - value: Str( - "individual_buy_", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12950, - end: 12968, - }, - value: Str( - "individual_sell_", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 12978, - end: 12994, - }, - value: Str( - "corporate_buy_", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 13004, - end: 13021, - }, - value: Str( - "corporate_sell_", - ), - }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 13038, - end: 13205, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 13038, - end: 13079, - }, - value: Name( - Name { - node: Node { - start: 13038, - end: 13061, - }, - id: "client_types_data_frame", - }, - ), - slice: JoinedStr( - JoinedStr { - node: Node { - start: 13062, - end: 13078, - }, - values: [ - Name( - Name { - node: Node { - start: 13065, - end: 13066, - }, - id: "i", - }, - ), - Constant( - Constant { - node: Node { - start: 13077, - end: 0, - }, - value: Str( - "mean_price", - ), - }, - ), - ], - }, - ), - }, - ), - ], - value: BinOp( - BinOp { - node: Node { - start: 13082, - end: 13205, - }, - op: Div, - left: Call( - Call { - node: Node { - start: 13147, - end: 13154, - }, - func: Attribute( - Attribute { - node: Node { - start: 13140, - end: 13147, - }, - value: Subscript( - Subscript { - node: Node { - start: 13082, - end: 13140, - }, - value: Name( - Name { - node: Node { - start: 13082, - end: 13105, - }, - id: "client_types_data_frame", - }, - ), - slice: JoinedStr( - JoinedStr { - node: Node { - start: 13119, - end: 13130, - }, - values: [ - Name( - Name { - node: Node { - start: 13122, - end: 13123, - }, - id: "i", - }, - ), - Constant( - Constant { - node: Node { - start: 13129, - end: 0, - }, - value: Str( - "value", - ), - }, - ), - ], - }, - ), - }, - ), - attr: "astype", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 13148, - end: 13153, - }, - id: "float", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - right: Call( - Call { - node: Node { - start: 13198, - end: 13205, - }, - func: Attribute( - Attribute { - node: Node { - start: 13191, - end: 13198, - }, - value: Subscript( - Subscript { - node: Node { - start: 13157, - end: 13191, - }, - value: Name( - Name { - node: Node { - start: 13157, - end: 13180, - }, - id: "client_types_data_frame", - }, - ), - slice: JoinedStr( - JoinedStr { - node: Node { - start: 13181, - end: 13190, - }, - values: [ - Name( - Name { - node: Node { - start: 13184, - end: 13185, - }, - id: "i", - }, - ), - Constant( - Constant { - node: Node { - start: 13189, - end: 0, - }, - value: Str( - "vol", - ), - }, - ), - ], - }, - ), - }, - ), - attr: "astype", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 13199, - end: 13204, - }, - id: "float", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - }, - ), - ], - orelse: [], + id: "i", + }, + ), + Constant( + Constant { + node: Node { + start: 13077, + end: 0, }, - ), - AssignStatement( - Assign { - node: Node { - start: 13210, - end: 13443, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 13210, - end: 13278, - }, - value: Name( - Name { - node: Node { - start: 13210, - end: 13233, - }, - id: "client_types_data_frame", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13243, - end: 13272, - }, - value: Str( - "individual_ownership_change", - ), - }, - ), - }, - ), - ], - value: BinOp( - BinOp { - node: Node { - start: 13281, - end: 13443, - }, - op: Sub, - left: Call( - Call { + value: Str( + "mean_price", + ), + }, + ), + ], + }, + ), + }, + ), + ], + value: BinOp( + BinOp { + node: Node { + start: 13082, + end: 13205, + }, + op: Div, + left: Call( + Call { + node: Node { + start: 13147, + end: 13154, + }, + func: Attribute( + Attribute { + node: Node { + start: 13140, + end: 13147, + }, + value: Subscript( + Subscript { + node: Node { + start: 13082, + end: 13140, + }, + value: Name( + Name { + node: Node { + start: 13082, + end: 13105, + }, + id: "client_types_data_frame", + }, + ), + slice: JoinedStr( + JoinedStr { + node: Node { + start: 13119, + end: 13130, + }, + values: [ + Name( + Name { node: Node { - start: 13333, - end: 13354, + start: 13122, + end: 13123, }, - func: Attribute( - Attribute { - node: Node { - start: 13326, - end: 13333, - }, - value: Subscript( - Subscript { - node: Node { - start: 13281, - end: 13326, - }, - value: Name( - Name { - node: Node { - start: 13281, - end: 13304, - }, - id: "client_types_data_frame", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13305, - end: 13325, - }, - value: Str( - "corporate_sell_vol", - ), - }, - ), - }, - ), - attr: "astype", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 13343, - end: 13348, - }, - id: "float", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "i", }, ), - right: Call( - Call { + Constant( + Constant { node: Node { - start: 13422, - end: 13443, + start: 13129, + end: 0, }, - func: Attribute( - Attribute { - node: Node { - start: 13415, - end: 13422, - }, - value: Subscript( - Subscript { - node: Node { - start: 13357, - end: 13415, - }, - value: Name( - Name { - node: Node { - start: 13357, - end: 13380, - }, - id: "client_types_data_frame", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13390, - end: 13409, - }, - value: Str( - "corporate_buy_vol", - ), - }, - ), - }, - ), - attr: "astype", - }, + value: Str( + "value", ), - args: [ - Name( - Name { - node: Node { - start: 13432, - end: 13437, - }, - id: "float", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, }, ), - }, - ), + ], + }, + ), + }, + ), + attr: "astype", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 13148, + end: 13153, + }, + id: "float", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + right: Call( + Call { + node: Node { + start: 13198, + end: 13205, + }, + func: Attribute( + Attribute { + node: Node { + start: 13191, + end: 13198, + }, + value: Subscript( + Subscript { + node: Node { + start: 13157, + end: 13191, }, - ), - Return( - Return { - node: Node { - start: 13448, - end: 13478, + value: Name( + Name { + node: Node { + start: 13157, + end: 13180, + }, + id: "client_types_data_frame", }, - value: Some( - Name( - Name { - node: Node { - start: 13455, - end: 13478, + ), + slice: JoinedStr( + JoinedStr { + node: Node { + start: 13181, + end: 13190, + }, + values: [ + Name( + Name { + node: Node { + start: 13184, + end: 13185, + }, + id: "i", }, - id: "client_types_data_frame", - }, - ), - ), + ), + Constant( + Constant { + node: Node { + start: 13189, + end: 0, + }, + value: Str( + "vol", + ), + }, + ), + ], + }, + ), + }, + ), + attr: "astype", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 13199, + end: 13204, + }, + id: "float", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + }, + ), + ], + orelse: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 13210, + end: 13443, + }, + targets: [ + Subscript( + Subscript { + node: Node { + start: 13210, + end: 13278, + }, + value: Name( + Name { + node: Node { + start: 13210, + end: 13233, + }, + id: "client_types_data_frame", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 13243, + end: 13272, + }, + value: Str( + "individual_ownership_change", + ), + }, + ), + }, + ), + ], + value: BinOp( + BinOp { + node: Node { + start: 13281, + end: 13443, + }, + op: Sub, + left: Call( + Call { + node: Node { + start: 13333, + end: 13354, + }, + func: Attribute( + Attribute { + node: Node { + start: 13326, + end: 13333, + }, + value: Subscript( + Subscript { + node: Node { + start: 13281, + end: 13326, + }, + value: Name( + Name { + node: Node { + start: 13281, + end: 13304, + }, + id: "client_types_data_frame", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 13305, + end: 13325, + }, + value: Str( + "corporate_sell_vol", + ), + }, + ), + }, + ), + attr: "astype", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 13343, + end: 13348, + }, + id: "float", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + right: Call( + Call { + node: Node { + start: 13422, + end: 13443, + }, + func: Attribute( + Attribute { + node: Node { + start: 13415, + end: 13422, + }, + value: Subscript( + Subscript { + node: Node { + start: 13357, + end: 13415, + }, + value: Name( + Name { + node: Node { + start: 13357, + end: 13380, + }, + id: "client_types_data_frame", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 13390, + end: 13409, + }, + value: Str( + "corporate_buy_vol", + ), + }, + ), + }, + ), + attr: "astype", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 13432, + end: 13437, + }, + id: "float", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + }, + ), + Return( + Return { + node: Node { + start: 13448, + end: 13478, + }, + value: Some( + Name( + Name { + node: Node { + start: 13455, + end: 13478, + }, + id: "client_types_data_frame", + }, + ), + ), + }, + ), + ], + decorator_list: [ + Call( + Call { + node: Node { + start: 11850, + end: 11998, + }, + func: Name( + Name { + node: Node { + start: 11850, + end: 11855, + }, + id: "retry", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 11861, + end: 11901, + }, + arg: Some( + "retry", + ), + value: Call( + Call { + node: Node { + start: 11867, + end: 11901, + }, + func: Name( + Name { + node: Node { + start: 11867, + end: 11890, + }, + id: "retry_if_exception_type", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 11891, + end: 11900, + }, + id: "HTTPError", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + Keyword { + node: Node { + start: 11907, + end: 11937, + }, + arg: Some( + "wait", + ), + value: Call( + Call { + node: Node { + start: 11912, + end: 11937, + }, + func: Name( + Name { + node: Node { + start: 11912, + end: 11923, + }, + id: "wait_random", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 11924, + end: 11929, + }, + arg: Some( + "min", + ), + value: Constant( + Constant { + node: Node { + start: 11928, + end: 11929, + }, + value: Int( + "1", + ), + }, + ), + }, + Keyword { + node: Node { + start: 11931, + end: 11936, + }, + arg: Some( + "max", + ), + value: Constant( + Constant { + node: Node { + start: 11935, + end: 11936, + }, + value: Int( + "4", + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + Keyword { + node: Node { + start: 11943, + end: 11995, + }, + arg: Some( + "before_sleep", + ), + value: Call( + Call { + node: Node { + start: 11956, + end: 11995, + }, + func: Name( + Name { + node: Node { + start: 11956, + end: 11972, + }, + id: "before_sleep_log", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 11973, + end: 11979, + }, + id: "logger", + }, + ), + Attribute( + Attribute { + node: Node { + start: 11981, + end: 11994, + }, + value: Name( + Name { + node: Node { + start: 11981, + end: 11988, + }, + id: "logging", + }, + ), + attr: "DEBUG", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + ], + returns: None, + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 13481, + end: 13980, + }, + name: "get_symbol_id", + args: Arguments { + node: Node { + start: 13499, + end: 13515, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 13499, + end: 13515, + }, + arg: "symbol_name", + annotation: Some( + Name( + Name { + node: Node { + start: 13512, + end: 13515, + }, + id: "str", + }, + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 13522, + end: 13586, + }, + targets: [ + Name( + Name { + node: Node { + start: 13522, + end: 13525, + }, + id: "url", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 13565, + end: 13586, + }, + func: Attribute( + Attribute { + node: Node { + start: 13528, + end: 13565, + }, + value: Attribute( + Attribute { + node: Node { + start: 13528, + end: 13558, + }, + value: Name( + Name { + node: Node { + start: 13528, + end: 13540, + }, + id: "tse_settings", + }, + ), + attr: "TSE_SYMBOL_ID_URL", + }, + ), + attr: "format", + }, + ), + args: [ + Call( + Call { + node: Node { + start: 13583, + end: 13585, + }, + func: Attribute( + Attribute { + node: Node { + start: 13566, + end: 13583, + }, + value: Name( + Name { + node: Node { + start: 13566, + end: 13577, + }, + id: "symbol_name", + }, + ), + attr: "strip", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 13591, + end: 13647, + }, + targets: [ + Name( + Name { + node: Node { + start: 13591, + end: 13599, + }, + id: "response", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 13630, + end: 13647, + }, + func: Attribute( + Attribute { + node: Node { + start: 13626, + end: 13630, + }, + value: Call( + Call { + node: Node { + start: 13602, + end: 13626, + }, + func: Name( + Name { + node: Node { + start: 13602, + end: 13624, + }, + id: "requests_retry_session", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + attr: "get", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 13631, + end: 13634, + }, + id: "url", + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 13636, + end: 13646, + }, + arg: Some( + "timeout", + ), + value: Constant( + Constant { + node: Node { + start: 13644, + end: 13646, + }, + value: Int( + "10", + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + TryStatement( + Try { + node: Node { + start: 13652, + end: 13781, + }, + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 13690, + end: 13692, + }, + func: Attribute( + Attribute { + node: Node { + start: 13665, + end: 13690, + }, + value: Name( + Name { + node: Node { + start: 13665, + end: 13673, + }, + id: "response", + }, + ), + attr: "raise_for_status", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + handlers: [ + ExceptHandler { + node: Node { + start: 13697, + end: 13781, + }, + typ: Some( + Name( + Name { + node: Node { + start: 13704, + end: 13713, + }, + id: "HTTPError", + }, + ), + ), + name: None, + body: [ + Raise( + Raise { + node: Node { + start: 13723, + end: 13775, + }, + exc: Some( + Call( + Call { + node: Node { + start: 13729, + end: 13775, + }, + func: Name( + Name { + node: Node { + start: 13729, + end: 13738, + }, + id: "Exception", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 13739, + end: 13774, }, - ), - ], - decorator_list: [ - Call( - Call { + value: Str( + "Sorry, tse server did not respond", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + cause: None, + }, + ), + ], + }, + ], + orelse: [], + finalbody: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 13781, + end: 13838, + }, + targets: [ + Name( + Name { + node: Node { + start: 13781, + end: 13797, + }, + id: "symbol_full_info", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 13833, + end: 13838, + }, + func: Attribute( + Attribute { + node: Node { + start: 13827, + end: 13833, + }, + value: Subscript( + Subscript { + node: Node { + start: 13824, + end: 13827, + }, + value: Call( + Call { + node: Node { + start: 13819, + end: 13824, + }, + func: Attribute( + Attribute { + node: Node { + start: 13800, + end: 13819, + }, + value: Attribute( + Attribute { node: Node { - start: 11850, - end: 11998, - }, - func: Name( - Name { - node: Node { - start: 11850, - end: 11855, - }, - id: "retry", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 11861, - end: 11901, - }, - arg: Some( - "retry", - ), - value: Call( - Call { - node: Node { - start: 11867, - end: 11901, - }, - func: Name( - Name { - node: Node { - start: 11867, - end: 11890, - }, - id: "retry_if_exception_type", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11891, - end: 11900, - }, - id: "HTTPError", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - Keyword { - node: Node { - start: 11907, - end: 11937, - }, - arg: Some( - "wait", - ), - value: Call( - Call { - node: Node { - start: 11912, - end: 11937, - }, - func: Name( - Name { - node: Node { - start: 11912, - end: 11923, - }, - id: "wait_random", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 11924, - end: 11929, - }, - arg: Some( - "min", - ), - value: Constant( - Constant { - node: Node { - start: 11928, - end: 11929, - }, - value: Int( - "1", - ), - }, - ), - }, - Keyword { - node: Node { - start: 11931, - end: 11936, - }, - arg: Some( - "max", - ), - value: Constant( - Constant { - node: Node { - start: 11935, - end: 11936, - }, - value: Int( - "4", - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - Keyword { - node: Node { - start: 11943, - end: 11995, - }, - arg: Some( - "before_sleep", - ), - value: Call( - Call { - node: Node { - start: 11956, - end: 11995, - }, - func: Name( - Name { - node: Node { - start: 11956, - end: 11972, - }, - id: "before_sleep_log", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11973, - end: 11979, - }, - id: "logger", - }, - ), - Attribute( - Attribute { - node: Node { - start: 11981, - end: 11994, - }, - value: Name( - Name { - node: Node { - start: 11981, - end: 11988, - }, - id: "logging", - }, - ), - attr: "DEBUG", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), + start: 13800, + end: 13813, + }, + value: Name( + Name { + node: Node { + start: 13800, + end: 13808, + }, + id: "response", }, - ], - starargs: None, - kwargs: None, + ), + attr: "text", }, ), - ], - returns: None, - type_comment: None, + attr: "split", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 13820, + end: 13823, + }, + value: Str( + ";", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + slice: Constant( + Constant { + node: Node { + start: 13825, + end: 13826, }, - ), - FunctionDef( - FunctionDef { + value: Int( + "0", + ), + }, + ), + }, + ), + attr: "split", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 13834, + end: 13837, + }, + value: Str( + ",", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 13843, + end: 13966, + }, + test: Compare( + Compare { + node: Node { + start: 13846, + end: 13912, + }, + left: Call( + Call { + node: Node { + start: 13868, + end: 13881, + }, + func: Attribute( + Attribute { + node: Node { + start: 13846, + end: 13868, + }, + value: Name( + Name { + node: Node { + start: 13846, + end: 13853, + }, + id: "persian", + }, + ), + attr: "replace_arabic", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 13869, + end: 13880, + }, + id: "symbol_name", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ops: [ + Eq, + ], + comparators: [ + Call( + Call { + node: Node { + start: 13910, + end: 13912, + }, + func: Attribute( + Attribute { + node: Node { + start: 13904, + end: 13910, + }, + value: Subscript( + Subscript { node: Node { - start: 13481, - end: 13980, + start: 13885, + end: 13904, }, - name: "get_symbol_id", - args: Arguments { - node: Node { - start: 13499, - end: 13515, + value: Name( + Name { + node: Node { + start: 13885, + end: 13901, + }, + id: "symbol_full_info", }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 13499, - end: 13515, - }, - arg: "symbol_name", - annotation: Some( - Name( - Name { - node: Node { - start: 13512, - end: 13515, - }, - id: "str", - }, - ), - ), + ), + slice: Constant( + Constant { + node: Node { + start: 13902, + end: 13903, }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], + value: Int( + "0", + ), + }, + ), + }, + ), + attr: "strip", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ], + }, + ), + body: [ + Return( + Return { + node: Node { + start: 13922, + end: 13961, + }, + value: Some( + Subscript( + Subscript { + node: Node { + start: 13929, + end: 13961, + }, + value: Name( + Name { + node: Node { + start: 13929, + end: 13945, + }, + id: "symbol_full_info", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 13946, + end: 13947, + }, + value: Int( + "2", + ), + }, + ), + }, + ), + ), + }, + ), + ], + orelse: [], + }, + ), + Return( + Return { + node: Node { + start: 13966, + end: 13977, + }, + value: Some( + Constant( + Constant { + node: Node { + start: 13973, + end: 13977, + }, + value: None, + }, + ), + ), + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 13980, + end: 15273, + }, + name: "get_symbol_info", + args: Arguments { + node: Node { + start: 14000, + end: 14016, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 14000, + end: 14016, + }, + arg: "symbol_name", + annotation: Some( + Name( + Name { + node: Node { + start: 14013, + end: 14016, + }, + id: "str", + }, + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 14023, + end: 14087, + }, + targets: [ + Name( + Name { + node: Node { + start: 14023, + end: 14026, + }, + id: "url", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 14066, + end: 14087, + }, + func: Attribute( + Attribute { + node: Node { + start: 14029, + end: 14066, + }, + value: Attribute( + Attribute { + node: Node { + start: 14029, + end: 14059, + }, + value: Name( + Name { + node: Node { + start: 14029, + end: 14041, + }, + id: "tse_settings", + }, + ), + attr: "TSE_SYMBOL_ID_URL", + }, + ), + attr: "format", + }, + ), + args: [ + Call( + Call { + node: Node { + start: 14084, + end: 14086, + }, + func: Attribute( + Attribute { + node: Node { + start: 14067, + end: 14084, + }, + value: Name( + Name { + node: Node { + start: 14067, + end: 14078, }, - body: [ - AssignStatement( - Assign { - node: Node { - start: 13522, - end: 13586, - }, - targets: [ - Name( - Name { - node: Node { - start: 13522, - end: 13525, - }, - id: "url", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 13565, - end: 13586, - }, - func: Attribute( - Attribute { - node: Node { - start: 13528, - end: 13565, - }, - value: Attribute( - Attribute { - node: Node { - start: 13528, - end: 13558, - }, - value: Name( - Name { - node: Node { - start: 13528, - end: 13540, - }, - id: "tse_settings", - }, - ), - attr: "TSE_SYMBOL_ID_URL", - }, - ), - attr: "format", - }, - ), - args: [ - Call( - Call { - node: Node { - start: 13583, - end: 13585, - }, - func: Attribute( - Attribute { - node: Node { - start: 13566, - end: 13583, - }, - value: Name( - Name { - node: Node { - start: 13566, - end: 13577, - }, - id: "symbol_name", - }, - ), - attr: "strip", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 13591, - end: 13647, - }, - targets: [ - Name( - Name { - node: Node { - start: 13591, - end: 13599, - }, - id: "response", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 13630, - end: 13647, - }, - func: Attribute( - Attribute { - node: Node { - start: 13626, - end: 13630, - }, - value: Call( - Call { - node: Node { - start: 13602, - end: 13626, - }, - func: Name( - Name { - node: Node { - start: 13602, - end: 13624, - }, - id: "requests_retry_session", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "get", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 13631, - end: 13634, - }, - id: "url", - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 13636, - end: 13646, - }, - arg: Some( - "timeout", - ), - value: Constant( - Constant { - node: Node { - start: 13644, - end: 13646, - }, - value: Int( - "10", - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - TryStatement( - Try { - node: Node { - start: 13652, - end: 13781, - }, - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 13690, - end: 13692, - }, - func: Attribute( - Attribute { - node: Node { - start: 13665, - end: 13690, - }, - value: Name( - Name { - node: Node { - start: 13665, - end: 13673, - }, - id: "response", - }, - ), - attr: "raise_for_status", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - handlers: [ - ExceptHandler { - node: Node { - start: 13697, - end: 13781, - }, - typ: Some( - Name( - Name { - node: Node { - start: 13704, - end: 13713, - }, - id: "HTTPError", - }, - ), - ), - name: None, - body: [ - Raise( - Raise { - node: Node { - start: 13723, - end: 13775, - }, - exc: Some( - Call( - Call { - node: Node { - start: 13729, - end: 13775, - }, - func: Name( - Name { - node: Node { - start: 13729, - end: 13738, - }, - id: "Exception", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 13739, - end: 13774, - }, - value: Str( - "Sorry, tse server did not respond", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - cause: None, - }, - ), - ], - }, - ], - orelse: [], - finalbody: [], + id: "symbol_name", + }, + ), + attr: "strip", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 14092, + end: 14148, + }, + targets: [ + Name( + Name { + node: Node { + start: 14092, + end: 14100, + }, + id: "response", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 14131, + end: 14148, + }, + func: Attribute( + Attribute { + node: Node { + start: 14127, + end: 14131, + }, + value: Call( + Call { + node: Node { + start: 14103, + end: 14127, + }, + func: Name( + Name { + node: Node { + start: 14103, + end: 14125, + }, + id: "requests_retry_session", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + attr: "get", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 14132, + end: 14135, + }, + id: "url", + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 14137, + end: 14147, + }, + arg: Some( + "timeout", + ), + value: Constant( + Constant { + node: Node { + start: 14145, + end: 14147, + }, + value: Int( + "10", + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + TryStatement( + Try { + node: Node { + start: 14153, + end: 14298, + }, + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 14191, + end: 14193, + }, + func: Attribute( + Attribute { + node: Node { + start: 14166, + end: 14191, + }, + value: Name( + Name { + node: Node { + start: 14166, + end: 14174, + }, + id: "response", + }, + ), + attr: "raise_for_status", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + handlers: [ + ExceptHandler { + node: Node { + start: 14198, + end: 14298, + }, + typ: Some( + Name( + Name { + node: Node { + start: 14205, + end: 14214, + }, + id: "HTTPError", + }, + ), + ), + name: None, + body: [ + Raise( + Raise { + node: Node { + start: 14224, + end: 14292, + }, + exc: Some( + Call( + Call { + node: Node { + start: 14230, + end: 14292, + }, + func: Name( + Name { + node: Node { + start: 14230, + end: 14239, + }, + id: "Exception", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 14240, + end: 14291, }, - ), - AssignStatement( - Assign { - node: Node { - start: 13781, - end: 13838, - }, - targets: [ - Name( - Name { - node: Node { - start: 13781, - end: 13797, - }, - id: "symbol_full_info", - }, - ), - ], - value: Call( - Call { + values: [ + Name( + Name { node: Node { - start: 13833, - end: 13838, + start: 14243, + end: 14254, }, - func: Attribute( - Attribute { - node: Node { - start: 13827, - end: 13833, - }, - value: Subscript( - Subscript { - node: Node { - start: 13824, - end: 13827, - }, - value: Call( - Call { - node: Node { - start: 13819, - end: 13824, - }, - func: Attribute( - Attribute { - node: Node { - start: 13800, - end: 13819, - }, - value: Attribute( - Attribute { - node: Node { - start: 13800, - end: 13813, - }, - value: Name( - Name { - node: Node { - start: 13800, - end: 13808, - }, - id: "response", - }, - ), - attr: "text", - }, - ), - attr: "split", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 13820, - end: 13823, - }, - value: Str( - ";", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13825, - end: 13826, - }, - value: Int( - "0", - ), - }, - ), - }, - ), - attr: "split", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 13834, - end: 13837, - }, - value: Str( - ",", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "symbol_name", }, ), - }, - ), - IfStatement( - If { - node: Node { - start: 13843, - end: 13966, - }, - test: Compare( - Compare { + Constant( + Constant { node: Node { - start: 13846, - end: 13912, + start: 14290, + end: 0, }, - left: Call( - Call { - node: Node { - start: 13868, - end: 13881, - }, - func: Attribute( - Attribute { - node: Node { - start: 13846, - end: 13868, - }, - value: Name( - Name { - node: Node { - start: 13846, - end: 13853, - }, - id: "persian", - }, - ), - attr: "replace_arabic", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 13869, - end: 13880, - }, - id: "symbol_name", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, + value: Str( + ": Sorry, tse server did not respond", ), - ops: [ - Eq, - ], - comparators: [ - Call( - Call { - node: Node { - start: 13910, - end: 13912, - }, - func: Attribute( - Attribute { - node: Node { - start: 13904, - end: 13910, - }, - value: Subscript( - Subscript { - node: Node { - start: 13885, - end: 13904, - }, - value: Name( - Name { - node: Node { - start: 13885, - end: 13901, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13902, - end: 13903, - }, - value: Int( - "0", - ), - }, - ), - }, - ), - attr: "strip", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ], }, ), - body: [ - Return( - Return { - node: Node { - start: 13922, - end: 13961, - }, - value: Some( - Subscript( - Subscript { - node: Node { - start: 13929, - end: 13961, - }, - value: Name( - Name { - node: Node { - start: 13929, - end: 13945, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13946, - end: 13947, - }, - value: Int( - "2", - ), - }, - ), - }, - ), - ), - }, - ), - ], - orelse: [], - }, - ), - Return( - Return { - node: Node { - start: 13966, - end: 13977, - }, - value: Some( - Constant( - Constant { - node: Node { - start: 13973, - end: 13977, - }, - value: None, - }, - ), - ), + ], + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + cause: None, + }, + ), + ], + }, + ], + orelse: [], + finalbody: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 14298, + end: 14332, + }, + targets: [ + Name( + Name { + node: Node { + start: 14298, + end: 14305, + }, + id: "symbols", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 14327, + end: 14332, + }, + func: Attribute( + Attribute { + node: Node { + start: 14308, + end: 14327, + }, + value: Attribute( + Attribute { + node: Node { + start: 14308, + end: 14321, + }, + value: Name( + Name { + node: Node { + start: 14308, + end: 14316, + }, + id: "response", + }, + ), + attr: "text", + }, + ), + attr: "split", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 14328, + end: 14331, + }, + value: Str( + ";", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 14337, + end: 14467, + }, + targets: [ + Name( + Name { + node: Node { + start: 14337, + end: 14350, + }, + id: "market_symbol", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 14353, + end: 14467, + }, + func: Name( + Name { + node: Node { + start: 14353, + end: 14365, + }, + id: "MarketSymbol", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 14375, + end: 14384, + }, + arg: Some( + "code", + ), + value: Constant( + Constant { + node: Node { + start: 14380, + end: 14384, + }, + value: None, + }, + ), + }, + Keyword { + node: Node { + start: 14394, + end: 14405, + }, + arg: Some( + "symbol", + ), + value: Constant( + Constant { + node: Node { + start: 14401, + end: 14405, + }, + value: None, + }, + ), + }, + Keyword { + node: Node { + start: 14415, + end: 14425, + }, + arg: Some( + "index", + ), + value: Constant( + Constant { + node: Node { + start: 14421, + end: 14425, + }, + value: None, + }, + ), + }, + Keyword { + node: Node { + start: 14435, + end: 14444, + }, + arg: Some( + "name", + ), + value: Constant( + Constant { + node: Node { + start: 14440, + end: 14444, + }, + value: None, + }, + ), + }, + Keyword { + node: Node { + start: 14454, + end: 14460, + }, + arg: Some( + "old", + ), + value: List( + List { + node: Node { + start: 14458, + end: 14460, + }, + elements: [], + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ForStatement( + For { + node: Node { + start: 14472, + end: 15195, + }, + target: Name( + Name { + node: Node { + start: 14476, + end: 14492, + }, + id: "symbol_full_info", + }, + ), + iter: Name( + Name { + node: Node { + start: 14496, + end: 14503, + }, + id: "symbols", + }, + ), + body: [ + IfStatement( + If { + node: Node { + start: 14513, + end: 14577, + }, + test: Compare( + Compare { + node: Node { + start: 14516, + end: 14546, + }, + left: Call( + Call { + node: Node { + start: 14538, + end: 14540, + }, + func: Attribute( + Attribute { + node: Node { + start: 14516, + end: 14538, + }, + value: Name( + Name { + node: Node { + start: 14516, + end: 14532, }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, + id: "symbol_full_info", + }, + ), + attr: "strip", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ops: [ + Eq, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 14544, + end: 14546, + }, + value: Str( + "", + ), + }, + ), + ], + }, + ), + body: [ + Continue( + Continue { + node: Node { + start: 14560, + end: 14568, + }, + }, + ), + ], + orelse: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 14577, + end: 14623, + }, + targets: [ + Name( + Name { + node: Node { + start: 14577, + end: 14593, + }, + id: "symbol_full_info", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 14618, + end: 14623, + }, + func: Attribute( + Attribute { + node: Node { + start: 14596, + end: 14618, + }, + value: Name( + Name { + node: Node { + start: 14596, + end: 14612, + }, + id: "symbol_full_info", }, ), - FunctionDef( - FunctionDef { + attr: "split", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 14619, + end: 14622, + }, + value: Str( + ",", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 14632, + end: 15195, + }, + test: Compare( + Compare { + node: Node { + start: 14635, + end: 14693, + }, + left: Call( + Call { + node: Node { + start: 14657, + end: 14678, + }, + func: Attribute( + Attribute { node: Node { - start: 13980, - end: 15273, + start: 14635, + end: 14657, }, - name: "get_symbol_info", - args: Arguments { + value: Name( + Name { + node: Node { + start: 14635, + end: 14642, + }, + id: "persian", + }, + ), + attr: "replace_arabic", + }, + ), + args: [ + Subscript( + Subscript { node: Node { - start: 14000, - end: 14016, + start: 14658, + end: 14677, }, - posonlyargs: [], - args: [ - Arg { + value: Name( + Name { node: Node { - start: 14000, - end: 14016, + start: 14658, + end: 14674, }, - arg: "symbol_name", - annotation: Some( - Name( - Name { - node: Node { - start: 14013, - end: 14016, - }, - id: "str", - }, - ), - ), + id: "symbol_full_info", }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - AssignStatement( - Assign { + ), + slice: Constant( + Constant { node: Node { - start: 14023, - end: 14087, + start: 14675, + end: 14676, }, - targets: [ - Name( - Name { - node: Node { - start: 14023, - end: 14026, - }, - id: "url", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 14066, - end: 14087, - }, - func: Attribute( - Attribute { - node: Node { - start: 14029, - end: 14066, - }, - value: Attribute( - Attribute { - node: Node { - start: 14029, - end: 14059, - }, - value: Name( - Name { - node: Node { - start: 14029, - end: 14041, - }, - id: "tse_settings", - }, - ), - attr: "TSE_SYMBOL_ID_URL", - }, - ), - attr: "format", - }, - ), - args: [ - Call( - Call { - node: Node { - start: 14084, - end: 14086, - }, - func: Attribute( - Attribute { - node: Node { - start: 14067, - end: 14084, - }, - value: Name( - Name { - node: Node { - start: 14067, - end: 14078, - }, - id: "symbol_name", - }, - ), - attr: "strip", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, + value: Int( + "0", ), }, ), - AssignStatement( - Assign { + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ops: [ + Eq, + ], + comparators: [ + Name( + Name { + node: Node { + start: 14682, + end: 14693, + }, + id: "symbol_name", + }, + ), + ], + }, + ), + body: [ + IfStatement( + If { + node: Node { + start: 14744, + end: 15195, + }, + test: Compare( + Compare { + node: Node { + start: 14747, + end: 14773, + }, + left: Subscript( + Subscript { + node: Node { + start: 14747, + end: 14766, + }, + value: Name( + Name { node: Node { - start: 14092, - end: 14148, + start: 14747, + end: 14763, }, - targets: [ - Name( - Name { - node: Node { - start: 14092, - end: 14100, - }, - id: "response", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 14131, - end: 14148, - }, - func: Attribute( - Attribute { - node: Node { - start: 14127, - end: 14131, - }, - value: Call( - Call { - node: Node { - start: 14103, - end: 14127, - }, - func: Name( - Name { - node: Node { - start: 14103, - end: 14125, - }, - id: "requests_retry_session", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "get", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 14132, - end: 14135, - }, - id: "url", - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 14137, - end: 14147, - }, - arg: Some( - "timeout", - ), - value: Constant( - Constant { - node: Node { - start: 14145, - end: 14147, - }, - value: Int( - "10", - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), + id: "symbol_full_info", }, ), - TryStatement( - Try { + slice: Constant( + Constant { node: Node { - start: 14153, - end: 14298, + start: 14764, + end: 14765, }, - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 14191, - end: 14193, - }, - func: Attribute( - Attribute { - node: Node { - start: 14166, - end: 14191, - }, - value: Name( - Name { - node: Node { - start: 14166, - end: 14174, - }, - id: "response", - }, - ), - attr: "raise_for_status", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - handlers: [ - ExceptHandler { - node: Node { - start: 14198, - end: 14298, - }, - typ: Some( - Name( - Name { - node: Node { - start: 14205, - end: 14214, - }, - id: "HTTPError", - }, - ), - ), - name: None, - body: [ - Raise( - Raise { - node: Node { - start: 14224, - end: 14292, - }, - exc: Some( - Call( - Call { - node: Node { - start: 14230, - end: 14292, - }, - func: Name( - Name { - node: Node { - start: 14230, - end: 14239, - }, - id: "Exception", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 14240, - end: 14291, - }, - values: [ - Name( - Name { - node: Node { - start: 14243, - end: 14254, - }, - id: "symbol_name", - }, - ), - Constant( - Constant { - node: Node { - start: 14290, - end: 0, - }, - value: Str( - ": Sorry, tse server did not respond", - ), - }, - ), - ], - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - cause: None, - }, - ), - ], - }, - ], - orelse: [], - finalbody: [], + value: Int( + "7", + ), }, ), - AssignStatement( - Assign { + }, + ), + ops: [ + Eq, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 14770, + end: 14773, + }, + value: Str( + "1", + ), + }, + ), + ], + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 14791, + end: 14895, + }, + targets: [ + Attribute( + Attribute { node: Node { - start: 14298, - end: 14332, + start: 14791, + end: 14811, }, - targets: [ - Name( - Name { - node: Node { - start: 14298, - end: 14305, - }, - id: "symbols", - }, - ), - ], - value: Call( - Call { + value: Name( + Name { node: Node { - start: 14327, - end: 14332, + start: 14791, + end: 14804, }, - func: Attribute( - Attribute { - node: Node { - start: 14308, - end: 14327, - }, - value: Attribute( - Attribute { - node: Node { - start: 14308, - end: 14321, - }, - value: Name( - Name { - node: Node { - start: 14308, - end: 14316, - }, - id: "response", - }, - ), - attr: "text", - }, - ), - attr: "split", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 14328, - end: 14331, - }, - value: Str( - ";", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "market_symbol", }, ), + attr: "symbol", }, ), - AssignStatement( - Assign { - node: Node { - start: 14337, - end: 14467, - }, - targets: [ - Name( + ], + value: Call( + Call { + node: Node { + start: 14836, + end: 14895, + }, + func: Attribute( + Attribute { + node: Node { + start: 14814, + end: 14836, + }, + value: Name( Name { node: Node { - start: 14337, - end: 14350, + start: 14814, + end: 14821, }, - id: "market_symbol", + id: "persian", }, ), - ], - value: Call( - Call { + attr: "replace_arabic", + }, + ), + args: [ + Subscript( + Subscript { node: Node { - start: 14353, - end: 14467, + start: 14858, + end: 14877, }, - func: Name( + value: Name( Name { node: Node { - start: 14353, - end: 14365, + start: 14858, + end: 14874, }, - id: "MarketSymbol", + id: "symbol_full_info", }, ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 14375, - end: 14384, - }, - arg: Some( - "code", - ), - value: Constant( - Constant { - node: Node { - start: 14380, - end: 14384, - }, - value: None, - }, - ), - }, - Keyword { - node: Node { - start: 14394, - end: 14405, - }, - arg: Some( - "symbol", - ), - value: Constant( - Constant { - node: Node { - start: 14401, - end: 14405, - }, - value: None, - }, - ), - }, - Keyword { - node: Node { - start: 14415, - end: 14425, - }, - arg: Some( - "index", - ), - value: Constant( - Constant { - node: Node { - start: 14421, - end: 14425, - }, - value: None, - }, - ), - }, - Keyword { - node: Node { - start: 14435, - end: 14444, - }, - arg: Some( - "name", - ), - value: Constant( - Constant { - node: Node { - start: 14440, - end: 14444, - }, - value: None, - }, - ), - }, - Keyword { + slice: Constant( + Constant { node: Node { - start: 14454, - end: 14460, + start: 14875, + end: 14876, }, - arg: Some( - "old", - ), - value: List( - List { - node: Node { - start: 14458, - end: 14460, - }, - elements: [], - }, + value: Int( + "0", ), }, - ], - starargs: None, - kwargs: None, + ), }, ), - }, - ), - ForStatement( - For { + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 14912, + end: 15014, + }, + targets: [ + Attribute( + Attribute { node: Node { - start: 14472, - end: 15195, + start: 14912, + end: 14930, }, - target: Name( + value: Name( Name { node: Node { - start: 14476, - end: 14492, + start: 14912, + end: 14925, }, - id: "symbol_full_info", + id: "market_symbol", }, ), - iter: Name( - Name { - node: Node { - start: 14496, - end: 14503, - }, - id: "symbols", + attr: "name", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 14955, + end: 15014, + }, + func: Attribute( + Attribute { + node: Node { + start: 14933, + end: 14955, }, - ), - body: [ - IfStatement( - If { - node: Node { - start: 14513, - end: 14577, - }, - test: Compare( - Compare { - node: Node { - start: 14516, - end: 14546, - }, - left: Call( - Call { - node: Node { - start: 14538, - end: 14540, - }, - func: Attribute( - Attribute { - node: Node { - start: 14516, - end: 14538, - }, - value: Name( - Name { - node: Node { - start: 14516, - end: 14532, - }, - id: "symbol_full_info", - }, - ), - attr: "strip", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 14544, - end: 14546, - }, - value: Str( - "", - ), - }, - ), - ], - }, - ), - body: [ - Continue( - Continue { - node: Node { - start: 14560, - end: 14568, - }, - }, - ), - ], - orelse: [], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 14577, - end: 14623, - }, - targets: [ - Name( - Name { - node: Node { - start: 14577, - end: 14593, - }, - id: "symbol_full_info", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 14618, - end: 14623, - }, - func: Attribute( - Attribute { - node: Node { - start: 14596, - end: 14618, - }, - value: Name( - Name { - node: Node { - start: 14596, - end: 14612, - }, - id: "symbol_full_info", - }, - ), - attr: "split", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 14619, - end: 14622, - }, - value: Str( - ",", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { + value: Name( + Name { node: Node { - start: 14632, - end: 15195, + start: 14933, + end: 14940, }, - test: Compare( - Compare { - node: Node { - start: 14635, - end: 14693, - }, - left: Call( - Call { - node: Node { - start: 14657, - end: 14678, - }, - func: Attribute( - Attribute { - node: Node { - start: 14635, - end: 14657, - }, - value: Name( - Name { - node: Node { - start: 14635, - end: 14642, - }, - id: "persian", - }, - ), - attr: "replace_arabic", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 14658, - end: 14677, - }, - value: Name( - Name { - node: Node { - start: 14658, - end: 14674, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 14675, - end: 14676, - }, - value: Int( - "0", - ), - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - Eq, - ], - comparators: [ - Name( - Name { - node: Node { - start: 14682, - end: 14693, - }, - id: "symbol_name", - }, - ), - ], - }, - ), - body: [ - IfStatement( - If { - node: Node { - start: 14744, - end: 15195, - }, - test: Compare( - Compare { - node: Node { - start: 14747, - end: 14773, - }, - left: Subscript( - Subscript { - node: Node { - start: 14747, - end: 14766, - }, - value: Name( - Name { - node: Node { - start: 14747, - end: 14763, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 14764, - end: 14765, - }, - value: Int( - "7", - ), - }, - ), - }, - ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 14770, - end: 14773, - }, - value: Str( - "1", - ), - }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 14791, - end: 14895, - }, - targets: [ - Attribute( - Attribute { - node: Node { - start: 14791, - end: 14811, - }, - value: Name( - Name { - node: Node { - start: 14791, - end: 14804, - }, - id: "market_symbol", - }, - ), - attr: "symbol", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 14836, - end: 14895, - }, - func: Attribute( - Attribute { - node: Node { - start: 14814, - end: 14836, - }, - value: Name( - Name { - node: Node { - start: 14814, - end: 14821, - }, - id: "persian", - }, - ), - attr: "replace_arabic", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 14858, - end: 14877, - }, - value: Name( - Name { - node: Node { - start: 14858, - end: 14874, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 14875, - end: 14876, - }, - value: Int( - "0", - ), - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 14912, - end: 15014, - }, - targets: [ - Attribute( - Attribute { - node: Node { - start: 14912, - end: 14930, - }, - value: Name( - Name { - node: Node { - start: 14912, - end: 14925, - }, - id: "market_symbol", - }, - ), - attr: "name", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 14955, - end: 15014, - }, - func: Attribute( - Attribute { - node: Node { - start: 14933, - end: 14955, - }, - value: Name( - Name { - node: Node { - start: 14933, - end: 14940, - }, - id: "persian", - }, - ), - attr: "replace_arabic", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 14977, - end: 14996, - }, - value: Name( - Name { - node: Node { - start: 14977, - end: 14993, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 14994, - end: 14995, - }, - value: Int( - "1", - ), - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 15031, - end: 15092, - }, - targets: [ - Attribute( - Attribute { - node: Node { - start: 15031, - end: 15050, - }, - value: Name( - Name { - node: Node { - start: 15031, - end: 15044, - }, - id: "market_symbol", - }, - ), - attr: "index", - }, - ), - ], - value: Subscript( - Subscript { - node: Node { - start: 15053, - end: 15092, - }, - value: Name( - Name { - node: Node { - start: 15053, - end: 15069, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 15070, - end: 15071, - }, - value: Int( - "2", - ), - }, - ), - }, - ), - }, - ), - ], - orelse: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 15151, - end: 15189, - }, - func: Attribute( - Attribute { - node: Node { - start: 15127, - end: 15151, - }, - value: Attribute( - Attribute { - node: Node { - start: 15127, - end: 15144, - }, - value: Name( - Name { - node: Node { - start: 15127, - end: 15140, - }, - id: "market_symbol", - }, - ), - attr: "old", - }, - ), - attr: "append", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 15152, - end: 15171, - }, - value: Name( - Name { - node: Node { - start: 15152, - end: 15168, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 15169, - end: 15170, - }, - value: Int( - "2", - ), - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - }, - ), - ], - orelse: [], + id: "persian", }, ), - ], - orelse: [], - }, - ), - IfStatement( - If { - node: Node { - start: 15195, - end: 15251, + attr: "replace_arabic", }, - test: Compare( - Compare { + ), + args: [ + Subscript( + Subscript { node: Node { - start: 15198, - end: 15225, + start: 14977, + end: 14996, }, - left: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 15198, - end: 15217, + start: 14977, + end: 14993, }, - value: Name( - Name { - node: Node { - start: 15198, - end: 15211, - }, - id: "market_symbol", - }, - ), - attr: "index", + id: "symbol_full_info", }, ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 15221, - end: 15225, - }, - value: None, + slice: Constant( + Constant { + node: Node { + start: 14994, + end: 14995, }, - ), - ], + value: Int( + "1", + ), + }, + ), }, ), - body: [ - Return( - Return { - node: Node { - start: 15235, - end: 15246, - }, - value: Some( - Constant( - Constant { - node: Node { - start: 15242, - end: 15246, - }, - value: None, - }, - ), - ), - }, - ), - ], - orelse: [], - }, - ), - Return( - Return { + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 15031, + end: 15092, + }, + targets: [ + Attribute( + Attribute { node: Node { - start: 15251, - end: 15271, + start: 15031, + end: 15050, }, - value: Some( - Name( - Name { - node: Node { - start: 15258, - end: 15271, - }, - id: "market_symbol", + value: Name( + Name { + node: Node { + start: 15031, + end: 15044, }, - ), + id: "market_symbol", + }, ), + attr: "index", }, ), ], - decorator_list: [], - returns: None, - type_comment: None, - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, - }, - ), - ], - decorator_list: [], - returns: Some( - Subscript( - Subscript { - node: Node { - start: 8546, - end: 8569, - }, - value: Name( - Name { - node: Node { - start: 8546, - end: 8550, - }, - id: "Dict", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 8551, - end: 8569, - }, - elements: [ - Name( - Name { - node: Node { - start: 8551, - end: 8554, - }, - id: "str", - }, - ), - Attribute( - Attribute { + value: Subscript( + Subscript { node: Node { - start: 8556, - end: 8568, + start: 15053, + end: 15092, }, value: Name( Name { node: Node { - start: 8556, - end: 8558, + start: 15053, + end: 15069, }, - id: "pd", + id: "symbol_full_info", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 15070, + end: 15071, + }, + value: Int( + "2", + ), }, ), - attr: "DataFrame", }, ), - ], - }, - ), + }, + ), + ], + orelse: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 15151, + end: 15189, + }, + func: Attribute( + Attribute { + node: Node { + start: 15127, + end: 15151, + }, + value: Attribute( + Attribute { + node: Node { + start: 15127, + end: 15144, + }, + value: Name( + Name { + node: Node { + start: 15127, + end: 15140, + }, + id: "market_symbol", + }, + ), + attr: "old", + }, + ), + attr: "append", + }, + ), + args: [ + Subscript( + Subscript { + node: Node { + start: 15152, + end: 15171, + }, + value: Name( + Name { + node: Node { + start: 15152, + end: 15168, + }, + id: "symbol_full_info", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 15169, + end: 15170, + }, + value: Int( + "2", + ), + }, + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], }, ), - ), - type_comment: None, + ], + orelse: [], }, ), ], + orelse: [], }, ), - ], - decorator_list: [], - returns: Some( - Subscript( - Subscript { + IfStatement( + If { node: Node { - start: 1637, - end: 1660, + start: 15195, + end: 15251, }, - value: Name( - Name { - node: Node { - start: 1637, - end: 1641, - }, - id: "Dict", - }, - ), - slice: Tuple( - Tuple { + test: Compare( + Compare { node: Node { - start: 1642, - end: 1660, + start: 15198, + end: 15225, }, - elements: [ - Name( - Name { - node: Node { - start: 1642, - end: 1645, - }, - id: "str", + left: Attribute( + Attribute { + node: Node { + start: 15198, + end: 15217, }, - ), - Attribute( - Attribute { + value: Name( + Name { + node: Node { + start: 15198, + end: 15211, + }, + id: "market_symbol", + }, + ), + attr: "index", + }, + ), + ops: [ + Is, + ], + comparators: [ + Constant( + Constant { node: Node { - start: 1647, - end: 1659, + start: 15221, + end: 15225, }, - value: Name( - Name { - node: Node { - start: 1647, - end: 1649, - }, - id: "pd", - }, - ), - attr: "DataFrame", + value: None, }, ), ], }, ), + body: [ + Return( + Return { + node: Node { + start: 15235, + end: 15246, + }, + value: Some( + Constant( + Constant { + node: Node { + start: 15242, + end: 15246, + }, + value: None, + }, + ), + ), + }, + ), + ], + orelse: [], }, ), - ), + Return( + Return { + node: Node { + start: 15251, + end: 15271, + }, + value: Some( + Name( + Name { + node: Node { + start: 15258, + end: 15271, + }, + id: "market_symbol", + }, + ), + ), + }, + ), + ], + decorator_list: [], + returns: None, type_comment: None, }, ),