From 12604ab414912b68839bfc48855ceee20a22971e Mon Sep 17 00:00:00 2001 From: Glyphack Date: Sat, 30 Sep 2023 19:00:22 +0200 Subject: [PATCH] Fix nested indentation problem --- parser/src/lexer/lexer.rs | 18 + ...r__lexer__lexer__tests__indentation-2.snap | 6 + parser/src/parser/parser.rs | 95 +- ..._parser__tests__complete@functions.py.snap | 544 +- ...parser__parser__tests__complete@if.py.snap | 171 + ...ser__tests__complete@input_program.py.snap | 25398 ++++++++-------- ...__parser__tests__func_def_statement-2.snap | 47 - ...__parser__tests__func_def_statement-3.snap | 72 - ...__parser__tests__func_def_statement-4.snap | 74 - ...__parser__tests__func_def_statement-5.snap | 72 - ...__parser__tests__func_def_statement-6.snap | 57 - ...__parser__tests__func_def_statement-7.snap | 167 - ...__parser__tests__func_def_statement-8.snap | 57 - ...er__parser__tests__func_def_statement.snap | 47 - ...parser__tests__one_liners@match.py-2.snap} | 1 + ...parser__tests__one_liners@match.py-3.snap} | 1 + ...parser__tests__one_liners@match.py-4.snap} | 9 +- ...parser__tests__one_liners@match.py-5.snap} | 9 +- ...parser__tests__one_liners@match.py-6.snap} | 9 +- ...parser__tests__one_liners@match.py-7.snap} | 9 +- ...parser__tests__one_liners@match.py-8.snap} | 9 +- ...__parser__tests__one_liners@match.py.snap} | 1 + ...ser__tests__parse_import_statement-10.snap | 32 - ...ser__tests__parse_import_statement-11.snap | 32 - ...ser__tests__parse_import_statement-12.snap | 32 - ...ser__tests__parse_import_statement-13.snap | 32 - ...ser__tests__parse_import_statement-14.snap | 32 - ...ser__tests__parse_import_statement-15.snap | 11 - ...rser__tests__parse_import_statement-2.snap | 32 - ...rser__tests__parse_import_statement-3.snap | 30 - ...rser__tests__parse_import_statement-4.snap | 32 - ...rser__tests__parse_import_statement-5.snap | 30 - ...rser__tests__parse_import_statement-6.snap | 32 - ...rser__tests__parse_import_statement-7.snap | 34 - ...rser__tests__parse_import_statement-8.snap | 32 - ...rser__tests__parse_import_statement-9.snap | 34 - ...parser__tests__parse_import_statement.snap | 30 - parser/test_data/inputs/if.py | 8 + parser/test_data/inputs/one_liners/match.py | 49 + typechecker/src/build.rs | 1 - 40 files changed, 13279 insertions(+), 14109 deletions(-) create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@if.py.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-2.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-3.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-4.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-5.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-6.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-7.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-8.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement.snap rename parser/src/parser/snapshots/{enderpy_python_parser__parser__parser__tests__match_statement-2.snap => enderpy_python_parser__parser__parser__tests__one_liners@match.py-2.snap} (98%) rename parser/src/parser/snapshots/{enderpy_python_parser__parser__parser__tests__match_statement-3.snap => enderpy_python_parser__parser__parser__tests__one_liners@match.py-3.snap} (97%) rename parser/src/parser/snapshots/{enderpy_python_parser__parser__parser__tests__match_statement-4.snap => enderpy_python_parser__parser__parser__tests__one_liners@match.py-4.snap} (98%) rename parser/src/parser/snapshots/{enderpy_python_parser__parser__parser__tests__match_statement-5.snap => enderpy_python_parser__parser__parser__tests__one_liners@match.py-5.snap} (95%) rename parser/src/parser/snapshots/{enderpy_python_parser__parser__parser__tests__match_statement-6.snap => enderpy_python_parser__parser__parser__tests__one_liners@match.py-6.snap} (97%) rename parser/src/parser/snapshots/{enderpy_python_parser__parser__parser__tests__match_statement-7.snap => enderpy_python_parser__parser__parser__tests__one_liners@match.py-7.snap} (97%) rename parser/src/parser/snapshots/{enderpy_python_parser__parser__parser__tests__match_statement-8.snap => enderpy_python_parser__parser__parser__tests__one_liners@match.py-8.snap} (93%) rename parser/src/parser/snapshots/{enderpy_python_parser__parser__parser__tests__match_statement.snap => enderpy_python_parser__parser__parser__tests__one_liners@match.py.snap} (97%) delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-10.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-11.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-12.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-13.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-14.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-15.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-2.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-3.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-4.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-5.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-6.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-7.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-8.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-9.snap delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement.snap create mode 100644 parser/test_data/inputs/if.py create mode 100644 parser/test_data/inputs/one_liners/match.py diff --git a/parser/src/lexer/lexer.rs b/parser/src/lexer/lexer.rs index 167147aa..74b89f1c 100644 --- a/parser/src/lexer/lexer.rs +++ b/parser/src/lexer/lexer.rs @@ -26,6 +26,9 @@ pub struct Lexer { // Each time we see a right bracket we decrement this // This is used to match brackets in fstrings inside_fstring_bracket: i8, + + // TODO: Hacky way to handle emitting multiple de indents + next_token_is_dedent: u8, } impl Lexer { @@ -38,10 +41,20 @@ impl Lexer { nesting: 0, fstring_stack: vec![], inside_fstring_bracket: 0, + next_token_is_dedent: 0, } } pub fn next_token(&mut self) -> Result { + while self.next_token_is_dedent > 0 { + self.next_token_is_dedent -= 1; + return Ok(Token { + kind: Kind::Dedent, + value: TokenValue::None, + start: self.current, + end: self.current, + }); + } let start = self.current; let kind = self.next_kind()?; @@ -68,12 +81,14 @@ impl Lexer { let fstring_stack = self.fstring_stack.clone(); let start_of_line = self.start_of_line; let inside_fstring_bracket = self.inside_fstring_bracket; + let next_token_is_dedent = self.next_token_is_dedent; let token = self.next_token(); self.current = current; self.nesting = nesting; self.fstring_stack = fstring_stack; self.start_of_line = start_of_line; self.inside_fstring_bracket = inside_fstring_bracket; + self.next_token_is_dedent = next_token_is_dedent; token } @@ -843,6 +858,9 @@ impl Lexer { Ordering::Less => panic!("Invalid indentation, current indentation is {} which is less than previous {}", spaces_count, top), } } + if de_indents != 1 { + self.next_token_is_dedent += 1; + } TokenValue::Indent(de_indents) } Kind::Indent => TokenValue::Indent(1), diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__indentation-2.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__indentation-2.snap index 361c7962..f090829b 100644 --- a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__indentation-2.snap +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__indentation-2.snap @@ -87,6 +87,12 @@ description: "if True:\n if True:\n pass\ndef" start: 35, end: 35, }, + Token { + kind: Dedent, + value: None, + start: 35, + end: 35, + }, Token { kind: Def, value: None, diff --git a/parser/src/parser/parser.rs b/parser/src/parser/parser.rs index 0b1d7181..8e13f62a 100644 --- a/parser/src/parser/parser.rs +++ b/parser/src/parser/parser.rs @@ -167,7 +167,6 @@ impl Parser { } match token { Err(err) => { - // println!("Error: {:#?}", err); self.bump_any(); } Ok(token) => { @@ -204,6 +203,31 @@ impl Parser { Ok(()) } + /// Expect any of `Kinds` or return error + pub fn expect_any(&mut self, kind: Vec) -> Result<(), ParsingError> { + if !kind.contains(&self.cur_token.kind) { + let found = self.cur_token.kind; + let node = self.start_node(); + let range = self.finish_node(node); + let mut expected = String::new(); + for kind in kind { + expected.push_str(&format!("{:?}, ", kind)); + } + let err = ParsingError::InvalidSyntax { + path: Box::from(self.path.as_str()), + msg: Box::from(format!("Expected one of {:?} but found {:?}", expected, found)), + line: self.curr_line_number, + input: self.curr_line_string.clone(), + advice: "maybe you forgot to put this character".to_string(), + span: (range.start, range.end), + }; + self.advance_to_next_line_or_semicolon(); + return Err(err); + } + self.bump_any(); + Ok(()) + } + fn unepxted_token(&mut self, node: Node, kind: Kind) -> Result<(), ParsingError> { self.bump_any(); let range = self.finish_node(node); @@ -400,6 +424,7 @@ impl Parser { orelse = Some(if_value); } } + let mut single_else_body: Option> = None; if self.eat(Kind::Else) { self.expect(Kind::Colon)?; @@ -422,10 +447,6 @@ impl Parser { } }; - // There can be a dedent after the if block - // The only other token here can be a eof - self.bump(Kind::Dedent); - Ok(Statement::IfStatement(If { node: self.finish_node(node), test, @@ -753,6 +774,7 @@ impl Parser { self.expect(Kind::NewLine)?; self.expect(Kind::Indent)?; let cases = self.parse_cases()?; + self.expect_any(vec![Kind::Dedent, Kind::Eof])?; Ok(Statement::Match(Match { node: self.finish_node(node), @@ -2248,6 +2270,7 @@ impl Parser { } else if is_atom(&self.cur_kind()) { self.parse_atom()? } else { + panic!("invalid primary expression {:?}", self.cur_kind()); return Err(self.unepxted_token(node, self.cur_kind()).err().unwrap()); }; @@ -3656,68 +3679,6 @@ class a: pass", } } - #[test] - fn test_match_statement() { - for test_case in &[ - "match a: - case 1: - pass", - "match a: - case 1 | 2: - pass", - "match a.b: - case 1: - pass", - "match a: - case None: - pass - case True: - pass - case False: - pass - case -1: - pass - case 1.0: - pass - case _: - pass -", - "match a: - case a.b: - pass - case a: - pass -", - "match a: - case (a, b): - pass - case {1: _, 2: _}: - pass - case {**rest}: - pass -", - "match x: - case Point2D(0, 0): - pass - case Point3D(x=0, y=0, z=0): - pass -", - "match x: - case [a, b, c]: - pass", - ] { - 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_complete() { glob!("../../test_data", "inputs/*.py", |path| { diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@functions.py.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@functions.py.snap index ea78b72a..3c683fea 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@functions.py.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@functions.py.snap @@ -13,7 +13,7 @@ Module { FunctionDef { node: Node { start: 0, - end: 609, + end: 342, }, name: "_handle_ticker_index", args: Arguments { @@ -102,7 +102,7 @@ Module { If { node: Node { start: 96, - end: 342, + end: 320, }, test: Compare( Compare { @@ -307,366 +307,366 @@ Module { orelse: [], }, ), - Return( - Return { + ], + orelse: [], + }, + ), + Return( + Return { + node: Node { + start: 320, + end: 339, + }, + value: Some( + Name( + Name { node: Node { - start: 320, + start: 327, end: 339, }, - value: Some( - Name( - Name { - node: Node { - start: 327, - end: 339, - }, - id: "ticker_index", - }, - ), - ), + id: "ticker_index", }, ), - ], - orelse: [], + ), }, ), - FunctionDef( - FunctionDef { + ], + decorator_list: [], + returns: None, + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 342, + end: 609, + }, + name: "_extract_ticker_client_types_data", + args: Arguments { + node: Node { + start: 380, + end: 397, + }, + posonlyargs: [], + args: [ + Arg { node: Node { - start: 342, - end: 609, + start: 380, + end: 397, }, - name: "_extract_ticker_client_types_data", - args: Arguments { - node: Node { - start: 380, - end: 397, - }, - posonlyargs: [], - args: [ - Arg { + arg: "ticker_index", + annotation: Some( + Name( + Name { node: Node { - start: 380, + start: 394, end: 397, }, - arg: "ticker_index", - annotation: Some( - Name( + id: "str", + }, + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 412, + end: 463, + }, + targets: [ + Name( + Name { + node: Node { + start: 412, + end: 415, + }, + id: "url", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 449, + end: 463, + }, + func: Attribute( + Attribute { + node: Node { + start: 418, + end: 449, + }, + value: Name( Name { node: Node { - start: 394, - end: 397, + start: 418, + end: 442, }, - id: "str", + id: "TSE_CLIENT_TYPE_DATA_URL", }, ), + attr: "format", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 450, + end: 462, + }, + id: "ticker_index", + }, ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + WithStatement( + With { + node: Node { + start: 468, + end: 561, }, + items: [ + WithItem { + node: Node { + start: 473, + end: 508, + }, + context_expr: Call( + Call { + node: Node { + start: 473, + end: 497, + }, + func: Name( + Name { + node: Node { + start: 473, + end: 495, + }, + id: "requests_retry_session", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + optional_vars: Some( + Name( + Name { + node: Node { + start: 501, + end: 508, + }, + id: "session", + }, + ), + ), + }, + ], body: [ AssignStatement( Assign { node: Node { - start: 412, - end: 463, + start: 518, + end: 556, }, targets: [ Name( Name { node: Node { - start: 412, - end: 415, + start: 518, + end: 526, }, - id: "url", + id: "response", }, ), ], value: Call( Call { node: Node { - start: 449, - end: 463, + start: 540, + end: 556, }, func: Attribute( Attribute { node: Node { - start: 418, - end: 449, + start: 529, + end: 540, }, value: Name( Name { node: Node { - start: 418, - end: 442, + start: 529, + end: 536, }, - id: "TSE_CLIENT_TYPE_DATA_URL", + id: "session", }, ), - attr: "format", + attr: "get", }, ), args: [ Name( Name { node: Node { - start: 450, - end: 462, + start: 541, + end: 544, }, - id: "ticker_index", + id: "url", }, ), ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - WithStatement( - With { - node: Node { - start: 468, - end: 561, - }, - items: [ - WithItem { - node: Node { - start: 473, - end: 508, - }, - context_expr: Call( - Call { + keywords: [ + Keyword { node: Node { - start: 473, - end: 497, + start: 546, + end: 555, }, - func: Name( - Name { - node: Node { - start: 473, - end: 495, - }, - id: "requests_retry_session", - }, + arg: Some( + "timeout", ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - optional_vars: Some( - Name( - Name { - node: Node { - start: 501, - end: 508, - }, - id: "session", - }, - ), - ), - }, - ], - body: [ - AssignStatement( - Assign { - node: Node { - start: 518, - end: 556, - }, - targets: [ - Name( - Name { + value: Constant( + Constant { node: Node { - start: 518, - end: 526, + start: 554, + end: 555, }, - id: "response", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 540, - end: 556, - }, - func: Attribute( - Attribute { - node: Node { - start: 529, - end: 540, - }, - value: Name( - Name { - node: Node { - start: 529, - end: 536, - }, - id: "session", - }, - ), - attr: "get", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 541, - end: 544, - }, - id: "url", - }, + value: Int( + "5", ), - ], - keywords: [ - Keyword { - node: Node { - start: 546, - end: 555, - }, - arg: Some( - "timeout", - ), - value: Constant( - Constant { - node: Node { - start: 554, - end: 555, - }, - value: Int( - "5", - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 561, - end: 592, - }, - targets: [ - Name( - Name { - node: Node { - start: 561, - end: 565, - }, - id: "data", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 587, - end: 592, - }, - func: Attribute( - Attribute { - node: Node { - start: 568, - end: 587, - }, - value: Attribute( - Attribute { - node: Node { - start: 568, - end: 581, - }, - value: Name( - Name { - node: Node { - start: 568, - end: 576, - }, - id: "response", - }, - ), - attr: "text", }, ), - attr: "split", }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 588, - end: 591, - }, - value: Str( - ";", - ), - }, - ), ], - keywords: [], starargs: None, kwargs: None, }, ), }, ), - Return( - Return { + ], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 561, + end: 592, + }, + targets: [ + Name( + Name { node: Node { - start: 597, - end: 608, + start: 561, + end: 565, }, - value: Some( - Name( - Name { + id: "data", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 587, + end: 592, + }, + func: Attribute( + Attribute { + node: Node { + start: 568, + end: 587, + }, + value: Attribute( + Attribute { node: Node { - start: 604, - end: 608, + start: 568, + end: 581, }, - id: "data", + value: Name( + Name { + node: Node { + start: 568, + end: 576, + }, + id: "response", + }, + ), + attr: "text", }, ), + attr: "split", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 588, + end: 591, + }, + value: Str( + ";", + ), + }, ), - }, - ), - ], - decorator_list: [], - returns: Some( + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + Return( + Return { + node: Node { + start: 597, + end: 608, + }, + value: Some( Name( Name { node: Node { - start: 402, - end: 406, + start: 604, + end: 608, }, - id: "List", + id: "data", }, ), ), - type_comment: None, }, ), ], decorator_list: [], - returns: None, + returns: Some( + Name( + Name { + node: Node { + start: 402, + end: 406, + }, + id: "List", + }, + ), + ), type_comment: None, }, ), diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@if.py.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@if.py.snap new file mode 100644 index 00000000..0f6288c8 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@if.py.snap @@ -0,0 +1,171 @@ +--- +source: parser/src/parser/parser.rs +description: "if self.adjust:\n if True:\n print(\"adjust is True and adjusted_daily_records_csv_path exists\")\n else:\n print(\"adjust is True\")\nelse:\n print(\"adjust is False\")\n\n" +input_file: parser/test_data/inputs/if.py +--- +Module { + node: Node { + start: 0, + end: 182, + }, + body: [ + IfStatement( + If { + node: Node { + start: 0, + end: 182, + }, + test: Attribute( + Attribute { + node: Node { + start: 3, + end: 14, + }, + value: Name( + Name { + node: Node { + start: 3, + end: 7, + }, + id: "self", + }, + ), + attr: "adjust", + }, + ), + body: [ + IfStatement( + If { + node: Node { + start: 20, + end: 146, + }, + test: Constant( + Constant { + node: Node { + start: 23, + end: 27, + }, + value: Bool( + true, + ), + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 37, + end: 103, + }, + func: Name( + Name { + node: Node { + start: 37, + end: 42, + }, + id: "print", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 43, + end: 102, + }, + value: Str( + "adjust is True and adjusted_daily_records_csv_path exists", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + orelse: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 122, + end: 145, + }, + func: Name( + Name { + node: Node { + start: 122, + end: 127, + }, + id: "print", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 128, + end: 144, + }, + value: Str( + "adjust is True", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + }, + ), + ], + orelse: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 156, + end: 180, + }, + func: Name( + Name { + node: Node { + start: 156, + end: 161, + }, + id: "print", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 162, + end: 179, + }, + value: Str( + "adjust is False", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + }, + ), + ], +} 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 3a5d77b1..ee60a55f 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 @@ -13,7 +13,7 @@ Module { FunctionDef { node: Node { start: 0, - end: 15273, + end: 342, }, name: "_handle_ticker_index", args: Arguments { @@ -102,7 +102,7 @@ Module { If { node: Node { start: 96, - end: 342, + end: 320, }, test: Compare( Compare { @@ -307,581 +307,581 @@ Module { orelse: [], }, ), - Return( - Return { + ], + orelse: [], + }, + ), + Return( + Return { + node: Node { + start: 320, + end: 339, + }, + value: Some( + Name( + Name { node: Node { - start: 320, + start: 327, end: 339, }, - value: Some( - Name( - Name { - node: Node { - start: 327, - end: 339, - }, - id: "ticker_index", - }, - ), - ), + id: "ticker_index", }, ), - ], - orelse: [], + ), }, ), - FunctionDef( - FunctionDef { + ], + decorator_list: [], + returns: None, + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 342, + end: 655, + }, + name: "_extract_ticker_client_types_data", + args: Arguments { + node: Node { + start: 380, + end: 397, + }, + posonlyargs: [], + args: [ + Arg { node: Node { - start: 342, - end: 655, + start: 380, + end: 397, }, - name: "_extract_ticker_client_types_data", - args: Arguments { - node: Node { - start: 380, - end: 397, - }, - posonlyargs: [], - args: [ - Arg { + arg: "ticker_index", + annotation: Some( + Name( + Name { node: Node { - start: 380, + start: 394, end: 397, }, - arg: "ticker_index", - annotation: Some( - Name( + id: "str", + }, + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 412, + end: 463, + }, + targets: [ + Name( + Name { + node: Node { + start: 412, + end: 415, + }, + id: "url", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 449, + end: 463, + }, + func: Attribute( + Attribute { + node: Node { + start: 418, + end: 449, + }, + value: Name( Name { node: Node { - start: 394, - end: 397, + start: 418, + end: 442, }, - id: "str", + id: "TSE_CLIENT_TYPE_DATA_URL", }, ), + attr: "format", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 450, + end: 462, + }, + id: "ticker_index", + }, ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + WithStatement( + With { + node: Node { + start: 468, + end: 561, }, + items: [ + WithItem { + node: Node { + start: 473, + end: 508, + }, + context_expr: Call( + Call { + node: Node { + start: 473, + end: 497, + }, + func: Name( + Name { + node: Node { + start: 473, + end: 495, + }, + id: "requests_retry_session", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + optional_vars: Some( + Name( + Name { + node: Node { + start: 501, + end: 508, + }, + id: "session", + }, + ), + ), + }, + ], body: [ AssignStatement( Assign { node: Node { - start: 412, - end: 463, + start: 518, + end: 556, }, targets: [ Name( Name { node: Node { - start: 412, - end: 415, + start: 518, + end: 526, }, - id: "url", + id: "response", }, ), ], value: Call( Call { node: Node { - start: 449, - end: 463, + start: 540, + end: 556, }, func: Attribute( Attribute { node: Node { - start: 418, - end: 449, + start: 529, + end: 540, }, value: Name( Name { node: Node { - start: 418, - end: 442, + start: 529, + end: 536, }, - id: "TSE_CLIENT_TYPE_DATA_URL", + id: "session", }, ), - attr: "format", + attr: "get", }, ), args: [ Name( Name { node: Node { - start: 450, - end: 462, + start: 541, + end: 544, }, - id: "ticker_index", + id: "url", }, ), ], - keywords: [], + keywords: [ + Keyword { + node: Node { + start: 546, + end: 555, + }, + arg: Some( + "timeout", + ), + value: Constant( + Constant { + node: Node { + start: 554, + end: 555, + }, + value: Int( + "5", + ), + }, + ), + }, + ], starargs: None, kwargs: None, }, ), }, ), - WithStatement( - With { + ], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 561, + end: 592, + }, + targets: [ + Name( + Name { node: Node { - start: 468, - end: 561, + start: 561, + end: 565, }, - items: [ - WithItem { - node: Node { - start: 473, - end: 508, - }, - context_expr: Call( - Call { - node: Node { - start: 473, - end: 497, - }, - func: Name( - Name { - node: Node { - start: 473, - end: 495, - }, - id: "requests_retry_session", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - optional_vars: Some( - Name( - Name { - node: Node { - start: 501, - end: 508, - }, - id: "session", - }, - ), - ), + id: "data", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 587, + end: 592, + }, + func: Attribute( + Attribute { + node: Node { + start: 568, + end: 587, }, - ], - body: [ - AssignStatement( - Assign { + value: Attribute( + Attribute { node: Node { - start: 518, - end: 556, + start: 568, + end: 581, }, - targets: [ - Name( - Name { - node: Node { - start: 518, - end: 526, - }, - id: "response", - }, - ), - ], - value: Call( - Call { + value: Name( + Name { node: Node { - start: 540, - end: 556, + start: 568, + end: 576, }, - func: Attribute( - Attribute { - node: Node { - start: 529, - end: 540, - }, - value: Name( - Name { - node: Node { - start: 529, - end: 536, - }, - id: "session", - }, - ), - attr: "get", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 541, - end: 544, - }, - id: "url", - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 546, - end: 555, - }, - arg: Some( - "timeout", - ), - value: Constant( - Constant { - node: Node { - start: 554, - end: 555, - }, - value: Int( - "5", - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, + id: "response", }, ), + attr: "text", }, ), - ], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 561, - end: 592, + attr: "split", }, - targets: [ - Name( - Name { - node: Node { - start: 561, - end: 565, - }, - id: "data", - }, - ), - ], - value: Call( - Call { + ), + args: [ + Constant( + Constant { node: Node { - start: 587, - end: 592, + start: 588, + end: 591, }, - func: Attribute( - Attribute { - node: Node { - start: 568, - end: 587, - }, - value: Attribute( - Attribute { - node: Node { - start: 568, - end: 581, - }, - value: Name( - Name { - node: Node { - start: 568, - end: 576, - }, - id: "response", - }, - ), - attr: "text", - }, - ), - attr: "split", - }, + value: Str( + ";", ), - args: [ - Constant( - Constant { - node: Node { - start: 588, - end: 591, - }, - value: Str( - ";", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, }, ), - }, - ), - AssignStatement( - Assign { + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 597, + end: 636, + }, + targets: [ + Name( + Name { node: Node { start: 597, - end: 636, + end: 601, }, - targets: [ - Name( - Name { + id: "data", + }, + ), + ], + value: ListComp( + ListComp { + node: Node { + start: 604, + end: 636, + }, + element: Call( + Call { + node: Node { + start: 614, + end: 619, + }, + func: Attribute( + Attribute { node: Node { - start: 597, - end: 601, + start: 605, + end: 614, }, - id: "data", + value: Name( + Name { + node: Node { + start: 605, + end: 608, + }, + id: "row", + }, + ), + attr: "split", }, ), - ], - value: ListComp( - ListComp { - node: Node { - start: 604, - end: 636, - }, - element: Call( - Call { + args: [ + Constant( + Constant { node: Node { - start: 614, - end: 619, + start: 615, + end: 618, }, - func: Attribute( - Attribute { - node: Node { - start: 605, - end: 614, - }, - value: Name( - Name { - node: Node { - start: 605, - end: 608, - }, - id: "row", - }, - ), - attr: "split", - }, + value: Str( + ",", ), - args: [ - Constant( - Constant { - node: Node { - start: 615, - end: 618, - }, - value: Str( - ",", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, }, ), - generators: [ - Comprehension { - node: Node { - start: 620, - end: 635, - }, - target: Name( - Name { - node: Node { - start: 624, - end: 627, - }, - id: "row", - }, - ), - iter: Name( - Name { - node: Node { - start: 631, - end: 635, - }, - id: "data", - }, - ), - ifs: [], - is_async: false, - }, - ], - }, - ), - }, - ), - Return( - Return { - node: Node { - start: 641, - end: 652, + ], + keywords: [], + starargs: None, + kwargs: None, }, - value: Some( - Name( + ), + generators: [ + Comprehension { + node: Node { + start: 620, + end: 635, + }, + target: Name( + Name { + node: Node { + start: 624, + end: 627, + }, + id: "row", + }, + ), + iter: Name( Name { node: Node { - start: 648, - end: 652, + start: 631, + end: 635, }, id: "data", }, ), - ), - }, - ), - ], - decorator_list: [], - returns: Some( + ifs: [], + is_async: false, + }, + ], + }, + ), + }, + ), + Return( + Return { + node: Node { + start: 641, + end: 652, + }, + value: Some( Name( Name { node: Node { - start: 402, - end: 406, + start: 648, + end: 652, }, - id: "List", + id: "data", }, ), ), - type_comment: None, }, ), - FunctionDef( - FunctionDef { + ], + decorator_list: [], + returns: Some( + Name( + Name { node: Node { - start: 655, - end: 925, + start: 402, + end: 406, }, - name: "_create_financial_index_from_text_response", - args: Arguments { - node: Node { - start: 702, - end: 706, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 702, - end: 706, - }, - arg: "data", - annotation: None, - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], + id: "List", + }, + ), + ), + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 655, + end: 925, + }, + name: "_create_financial_index_from_text_response", + args: Arguments { + node: Node { + start: 702, + end: 706, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 702, + end: 706, }, - body: [ - AssignStatement( - Assign { + arg: "data", + annotation: None, + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 713, + end: 755, + }, + targets: [ + Name( + Name { node: Node { start: 713, - end: 755, + end: 717, }, - targets: [ - Name( + id: "data", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 732, + end: 755, + }, + func: Attribute( + Attribute { + node: Node { + start: 720, + end: 732, + }, + value: Name( Name { node: Node { - start: 713, - end: 717, + start: 720, + end: 722, }, - id: "data", + id: "pd", }, ), - ], - value: Call( + attr: "DataFrame", + }, + ), + args: [ + Call( Call { node: Node { - start: 732, - end: 755, + start: 741, + end: 754, }, func: Attribute( Attribute { node: Node { - start: 720, - end: 732, + start: 733, + end: 741, }, value: Name( Name { node: Node { - start: 720, - end: 722, + start: 733, + end: 735, }, - id: "pd", + id: "re", }, ), - attr: "DataFrame", + attr: "split", }, ), args: [ - Call( - Call { + Constant( + Constant { node: Node { - start: 741, - end: 754, + start: 742, + end: 747, }, - func: Attribute( - Attribute { - node: Node { - start: 733, - end: 741, - }, - value: Name( - Name { - node: Node { - start: 733, - end: 735, - }, - id: "re", - }, - ), - attr: "split", - }, + value: Str( + "\\;", ), - args: [ - Constant( - Constant { - node: Node { - start: 742, - end: 747, - }, - value: Str( - "\\;", - ), - }, - ), - Name( - Name { - node: Node { - start: 749, - end: 753, - }, - id: "data", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + }, + ), + Name( + Name { + node: Node { + start: 749, + end: 753, + }, + id: "data", }, ), ], @@ -890,1018 +890,1823 @@ Module { kwargs: None, }, ), - }, - ), - AssignStatement( - Assign { + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 760, + end: 826, + }, + targets: [ + Name( + Name { node: Node { start: 760, - end: 826, + end: 767, }, - targets: [ - Name( - Name { - node: Node { - start: 760, - end: 767, - }, - id: "columns", + id: "columns", + }, + ), + ], + value: List( + List { + node: Node { + start: 770, + end: 826, + }, + elements: [ + Constant( + Constant { + node: Node { + start: 771, + end: 777, }, - ), - ], - value: List( - List { + value: Str( + "date", + ), + }, + ), + Constant( + Constant { node: Node { - start: 770, - end: 826, + start: 779, + end: 785, }, - elements: [ - Constant( - Constant { - node: Node { - start: 771, - end: 777, - }, - value: Str( - "date", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 779, - end: 785, - }, - value: Str( - "high", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 787, - end: 792, - }, - value: Str( - "low", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 794, - end: 800, - }, - value: Str( - "open", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 802, - end: 809, - }, - value: Str( - "close", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 811, - end: 819, - }, - value: Str( - "volume", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 821, - end: 825, - }, - value: Str( - "__", - ), - }, - ), - ], + value: Str( + "high", + ), }, ), - }, - ), - AssignStatement( - Assign { + Constant( + Constant { + node: Node { + start: 787, + end: 792, + }, + value: Str( + "low", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 794, + end: 800, + }, + value: Str( + "open", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 802, + end: 809, + }, + value: Str( + "close", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 811, + end: 819, + }, + value: Str( + "volume", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 821, + end: 825, + }, + value: Str( + "__", + ), + }, + ), + ], + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 831, + end: 882, + }, + targets: [ + Subscript( + Subscript { node: Node { start: 831, - end: 882, + end: 844, }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 831, - end: 844, - }, - value: Name( - Name { - node: Node { - start: 831, - end: 835, - }, - id: "data", - }, - ), - slice: Name( - Name { - node: Node { - start: 836, - end: 843, - }, - id: "columns", - }, - ), + value: Name( + Name { + node: Node { + start: 831, + end: 835, }, - ), - ], - value: Call( - Call { + id: "data", + }, + ), + slice: Name( + Name { node: Node { - start: 864, - end: 882, + start: 836, + end: 843, }, - func: Attribute( - Attribute { - node: Node { - start: 854, - end: 864, - }, - value: Attribute( - Attribute { - node: Node { - start: 854, - end: 858, - }, - value: Subscript( - Subscript { - node: Node { - start: 847, - end: 854, - }, - value: Name( - Name { - node: Node { - start: 847, - end: 851, - }, - id: "data", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 852, - end: 853, - }, - value: Int( - "0", - ), - }, - ), - }, - ), - attr: "str", - }, - ), - attr: "split", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 865, - end: 868, - }, - value: Str( - ",", - ), - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 870, - end: 881, - }, - arg: Some( - "expand", - ), - value: Constant( - Constant { - node: Node { - start: 877, - end: 881, - }, - value: Bool( - true, - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, + id: "columns", }, ), }, ), - Return( - Return { - node: Node { - start: 887, - end: 922, - }, - value: Some( - Call( - Call { + ], + value: Call( + Call { + node: Node { + start: 864, + end: 882, + }, + func: Attribute( + Attribute { + node: Node { + start: 854, + end: 864, + }, + value: Attribute( + Attribute { node: Node { - start: 903, - end: 922, + start: 854, + end: 858, }, - func: Attribute( - Attribute { + value: Subscript( + Subscript { node: Node { - start: 894, - end: 903, + start: 847, + end: 854, }, value: Name( Name { node: Node { - start: 894, - end: 898, + start: 847, + end: 851, }, id: "data", }, ), - attr: "drop", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 904, - end: 921, - }, - arg: Some( - "columns", - ), - value: List( - List { + slice: Constant( + Constant { node: Node { - start: 912, - end: 921, + start: 852, + end: 853, }, - elements: [ - Constant( - Constant { - node: Node { - start: 913, - end: 917, - }, - value: Str( - "__", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 919, - end: 920, - }, - value: Int( - "0", - ), - }, - ), - ], + value: Int( + "0", + ), }, ), }, - ], - starargs: None, - kwargs: None, + ), + attr: "str", }, ), - ), - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, - }, + attr: "split", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 865, + end: 868, + }, + value: Str( + ",", + ), + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 870, + end: 881, + }, + arg: Some( + "expand", + ), + value: Constant( + Constant { + node: Node { + start: 877, + end: 881, + }, + value: Bool( + true, + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, ), - FunctionDef( - FunctionDef { + Return( + Return { node: Node { - start: 925, - end: 15273, + start: 887, + end: 922, }, - name: "_adjust_data_frame", - args: Arguments { - node: Node { - start: 948, - end: 965, - }, - posonlyargs: [], - args: [ - Arg { + value: Some( + Call( + Call { node: Node { - start: 948, - end: 950, + start: 903, + end: 922, }, - arg: "df", - annotation: None, + func: Attribute( + Attribute { + node: Node { + start: 894, + end: 903, + }, + value: Name( + Name { + node: Node { + start: 894, + end: 898, + }, + id: "data", + }, + ), + attr: "drop", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 904, + end: 921, + }, + arg: Some( + "columns", + ), + value: List( + List { + node: Node { + start: 912, + end: 921, + }, + elements: [ + Constant( + Constant { + node: Node { + start: 913, + end: 917, + }, + value: Str( + "__", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 919, + end: 920, + }, + value: Int( + "0", + ), + }, + ), + ], + }, + ), + }, + ], + starargs: None, + kwargs: None, }, - Arg { + ), + ), + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 925, + end: 1191, + }, + name: "_adjust_data_frame", + args: Arguments { + node: Node { + start: 948, + end: 965, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 948, + end: 950, + }, + arg: "df", + annotation: None, + }, + Arg { + node: Node { + start: 952, + end: 965, + }, + arg: "include_jdate", + annotation: None, + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 972, + end: 1022, + }, + targets: [ + Attribute( + Attribute { node: Node { - start: 952, - end: 965, + start: 972, + end: 979, }, - arg: "include_jdate", - annotation: None, + value: Name( + Name { + node: Node { + start: 972, + end: 974, + }, + id: "df", + }, + ), + attr: "date", }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], + ), + ], + value: Call( + Call { + node: Node { + start: 996, + end: 1022, + }, + func: Attribute( + Attribute { + node: Node { + start: 982, + end: 996, + }, + value: Name( + Name { + node: Node { + start: 982, + end: 984, + }, + id: "pd", + }, + ), + attr: "to_datetime", + }, + ), + args: [ + Attribute( + Attribute { + node: Node { + start: 997, + end: 1004, + }, + value: Name( + Name { + node: Node { + start: 997, + end: 999, + }, + id: "df", + }, + ), + attr: "date", + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 1006, + end: 1021, + }, + arg: Some( + "format", + ), + value: Constant( + Constant { + node: Node { + start: 1013, + end: 1021, + }, + value: Str( + "%Y%m%d", + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 1027, + end: 1191, }, + test: Name( + Name { + node: Node { + start: 1030, + end: 1043, + }, + id: "include_jdate", + }, + ), body: [ AssignStatement( Assign { node: Node { - start: 972, - end: 1022, + start: 1053, + end: 1069, + }, + targets: [ + Subscript( + Subscript { + node: Node { + start: 1053, + end: 1064, + }, + value: Name( + Name { + node: Node { + start: 1053, + end: 1055, + }, + id: "df", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 1056, + end: 1063, + }, + value: Str( + "jdate", + ), + }, + ), + }, + ), + ], + value: Constant( + Constant { + node: Node { + start: 1067, + end: 1069, + }, + value: Str( + "", + ), + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 1078, + end: 1188, }, targets: [ Attribute( Attribute { node: Node { - start: 972, - end: 979, + start: 1078, + end: 1086, }, value: Name( Name { node: Node { - start: 972, - end: 974, + start: 1078, + end: 1080, }, id: "df", }, ), - attr: "date", + attr: "jdate", }, ), ], value: Call( Call { node: Node { - start: 996, - end: 1022, + start: 1102, + end: 1188, }, func: Attribute( Attribute { node: Node { - start: 982, - end: 996, + start: 1089, + end: 1102, }, - value: Name( - Name { + value: Attribute( + Attribute { node: Node { - start: 982, - end: 984, + start: 1089, + end: 1096, }, - id: "pd", + value: Name( + Name { + node: Node { + start: 1089, + end: 1091, + }, + id: "df", + }, + ), + attr: "date", }, ), - attr: "to_datetime", + attr: "apply", }, ), args: [ - Attribute( - Attribute { + Lambda( + Lambda { node: Node { - start: 997, - end: 1004, + start: 1116, + end: 1178, }, - value: Name( - Name { + args: Arguments { + node: Node { + start: 1123, + end: 1132, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 1123, + end: 1132, + }, + arg: "gregorian", + annotation: None, + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: Call( + Call { node: Node { - start: 997, - end: 999, + start: 1162, + end: 1178, }, - id: "df", + func: Attribute( + Attribute { + node: Node { + start: 1134, + end: 1162, + }, + value: Attribute( + Attribute { + node: Node { + start: 1134, + end: 1148, + }, + value: Name( + Name { + node: Node { + start: 1134, + end: 1143, + }, + id: "jdatetime", + }, + ), + attr: "date", + }, + ), + attr: "fromgregorian", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 1163, + end: 1177, + }, + arg: Some( + "date", + ), + value: Name( + Name { + node: Node { + start: 1168, + end: 1177, + }, + id: "gregorian", + }, + ), + }, + ], + starargs: None, + kwargs: None, }, ), - attr: "date", }, ), ], - keywords: [ - Keyword { - node: Node { - start: 1006, - end: 1021, - }, - arg: Some( - "format", - ), - value: Constant( - Constant { - node: Node { - start: 1013, - end: 1021, - }, - value: Str( - "%Y%m%d", - ), - }, - ), - }, - ], + keywords: [], starargs: None, kwargs: None, }, ), }, ), - IfStatement( - If { + ], + orelse: [], + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 1191, + end: 1452, + }, + name: "_adjust_data_frame_for_fIndex", + args: Arguments { + node: Node { + start: 1225, + end: 1242, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 1225, + end: 1227, + }, + arg: "df", + annotation: None, + }, + Arg { + node: Node { + start: 1229, + end: 1242, + }, + arg: "include_jdate", + annotation: None, + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 1249, + end: 1305, + }, + targets: [ + Subscript( + Subscript { node: Node { - start: 1027, - end: 1191, + start: 1249, + end: 1259, }, - test: Name( + value: Name( Name { node: Node { - start: 1030, - end: 1043, + start: 1249, + end: 1251, }, - id: "include_jdate", + id: "df", }, ), - body: [ - AssignStatement( - Assign { + slice: Constant( + Constant { + node: Node { + start: 1252, + end: 1258, + }, + value: Str( + "date", + ), + }, + ), + }, + ), + ], + value: Call( + Call { + node: Node { + start: 1276, + end: 1305, + }, + func: Attribute( + Attribute { + node: Node { + start: 1262, + end: 1276, + }, + value: Name( + Name { node: Node { - start: 1053, - end: 1069, + start: 1262, + end: 1264, }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 1053, - end: 1064, - }, - value: Name( - Name { - node: Node { - start: 1053, - end: 1055, - }, - id: "df", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 1056, - end: 1063, - }, - value: Str( - "jdate", - ), - }, - ), - }, + id: "pd", + }, + ), + attr: "to_datetime", + }, + ), + args: [ + Subscript( + Subscript { + node: Node { + start: 1277, + end: 1287, + }, + value: Name( + Name { + node: Node { + start: 1277, + end: 1279, + }, + id: "df", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 1280, + end: 1286, + }, + value: Str( + "date", ), - ], - value: Constant( + }, + ), + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 1289, + end: 1304, + }, + arg: Some( + "format", + ), + value: Constant( + Constant { + node: Node { + start: 1296, + end: 1304, + }, + value: Str( + "%Y%m%d", + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 1310, + end: 1452, + }, + test: Name( + Name { + node: Node { + start: 1313, + end: 1326, + }, + id: "include_jdate", + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 1336, + end: 1449, + }, + targets: [ + Subscript( + Subscript { + node: Node { + start: 1336, + end: 1347, + }, + value: Name( + Name { + node: Node { + start: 1336, + end: 1338, + }, + id: "df", + }, + ), + slice: Constant( Constant { node: Node { - start: 1067, - end: 1069, + start: 1339, + end: 1346, }, value: Str( - "", + "jdate", ), }, ), }, ), - AssignStatement( - Assign { - node: Node { - start: 1078, - end: 1188, - }, - targets: [ - Attribute( + ], + value: Call( + Call { + node: Node { + start: 1363, + end: 1449, + }, + func: Attribute( + Attribute { + node: Node { + start: 1350, + end: 1363, + }, + value: Attribute( Attribute { node: Node { - start: 1078, - end: 1086, + start: 1350, + end: 1357, }, value: Name( Name { node: Node { - start: 1078, - end: 1080, + start: 1350, + end: 1352, }, id: "df", }, ), - attr: "jdate", + attr: "date", }, ), - ], - value: Call( - Call { + attr: "apply", + }, + ), + args: [ + Lambda( + Lambda { node: Node { - start: 1102, - end: 1188, + start: 1377, + end: 1439, }, - func: Attribute( - Attribute { + args: Arguments { + node: Node { + start: 1384, + end: 1393, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 1384, + end: 1393, + }, + arg: "gregorian", + annotation: None, + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: Call( + Call { node: Node { - start: 1089, - end: 1102, + start: 1423, + end: 1439, }, - value: Attribute( + func: Attribute( Attribute { node: Node { - start: 1089, - end: 1096, + start: 1395, + end: 1423, }, - value: Name( - Name { + value: Attribute( + Attribute { node: Node { - start: 1089, - end: 1091, + start: 1395, + end: 1409, }, - id: "df", + value: Name( + Name { + node: Node { + start: 1395, + end: 1404, + }, + id: "jdatetime", + }, + ), + attr: "date", }, ), - attr: "date", + attr: "fromgregorian", }, ), - attr: "apply", - }, - ), - args: [ - Lambda( - Lambda { - node: Node { - start: 1116, - end: 1178, - }, - args: Arguments { + args: [], + keywords: [ + Keyword { node: Node { - start: 1123, - end: 1132, + start: 1424, + end: 1438, }, - posonlyargs: [], - args: [ - Arg { + arg: Some( + "date", + ), + value: Name( + Name { node: Node { - start: 1123, - end: 1132, + start: 1429, + end: 1438, }, - arg: "gregorian", - annotation: None, + id: "gregorian", }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], + ), }, - body: Call( - Call { - node: Node { - start: 1162, - end: 1178, - }, - func: Attribute( - Attribute { - node: Node { - start: 1134, - end: 1162, - }, - value: Attribute( - Attribute { - node: Node { - start: 1134, - end: 1148, - }, - value: Name( - Name { - node: Node { - start: 1134, - end: 1143, - }, - id: "jdatetime", - }, - ), - attr: "date", - }, - ), - attr: "fromgregorian", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 1163, - end: 1177, - }, - arg: Some( - "date", - ), - value: Name( - Name { - node: Node { - start: 1168, - end: 1177, - }, - id: "gregorian", - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, + ], + starargs: None, + kwargs: None, + }, + ), + }, ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ], + orelse: [], + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 1452, + end: 15273, + }, + name: "download", + args: Arguments { + node: Node { + start: 1470, + end: 1631, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 1470, + end: 1495, + }, + arg: "symbols", + annotation: Some( + Subscript( + Subscript { + node: Node { + start: 1479, + end: 1495, + }, + value: Name( + Name { + node: Node { + start: 1479, + end: 1484, }, - ), - ], - orelse: [], + id: "Union", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 1485, + end: 1495, + }, + elements: [ + Name( + Name { + node: Node { + start: 1485, + end: 1489, + }, + id: "List", + }, + ), + Name( + Name { + node: Node { + start: 1491, + end: 1494, + }, + id: "str", + }, + ), + ], + }, + ), + }, + ), + ), + }, + Arg { + node: Node { + start: 1501, + end: 1527, + }, + arg: "write_to_csv", + annotation: Some( + Name( + Name { + node: Node { + start: 1515, + end: 1519, + }, + id: "bool", + }, + ), + ), + }, + Arg { + node: Node { + start: 1533, + end: 1560, + }, + arg: "include_jdate", + annotation: Some( + Name( + Name { + node: Node { + start: 1548, + end: 1552, + }, + id: "bool", }, ), - FunctionDef( - FunctionDef { + ), + }, + Arg { + node: Node { + start: 1566, + end: 1604, + }, + arg: "base_path", + annotation: Some( + Name( + Name { node: Node { - start: 1191, - end: 15273, + start: 1577, + end: 1580, + }, + id: "str", + }, + ), + ), + }, + Arg { + node: Node { + start: 1610, + end: 1630, + }, + arg: "adjust", + annotation: Some( + Name( + Name { + node: Node { + start: 1618, + end: 1622, + }, + id: "bool", + }, + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [ + Constant( + Constant { + node: Node { + start: 1522, + end: 1527, + }, + value: Bool( + false, + ), + }, + ), + Constant( + Constant { + node: Node { + start: 1555, + end: 1560, + }, + value: Bool( + false, + ), + }, + ), + Attribute( + Attribute { + node: Node { + start: 1583, + end: 1604, + }, + value: Name( + Name { + node: Node { + start: 1583, + end: 1589, }, - name: "_adjust_data_frame_for_fIndex", - args: Arguments { + id: "config", + }, + ), + attr: "DATA_BASE_PATH", + }, + ), + Constant( + Constant { + node: Node { + start: 1625, + end: 1630, + }, + value: Bool( + false, + ), + }, + ), + ], + }, + body: [ + IfStatement( + If { + node: Node { + start: 1666, + end: 1800, + }, + test: Compare( + Compare { + node: Node { + start: 1669, + end: 1685, + }, + left: Name( + Name { node: Node { - start: 1225, - end: 1242, + start: 1669, + end: 1676, }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 1225, - end: 1227, - }, - arg: "df", - annotation: None, + id: "symbols", + }, + ), + ops: [ + Eq, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 1680, + end: 1685, }, - Arg { + value: Str( + "all", + ), + }, + ), + ], + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 1695, + end: 1731, + }, + targets: [ + Name( + Name { node: Node { - start: 1229, - end: 1242, + start: 1695, + end: 1702, }, - arg: "include_jdate", - annotation: None, + id: "symbols", }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], + ), + ], + value: Call( + Call { + node: Node { + start: 1729, + end: 1731, + }, + func: Attribute( + Attribute { + node: Node { + start: 1705, + end: 1729, + }, + value: Name( + Name { + node: Node { + start: 1705, + end: 1717, + }, + id: "symbols_data", + }, + ), + attr: "all_symbols", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ], + orelse: [ + IfStatement( + If { + node: Node { + start: 1736, + end: 1800, }, + test: Call( + Call { + node: Node { + start: 1741, + end: 1765, + }, + func: Name( + Name { + node: Node { + start: 1741, + end: 1751, + }, + id: "isinstance", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 1752, + end: 1759, + }, + id: "symbols", + }, + ), + Name( + Name { + node: Node { + start: 1761, + end: 1764, + }, + id: "str", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), body: [ AssignStatement( Assign { node: Node { - start: 1249, - end: 1305, + start: 1775, + end: 1794, }, targets: [ - Subscript( - Subscript { + Name( + Name { node: Node { - start: 1249, - end: 1259, + start: 1775, + end: 1782, }, - value: Name( - Name { - node: Node { - start: 1249, - end: 1251, - }, - id: "df", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 1252, - end: 1258, - }, - value: Str( - "date", - ), - }, - ), + id: "symbols", }, ), ], - value: Call( - Call { + value: List( + List { node: Node { - start: 1276, - end: 1305, + start: 1785, + end: 1794, }, - func: Attribute( - Attribute { - node: Node { - start: 1262, - end: 1276, + elements: [ + Name( + Name { + node: Node { + start: 1786, + end: 1793, + }, + id: "symbols", }, - value: Name( - Name { - node: Node { - start: 1262, - end: 1264, - }, - id: "pd", - }, - ), - attr: "to_datetime", - }, + ), + ], + }, + ), + }, + ), + ], + orelse: [], + }, + ), + ], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 1800, + end: 1812, + }, + targets: [ + Name( + Name { + node: Node { + start: 1800, + end: 1807, + }, + id: "df_list", + }, + ), + ], + value: Dict( + Dict { + node: Node { + start: 1810, + end: 1812, + }, + keys: [], + values: [], + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 1817, + end: 1838, + }, + targets: [ + Name( + Name { + node: Node { + start: 1817, + end: 1833, + }, + id: "future_to_symbol", + }, + ), + ], + value: Dict( + Dict { + node: Node { + start: 1836, + end: 1838, + }, + keys: [], + values: [], + }, + ), + }, + ), + WithStatement( + With { + node: Node { + start: 1843, + end: 15273, + }, + items: [ + WithItem { + node: Node { + start: 1848, + end: 1902, + }, + context_expr: Call( + Call { + node: Node { + start: 1874, + end: 1890, + }, + func: Attribute( + Attribute { + node: Node { + start: 1848, + end: 1874, + }, + value: Name( + Name { + node: Node { + start: 1848, + end: 1855, + }, + id: "futures", + }, + ), + attr: "ThreadPoolExecutor", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 1875, + end: 1889, + }, + arg: Some( + "max_workers", + ), + value: Constant( + Constant { + node: Node { + start: 1887, + end: 1889, + }, + value: Int( + "10", ), - args: [ - Subscript( - Subscript { + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + optional_vars: Some( + Name( + Name { + node: Node { + start: 1894, + end: 1902, + }, + id: "executor", + }, + ), + ), + }, + ], + body: [ + AssignStatement( + Assign { + node: Node { + start: 1912, + end: 1946, + }, + targets: [ + Name( + Name { + node: Node { + start: 1912, + end: 1919, + }, + id: "session", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 1922, + end: 1946, + }, + func: Name( + Name { + node: Node { + start: 1922, + end: 1944, + }, + id: "requests_retry_session", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ForStatement( + For { + node: Node { + start: 1955, + end: 15273, + }, + target: Name( + Name { + node: Node { + start: 1959, + end: 1965, + }, + id: "symbol", + }, + ), + iter: Name( + Name { + node: Node { + start: 1969, + end: 1976, + }, + id: "symbols", + }, + ), + body: [ + IfStatement( + If { + node: Node { + start: 1990, + end: 2484, + }, + test: BoolOp( + BoolOperation { + node: Node { + start: 2011, + end: 2095, + }, + op: And, + values: [ + Call( + Call { node: Node { - start: 1277, - end: 1287, + start: 2027, + end: 2029, }, - value: Name( - Name { + func: Attribute( + Attribute { node: Node { - start: 1277, - end: 1279, + start: 2011, + end: 2027, }, - id: "df", + value: Name( + Name { + node: Node { + start: 2011, + end: 2017, + }, + id: "symbol", + }, + ), + attr: "isnumeric", }, ), - slice: Constant( - Constant { + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + Compare( + Compare { + node: Node { + start: 2050, + end: 2095, + }, + left: Call( + Call { node: Node { - start: 1280, - end: 1286, + start: 2079, + end: 2087, }, - value: Str( - "date", + func: Attribute( + Attribute { + node: Node { + start: 2050, + end: 2079, + }, + value: Name( + Name { + node: Node { + start: 2050, + end: 2062, + }, + id: "symbols_data", + }, + ), + attr: "get_ticker_index", + }, ), + args: [ + Name( + Name { + node: Node { + start: 2080, + end: 2086, + }, + id: "symbol", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, }, ), + ops: [ + Is, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 2091, + end: 2095, + }, + value: None, + }, + ), + ], }, ), ], - keywords: [ - Keyword { - node: Node { - start: 1289, - end: 1304, - }, - arg: Some( - "format", - ), - value: Constant( - Constant { - node: Node { - start: 1296, - end: 1304, - }, - value: Str( - "%Y%m%d", - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 1310, - end: 1452, - }, - test: Name( - Name { - node: Node { - start: 1313, - end: 1326, - }, - id: "include_jdate", }, ), body: [ AssignStatement( Assign { node: Node { - start: 1336, - end: 1449, + start: 2127, + end: 2152, }, targets: [ - Subscript( - Subscript { + Name( + Name { node: Node { - start: 1336, - end: 1347, + start: 2127, + end: 2141, }, - value: Name( + id: "ticker_indexes", + }, + ), + ], + value: List( + List { + node: Node { + start: 2144, + end: 2152, + }, + elements: [ + Name( Name { node: Node { - start: 1336, - end: 1338, - }, - id: "df", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 1339, - end: 1346, + start: 2145, + end: 2151, }, - value: Str( - "jdate", - ), + id: "symbol", }, ), + ], + }, + ), + }, + ), + ], + orelse: [ + AssignStatement( + Assign { + node: Node { + start: 2187, + end: 2230, + }, + targets: [ + Name( + Name { + node: Node { + start: 2187, + end: 2199, + }, + id: "ticker_index", }, ), ], value: Call( Call { node: Node { - start: 1363, - end: 1449, + start: 2202, + end: 2230, }, - func: Attribute( - Attribute { + func: Name( + Name { node: Node { - start: 1350, - end: 1363, + start: 2202, + end: 2222, }, - value: Attribute( - Attribute { - node: Node { - start: 1350, - end: 1357, - }, - value: Name( - Name { - node: Node { - start: 1350, - end: 1352, - }, - id: "df", - }, - ), - attr: "date", - }, - ), - attr: "apply", + id: "_handle_ticker_index", }, ), args: [ - Lambda( - Lambda { + Name( + Name { node: Node { - start: 1377, - end: 1439, - }, - args: Arguments { - node: Node { - start: 1384, - end: 1393, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 1384, - end: 1393, - }, - arg: "gregorian", - annotation: None, - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], + start: 2223, + end: 2229, }, - body: Call( - Call { - node: Node { - start: 1423, - end: 1439, - }, - func: Attribute( - Attribute { - node: Node { - start: 1395, - end: 1423, - }, - value: Attribute( - Attribute { - node: Node { - start: 1395, - end: 1409, - }, - value: Name( - Name { - node: Node { - start: 1395, - end: 1404, - }, - id: "jdatetime", - }, - ), - attr: "date", - }, - ), - attr: "fromgregorian", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 1424, - end: 1438, - }, - arg: Some( - "date", - ), - value: Name( - Name { - node: Node { - start: 1429, - end: 1438, - }, - id: "gregorian", - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), + id: "symbol", }, ), ], @@ -1912,418 +2717,828 @@ Module { ), }, ), - ], - orelse: [], - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 1452, - end: 15273, - }, - name: "download", - args: Arguments { - node: Node { - start: 1470, - end: 1631, - }, - posonlyargs: [], - args: [ - Arg { + IfStatement( + If { node: Node { - start: 1470, - end: 1495, + start: 2247, + end: 2357, }, - arg: "symbols", - annotation: Some( - Subscript( - Subscript { - node: Node { - start: 1479, - end: 1495, + test: Compare( + Compare { + node: Node { + start: 2250, + end: 2270, + }, + left: Name( + Name { + node: Node { + start: 2250, + end: 2262, + }, + id: "ticker_index", }, - value: Name( - Name { + ), + ops: [ + Is, + ], + comparators: [ + Constant( + Constant { node: Node { - start: 1479, - end: 1484, + start: 2266, + end: 2270, }, - id: "Union", + value: None, }, ), - slice: Tuple( - Tuple { - node: Node { - start: 1485, - end: 1495, - }, - elements: [ - Name( + ], + }, + ), + body: [ + Raise( + Raise { + node: Node { + start: 2292, + end: 2340, + }, + exc: Some( + Call( + Call { + node: Node { + start: 2298, + end: 2340, + }, + func: Name( Name { node: Node { - start: 1485, - end: 1489, + start: 2298, + end: 2307, }, - id: "List", + id: "Exception", }, ), - Name( - Name { - node: Node { - start: 1491, - end: 1494, + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 2308, + end: 2339, + }, + values: [ + Constant( + Constant { + node: Node { + start: 2330, + end: 0, + }, + value: Str( + "Cannot find symbol: ", + ), + }, + ), + Name( + Name { + node: Node { + start: 2331, + end: 2337, + }, + id: "symbol", + }, + ), + ], }, - id: "str", - }, - ), - ], - }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), ), + cause: None, }, ), - ), + ], + orelse: [], }, - Arg { + ), + AssignStatement( + Assign { node: Node { - start: 1501, - end: 1527, + start: 2357, + end: 2415, }, - arg: "write_to_csv", - annotation: Some( + targets: [ Name( Name { node: Node { - start: 1515, - end: 1519, + start: 2357, + end: 2371, }, - id: "bool", + id: "ticker_indexes", }, ), - ), - }, - Arg { - node: Node { - start: 1533, - end: 1560, - }, - arg: "include_jdate", - annotation: Some( - Name( - Name { - node: Node { - start: 1548, - end: 1552, - }, - id: "bool", + ], + value: Call( + Call { + node: Node { + start: 2407, + end: 2415, }, - ), + func: Attribute( + Attribute { + node: Node { + start: 2374, + end: 2407, + }, + value: Name( + Name { + node: Node { + start: 2374, + end: 2386, + }, + id: "symbols_data", + }, + ), + attr: "get_ticker_old_index", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 2408, + end: 2414, + }, + id: "symbol", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, ), }, - Arg { - node: Node { - start: 1566, - end: 1604, - }, - arg: "base_path", - annotation: Some( - Name( - Name { + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 2453, + end: 2470, + }, + func: Attribute( + Attribute { node: Node { - start: 1577, - end: 1580, + start: 2432, + end: 2453, }, - id: "str", + value: Name( + Name { + node: Node { + start: 2432, + end: 2446, + }, + id: "ticker_indexes", + }, + ), + attr: "insert", }, ), - ), + args: [ + Constant( + Constant { + node: Node { + start: 2454, + end: 2455, + }, + value: Int( + "0", + ), + }, + ), + Name( + Name { + node: Node { + start: 2457, + end: 2469, + }, + id: "ticker_index", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + }, + ), + ForStatement( + For { + node: Node { + start: 2484, + end: 2698, + }, + target: Name( + Name { + node: Node { + start: 2488, + end: 2493, }, - Arg { + id: "index", + }, + ), + iter: Name( + Name { + node: Node { + start: 2497, + end: 2511, + }, + id: "ticker_indexes", + }, + ), + body: [ + AssignStatement( + Assign { node: Node { - start: 1610, - end: 1630, + start: 2529, + end: 2637, }, - arg: "adjust", - annotation: Some( + targets: [ Name( Name { node: Node { - start: 1618, - end: 1622, + start: 2529, + end: 2535, }, - id: "bool", + id: "future", }, ), + ], + value: Call( + Call { + node: Node { + start: 2553, + end: 2637, + }, + func: Attribute( + Attribute { + node: Node { + start: 2538, + end: 2553, + }, + value: Name( + Name { + node: Node { + start: 2538, + end: 2546, + }, + id: "executor", + }, + ), + attr: "submit", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 2575, + end: 2603, + }, + id: "download_ticker_daily_record", + }, + ), + Name( + Name { + node: Node { + start: 2605, + end: 2610, + }, + id: "index", + }, + ), + Name( + Name { + node: Node { + start: 2612, + end: 2619, + }, + id: "session", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, ), }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [ - Constant( - Constant { - node: Node { - start: 1522, - end: 1527, - }, - value: Bool( - false, - ), + ), + AssignStatement( + Assign { + node: Node { + start: 2655, + end: 2688, }, - ), - Constant( - Constant { - node: Node { - start: 1555, - end: 1560, - }, - value: Bool( - false, + targets: [ + Subscript( + Subscript { + node: Node { + start: 2655, + end: 2679, + }, + value: Name( + Name { + node: Node { + start: 2655, + end: 2671, + }, + id: "future_to_symbol", + }, + ), + slice: Name( + Name { + node: Node { + start: 2672, + end: 2678, + }, + id: "future", + }, + ), + }, ), - }, - ), - Attribute( + ], + value: Name( + Name { + node: Node { + start: 2682, + end: 2688, + }, + id: "symbol", + }, + ), + }, + ), + ], + orelse: [], + }, + ), + ForStatement( + For { + node: Node { + start: 2698, + end: 4346, + }, + 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: 1583, - end: 1604, + start: 2712, + end: 2732, }, value: Name( Name { node: Node { - start: 1583, - end: 1589, + start: 2712, + end: 2719, }, - id: "config", + id: "futures", }, ), - attr: "DATA_BASE_PATH", + attr: "as_completed", }, ), - Constant( - Constant { - node: Node { - start: 1625, - end: 1630, + args: [ + Name( + Name { + node: Node { + start: 2733, + end: 2749, + }, + id: "future_to_symbol", }, - value: Bool( - false, - ), - }, - ), - ], - }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), body: [ - IfStatement( - If { + AssignStatement( + Assign { node: Node { - start: 1666, - end: 1800, + start: 2764, + end: 2797, }, - test: Compare( - Compare { + targets: [ + Name( + Name { + node: Node { + start: 2764, + end: 2770, + }, + id: "symbol", + }, + ), + ], + value: Subscript( + Subscript { node: Node { - start: 1669, - end: 1685, + start: 2773, + end: 2797, }, - left: Name( + value: Name( Name { node: Node { - start: 1669, - end: 1676, + start: 2773, + end: 2789, }, - id: "symbols", + id: "future_to_symbol", }, ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 1680, - end: 1685, - }, - value: Str( - "all", - ), + slice: Name( + Name { + node: Node { + start: 2790, + end: 2796, }, - ), - ], + id: "future", + }, + ), }, ), + }, + ), + TryStatement( + Try { + node: Node { + start: 2810, + end: 3120, + }, body: [ - AssignStatement( - Assign { + AnnAssignStatement( + AnnAssign { node: Node { - start: 1695, - end: 1731, + start: 2831, + end: 2865, }, - targets: [ - Name( - Name { + target: Name( + Name { + node: Node { + start: 2831, + end: 2833, + }, + id: "df", + }, + ), + annotation: Attribute( + Attribute { + node: Node { + start: 2835, + end: 2847, + }, + value: Name( + Name { + node: Node { + start: 2835, + end: 2837, + }, + id: "pd", + }, + ), + attr: "DataFrame", + }, + ), + value: Some( + Call( + Call { node: Node { - start: 1695, - end: 1702, + start: 2863, + end: 2865, }, - id: "symbols", + 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, }, ), - ], - value: Call( - Call { + ), + simple: true, + }, + ), + ], + handlers: [ + ExceptHandler { + node: Node { + start: 2878, + end: 3120, + }, + typ: Some( + Attribute( + Attribute { node: Node { - start: 1729, - end: 1731, + start: 2885, + end: 2909, }, - func: Attribute( + value: Attribute( Attribute { node: Node { - start: 1705, - end: 1729, + start: 2885, + end: 2894, }, value: Name( Name { node: Node { - start: 1705, - end: 1717, + start: 2885, + end: 2887, }, - id: "symbols_data", + id: "pd", }, ), - attr: "all_symbols", + attr: "errors", }, ), - args: [], - keywords: [], - starargs: None, - kwargs: None, + attr: "EmptyDataError", }, ), - }, - ), - ], - orelse: [ - IfStatement( - If { - node: Node { - start: 1736, - end: 1800, - }, - test: Call( - Call { - node: Node { - start: 1741, - end: 1765, - }, - func: Name( - Name { - node: Node { - start: 1741, - end: 1751, - }, - id: "isinstance", + ), + name: Some( + "ex", + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 2945, + end: 3082, }, - ), - args: [ - Name( - Name { + func: Attribute( + Attribute { node: Node { - start: 1752, - end: 1759, + start: 2933, + end: 2945, }, - id: "symbols", - }, - ), - Name( - Name { - node: Node { - start: 1761, - end: 1764, - }, - id: "str", + value: Name( + Name { + node: Node { + start: 2933, + end: 2939, + }, + id: "logger", + }, + ), + attr: "error", }, ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 1775, - end: 1794, - }, - targets: [ - Name( - Name { + args: [ + JoinedStr( + JoinedStr { node: Node { - start: 1775, - end: 1782, + start: 2967, + end: 3022, }, - id: "symbols", + 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", + }, + ), + ], }, ), ], - value: List( - List { + keywords: [ + Keyword { node: Node { - start: 1785, - end: 1794, + start: 3044, + end: 3063, }, - elements: [ - Name( - Name { - node: Node { - start: 1786, - end: 1793, - }, - id: "symbols", + 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, }, ), - ], - orelse: [], - }, - ), + ), + Continue( + Continue { + node: Node { + start: 3099, + end: 3107, + }, + }, + ), + ], + }, ], + orelse: [], + finalbody: [], }, ), AssignStatement( Assign { node: Node { - start: 1800, - end: 1812, + start: 3120, + end: 3161, }, targets: [ Name( Name { node: Node { - start: 1800, - end: 1807, + start: 3120, + end: 3122, }, - id: "df_list", + id: "df", }, ), ], - value: Dict( - Dict { + value: Call( + Call { node: Node { - start: 1810, - end: 1812, + start: 3150, + end: 3161, }, - keys: [], - values: [], + 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", + }, + ), + 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, + }, + arg: Some( + "drop", + ), + value: Constant( + Constant { + node: Node { + start: 3156, + end: 3160, + }, + value: Bool( + true, + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, }, ), }, @@ -2331,1010 +3546,7020 @@ Module { AssignStatement( Assign { node: Node { - start: 1817, - end: 1838, + start: 3174, + end: 3233, }, targets: [ Name( Name { node: Node { - start: 1817, - end: 1833, + start: 3174, + end: 3176, }, - id: "future_to_symbol", + id: "df", }, ), ], - value: Dict( - Dict { - node: Node { - start: 1836, - end: 1838, - }, - keys: [], - values: [], - }, - ), - }, - ), - WithStatement( - With { - node: Node { - start: 1843, - end: 15273, - }, - items: [ - WithItem { + value: Call( + Call { node: Node { - start: 1848, - end: 1902, + start: 3188, + end: 3233, }, - context_expr: Call( - Call { + func: Attribute( + Attribute { node: Node { - start: 1874, - end: 1890, + start: 3179, + end: 3188, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 1848, - end: 1874, + start: 3179, + end: 3181, }, - value: Name( - Name { - node: Node { - start: 1848, - end: 1855, - }, - id: "futures", - }, - ), - attr: "ThreadPoolExecutor", + id: "df", }, ), - args: [], - keywords: [ - Keyword { + attr: "rename", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 3189, + end: 3232, + }, + arg: Some( + "columns", + ), + value: Attribute( + Attribute { node: Node { - start: 1875, - end: 1889, + start: 3197, + end: 3232, }, - arg: Some( - "max_workers", - ), - value: Constant( - Constant { + value: Name( + Name { node: Node { - start: 1887, - end: 1889, + start: 3197, + end: 3209, }, - value: Int( - "10", - ), + id: "translations", }, ), + attr: "HISTORY_FIELD_MAPPINGS", }, - ], - starargs: None, - kwargs: None, + ), }, - ), - optional_vars: Some( - Name( - Name { - node: Node { - start: 1894, - end: 1902, - }, - id: "executor", - }, - ), - ), + ], + starargs: None, + kwargs: None, }, - ], - body: [ - AssignStatement( - Assign { + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 3246, + end: 3289, + }, + targets: [ + Name( + Name { node: Node { - start: 1912, - end: 1946, + start: 3246, + 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: 1912, - end: 1919, + start: 3251, + end: 3253, }, - id: "session", + id: "df", }, ), - ], - value: Call( - Call { - node: Node { - start: 1922, - end: 1946, - }, - func: Name( - Name { - node: Node { - start: 1922, - end: 1944, - }, - id: "requests_retry_session", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, + 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: 3268, + end: 3275, + }, + value: Str( + "", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 3277, + end: 3287, + }, + value: Str( + "", + ), + }, + ), + ], + }, + ), + }, + ], + 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", }, ), - ForStatement( - For { - node: Node { - start: 1955, - end: 15273, + args: [ + Name( + Name { + node: Node { + start: 3321, + end: 3323, + }, + id: "df", }, - target: Name( - Name { - node: Node { - start: 1959, - end: 1965, - }, - id: "symbol", + ), + Name( + Name { + node: Node { + start: 3325, + end: 3338, }, - ), - iter: Name( + id: "include_jdate", + }, + ), + ], + 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: 1969, - end: 1976, + start: 3366, + end: 3373, }, - id: "symbols", + id: "df_list", }, ), - body: [ - IfStatement( - If { + ], + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 3391, + end: 3643, + }, + targets: [ + Subscript( + Subscript { node: Node { - start: 1990, - end: 2484, + start: 3391, + end: 3406, }, - test: BoolOp( - BoolOperation { + value: Name( + Name { node: Node { - start: 2011, - end: 2095, + start: 3391, + end: 3398, }, - op: And, - values: [ - Call( - Call { - node: Node { - start: 2027, - end: 2029, - }, - func: Attribute( - Attribute { - node: Node { - start: 2011, - end: 2027, - }, - value: Name( - Name { - node: Node { - start: 2011, - end: 2017, - }, - id: "symbol", - }, - ), - attr: "isnumeric", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - Compare( - Compare { + id: "df_list", + }, + ), + 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: 3573, + end: 3581, + }, + func: Attribute( + Attribute { node: Node { - start: 2050, - end: 2095, + start: 3561, + end: 3573, }, - left: Call( + value: Call( Call { node: Node { - start: 2079, - end: 2087, + start: 3440, + end: 3540, }, func: Attribute( Attribute { node: Node { - start: 2050, - end: 2079, + start: 3431, + end: 3440, }, value: Name( Name { node: Node { - start: 2050, - end: 2062, + start: 3431, + end: 3433, }, - id: "symbols_data", + id: "pd", }, ), - attr: "get_ticker_index", + attr: "concat", }, ), args: [ - Name( - Name { + List( + List { node: Node { - start: 2080, - end: 2086, + start: 3466, + end: 3487, }, - id: "symbol", + 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", + }, + ), + }, + ), + Name( + Name { + node: Node { + start: 3484, + end: 3486, + }, + id: "df", + }, + ), + ], }, ), ], - keywords: [], + keywords: [ + Keyword { + node: Node { + start: 3489, + end: 3506, + }, + arg: Some( + "ignore_index", + ), + value: Constant( + Constant { + node: Node { + start: 3502, + end: 3506, + }, + value: Bool( + true, + ), + }, + ), + }, + 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, }, ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 2091, - end: 2095, - }, - value: None, - }, - ), - ], + attr: "sort_values", }, ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 2127, - end: 2152, - }, - targets: [ - Name( - Name { + args: [ + Constant( + Constant { node: Node { - start: 2127, - end: 2141, + start: 3574, + end: 3580, }, - id: "ticker_indexes", + value: Str( + "date", + ), }, ), ], - value: List( - List { - node: Node { - start: 2144, - end: 2152, - }, - elements: [ - Name( - Name { - node: Node { - start: 2145, - end: 2151, - }, - id: "symbol", - }, - ), - ], - }, - ), + keywords: [], + starargs: None, + kwargs: None, }, ), - ], - orelse: [ - AssignStatement( - Assign { + attr: "reset_index", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 3615, + end: 3624, + }, + arg: Some( + "drop", + ), + value: Constant( + Constant { node: Node { - start: 2187, - end: 2230, + start: 3620, + end: 3624, }, - targets: [ - Name( - Name { - node: Node { - start: 2187, - end: 2199, + 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: 3678, + end: 3685, + }, + id: "df_list", + }, + ), + slice: Name( + Name { + node: Node { + start: 3686, + end: 3692, + }, + id: "symbol", + }, + ), + }, + ), + ], + value: Name( + Name { + node: Node { + start: 3696, + end: 3698, + }, + id: "df", + }, + ), + }, + ), + ], + }, + ), + 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: 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: 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: 3770, + end: 3777, + }, + id: "df_list", + }, + ), + 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, + }, + id: "base_path", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + attr: "mkdir", + }, + ), + 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: 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: [], + }, + ), + 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 { + 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, + }, + 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", + }, + ), + 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: [], + }, + ), + 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: 5700, + end: 5702, + }, + id: "df", + }, + ), + 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: 5721, + end: 5727, + }, + 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: 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, + }, + ), + }, + ), + 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", + }, + ), + ], + 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: 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 { + 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", + }, + ), + 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", + }, + ), + 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: 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", + }, + ), + }, + ), + ], + orelse: [ + AssignStatement( + Assign { + node: Node { + start: 6174, + end: 6193, + }, + 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", + ), + }, + ), + }, + ), + }, + ), + }, + ), + ], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 6202, + end: 6222, + }, + targets: [ + Name( + Name { + node: Node { + start: 6202, + end: 6205, + }, + 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: 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", + ), + }, + ), + ], + }, + ), + ], + }, + ), + }, + ), + ], + 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, + }, + 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: 7036, + end: 7079, + }, + 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", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 7105, + end: 7144, + }, + targets: [ + Name( + Name { + 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", + ), + }, + ), + 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: 7195, + end: 7207, + }, + value: Name( + Name { + node: Node { + start: 7195, + end: 7201, + }, + 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: 7270, + end: 7273, + }, + id: "url", + }, + ), + ], + }, + ), + ], + 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, + }, + value: Str( + "response", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 7323, + end: 7329, + }, + value: Str( + "code", + ), + }, + ), + ], + values: [ + Attribute( + Attribute { + node: Node { + start: 7308, + end: 7321, + }, + value: Name( + Name { + node: Node { + start: 7308, + end: 7316, + }, + id: "response", + }, + ), + attr: "text", + }, + ), + Attribute( + Attribute { + node: Node { + start: 7331, + end: 7351, + }, + 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: 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", + }, + ), + ], + 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: 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, + }, + ), + 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", + }, + ), + ), + }, + ], + 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: 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, + }, + ), + }, + ), + 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: 7766, + end: 7773, + }, + id: "session", + }, + ), + attr: "get", + }, + ), + 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, + }, + ), + }, + ), + 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: 7809, + end: 7817, + }, + id: "response", + }, + ), + attr: "status_code", + }, + ), + 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: 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: [], + }, + ), + 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, + }, + 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", + }, + ), + ], + }, + ), + ], + }, + ), + ], + }, + ), + 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 { + 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: 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: 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", + }, + ), + 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: "persian", + }, + ), + attr: "replace_persian", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 8940, + end: 8946, + }, + id: "symbol", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 8960, + end: 9230, + }, + 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, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 9463, + end: 9496, + }, + 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", + }, + ), + }, + ), + ], + 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", }, - id: "ticker_index", + ), + 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, }, ), - ], - value: Call( - Call { + ), + simple: true, + }, + ), + ], + handlers: [ + ExceptHandler { + node: Node { + start: 9686, + end: 9928, + }, + typ: Some( + Attribute( + Attribute { node: Node { - start: 2202, - end: 2230, + start: 9693, + end: 9717, }, - func: Name( - Name { + value: Attribute( + Attribute { node: Node { - start: 2202, - end: 2222, + 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, }, - id: "_handle_ticker_index", + ), + attr: "mkdir", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 10078, + end: 10090, }, - ), - args: [ - Name( - Name { + arg: Some( + "parents", + ), + value: Constant( + Constant { node: Node { - start: 2223, - end: 2229, + start: 10086, + end: 10090, }, - id: "symbol", + value: Bool( + true, + ), }, ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 2247, - end: 2357, - }, - test: Compare( - Compare { - node: Node { - start: 2250, - end: 2270, }, - left: Name( - Name { - node: Node { - start: 2250, - end: 2262, - }, - id: "ticker_index", + Keyword { + node: Node { + start: 10092, + end: 10105, }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( + arg: Some( + "exist_ok", + ), + value: Constant( Constant { node: Node { - start: 2266, - end: 2270, + start: 10101, + end: 10105, }, - value: None, + value: Bool( + true, + ), }, ), - ], + }, + ], + starargs: None, + kwargs: None, + }, + ), + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 10145, + end: 10225, }, - ), - body: [ - Raise( - Raise { + func: Attribute( + Attribute { node: Node { - start: 2292, - end: 2340, + start: 10138, + end: 10145, }, - exc: Some( - Call( - Call { - node: Node { - start: 2298, - end: 2340, + value: Subscript( + Subscript { + node: Node { + start: 10123, + end: 10138, + }, + value: Name( + Name { + node: Node { + start: 10123, + end: 10130, + }, + id: "df_list", }, - func: Name( - Name { - node: Node { - start: 2298, - end: 2307, - }, - id: "Exception", + ), + slice: Name( + Name { + node: Node { + start: 10131, + end: 10137, }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 2308, - end: 2339, - }, - values: [ - Constant( - Constant { - node: Node { - start: 2330, - end: 0, - }, - value: Str( - "Cannot find symbol: ", - ), - }, - ), - Name( - Name { - node: Node { - start: 2331, - end: 2337, - }, - id: "symbol", - }, - ), - ], - }, + 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( + "/", ), - ], - 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", + ), + }, + ), + ], + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 10196, + end: 10207, + }, + arg: Some( + "index", + ), + value: Constant( + Constant { + node: Node { + start: 10202, + end: 10207, }, - ), + value: Bool( + false, + ), + }, ), - cause: None, }, + ], + 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", ), - ], - orelse: [], + }, + ), + ], + 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, }, - ), - AssignStatement( - Assign { - node: Node { - start: 2357, - end: 2415, - }, - targets: [ - Name( - Name { - node: Node { - start: 2357, - end: 2371, - }, - id: "ticker_indexes", + 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 { + 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: 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, }, - ), - ], - value: Call( - Call { + id: "List", + }, + ), + Name( + Name { node: Node { - start: 2407, - end: 2415, + start: 10434, + end: 10437, }, - func: Attribute( - Attribute { - node: Node { - start: 2374, - end: 2407, - }, - value: Name( - Name { - node: Node { - start: 2374, - end: 2386, - }, - id: "symbols_data", - }, - ), - attr: "get_ticker_old_index", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 2408, - end: 2414, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + 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", }, ), - ExpressionStatement( - Call( - Call { + ], + value: Call( + Call { + node: Node { + start: 10632, + end: 10634, + }, + func: Attribute( + Attribute { node: Node { - start: 2453, - end: 2470, + start: 10608, + end: 10632, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 2432, - end: 2453, + start: 10608, + end: 10620, }, - value: Name( - Name { - node: Node { - start: 2432, - end: 2446, - }, - id: "ticker_indexes", - }, - ), - attr: "insert", + id: "symbols_data", }, ), - args: [ - Constant( - Constant { - node: Node { - start: 2454, - end: 2455, - }, - value: Int( - "0", - ), - }, - ), - Name( - Name { - node: Node { - start: 2457, - end: 2469, - }, - id: "ticker_index", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + attr: "all_symbols", }, ), - ), - ], + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), }, ), - ForStatement( - For { + ], + orelse: [ + IfStatement( + If { node: Node { - start: 2484, - end: 2698, + start: 10639, + end: 10703, }, - target: Name( - Name { - node: Node { - start: 2488, - end: 2493, - }, - id: "index", - }, - ), - iter: Name( - Name { + test: Call( + Call { node: Node { - start: 2497, - end: 2511, + start: 10644, + end: 10668, }, - id: "ticker_indexes", + 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: 2529, - end: 2637, + start: 10678, + end: 10697, }, targets: [ Name( Name { node: Node { - start: 2529, - end: 2535, + start: 10678, + end: 10685, }, - id: "future", + id: "symbols", }, ), ], - value: Call( - Call { + value: List( + List { node: Node { - start: 2553, - end: 2637, + start: 10688, + end: 10697, }, - func: Attribute( - Attribute { - node: Node { - start: 2538, - end: 2553, - }, - value: Name( - Name { - node: Node { - start: 2538, - end: 2546, - }, - id: "executor", - }, - ), - attr: "submit", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 2575, - end: 2603, - }, - id: "download_ticker_daily_record", - }, - ), - Name( - Name { - node: Node { - start: 2605, - end: 2610, - }, - id: "index", - }, - ), + elements: [ Name( Name { node: Node { - start: 2612, - end: 2619, + start: 10689, + end: 10696, }, - id: "session", + id: "symbols", }, ), ], - keywords: [], - starargs: None, - kwargs: None, }, ), }, ), - AssignStatement( - Assign { + ], + 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: 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: 2655, - end: 2688, + start: 10751, + end: 10777, }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 2655, - end: 2679, - }, - value: Name( - Name { - node: Node { - start: 2655, - end: 2671, - }, - id: "future_to_symbol", - }, - ), - slice: Name( - Name { - node: Node { - start: 2672, - end: 2678, - }, - id: "future", - }, - ), - }, - ), - ], value: Name( Name { node: Node { - start: 2682, - end: 2688, + start: 10751, + end: 10758, }, - id: "symbol", + id: "futures", }, ), + attr: "ThreadPoolExecutor", }, ), - ], - orelse: [], - }, - ), + 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: 2698, - end: 15273, + start: 10815, + end: 11168, }, target: Name( Name { node: Node { - start: 2702, - end: 2708, + start: 10819, + end: 10825, }, - id: "future", + id: "symbol", }, ), - iter: Call( - Call { + iter: Name( + Name { node: Node { - start: 2732, - end: 2750, + start: 10829, + end: 10836, }, - func: Attribute( - Attribute { - node: Node { - start: 2712, - end: 2732, - }, - value: Name( - Name { - node: Node { - start: 2712, - end: 2719, - }, - id: "futures", - }, - ), - attr: "as_completed", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 2733, - end: 2749, - }, - id: "future_to_symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "symbols", }, ), body: [ AssignStatement( Assign { node: Node { - start: 2764, - end: 2797, + start: 10850, + end: 10893, }, targets: [ Name( Name { node: Node { - start: 2764, - end: 2770, + start: 10850, + end: 10862, }, - id: "symbol", + id: "ticker_index", }, ), ], - value: Subscript( - Subscript { + value: Call( + Call { node: Node { - start: 2773, - end: 2797, + start: 10865, + end: 10893, }, - value: Name( - Name { - node: Node { - start: 2773, - end: 2789, - }, - id: "future_to_symbol", - }, - ), - slice: Name( + func: Name( Name { node: Node { - start: 2790, - end: 2796, + start: 10865, + end: 10885, }, - id: "future", - }, - ), - }, - ), - }, - ), - TryStatement( - Try { - node: Node { - start: 2810, - end: 3120, - }, - body: [ - AnnAssignStatement( - AnnAssign { - node: Node { - start: 2831, - end: 2865, + id: "_handle_ticker_index", }, - target: Name( - Name { - node: Node { - start: 2831, - end: 2833, - }, - id: "df", - }, - ), - annotation: Attribute( - Attribute { - node: Node { - start: 2835, - end: 2847, - }, - value: Name( - Name { - node: Node { - start: 2835, - end: 2837, - }, - id: "pd", - }, - ), - attr: "DataFrame", - }, - ), - 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, + ), + args: [ + Name( + Name { + node: Node { + start: 10886, + end: 10892, }, - ), + id: "symbol", + }, ), - simple: true, - }, - ), - ], - handlers: [ - ExceptHandler { + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 10906, + end: 11008, + }, + test: Compare( + Compare { node: Node { - start: 2878, - end: 3120, + start: 10909, + end: 10929, }, - typ: Some( - Attribute( - Attribute { + left: Name( + Name { + node: Node { + start: 10909, + end: 10921, + }, + id: "ticker_index", + }, + ), + ops: [ + Is, + ], + comparators: [ + Constant( + Constant { node: Node { - start: 2885, - end: 2909, + start: 10925, + end: 10929, }, - value: Attribute( - Attribute { - node: Node { - start: 2885, - end: 2894, - }, - value: Name( - Name { - node: Node { - start: 2885, - end: 2887, - }, - id: "pd", - }, - ), - attr: "errors", - }, - ), - attr: "EmptyDataError", + value: None, }, ), - ), - name: Some( - "ex", - ), - body: [ - ExpressionStatement( + ], + }, + ), + body: [ + Raise( + Raise { + node: Node { + start: 10947, + end: 10995, + }, + exc: Some( Call( Call { node: Node { - start: 2945, - end: 3082, + start: 10953, + end: 10995, }, - func: Attribute( - Attribute { + func: Name( + Name { node: Node { - start: 2933, - end: 2945, + start: 10953, + end: 10962, }, - value: Name( - Name { - node: Node { - start: 2933, - end: 2939, - }, - id: "logger", - }, - ), - attr: "error", + id: "Exception", }, ), args: [ JoinedStr( JoinedStr { node: Node { - start: 2967, - end: 3022, + start: 10963, + end: 10994, }, values: [ Constant( Constant { node: Node { - start: 3013, + start: 10985, end: 0, }, value: Str( - "Cannot read daily trade records for symbol: ", + "Cannot find symbol: ", ), }, ), Name( Name { node: Node { - start: 3014, - end: 3020, + start: 10986, + end: 10992, }, id: "symbol", }, @@ -3343,182 +10568,81 @@ Module { }, ), ], - 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", - }, - ), - ], - }, - ), - }, - ], + keywords: [], starargs: None, kwargs: None, }, ), ), - Continue( - Continue { - node: Node { - start: 3099, - end: 3107, - }, - }, - ), - ], - }, + cause: None, + }, + ), ], orelse: [], - finalbody: [], }, ), AssignStatement( Assign { node: Node { - start: 3120, - end: 3161, + start: 11008, + end: 11113, }, targets: [ Name( Name { node: Node { - start: 3120, - end: 3122, + start: 11008, + end: 11014, }, - id: "df", + id: "future", }, ), ], value: Call( Call { node: Node { - start: 3150, - end: 3161, + start: 11032, + end: 11113, }, func: Attribute( Attribute { node: Node { - start: 3138, - end: 3150, + start: 11017, + end: 11032, }, - value: Subscript( - Subscript { + value: Name( + Name { node: Node { - start: 3132, - end: 3138, + start: 11017, + end: 11025, }, - value: Attribute( - Attribute { - node: Node { - start: 3125, - end: 3132, - }, - value: Name( - Name { - node: Node { - start: 3125, - end: 3127, - }, - id: "df", - }, - ), - 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, - }, - ), + id: "executor", }, ), - attr: "reset_index", + attr: "submit", }, ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 3151, - end: 3160, + args: [ + Name( + Name { + node: Node { + start: 11050, + end: 11085, + }, + id: "download_ticker_client_types_record", }, - arg: Some( - "drop", - ), - value: Constant( - Constant { - node: Node { - start: 3156, - end: 3160, - }, - value: Bool( - true, - ), + ), + Name( + Name { + node: Node { + start: 11087, + end: 11099, }, - ), - }, + id: "ticker_index", + }, + ), ], + keywords: [], starargs: None, kwargs: None, }, @@ -3528,183 +10652,283 @@ Module { AssignStatement( Assign { node: Node { - start: 3174, - end: 3233, + 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: 3174, - end: 3176, + start: 11234, + end: 11240, }, - id: "df", + id: "symbol", }, ), ], - value: Call( - Call { + value: Subscript( + Subscript { node: Node { - start: 3188, - end: 3233, + start: 11243, + end: 11267, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 3179, - end: 3188, + start: 11243, + end: 11259, }, - value: Name( - Name { - node: Node { - start: 3179, - end: 3181, - }, - id: "df", - }, - ), - attr: "rename", + id: "future_to_symbol", }, ), - args: [], - keywords: [ - Keyword { + slice: Name( + Name { node: Node { - start: 3189, - end: 3232, + start: 11260, + end: 11266, }, - 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", - }, - ), + id: "future", }, - ], - starargs: None, - kwargs: None, + ), }, ), }, ), - AssignStatement( - Assign { + AnnAssignStatement( + AnnAssign { node: Node { - start: 3246, - end: 3289, + start: 11280, + end: 11314, }, - targets: [ - Name( - Name { + 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: 3246, - end: 3248, + start: 11312, + end: 11314, }, - id: "df", + func: Attribute( + Attribute { + node: Node { + start: 11299, + end: 11312, + }, + value: Name( + Name { + node: Node { + start: 11299, + end: 11305, + }, + id: "future", + }, + ), + attr: "result", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, }, ), - ], - value: Call( - Call { + ), + simple: true, + }, + ), + IfStatement( + If { + node: Node { + start: 11357, + end: 11409, + }, + test: Compare( + Compare { node: Node { - start: 3258, - end: 3289, + start: 11360, + end: 11370, }, - func: Attribute( - Attribute { + left: Name( + Name { node: Node { - start: 3251, - end: 3258, + start: 11360, + end: 11362, }, - value: Name( - Name { - node: Node { - start: 3251, - end: 3253, - }, - id: "df", - }, - ), - attr: "drop", + id: "df", }, ), - 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: 3268, - end: 3275, - }, - value: Str( - "", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 3277, - end: 3287, - }, - value: Str( - "", - ), - }, - ), - ], + ops: [ + Is, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 11366, + end: 11370, }, - ), - }, + value: None, + }, + ), ], - starargs: None, - kwargs: None, }, ), + body: [ + Continue( + Continue { + node: Node { + start: 11388, + end: 11396, + }, + }, + ), + ], + orelse: [], }, ), ExpressionStatement( Call( Call { node: Node { - start: 3302, - end: 3339, + start: 11409, + end: 11446, }, func: Name( Name { node: Node { - start: 3302, - end: 3320, + start: 11409, + end: 11427, }, id: "_adjust_data_frame", }, @@ -3713,8 +10937,8 @@ Module { Name( Name { node: Node { - start: 3321, - end: 3323, + start: 11428, + end: 11430, }, id: "df", }, @@ -3722,8 +10946,8 @@ Module { Name( Name { node: Node { - start: 3325, - end: 3338, + start: 11432, + end: 11445, }, id: "include_jdate", }, @@ -3735,437 +10959,62 @@ Module { }, ), ), - IfStatement( - If { + AssignStatement( + Assign { node: Node { - start: 3353, - end: 3712, + start: 11459, + end: 11479, }, - test: Compare( - Compare { - node: Node { - start: 3356, - end: 3373, - }, - left: Name( - Name { - node: Node { - start: 3356, - end: 3362, - }, - id: "symbol", + targets: [ + Subscript( + Subscript { + node: Node { + start: 11459, + end: 11474, }, - ), - ops: [ - In, - ], - comparators: [ - Name( + value: Name( Name { node: Node { - start: 3366, - end: 3373, + start: 11459, + end: 11466, }, id: "df_list", }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 3391, - end: 3643, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 3391, - end: 3406, - }, - value: Name( - Name { - node: Node { - start: 3391, - end: 3398, - }, - id: "df_list", - }, - ), - 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: 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", - }, - ), - args: [ - List( - List { - node: Node { - start: 3466, - end: 3487, - }, - 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", - }, - ), - }, - ), - Name( - Name { - node: Node { - start: 3484, - end: 3486, - }, - id: "df", - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 3489, - end: 3506, - }, - arg: Some( - "ignore_index", - ), - value: Constant( - Constant { - node: Node { - start: 3502, - end: 3506, - }, - value: Bool( - true, - ), - }, - ), - }, - 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", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 3574, - end: 3580, - }, - value: Str( - "date", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "reset_index", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 3615, - end: 3624, - }, - arg: Some( - "drop", - ), - value: Constant( - Constant { - node: Node { - start: 3620, - end: 3624, - }, - 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: 3678, - end: 3685, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 3686, - end: 3692, - }, - id: "symbol", - }, - ), - }, - ), - ], - value: Name( + ), + slice: Name( Name { node: Node { - start: 3696, - end: 3698, + start: 11467, + end: 11473, }, - id: "df", + id: "symbol", }, ), }, ), ], - }, - ), - IfStatement( - If { - node: Node { - start: 3712, - end: 3800, - }, - test: Name( + value: Name( Name { node: Node { - start: 3715, - end: 3721, + start: 11477, + end: 11479, }, - id: "adjust", + id: "df", }, ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 3739, - end: 3786, - }, - 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: 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: 3770, - end: 3777, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 3778, - end: 3784, - }, - id: "symbol", - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - orelse: [], }, ), IfStatement( If { node: Node { - start: 3800, - end: 4346, + start: 11492, + end: 11636, }, test: Name( Name { node: Node { - start: 3803, - end: 3815, + start: 11495, + end: 11507, }, id: "write_to_csv", }, @@ -4175,26 +11024,26 @@ Module { Call( Call { node: Node { - start: 3854, - end: 3883, + start: 11546, + end: 11575, }, func: Attribute( Attribute { node: Node { - start: 3848, - end: 3854, + start: 11540, + end: 11546, }, value: Call( Call { node: Node { - start: 3833, - end: 3848, + start: 11525, + end: 11540, }, func: Name( Name { node: Node { - start: 3833, - end: 3837, + start: 11525, + end: 11529, }, id: "Path", }, @@ -4203,8 +11052,8 @@ Module { Name( Name { node: Node { - start: 3838, - end: 3847, + start: 11530, + end: 11539, }, id: "base_path", }, @@ -4222,8 +11071,8 @@ Module { keywords: [ Keyword { node: Node { - start: 3855, - end: 3867, + start: 11547, + end: 11559, }, arg: Some( "parents", @@ -4231,8 +11080,8 @@ Module { value: Constant( Constant { node: Node { - start: 3863, - end: 3867, + start: 11555, + end: 11559, }, value: Bool( true, @@ -4242,8 +11091,8 @@ Module { }, Keyword { node: Node { - start: 3869, - end: 3882, + start: 11561, + end: 11574, }, arg: Some( "exist_ok", @@ -4251,8 +11100,8 @@ Module { value: Constant( Constant { node: Node { - start: 3878, - end: 3882, + start: 11570, + end: 11574, }, value: Bool( true, @@ -4266,10243 +11115,3339 @@ 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, - }, - ), - ), - ], - }, - ), - IfStatement( - If { - node: Node { - start: 4203, - end: 4309, - }, - test: Compare( - Compare { - node: Node { - start: 4206, - end: 4234, + 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", }, - left: Call( - Call { + ), + args: [ + JoinedStr( + JoinedStr { node: Node { - start: 4206, - end: 4218, + start: 11602, + end: 11629, }, - func: Name( - Name { - node: Node { - start: 4206, - end: 4209, - }, - id: "len", - }, - ), - args: [ + values: [ Name( Name { node: Node { - start: 4210, - end: 4217, + start: 11605, + end: 11614, }, - id: "df_list", + id: "base_path", }, ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - NotEq, - ], - comparators: [ - Call( - Call { - node: Node { - start: 4222, - end: 4234, - }, - func: Name( - Name { + Constant( + Constant { node: Node { - start: 4222, - end: 4225, + start: 11616, + end: 0, }, - id: "len", + value: Str( + "/", + ), }, ), - args: [ - Name( - Name { - node: Node { - start: 4226, - end: 4233, - }, - id: "symbols", + Name( + Name { + node: Node { + start: 11617, + end: 11623, }, - ), - ], - 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: "symbol", }, - id: "print", - }, - ), - args: [ + ), Constant( Constant { node: Node { - start: 4250, - end: 4303, + start: 11628, + end: 0, }, value: Str( - "Warning, download did not complete, re-run the code", + ".csv", ), }, ), ], - 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 { + ], + 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: 4329, - end: 4343, + start: 11639, + end: 11642, }, - value: Some( - Name( - Name { - node: Node { - start: 4336, - end: 4343, - }, - id: "df_list", + 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", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 12114, + end: 12126, }, - ), - ], - orelse: [], + 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, }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 4346, - end: 6805, - }, - name: "adjust_price", - args: Arguments { + left: Call( + Call { node: Node { - start: 4363, - end: 4379, + start: 12135, + end: 12144, }, - posonlyargs: [], - args: [ - Arg { + func: Name( + Name { node: Node { - start: 4363, - end: 4379, + start: 12135, + end: 12138, }, - 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: 12139, + end: 12143, }, - 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: "data", }, ), - ), - 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: [ + Eq, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 12148, + end: 12149, }, - ), - AssignStatement( - Assign { + value: Int( + "1", + ), + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 12173, + end: 12342, + }, + func: Attribute( + Attribute { node: Node { - start: 5691, - end: 5709, + start: 12159, + end: 12173, }, - targets: [ - Name( - Name { - node: Node { - start: 5691, - end: 5697, - }, - id: "new_df", - }, - ), - ], - value: Call( - Call { + value: Name( + Name { node: Node { - start: 5707, - end: 5709, + start: 12159, + end: 12165, }, - 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: "logger", }, ), + attr: "warning", }, ), - 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 { + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 12187, + end: 12281, + }, + values: [ + Constant( + Constant { node: Node { - start: 5721, - end: 5733, + start: 12233, + end: 0, }, - value: Name( - Name { - node: Node { - start: 5721, - end: 5727, - }, - id: "new_df", - }, + value: Str( + "Cannot create client types data for ticker", ), - 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( Name { node: Node { - start: 5750, - end: 5754, + start: 12234, + end: 12246, }, - id: "list", + id: "ticker_index", }, ), - 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", - }, - ), - ], - }, - ), + Constant( + Constant { + node: Node { + start: 12272, + end: 0, }, - ), - ], - 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 { + value: Str( + "\n from data: ", + ), + }, + ), + Name( + Name { node: Node { - start: 5822, - end: 5831, + start: 12273, + end: 12277, }, - func: Name( - Name { - node: Node { - start: 5822, - end: 5825, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 5826, - end: 5830, - }, - id: "diff", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "data", }, ), - ops: [ - Gt, - ], - comparators: [ + ], + }, + ), + ], + 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: 5834, - end: 5835, + start: 12302, + end: 12316, }, - value: Int( - "0", + value: Str( + "ticker_index", ), }, ), ], + values: [ + Name( + Name { + node: Node { + start: 12318, + end: 12330, + }, + id: "ticker_index", + }, + ), + ], }, ), - 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: [], + }, + ], + starargs: None, + kwargs: None, + }, + ), + ), + Return( + Return { + node: Node { + start: 12351, + end: 12362, + }, + value: Some( + Constant( + Constant { + node: Node { + start: 12358, + end: 12362, + }, + value: None, }, ), - AssignStatement( - Assign { + ), + }, + ), + ], + 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: 5861, - end: 5870, + start: 12393, + end: 12395, }, - targets: [ - Name( - Name { - node: Node { - start: 5861, - end: 5866, - }, - id: "ratio", - }, - ), - ], - value: Constant( - Constant { - node: Node { - start: 5869, - end: 5870, - }, - value: Int( - "1", - ), - }, - ), + 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", ), - AssignStatement( - Assign { + value: List( + List { node: Node { - start: 5875, - end: 5890, + start: 12437, + end: 12892, }, - targets: [ - Name( - Name { + elements: [ + Constant( + Constant { node: Node { - start: 5875, - end: 5885, + start: 12451, + end: 12457, }, - id: "ratio_list", + value: Str( + "date", + ), }, ), - ], - 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, + Constant( + Constant { + node: Node { + start: 12471, + end: 12493, + }, + value: Str( + "individual_buy_count", + ), }, - id: "i", - }, - ), - iter: Subscript( - Subscript { - node: Node { - start: 5904, - end: 5914, + ), + Constant( + Constant { + node: Node { + start: 12507, + end: 12528, + }, + value: Str( + "corporate_buy_count", + ), }, - value: Name( - Name { - node: Node { - start: 5904, - end: 5908, - }, - id: "diff", + ), + Constant( + Constant { + node: Node { + start: 12542, + end: 12565, }, - ), - 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, + value: Str( + "individual_sell_count", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12579, + end: 12601, }, - ), - }, - ), - body: [ - AugAssignStatement( - AugAssign { + value: Str( + "corporate_sell_count", + ), + }, + ), + Constant( + Constant { node: Node { - start: 5924, - end: 6020, + start: 12615, + end: 12635, }, - target: Name( - Name { - node: Node { - start: 5924, - end: 5929, - }, - id: "ratio", - }, + value: Str( + "individual_buy_vol", ), - 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", - ), - }, - ), - ], - }, - ), - }, - ), - }, + }, + ), + Constant( + Constant { + node: Node { + start: 12649, + end: 12668, + }, + value: Str( + "corporate_buy_vol", ), }, ), - 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, + 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", + ), + }, ), ], - orelse: [], }, ), - ForStatement( - For { + }, + ], + 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: 6061, - end: 6789, + start: 13038, + end: 13079, }, - target: Tuple( - Tuple { + value: Name( + Name { node: Node { - start: 6065, - end: 6069, + start: 13038, + end: 13061, }, - elements: [ - Name( - Name { - node: Node { - start: 6065, - end: 6066, - }, - id: "i", - }, - ), - Name( - Name { - node: Node { - start: 6068, - end: 6069, - }, - id: "k", - }, - ), - ], + id: "client_types_data_frame", }, ), - iter: Call( - Call { + slice: JoinedStr( + JoinedStr { node: Node { - start: 6073, - end: 6088, + start: 13062, + end: 13078, }, - func: Name( - Name { - node: Node { - start: 6073, - end: 6082, - }, - id: "enumerate", - }, - ), - args: [ + values: [ Name( Name { node: Node { - start: 6083, - end: 6087, + start: 13065, + end: 13066, }, - id: "diff", + id: "i", }, ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - body: [ - IfStatement( - If { - node: Node { - start: 6098, - end: 6202, - }, - test: Compare( - Compare { + Constant( + Constant { node: Node { - start: 6101, - end: 6107, + start: 13077, + end: 0, }, - left: Name( - Name { - node: Node { - start: 6101, - end: 6102, - }, - id: "i", - }, + value: Str( + "mean_price", ), - 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: 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", - }, - ), - }, - ), - ], - orelse: [ - AssignStatement( - Assign { - node: Node { - start: 6174, - end: 6193, - }, - 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", - ), - }, - ), - }, - ), - }, - ), - }, - ), - ], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 6202, - end: 6222, - }, - targets: [ - Name( - Name { - node: Node { - start: 6202, - end: 6205, - }, - id: "end", - }, - ), - ], - value: BinOp( - BinOp { + ], + }, + ), + }, + ), + ], + 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: 6208, - end: 6222, + start: 13082, + end: 13140, }, - op: Sub, - left: Subscript( - Subscript { + value: Name( + Name { node: Node { - start: 6208, - end: 6215, + start: 13082, + end: 13105, }, - value: Name( - Name { - node: Node { - start: 6208, - end: 6212, - }, - id: "diff", - }, - ), - slice: Name( - Name { - node: Node { - start: 6213, - end: 6214, - }, - id: "i", - }, - ), + id: "client_types_data_frame", }, ), - right: Name( - Name { + slice: JoinedStr( + JoinedStr { node: Node { - start: 6218, - end: 6222, + start: 13119, + end: 13130, }, - id: "step", + values: [ + Name( + Name { + node: Node { + start: 13122, + end: 13123, + }, + id: "i", + }, + ), + Constant( + Constant { + node: Node { + start: 13129, + end: 0, + }, + value: Str( + "value", + ), + }, + ), + ], }, ), }, ), + attr: "astype", }, ), - AssignStatement( - Assign { + 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: 6231, - end: 6783, + start: 13191, + end: 13198, }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 6241, - end: 6457, - }, - 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", - ), - }, - ), - ], - }, - ), - ], - }, - ), - }, - ), - ], - value: Call( - Call { + value: Subscript( + Subscript { node: Node { - start: 6460, - end: 6783, + start: 13157, + end: 13191, }, - func: Name( + value: Name( Name { node: Node { - start: 6460, - end: 6465, + start: 13157, + end: 13180, }, - id: "round", + id: "client_types_data_frame", }, ), - args: [ - BinOp( - BinOp { - node: Node { - start: 6479, - end: 6773, - }, - op: Mult, - left: Subscript( - Subscript { + slice: JoinedStr( + JoinedStr { + node: Node { + start: 13181, + end: 13190, + }, + values: [ + Name( + Name { node: Node { - start: 6489, - end: 6745, + start: 13184, + end: 13185, }, - 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", - ), - }, - ), - ], - }, - ), - ], - }, - ), + id: "i", }, ), - right: Subscript( - Subscript { + Constant( + Constant { node: Node { - start: 6760, - end: 6773, + start: 13189, + end: 0, }, - value: Name( - Name { - node: Node { - start: 6760, - end: 6770, - }, - id: "ratio_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 6771, - end: 6772, - }, - id: "i", - }, + value: Str( + "vol", ), }, ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + ], + }, + ), }, ), + attr: "astype", }, ), - ], - orelse: [], + 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, }, - ), - Return( - Return { + 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: 6789, - end: 6802, + start: 13326, + end: 13333, }, - value: Some( - Name( - Name { - node: Node { - start: 6796, - end: 6802, - }, - id: "new_df", + 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", }, ), - ], - decorator_list: [], - returns: Some( - Attribute( + 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: 4384, - end: 4396, + start: 13415, + end: 13422, }, - value: Name( - Name { + value: Subscript( + Subscript { node: Node { - start: 4384, - end: 4386, + start: 13357, + end: 13415, }, - id: "pd", + 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: "DataFrame", + attr: "astype", }, ), - ), - type_comment: None, - }, - ), - FunctionDef( - FunctionDef { + 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: 6955, - end: 7464, + start: 13455, + end: 13478, }, - name: "download_ticker_daily_record", - args: Arguments { + 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: 6988, - end: 7023, + start: 11867, + end: 11901, }, - posonlyargs: [], - args: [ - Arg { + func: Name( + Name { node: Node { - start: 6988, - end: 7005, + start: 11867, + end: 11890, }, - arg: "ticker_index", - annotation: Some( - Name( - Name { - node: Node { - start: 7002, - end: 7005, - }, - id: "str", - }, - ), - ), + id: "retry_if_exception_type", }, - Arg { - node: Node { - start: 7007, - end: 7023, + ), + args: [ + Name( + Name { + node: Node { + start: 11891, + end: 11900, + }, + id: "HTTPError", }, - arg: "session", - annotation: Some( - Name( - Name { - node: Node { - start: 7016, - end: 7023, - }, - id: "Session", - }, - ), - ), - }, + ), ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], + keywords: [], + starargs: None, + kwargs: None, }, - body: [ - AssignStatement( - Assign { + ), + }, + 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: 7030, - end: 7100, + start: 11912, + end: 11923, }, - 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: 7036, - end: 7079, - }, - 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", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), + id: "wait_random", }, ), - AssignStatement( - Assign { + args: [], + keywords: [ + Keyword { node: Node { - start: 7105, - end: 7144, + start: 11924, + end: 11929, }, - targets: [ - Name( - Name { - node: Node { - start: 7105, - end: 7113, - }, - id: "response", - }, - ), - ], - value: Call( - Call { + arg: Some( + "min", + ), + value: Constant( + Constant { node: Node { - start: 7127, - end: 7144, + start: 11928, + end: 11929, }, - func: Attribute( - Attribute { - node: Node { - start: 7116, - end: 7127, - }, - value: Name( - Name { - node: Node { - start: 7116, - end: 7123, - }, - id: "session", - }, - ), - attr: "get", - }, + value: Int( + "1", ), - 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 { + Keyword { node: Node { - start: 7149, - end: 7369, + start: 11931, + end: 11936, }, - test: Compare( - Compare { + arg: Some( + "max", + ), + value: Constant( + Constant { node: Node { - start: 7152, - end: 7185, + start: 11935, + end: 11936, }, - left: Constant( - Constant { - node: Node { - start: 7152, - end: 7155, - }, - value: Int( - "400", - ), - }, + value: Int( + "4", ), - 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: 7195, - end: 7207, - }, - value: Name( - Name { - node: Node { - start: 7195, - end: 7201, - }, - 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: 7270, - end: 7273, - }, - id: "url", - }, - ), - ], - }, - ), - ], - 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, - }, - value: Str( - "response", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 7323, - end: 7329, - }, - value: Str( - "code", - ), - }, - ), - ], - values: [ - Attribute( - Attribute { - node: Node { - start: 7308, - end: 7321, - }, - value: Name( - Name { - node: Node { - start: 7308, - end: 7316, - }, - id: "response", - }, - ), - attr: "text", - }, - ), - Attribute( - Attribute { - node: Node { - start: 7331, - end: 7351, - }, - value: Name( - Name { - node: Node { - start: 7331, - end: 7339, - }, - id: "response", - }, - ), - attr: "status_code", - }, - ), - ], - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], + }, + ], + 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", }, ), - ExpressionStatement( - Call( - Call { + args: [ + Name( + Name { + node: Node { + start: 11973, + end: 11979, + }, + id: "logger", + }, + ), + Attribute( + Attribute { node: Node { - start: 7394, - end: 7396, + start: 11981, + end: 11994, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 7369, - end: 7394, + start: 11981, + end: 11988, }, - value: Name( - Name { - node: Node { - start: 7369, - end: 7377, - }, - id: "response", - }, - ), - attr: "raise_for_status", + id: "logging", }, ), - args: [], - keywords: [], - starargs: None, - kwargs: None, + attr: "DEBUG", }, ), - ), - AssignStatement( - Assign { + ], + 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: 7402, - end: 7432, + start: 13528, + end: 13558, }, - targets: [ - Name( - Name { - node: Node { - start: 7402, - end: 7406, - }, - id: "data", - }, - ), - ], - value: Call( - Call { + value: Name( + Name { node: Node { - start: 7409, - end: 7432, + start: 13528, + end: 13540, }, - 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, + id: "tse_settings", }, ), + attr: "TSE_SYMBOL_ID_URL", }, ), - Return( - Return { - node: Node { - start: 7437, - end: 7461, - }, - value: Some( - Call( - Call { + 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: 7455, - end: 7461, + start: 13566, + end: 13577, }, - 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, + id: "symbol_name", }, ), - ), - }, - ), - ], - decorator_list: [ - Call( + 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: 6806, - end: 6954, + start: 13602, + end: 13626, }, - 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: 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 { + func: Name( + Name { node: Node { - start: 6899, - end: 6951, + start: 13602, + end: 13624, }, - 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, - }, - ), + id: "requests_retry_session", }, - ], + ), + args: [], + keywords: [], starargs: None, kwargs: None, }, ), - ], - returns: None, - type_comment: None, - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 7614, - end: 8358, + attr: "get", }, - name: "download_fIndex_record", - args: Arguments { + ), + args: [ + Name( + Name { + node: Node { + start: 13631, + end: 13634, + }, + id: "url", + }, + ), + ], + keywords: [ + Keyword { node: Node { - start: 7641, - end: 7670, + start: 13636, + end: 13646, }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 7641, - end: 7652, - }, - arg: "fIndex", - annotation: Some( - Name( - Name { - node: Node { - start: 7649, - end: 7652, - }, - id: "str", - }, - ), - ), - }, - Arg { + arg: Some( + "timeout", + ), + value: Constant( + Constant { node: Node { - start: 7654, - end: 7670, + start: 13644, + end: 13646, }, - arg: "session", - annotation: Some( - Name( - Name { - node: Node { - start: 7663, - end: 7670, - }, - id: "Session", - }, - ), + value: Int( + "10", ), }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], + ), }, - body: [ - AssignStatement( - Assign { + ], + 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: 7677, - end: 7750, + start: 13665, + end: 13690, }, - targets: [ - Name( - Name { - node: Node { - start: 7677, - end: 7680, - }, - id: "url", - }, - ), - ], - value: Call( - Call { + value: Name( + Name { node: Node { - start: 7742, - end: 7750, + start: 13665, + end: 13673, }, - 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: "response", }, ), + attr: "raise_for_status", }, ), - AssignStatement( - Assign { - node: Node { - start: 7755, - end: 7794, - }, - targets: [ - Name( - Name { - node: Node { - start: 7755, - end: 7763, - }, - id: "response", - }, - ), - ], - value: Call( + 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: 7777, - end: 7794, + start: 13729, + end: 13775, }, - func: Attribute( - Attribute { + func: Name( + Name { node: Node { - start: 7766, - end: 7777, + start: 13729, + end: 13738, }, - value: Name( - Name { - node: Node { - start: 7766, - end: 7773, - }, - id: "session", - }, - ), - attr: "get", + id: "Exception", }, ), args: [ - Name( - Name { + Constant( + Constant { node: Node { - start: 7778, - end: 7781, + start: 13739, + end: 13774, }, - id: "url", + value: Str( + "Sorry, tse server did not respond", + ), }, ), ], - keywords: [ - Keyword { - node: Node { - start: 7783, - end: 7793, - }, - arg: Some( - "timeout", - ), - value: Constant( - Constant { - node: Node { - start: 7791, - end: 7793, - }, - value: Int( - "10", - ), - }, - ), - }, - ], + keywords: [], starargs: None, kwargs: None, }, ), - }, - ), - IfStatement( - If { + ), + 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: 7799, - end: 8019, + start: 13824, + end: 13827, }, - 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: 7809, - end: 7817, - }, - id: "response", - }, - ), - attr: "status_code", - }, - ), - Constant( - Constant { - node: Node { - start: 7832, - end: 7835, - }, - value: Int( - "500", - ), - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { + value: Call( + Call { + node: Node { + start: 13819, + end: 13824, + }, + func: Attribute( + Attribute { node: Node { - start: 7857, - end: 8013, + start: 13800, + end: 13819, }, - func: Attribute( + value: Attribute( Attribute { node: Node { - start: 7845, - end: 7857, + start: 13800, + end: 13813, }, value: Name( Name { node: Node { - start: 7845, - end: 7851, + start: 13800, + end: 13808, }, - id: "logger", + id: "response", }, ), - attr: "error", + attr: "text", }, ), - 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, + attr: "split", }, ), - ), - ], - orelse: [], - }, - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 8044, - end: 8046, - }, - func: Attribute( - Attribute { - node: Node { - start: 8019, - end: 8044, - }, - value: Name( - Name { + args: [ + Constant( + Constant { node: Node { - start: 8019, - end: 8027, + start: 13820, + end: 13823, }, - id: "response", + value: Str( + ";", + ), }, ), - 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 { + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + slice: Constant( + Constant { node: Node { - start: 8058, - end: 8071, + start: 13825, + end: 13826, }, - value: Name( - Name { - node: Node { - start: 8058, - end: 8066, - }, - id: "response", - }, + value: Int( + "0", ), - attr: "text", }, ), }, ), - IfStatement( - If { + 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: 8076, - end: 8288, + start: 13846, + end: 13868, }, - test: BoolOp( - BoolOperation { + value: Name( + Name { node: Node { - start: 8079, - end: 8125, + start: 13846, + end: 13853, }, - op: Or, - values: [ - UnaryOp( - UnaryOperation { + 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: 13885, + end: 13904, + }, + value: Name( + Name { node: Node { - start: 8079, - end: 8087, + start: 13885, + end: 13901, }, - op: Not, - operand: Name( - Name { - node: Node { - start: 8083, - end: 8087, - }, - id: "data", - }, - ), + id: "symbol_full_info", }, ), - BoolOp( - BoolOperation { + slice: Constant( + Constant { node: Node { - start: 8091, - end: 8125, + start: 13902, + end: 13903, }, - 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( + "0", + ), }, ), - ], + }, + ), + attr: "strip", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ], + }, + ), + body: [ + Return( + Return { + node: Node { + start: 13922, + end: 13948, + }, + value: Some( + Subscript( + Subscript { + node: Node { + start: 13929, + end: 13948, + }, + value: Name( + Name { + node: Node { + start: 13929, + end: 13945, + }, + id: "symbol_full_info", }, ), - 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, + slice: Constant( + Constant { + node: Node { + start: 13946, + end: 13947, }, - ), - ], - orelse: [], + value: Int( + "2", + ), + }, + ), }, ), - AssignStatement( - Assign { + ), + }, + ), + ], + 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: 8288, - end: 8341, + start: 14029, + end: 14059, }, - targets: [ - Name( - Name { - node: Node { - start: 8288, - end: 8290, - }, - id: "df", - }, - ), - ], - value: Call( - Call { + value: Name( + Name { node: Node { - start: 8293, - end: 8341, + start: 14029, + end: 14041, }, - 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: "tse_settings", }, ), + attr: "TSE_SYMBOL_ID_URL", }, ), - Return( - Return { - node: Node { - start: 8346, - end: 8355, - }, - value: Some( - Name( + 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: 8353, - end: 8355, + start: 14067, + end: 14078, }, - id: "df", + id: "symbol_name", }, ), - ), - }, - ), - ], - decorator_list: [ - Call( + 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: 7465, - end: 7613, + start: 14103, + end: 14127, }, func: Name( Name { node: Node { - start: 7465, - end: 7470, + start: 14103, + end: 14125, }, - id: "retry", + id: "requests_retry_session", }, ), 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, - }, - ), - }, - ], + keywords: [], starargs: None, kwargs: None, }, ), - ], - returns: None, - type_comment: None, - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 8358, - end: 15273, + 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", + ), + }, + ), }, - name: "download_financial_indexes", - args: Arguments { + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + TryStatement( + Try { + node: Node { + start: 14153, + end: 14298, + }, + body: [ + ExpressionStatement( + Call( + Call { node: Node { - start: 8394, - end: 8540, + start: 14191, + end: 14193, }, - posonlyargs: [], - args: [ - Arg { + func: Attribute( + Attribute { node: Node { - start: 8394, - end: 8419, + start: 14166, + end: 14191, }, - arg: "symbols", - annotation: Some( - Subscript( - Subscript { - node: Node { - start: 8403, - end: 8419, - }, - value: Name( - Name { - node: Node { - start: 8403, - end: 8408, - }, - id: "Union", + 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, }, - ), - slice: Tuple( - Tuple { + id: "Exception", + }, + ), + args: [ + JoinedStr( + JoinedStr { node: Node { - start: 8409, - end: 8419, + start: 14240, + end: 14291, }, - elements: [ + values: [ Name( Name { node: Node { - start: 8409, - end: 8413, + start: 14243, + end: 14254, }, - id: "List", + id: "symbol_name", }, ), - Name( - Name { + Constant( + Constant { node: Node { - start: 8415, - end: 8418, + start: 14290, + end: 0, }, - id: "str", + value: Str( + ": Sorry, tse server did not respond", + ), }, ), ], }, ), - }, - ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, ), - }, - Arg { + ), + 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: 8425, - end: 8451, + start: 14308, + end: 14321, }, - arg: "write_to_csv", - annotation: Some( - Name( - Name { - node: Node { - start: 8439, - end: 8443, - }, - id: "bool", + value: Name( + Name { + node: Node { + start: 14308, + end: 14316, }, - ), + id: "response", + }, ), + attr: "text", + }, + ), + attr: "split", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 14328, + end: 14331, }, - Arg { + 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: 8457, - end: 8484, + start: 14380, + end: 14384, }, - arg: "include_jdate", - annotation: Some( - Name( - Name { - node: Node { - start: 8472, - end: 8476, - }, - id: "bool", - }, - ), - ), + value: None, }, - Arg { + ), + }, + Keyword { + node: Node { + start: 14394, + end: 14405, + }, + arg: Some( + "symbol", + ), + value: Constant( + Constant { node: Node { - start: 8490, - end: 8539, + start: 14401, + end: 14405, }, - arg: "base_path", - annotation: Some( - Name( - Name { - node: Node { - start: 8501, - end: 8504, - }, - id: "str", - }, - ), - ), + value: None, }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [ - Constant( - Constant { - node: Node { - start: 8446, - end: 8451, - }, - value: Bool( - false, - ), + ), + }, + Keyword { + node: Node { + start: 14415, + end: 14425, + }, + arg: Some( + "index", + ), + value: Constant( + Constant { + node: Node { + start: 14421, + end: 14425, }, - ), - Constant( - Constant { - node: Node { - start: 8479, - end: 8484, - }, - value: Bool( - false, - ), + value: None, + }, + ), + }, + Keyword { + node: Node { + start: 14435, + end: 14444, + }, + arg: Some( + "name", + ), + value: Constant( + Constant { + node: Node { + start: 14440, + end: 14444, }, - ), - Attribute( - Attribute { - node: Node { - start: 8507, - end: 8539, - }, - value: Name( - Name { - node: Node { - start: 8507, - end: 8513, - }, - id: "config", - }, - ), - attr: "FINANCIAL_INDEX_BASE_PATH", + 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: 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, }, - 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", - ), - }, - ), - ], + test: Compare( + Compare { + node: Node { + start: 14516, + end: 14546, + }, + left: Call( + Call { + node: Node { + start: 14538, + end: 14540, }, - ), - 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 { + func: Attribute( + Attribute { node: Node { - start: 8653, - end: 8717, + start: 14516, + end: 14538, }, - test: Call( - Call { + value: Name( + Name { node: Node { - start: 8658, - end: 8682, + start: 14516, + end: 14532, }, - 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, + id: "symbol_full_info", }, ), - 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: [], + attr: "strip", }, ), - ], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 8717, - end: 8729, + args: [], + keywords: [], + starargs: None, + kwargs: None, }, - targets: [ - Name( - Name { - node: Node { - start: 8717, - end: 8724, - }, - id: "df_list", - }, - ), - ], - value: Dict( - Dict { + ), + ops: [ + Eq, + ], + comparators: [ + Constant( + Constant { node: Node { - start: 8727, - end: 8729, + start: 14544, + end: 14546, }, - keys: [], - values: [], + value: Str( + "", + ), }, ), + ], + }, + ), + body: [ + Continue( + Continue { + node: Node { + start: 14560, + end: 14568, + }, }, ), - AssignStatement( - Assign { + ], + orelse: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 14577, + end: 14623, + }, + targets: [ + Name( + Name { node: Node { - start: 8734, - end: 8755, + start: 14577, + end: 14593, }, - targets: [ - Name( + 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: 8734, - end: 8750, + start: 14596, + end: 14612, }, - id: "future_to_symbol", + id: "symbol_full_info", }, ), - ], - value: Dict( - Dict { - node: Node { - start: 8753, - end: 8755, - }, - keys: [], - values: [], - }, - ), - }, - ), - WithStatement( - With { - node: Node { - start: 8760, - end: 15273, + attr: "split", }, - items: [ - WithItem { + ), + args: [ + Constant( + Constant { node: Node { - start: 8765, - end: 8819, + start: 14619, + end: 14622, }, - 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", - }, - ), + value: Str( + ",", ), }, - ], - 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 { + ), + ], + 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: 8872, - end: 9506, + start: 14635, + end: 14657, }, - target: Name( + value: Name( Name { node: Node { - start: 8876, - end: 8882, + start: 14635, + end: 14642, }, - id: "symbol", + id: "persian", }, ), - iter: Name( - Name { - node: Node { - start: 8886, - end: 8893, - }, - id: "symbols", + attr: "replace_arabic", + }, + ), + args: [ + Subscript( + Subscript { + node: Node { + start: 14658, + end: 14677, }, - ), - 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: "persian", - }, - ), - attr: "replace_persian", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 8940, - end: 8946, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 8960, - end: 9230, - }, - 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 { + value: Name( + Name { node: Node { - start: 9345, - end: 9449, + start: 14658, + end: 14674, }, - 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: "symbol_full_info", }, ), - AssignStatement( - Assign { + slice: Constant( + Constant { node: Node { - start: 9463, - end: 9496, + start: 14675, + end: 14676, }, - 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: Int( + "0", ), }, ), - ], - orelse: [], - }, - ), - ForStatement( - For { - node: Node { - start: 9506, - end: 10374, }, - 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: [], + ), + ], + 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", }, ), - 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, + slice: Constant( + Constant { + node: Node { + start: 14764, + end: 14765, }, - ), + 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: 9989, - end: 10009, + start: 14791, + end: 14811, }, - 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, + start: 14791, + end: 14804, }, - id: "df", + id: "market_symbol", }, ), + attr: "symbol", }, ), - IfStatement( - If { - node: Node { - start: 10023, - end: 10231, - }, - test: Name( - Name { - node: Node { - start: 10026, - end: 10038, - }, - id: "write_to_csv", + ], + value: Call( + Call { + node: Node { + start: 14836, + end: 14895, + }, + func: Attribute( + Attribute { + node: Node { + start: 14814, + end: 14836, }, - ), - 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, + value: Name( + Name { + node: Node { + start: 14814, + end: 14821, }, - ), + id: "persian", + }, ), - ], - orelse: [], - }, - ), - IfStatement( - If { - node: Node { - start: 10231, - end: 10337, + attr: "replace_arabic", }, - test: Compare( - Compare { + ), + args: [ + Subscript( + Subscript { node: Node { - start: 10234, - end: 10262, + start: 14858, + end: 14877, }, - left: Call( - Call { + value: Name( + Name { node: Node { - start: 10234, - end: 10246, + start: 14858, + end: 14874, }, - 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, + id: "symbol_full_info", }, ), - 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 { + slice: Constant( + Constant { node: Node { - start: 10272, - end: 10332, + start: 14875, + end: 14876, }, - func: Name( - Name { - node: Node { - start: 10272, - end: 10277, - }, - id: "print", - }, + value: Int( + "0", ), - 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", - }, - ), ), - }, - ), - ], - orelse: [], + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), }, ), - FunctionDef( - FunctionDef { + AssignStatement( + Assign { node: Node { - start: 10374, - end: 15273, + start: 14912, + end: 15014, }, - 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 { + targets: [ + Attribute( + Attribute { node: Node { - start: 10476, - end: 10503, + start: 14912, + end: 14930, }, - arg: "include_jdate", - annotation: Some( - Name( - Name { - node: Node { - start: 10491, - end: 10495, - }, - id: "bool", + value: Name( + Name { + node: Node { + start: 14912, + end: 14925, }, - ), + id: "market_symbol", + }, ), + attr: "name", }, - Arg { - node: Node { - start: 10509, - end: 10560, - }, - arg: "base_path", - annotation: Some( - Name( - Name { - node: Node { - start: 10520, - end: 10523, - }, - id: "str", - }, - ), - ), + ), + ], + value: Call( + Call { + node: Node { + start: 14955, + end: 15014, }, - ], - 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( + func: Attribute( Attribute { node: Node { - start: 10526, - end: 10560, + start: 14933, + end: 14955, }, value: Name( Name { node: Node { - start: 10526, - end: 10532, + start: 14933, + end: 14940, }, - id: "config", + id: "persian", }, ), - attr: "CLIENT_TYPES_DATA_BASE_PATH", + attr: "replace_arabic", }, ), - ], - }, - body: [ - IfStatement( - If { - node: Node { - start: 10569, - end: 10703, - }, - test: Compare( - Compare { + args: [ + Subscript( + Subscript { node: Node { - start: 10572, - end: 10588, + start: 14977, + end: 14996, }, - left: Name( + value: Name( Name { node: Node { - start: 10572, - end: 10579, + start: 14977, + end: 14993, }, - id: "symbols", + id: "symbol_full_info", }, ), - 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, + slice: Constant( + Constant { + node: Node { + start: 14994, + end: 14995, }, - ), - 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", - }, - ), - ], - }, - ), - }, + value: Int( + "1", ), - ], - 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 { + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 15031, + end: 15072, + }, + targets: [ + Attribute( + Attribute { node: Node { - start: 10720, - end: 10741, + start: 15031, + end: 15050, }, - targets: [ - Name( - Name { - node: Node { - start: 10720, - end: 10736, - }, - id: "future_to_symbol", - }, - ), - ], - value: Dict( - Dict { + value: Name( + Name { node: Node { - start: 10739, - end: 10741, + start: 15031, + end: 15044, }, - keys: [], - values: [], + id: "market_symbol", }, ), + attr: "index", }, ), - WithStatement( - With { + ], + value: Subscript( + Subscript { + node: Node { + start: 15053, + end: 15072, + }, + 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: 15172, + }, + func: Attribute( + Attribute { node: Node { - start: 10746, - end: 15273, + start: 15127, + end: 15151, }, - items: [ - WithItem { + value: Attribute( + Attribute { node: Node { - start: 10751, - end: 10805, + start: 15127, + end: 15144, }, - context_expr: Call( - Call { + value: Name( + Name { node: Node { - start: 10777, - end: 10793, + start: 15127, + end: 15140, }, - 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, + id: "market_symbol", }, ), - optional_vars: Some( - Name( - Name { - node: Node { - start: 10797, - end: 10805, - }, - id: "executor", - }, - ), - ), + attr: "old", }, - ], - body: [ - ForStatement( - For { + ), + attr: "append", + }, + ), + args: [ + Subscript( + Subscript { + node: Node { + start: 15152, + end: 15171, + }, + value: Name( + Name { node: Node { - start: 10815, - end: 11168, + start: 15152, + end: 15168, }, - 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, - }, - value: None, - }, - ), - ], - }, - ), - 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, - }, - 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: [], + id: "symbol_full_info", }, ), - ForStatement( - For { + slice: Constant( + Constant { node: Node { - start: 11168, - end: 11849, + start: 15169, + end: 15170, }, - 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, - }, + value: Int( + "2", ), - 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, - }, - value: Name( - Name { - node: Node { - 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", - }, - ), - 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: 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", - }, - ), - }, - ), - 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: 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 { - 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, - }, - ), - ), - ], - 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", - }, - ), - ), - }, - ), - ], - orelse: [], - }, - ), - 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, - }, - 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: [], - }, - ), - 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, - }, - 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: 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, - }, - ), - }, - ), - 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: 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: 13948, - }, - value: Some( - Subscript( - Subscript { - node: Node { - start: 13929, - end: 13948, - }, - 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, - }, - 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, - }, - 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: [], - }, - ), - 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: 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, - }, - ), - 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 { - node: Node { - start: 14632, - end: 15273, - }, - 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: 15072, - }, - 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: 15072, - }, - 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: 15172, - }, - 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, - }, - ), - ), - ], - }, - ), - 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: 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: [], - }, - ), - Return( - Return { - node: Node { - start: 15251, - end: 15271, - }, - value: Some( - Name( - Name { - node: Node { - start: 15258, - end: 15271, - }, - id: "market_symbol", - }, - ), - ), - }, - ), - ], - orelse: [], - }, - ), - ], - orelse: [], - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, }, ), - ], - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, - }, + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), ), ], }, ), ], - decorator_list: [], - returns: Some( - Subscript( - Subscript { - node: Node { - start: 8546, - end: 8569, + 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: 15198, + end: 15211, + }, + id: "market_symbol", + }, + ), + attr: "index", }, - value: Name( - Name { + ), + ops: [ + Is, + ], + comparators: [ + Constant( + Constant { node: Node { - start: 8546, - end: 8550, + start: 15221, + end: 15225, }, - id: "Dict", + value: None, }, ), - slice: Tuple( - Tuple { - node: Node { - start: 8551, - end: 8569, + ], + }, + ), + body: [ + Return( + Return { + node: Node { + start: 15235, + end: 15246, + }, + value: Some( + Constant( + Constant { + node: Node { + start: 15242, + end: 15246, + }, + value: None, }, - 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", - }, - ), - ], - }, + ), ), }, ), + ], + orelse: [], + }, + ), + Return( + Return { + node: Node { + start: 15251, + end: 15271, + }, + value: Some( + Name( + Name { + node: Node { + start: 15258, + end: 15271, + }, + id: "market_symbol", + }, + ), ), - type_comment: None, }, ), ], @@ -14510,10 +14455,15 @@ Module { }, ), ], - orelse: [], + decorator_list: [], + returns: None, + type_comment: None, }, ), ], + decorator_list: [], + returns: None, + type_comment: None, }, ), ], @@ -14522,14 +14472,14 @@ Module { Subscript( Subscript { node: Node { - start: 1637, - end: 1660, + start: 8546, + end: 8569, }, value: Name( Name { node: Node { - start: 1637, - end: 1641, + start: 8546, + end: 8550, }, id: "Dict", }, @@ -14537,15 +14487,15 @@ Module { slice: Tuple( Tuple { node: Node { - start: 1642, - end: 1660, + start: 8551, + end: 8569, }, elements: [ Name( Name { node: Node { - start: 1642, - end: 1645, + start: 8551, + end: 8554, }, id: "str", }, @@ -14553,14 +14503,14 @@ Module { Attribute( Attribute { node: Node { - start: 1647, - end: 1659, + start: 8556, + end: 8568, }, value: Name( Name { node: Node { - start: 1647, - end: 1649, + start: 8556, + end: 8558, }, id: "pd", }, @@ -14578,20 +14528,70 @@ Module { }, ), ], - decorator_list: [], - returns: None, - type_comment: None, + orelse: [], }, ), ], - decorator_list: [], - returns: None, - type_comment: None, }, ), ], decorator_list: [], - returns: None, + 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, }, ), diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-2.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-2.snap deleted file mode 100644 index 67945772..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-2.snap +++ /dev/null @@ -1,47 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: "def a():\n pass" ---- -Module { - node: Node { - start: 0, - end: 17, - }, - body: [ - FunctionDef( - FunctionDef { - node: Node { - start: 0, - end: 17, - }, - name: "a", - args: Arguments { - node: Node { - start: 6, - end: 6, - }, - posonlyargs: [], - args: [], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - Pass( - Pass { - node: Node { - start: 13, - end: 17, - }, - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-3.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-3.snap deleted file mode 100644 index 23dcab4d..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-3.snap +++ /dev/null @@ -1,72 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: "def a(a, b, c): pass" ---- -Module { - node: Node { - start: 0, - end: 20, - }, - body: [ - FunctionDef( - FunctionDef { - node: Node { - start: 0, - end: 20, - }, - name: "a", - args: Arguments { - node: Node { - start: 6, - end: 13, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 6, - end: 7, - }, - arg: "a", - annotation: None, - }, - Arg { - node: Node { - start: 9, - end: 10, - }, - arg: "b", - annotation: None, - }, - Arg { - node: Node { - start: 12, - end: 13, - }, - arg: "c", - annotation: None, - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - Pass( - Pass { - node: Node { - start: 16, - end: 20, - }, - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-4.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-4.snap deleted file mode 100644 index 64b30eca..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-4.snap +++ /dev/null @@ -1,74 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: "def a(a, *b, **c): pass" ---- -Module { - node: Node { - start: 0, - end: 23, - }, - body: [ - FunctionDef( - FunctionDef { - node: Node { - start: 0, - end: 23, - }, - name: "a", - args: Arguments { - node: Node { - start: 6, - end: 16, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 6, - end: 7, - }, - arg: "a", - annotation: None, - }, - ], - vararg: Some( - Arg { - node: Node { - start: 10, - end: 11, - }, - arg: "b", - annotation: None, - }, - ), - kwonlyargs: [], - kw_defaults: [], - kwarg: Some( - Arg { - node: Node { - start: 15, - end: 16, - }, - arg: "c", - annotation: None, - }, - ), - defaults: [], - }, - body: [ - Pass( - Pass { - node: Node { - start: 19, - end: 23, - }, - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-5.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-5.snap deleted file mode 100644 index fa36ce82..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-5.snap +++ /dev/null @@ -1,72 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: "def a(a,\n b,\n c): pass" ---- -Module { - node: Node { - start: 0, - end: 52, - }, - body: [ - FunctionDef( - FunctionDef { - node: Node { - start: 0, - end: 52, - }, - name: "a", - args: Arguments { - node: Node { - start: 6, - end: 45, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 6, - end: 7, - }, - arg: "a", - annotation: None, - }, - Arg { - node: Node { - start: 25, - end: 26, - }, - arg: "b", - annotation: None, - }, - Arg { - node: Node { - start: 44, - end: 45, - }, - arg: "c", - annotation: None, - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - Pass( - Pass { - node: Node { - start: 48, - end: 52, - }, - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-6.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-6.snap deleted file mode 100644 index 21c6d8e4..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-6.snap +++ /dev/null @@ -1,57 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: "@decor\ndef a(): pass" ---- -Module { - node: Node { - start: 0, - end: 20, - }, - body: [ - FunctionDef( - FunctionDef { - node: Node { - start: 7, - end: 20, - }, - name: "a", - args: Arguments { - node: Node { - start: 13, - end: 13, - }, - posonlyargs: [], - args: [], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - Pass( - Pass { - node: Node { - start: 16, - end: 20, - }, - }, - ), - ], - decorator_list: [ - Name( - Name { - node: Node { - start: 1, - end: 6, - }, - id: "decor", - }, - ), - ], - returns: None, - type_comment: None, - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-7.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-7.snap deleted file mode 100644 index b98b780a..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-7.snap +++ /dev/null @@ -1,167 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: "@decor\ndef f(a: 'annotation', b=1, c=2, *d, e, f=3, **g): pass" ---- -Module { - node: Node { - start: 0, - end: 62, - }, - body: [ - FunctionDef( - FunctionDef { - node: Node { - start: 7, - end: 62, - }, - name: "f", - args: Arguments { - node: Node { - start: 13, - end: 55, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 13, - end: 28, - }, - arg: "a", - annotation: Some( - Constant( - Constant { - node: Node { - start: 16, - end: 28, - }, - value: Str( - "annotation", - ), - }, - ), - ), - }, - Arg { - node: Node { - start: 30, - end: 33, - }, - arg: "b", - annotation: None, - }, - Arg { - node: Node { - start: 35, - end: 38, - }, - arg: "c", - annotation: None, - }, - ], - vararg: Some( - Arg { - node: Node { - start: 41, - end: 42, - }, - arg: "d", - annotation: None, - }, - ), - kwonlyargs: [ - Arg { - node: Node { - start: 44, - end: 45, - }, - arg: "e", - annotation: None, - }, - Arg { - node: Node { - start: 47, - end: 50, - }, - arg: "f", - annotation: None, - }, - ], - kw_defaults: [ - None, - Some( - Constant( - Constant { - node: Node { - start: 49, - end: 50, - }, - value: Int( - "3", - ), - }, - ), - ), - ], - kwarg: Some( - Arg { - node: Node { - start: 54, - end: 55, - }, - arg: "g", - annotation: None, - }, - ), - defaults: [ - Constant( - Constant { - node: Node { - start: 32, - end: 33, - }, - value: Int( - "1", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 37, - end: 38, - }, - value: Int( - "2", - ), - }, - ), - ], - }, - body: [ - Pass( - Pass { - node: Node { - start: 58, - end: 62, - }, - }, - ), - ], - decorator_list: [ - Name( - Name { - node: Node { - start: 1, - end: 6, - }, - id: "decor", - }, - ), - ], - returns: None, - type_comment: None, - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-8.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-8.snap deleted file mode 100644 index fa1d03ef..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement-8.snap +++ /dev/null @@ -1,57 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: "def func() -> None: pass" ---- -Module { - node: Node { - start: 0, - end: 24, - }, - body: [ - FunctionDef( - FunctionDef { - node: Node { - start: 0, - end: 24, - }, - name: "func", - args: Arguments { - node: Node { - start: 9, - end: 9, - }, - posonlyargs: [], - args: [], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - Pass( - Pass { - node: Node { - start: 20, - end: 24, - }, - }, - ), - ], - decorator_list: [], - returns: Some( - Constant( - Constant { - node: Node { - start: 14, - end: 18, - }, - value: None, - }, - ), - ), - type_comment: None, - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement.snap deleted file mode 100644 index 9d796ffc..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__func_def_statement.snap +++ /dev/null @@ -1,47 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: "def a(): pass" ---- -Module { - node: Node { - start: 0, - end: 13, - }, - body: [ - FunctionDef( - FunctionDef { - node: Node { - start: 0, - end: 13, - }, - name: "a", - args: Arguments { - node: Node { - start: 6, - end: 6, - }, - posonlyargs: [], - args: [], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - Pass( - Pass { - node: Node { - start: 9, - end: 13, - }, - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-2.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-2.snap similarity index 98% rename from parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-2.snap rename to parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-2.snap index 854051c5..120b17ea 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-2.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-2.snap @@ -1,6 +1,7 @@ --- source: parser/src/parser/parser.rs description: "match a:\n case 1 | 2:\n pass" +input_file: parser/test_data/inputs/one_liners/match.py --- Module { node: Node { diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-3.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-3.snap similarity index 97% rename from parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-3.snap rename to parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-3.snap index b7432db6..56b8f95f 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-3.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-3.snap @@ -1,6 +1,7 @@ --- source: parser/src/parser/parser.rs description: "match a.b:\n case 1:\n pass" +input_file: parser/test_data/inputs/one_liners/match.py --- Module { node: Node { diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-4.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-4.snap similarity index 98% rename from parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-4.snap rename to parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-4.snap index 71212c4b..b1c72ca8 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-4.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-4.snap @@ -1,18 +1,19 @@ --- source: parser/src/parser/parser.rs -description: "match a:\n case None:\n pass\n case True:\n pass\n case False:\n pass\n case -1:\n pass\n case 1.0:\n pass\n case _:\n pass\n" +description: "match a:\n case None:\n pass\n case True:\n pass\n case False:\n pass\n case -1:\n pass\n case 1.0:\n pass\n case _:\n pass" +input_file: parser/test_data/inputs/one_liners/match.py --- Module { node: Node { start: 0, - end: 172, + end: 171, }, body: [ Match( Match { node: Node { start: 0, - end: 172, + end: 171, }, subject: Name( Name { @@ -214,7 +215,7 @@ Module { MatchCase { node: Node { start: 151, - end: 172, + end: 171, }, pattern: MatchAs( MatchAs { diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-5.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-5.snap similarity index 95% rename from parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-5.snap rename to parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-5.snap index 87595871..d0fe6265 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-5.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-5.snap @@ -1,18 +1,19 @@ --- source: parser/src/parser/parser.rs -description: "match a:\n case a.b:\n pass\n case a:\n pass\n" +description: "match a:\n case a.b:\n pass\n case a:\n pass" +input_file: parser/test_data/inputs/one_liners/match.py --- Module { node: Node { start: 0, - end: 61, + end: 60, }, body: [ Match( Match { node: Node { start: 0, - end: 61, + end: 60, }, subject: Name( Name { @@ -70,7 +71,7 @@ Module { MatchCase { node: Node { start: 40, - end: 61, + end: 60, }, pattern: MatchAs( MatchAs { diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-6.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-6.snap similarity index 97% rename from parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-6.snap rename to parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-6.snap index 9f32f3ef..269b4b28 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-6.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-6.snap @@ -1,18 +1,19 @@ --- source: parser/src/parser/parser.rs -description: "match a:\n case (a, b):\n pass\n case {1: _, 2: _}:\n pass\n case {**rest}:\n pass\n" +description: "match a:\n case (a, b):\n pass\n case {1: _ ,2: _}:\n pass\n case {**rest}:\n pass" +input_file: parser/test_data/inputs/one_liners/match.py --- Module { node: Node { start: 0, - end: 107, + end: 106, }, body: [ Match( Match { node: Node { start: 0, - end: 107, + end: 106, }, subject: Name( Name { @@ -144,7 +145,7 @@ Module { MatchCase { node: Node { start: 79, - end: 107, + end: 106, }, pattern: MatchMapping( MatchMapping { diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-7.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-7.snap similarity index 97% rename from parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-7.snap rename to parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-7.snap index eea1068c..da821fd6 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-7.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-7.snap @@ -1,18 +1,19 @@ --- source: parser/src/parser/parser.rs -description: "match x:\n case Point2D(0, 0):\n pass\n case Point3D(x=0, y=0, z=0):\n pass\n" +description: "match x:\n case Point2D(0, 0):\n pass\n case Point3D(x=0, y=0, z=0):\n pass" +input_file: parser/test_data/inputs/one_liners/match.py --- Module { node: Node { start: 0, - end: 92, + end: 91, }, body: [ Match( Match { node: Node { start: 0, - end: 92, + end: 91, }, subject: Name( Name { @@ -103,7 +104,7 @@ Module { MatchCase { node: Node { start: 50, - end: 92, + end: 91, }, pattern: MatchClass( MatchClass { diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-8.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-8.snap similarity index 93% rename from parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-8.snap rename to parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-8.snap index bfce172e..c8a1166e 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement-8.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py-8.snap @@ -1,18 +1,19 @@ --- source: parser/src/parser/parser.rs -description: "match x:\n case [a, b, c]:\n pass" +description: "match x:\n case [a, b, c]:\n pass\n" +input_file: parser/test_data/inputs/one_liners/match.py --- Module { node: Node { start: 0, - end: 41, + end: 42, }, body: [ Match( Match { node: Node { start: 0, - end: 41, + end: 42, }, subject: Name( Name { @@ -27,7 +28,7 @@ Module { MatchCase { node: Node { start: 13, - end: 41, + end: 42, }, pattern: MatchSequence( [ diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py.snap similarity index 97% rename from parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement.snap rename to parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py.snap index 46f86183..1b0911aa 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__match_statement.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@match.py.snap @@ -1,6 +1,7 @@ --- source: parser/src/parser/parser.rs description: "match a:\n case 1:\n pass" +input_file: parser/test_data/inputs/one_liners/match.py --- Module { node: Node { diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-10.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-10.snap deleted file mode 100644 index 1b2d6c93..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-10.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: from ...a import b ---- -Module { - node: Node { - start: 0, - end: 18, - }, - body: [ - ImportFrom( - ImportFrom { - node: Node { - start: 0, - end: 18, - }, - module: "a", - names: [ - Alias { - node: Node { - start: 17, - end: 18, - }, - name: "b", - asname: None, - }, - ], - level: 3, - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-11.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-11.snap deleted file mode 100644 index 3775ce5d..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-11.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: from ....a import b ---- -Module { - node: Node { - start: 0, - end: 19, - }, - body: [ - ImportFrom( - ImportFrom { - node: Node { - start: 0, - end: 19, - }, - module: "a", - names: [ - Alias { - node: Node { - start: 18, - end: 19, - }, - name: "b", - asname: None, - }, - ], - level: 4, - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-12.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-12.snap deleted file mode 100644 index 5e1f520e..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-12.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: from .....a import b ---- -Module { - node: Node { - start: 0, - end: 20, - }, - body: [ - ImportFrom( - ImportFrom { - node: Node { - start: 0, - end: 20, - }, - module: "a", - names: [ - Alias { - node: Node { - start: 19, - end: 20, - }, - name: "b", - asname: None, - }, - ], - level: 5, - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-13.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-13.snap deleted file mode 100644 index 1bc38a45..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-13.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: from ......a import b ---- -Module { - node: Node { - start: 0, - end: 21, - }, - body: [ - ImportFrom( - ImportFrom { - node: Node { - start: 0, - end: 21, - }, - module: "a", - names: [ - Alias { - node: Node { - start: 20, - end: 21, - }, - name: "b", - asname: None, - }, - ], - level: 6, - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-14.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-14.snap deleted file mode 100644 index f24d360a..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-14.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: from .......a import b ---- -Module { - node: Node { - start: 0, - end: 22, - }, - body: [ - ImportFrom( - ImportFrom { - node: Node { - start: 0, - end: 22, - }, - module: "a", - names: [ - Alias { - node: Node { - start: 21, - end: 22, - }, - name: "b", - asname: None, - }, - ], - level: 7, - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-15.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-15.snap deleted file mode 100644 index be92f832..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-15.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: from ... ---- -Module { - node: Node { - start: 0, - end: 8, - }, - body: [], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-2.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-2.snap deleted file mode 100644 index 4f1b27a1..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-2.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: import a as b ---- -Module { - node: Node { - start: 0, - end: 13, - }, - body: [ - Import( - Import { - node: Node { - start: 0, - end: 13, - }, - names: [ - Alias { - node: Node { - start: 7, - end: 13, - }, - name: "a", - asname: Some( - "b", - ), - }, - ], - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-3.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-3.snap deleted file mode 100644 index 010c5405..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-3.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: import a.b ---- -Module { - node: Node { - start: 0, - end: 10, - }, - body: [ - Import( - Import { - node: Node { - start: 0, - end: 10, - }, - names: [ - Alias { - node: Node { - start: 7, - end: 10, - }, - name: "a.b", - asname: None, - }, - ], - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-4.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-4.snap deleted file mode 100644 index 095f39a4..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-4.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: import a.b as c ---- -Module { - node: Node { - start: 0, - end: 15, - }, - body: [ - Import( - Import { - node: Node { - start: 0, - end: 15, - }, - names: [ - Alias { - node: Node { - start: 7, - end: 15, - }, - name: "a.b", - asname: Some( - "c", - ), - }, - ], - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-5.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-5.snap deleted file mode 100644 index b34bfae2..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-5.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: import a.b.c ---- -Module { - node: Node { - start: 0, - end: 12, - }, - body: [ - Import( - Import { - node: Node { - start: 0, - end: 12, - }, - names: [ - Alias { - node: Node { - start: 7, - end: 12, - }, - name: "a.b.c", - asname: None, - }, - ], - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-6.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-6.snap deleted file mode 100644 index 8a02e565..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-6.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: from a import b ---- -Module { - node: Node { - start: 0, - end: 15, - }, - body: [ - ImportFrom( - ImportFrom { - node: Node { - start: 0, - end: 15, - }, - module: "a", - names: [ - Alias { - node: Node { - start: 14, - end: 15, - }, - name: "b", - asname: None, - }, - ], - level: 0, - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-7.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-7.snap deleted file mode 100644 index 917f6112..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-7.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: from a import b as c ---- -Module { - node: Node { - start: 0, - end: 20, - }, - body: [ - ImportFrom( - ImportFrom { - node: Node { - start: 0, - end: 20, - }, - module: "a", - names: [ - Alias { - node: Node { - start: 14, - end: 20, - }, - name: "b", - asname: Some( - "c", - ), - }, - ], - level: 0, - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-8.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-8.snap deleted file mode 100644 index 66fd30ce..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-8.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: from a.b import c ---- -Module { - node: Node { - start: 0, - end: 17, - }, - body: [ - ImportFrom( - ImportFrom { - node: Node { - start: 0, - end: 17, - }, - module: "a.b", - names: [ - Alias { - node: Node { - start: 16, - end: 17, - }, - name: "c", - asname: None, - }, - ], - level: 0, - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-9.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-9.snap deleted file mode 100644 index a2ba1b38..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement-9.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: from a.b import c as d ---- -Module { - node: Node { - start: 0, - end: 22, - }, - body: [ - ImportFrom( - ImportFrom { - node: Node { - start: 0, - end: 22, - }, - module: "a.b", - names: [ - Alias { - node: Node { - start: 16, - end: 22, - }, - name: "c", - asname: Some( - "d", - ), - }, - ], - level: 0, - }, - ), - ], -} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement.snap deleted file mode 100644 index 618f68b4..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__parse_import_statement.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: import a ---- -Module { - node: Node { - start: 0, - end: 8, - }, - body: [ - Import( - Import { - node: Node { - start: 0, - end: 8, - }, - names: [ - Alias { - node: Node { - start: 7, - end: 8, - }, - name: "a", - asname: None, - }, - ], - }, - ), - ], -} diff --git a/parser/test_data/inputs/if.py b/parser/test_data/inputs/if.py new file mode 100644 index 00000000..5919eeae --- /dev/null +++ b/parser/test_data/inputs/if.py @@ -0,0 +1,8 @@ +if self.adjust: + if True: + print("adjust is True and adjusted_daily_records_csv_path exists") + else: + print("adjust is True") +else: + print("adjust is False") + diff --git a/parser/test_data/inputs/one_liners/match.py b/parser/test_data/inputs/one_liners/match.py new file mode 100644 index 00000000..9171978e --- /dev/null +++ b/parser/test_data/inputs/one_liners/match.py @@ -0,0 +1,49 @@ +match a: + case 1: + pass + +match a: + case 1 | 2: + pass + +match a.b: + case 1: + pass + +match a: + case None: + pass + case True: + pass + case False: + pass + case -1: + pass + case 1.0: + pass + case _: + pass + +match a: + case a.b: + pass + case a: + pass + +match a: + case (a, b): + pass + case {1: _ ,2: _}: + pass + case {**rest}: + pass + +match x: + case Point2D(0, 0): + pass + case Point3D(x=0, y=0, z=0): + pass + +match x: + case [a, b, c]: + pass diff --git a/typechecker/src/build.rs b/typechecker/src/build.rs index 09d5aa75..b463eb40 100644 --- a/typechecker/src/build.rs +++ b/typechecker/src/build.rs @@ -60,7 +60,6 @@ impl BuildManager { } else { builder.filter(None, log::LevelFilter::Warn); } - builder.init(); BuildManager { errors: vec![],