diff --git a/parser/src/lexer/lexer.rs b/parser/src/lexer/lexer.rs index 74b89f1c..f7374ff7 100644 --- a/parser/src/lexer/lexer.rs +++ b/parser/src/lexer/lexer.rs @@ -859,9 +859,11 @@ impl Lexer { } } if de_indents != 1 { - self.next_token_is_dedent += 1; + // minus 1 because the dedent with actual Indent value is already added + // This is super hacky and I don't like it + self.next_token_is_dedent += de_indents - 1; } - TokenValue::Indent(de_indents) + TokenValue::Indent(de_indents.into()) } Kind::Indent => TokenValue::Indent(1), _ => TokenValue::None, diff --git a/parser/src/parser/parser.rs b/parser/src/parser/parser.rs index e3d1514e..3907dbaa 100644 --- a/parser/src/parser/parser.rs +++ b/parser/src/parser/parser.rs @@ -472,8 +472,6 @@ impl Parser { vec![] }; - self.bump(Kind::Dedent); - Ok(Statement::WhileStatement(While { node: self.finish_node(node), test, @@ -510,8 +508,6 @@ impl Parser { vec![] }; - self.bump(Kind::Dedent); - if is_async { Ok(Statement::AsyncForStatement(AsyncFor { node: self.finish_node(node), @@ -539,8 +535,6 @@ impl Parser { self.expect(Kind::Colon)?; let body = self.parse_suite()?; - self.bump(Kind::Dedent); - if is_async { Ok(Statement::AsyncWithStatement(AsyncWith { node: self.finish_node(node), @@ -1915,6 +1909,11 @@ impl Parser { values: vec![], }))); } + if self.at(Kind::Pow) { + // key must be None + let (key, value) = self.parse_double_starred_kv_pair()?; + return self.parse_dict(node, key, value) + } let first_key_or_element = self.parse_star_named_expression()?; if matches!( self.cur_kind(), @@ -1922,7 +1921,9 @@ impl Parser { ) { self.parse_set(node, first_key_or_element) } else { - self.parse_dict(node, first_key_or_element) + self.expect(Kind::Colon)?; + let first_value = self.parse_expression_2()?; + self.parse_dict(node, Some(first_key_or_element), first_value) } } @@ -1957,17 +1958,30 @@ impl Parser { fn parse_dict( &mut self, node: Node, - first_key: Expression, + first_key: Option, + first_value: Expression, ) -> Result { - self.expect(Kind::Colon)?; - let first_val = self.parse_expression_2()?; if self.at(Kind::For) || self.at(Kind::Async) && matches!(self.peek_kind(), Ok(Kind::For)) { + let key = if first_key.is_none() { + let err = ParsingError::InvalidSyntax { + path: Box::from(self.path.as_str()), + msg: Box::from("cannot use ** in dict comprehension"), + line: self.get_line_number_of_character_position(self.cur_token.end), + input: self.curr_line_string.clone(), + advice: "".into(), + span: (node.start, node.end), + }; + return Err(err); + } else { + first_key.unwrap() + }; + // make sure the first key is some let generators = self.parse_comp_for()?; self.expect(Kind::RightBracket)?; Ok(Expression::DictComp(Box::new(DictComp { node: self.finish_node(node), - key: Box::new(first_key), - value: Box::new(first_val), + key: Box::new(key), + value: Box::new(first_value), generators, }))) } else { @@ -1977,13 +1991,17 @@ impl Parser { self.expect(Kind::Comma)?; self.consume_whitespace_and_newline(); } - let mut keys = vec![first_key]; - let mut values = vec![first_val]; + let mut keys = match first_key { + Some(k) => vec![k], + None => vec![], + }; + let mut values = vec![first_value]; while !self.eat(Kind::RightBracket) { - let key = self.parse_expression_2()?; - self.expect(Kind::Colon)?; - let value = self.parse_expression_2()?; - keys.push(key); + let (key, value) = self.parse_double_starred_kv_pair()?; + match key { + Some(k) => keys.push(k), + None => {} + } values.push(value); if !self.at(Kind::RightBracket) { self.expect(Kind::Comma)?; @@ -1998,6 +2016,18 @@ impl Parser { } } + fn parse_double_starred_kv_pair(&mut self) -> Result<(Option,Expression), ParsingError> { + if self.eat(Kind::Pow) { + let value = self.parse_expression_2()?; + Ok((None, value)) + } else { + let key = self.parse_expression_2()?; + self.expect(Kind::Colon)?; + let value = self.parse_expression_2()?; + Ok((Some(key), value)) + } + } + fn consume_whitespace_and_newline(&mut self) -> bool { let mut consumed = false; while matches!(self.cur_kind(), Kind::WhiteSpace | Kind::NewLine) { @@ -2611,6 +2641,7 @@ impl Parser { fn parse_slice_list(&mut self) -> Result { let node = self.start_node(); let mut elements = vec![]; + // TODO: This EOF check should not be here. while !self.at(Kind::Eof) && !self.at(Kind::RightBrace) { if self.at(Kind::Colon) { elements.push(self.parse_proper_slice(None)?); @@ -2651,7 +2682,7 @@ impl Parser { Some(Box::new(self.parse_expression_2()?)) }; let upper = if self.eat(Kind::Colon) { - if self.at(Kind::RightBrace) { + if self.at(Kind::RightBrace) || self.at(Kind::Colon) { None } else { Some(Box::new(self.parse_expression_2()?)) @@ -3309,30 +3340,6 @@ mod tests { } } - #[test] - fn test_subscript() { - for test_case in &[ - "a[b]", - "a[b:c]", - "a[b:c:d]", - "a[b, c, d]", - "a[b, c: d, e]", - "a[::]", - "a[b, c:d:e, f]", - "a[::d,]", - ] { - let mut parser = Parser::new(test_case.to_string(), String::from("")); - let program = parser.parse(); - - insta::with_settings!({ - description => test_case.to_string(), // the template source code - omit_expression => true // do not include the default expression - }, { - assert_debug_snapshot!(program); - }); - } - } - #[test] fn test_attribute_ref() { for test_case in &["a.b", "a.b.c", "a.b_c", "a.b.c.d"] { diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap index 48419f6d..6d0c29ca 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap @@ -1938,7 +1938,7 @@ Module { FunctionDef { node: Node { start: 1452, - end: 15273, + end: 4346, }, name: "download", args: Arguments { @@ -2379,7 +2379,7 @@ Module { With { node: Node { start: 1843, - end: 15273, + end: 4203, }, items: [ WithItem { @@ -2496,7 +2496,7 @@ Module { For { node: Node { start: 1955, - end: 15273, + end: 2698, }, target: Name( Name { @@ -3088,1192 +3088,1333 @@ Module { orelse: [], }, ), - ForStatement( - For { - node: Node { - start: 2698, - end: 4346, + ], + orelse: [], + }, + ), + ForStatement( + For { + node: Node { + start: 2698, + end: 4203, + }, + target: Name( + Name { + node: Node { + start: 2702, + end: 2708, + }, + id: "future", + }, + ), + iter: Call( + Call { + node: Node { + start: 2732, + end: 2750, + }, + func: Attribute( + Attribute { + node: Node { + start: 2712, + end: 2732, + }, + value: Name( + Name { + node: Node { + start: 2712, + end: 2719, + }, + id: "futures", + }, + ), + attr: "as_completed", }, - target: Name( + ), + args: [ + Name( Name { node: Node { - start: 2702, - end: 2708, + start: 2733, + end: 2749, }, - id: "future", + id: "future_to_symbol", }, ), - iter: Call( - Call { + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 2764, + end: 2797, + }, + targets: [ + Name( + Name { + node: Node { + start: 2764, + end: 2770, + }, + id: "symbol", + }, + ), + ], + value: Subscript( + Subscript { node: Node { - start: 2732, - end: 2750, + start: 2773, + end: 2797, }, - func: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 2712, - end: 2732, + start: 2773, + end: 2789, }, - value: Name( - Name { - node: Node { - start: 2712, - end: 2719, - }, - id: "futures", - }, - ), - attr: "as_completed", + id: "future_to_symbol", }, ), - args: [ - Name( - Name { - node: Node { - start: 2733, - end: 2749, - }, - id: "future_to_symbol", + slice: Name( + Name { + node: Node { + start: 2790, + end: 2796, }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "future", + }, + ), }, ), + }, + ), + TryStatement( + Try { + node: Node { + start: 2810, + end: 3120, + }, body: [ - AssignStatement( - Assign { + AnnAssignStatement( + AnnAssign { node: Node { - start: 2764, - end: 2797, + start: 2831, + end: 2865, }, - targets: [ - Name( - Name { - node: Node { - start: 2764, - end: 2770, - }, - id: "symbol", + target: Name( + Name { + node: Node { + start: 2831, + end: 2833, }, - ), - ], - value: Subscript( - Subscript { + id: "df", + }, + ), + annotation: Attribute( + Attribute { node: Node { - start: 2773, - end: 2797, + start: 2835, + end: 2847, }, value: Name( Name { node: Node { - start: 2773, - end: 2789, - }, - id: "future_to_symbol", - }, - ), - slice: Name( - Name { - node: Node { - start: 2790, - end: 2796, + start: 2835, + end: 2837, }, - id: "future", + id: "pd", }, ), + attr: "DataFrame", }, ), - }, - ), - TryStatement( - Try { - node: Node { - start: 2810, - end: 3120, - }, - body: [ - AnnAssignStatement( - AnnAssign { + value: Some( + Call( + Call { node: Node { - start: 2831, + start: 2863, end: 2865, }, - target: Name( - Name { - node: Node { - start: 2831, - end: 2833, - }, - id: "df", - }, - ), - annotation: Attribute( + func: Attribute( Attribute { node: Node { - start: 2835, - end: 2847, + start: 2850, + end: 2863, }, value: Name( Name { node: Node { - start: 2835, - end: 2837, + start: 2850, + end: 2856, }, - id: "pd", + id: "future", }, ), - attr: "DataFrame", + attr: "result", }, ), - value: Some( - Call( - Call { - node: Node { - start: 2863, - end: 2865, - }, - func: Attribute( - Attribute { - node: Node { - start: 2850, - end: 2863, - }, - value: Name( - Name { - node: Node { - start: 2850, - end: 2856, - }, - id: "future", - }, - ), - attr: "result", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - simple: true, + args: [], + keywords: [], + starargs: None, + kwargs: None, }, ), - ], - handlers: [ - ExceptHandler { + ), + simple: true, + }, + ), + ], + handlers: [ + ExceptHandler { + node: Node { + start: 2878, + end: 3120, + }, + typ: Some( + Attribute( + Attribute { node: Node { - start: 2878, - end: 3120, + start: 2885, + end: 2909, }, - typ: Some( - Attribute( + value: Attribute( + Attribute { + node: Node { + start: 2885, + end: 2894, + }, + value: Name( + Name { + node: Node { + start: 2885, + end: 2887, + }, + id: "pd", + }, + ), + attr: "errors", + }, + ), + attr: "EmptyDataError", + }, + ), + ), + name: Some( + "ex", + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 2945, + end: 3082, + }, + func: Attribute( Attribute { node: Node { - start: 2885, - end: 2909, + start: 2933, + end: 2945, }, - value: Attribute( - Attribute { + value: Name( + Name { node: Node { - start: 2885, - end: 2894, + start: 2933, + end: 2939, }, - value: Name( - Name { - node: Node { - start: 2885, - end: 2887, - }, - id: "pd", - }, - ), - attr: "errors", + id: "logger", }, ), - attr: "EmptyDataError", + attr: "error", }, ), - ), - name: Some( - "ex", - ), - body: [ - ExpressionStatement( - Call( - Call { + args: [ + JoinedStr( + JoinedStr { node: Node { - start: 2945, - end: 3082, + start: 2967, + end: 3022, }, - func: Attribute( - Attribute { - node: Node { - start: 2933, - end: 2945, - }, - value: Name( - Name { - node: Node { - start: 2933, - end: 2939, - }, - id: "logger", + values: [ + Constant( + Constant { + node: Node { + start: 3013, + end: 0, }, - ), - attr: "error", - }, - ), - args: [ - JoinedStr( - JoinedStr { + value: Str( + "Cannot read daily trade records for symbol: ", + ), + }, + ), + Name( + Name { node: Node { - start: 2967, - end: 3022, + start: 3014, + end: 3020, }, - values: [ - Constant( - Constant { - node: Node { - start: 3013, - end: 0, - }, - value: Str( - "Cannot read daily trade records for symbol: ", - ), - }, - ), - Name( - Name { - node: Node { - start: 3014, - end: 3020, - }, - id: "symbol", - }, - ), - ], + id: "symbol", }, ), ], - keywords: [ - Keyword { - node: Node { - start: 3044, - end: 3063, - }, - arg: Some( - "extra", - ), - value: Dict( - Dict { + }, + ), + ], + 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: 3050, - end: 3063, + start: 3051, + end: 3058, }, - keys: [ - Constant( - Constant { - node: Node { - start: 3051, - end: 3058, - }, - value: Str( - "Error", - ), - }, - ), - ], - values: [ - Name( - Name { - node: Node { - start: 3060, - end: 3062, - }, - id: "ex", - }, - ), - ], + value: Str( + "Error", + ), }, ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - Continue( - Continue { - node: Node { - start: 3099, - end: 3107, - }, + ], + values: [ + Name( + Name { + node: Node { + start: 3060, + end: 3062, + }, + id: "ex", + }, + ), + ], + }, + ), }, - ), - ], + ], + starargs: None, + kwargs: None, + }, + ), + ), + Continue( + Continue { + node: Node { + start: 3099, + end: 3107, + }, }, - ], - orelse: [], - finalbody: [], - }, - ), - AssignStatement( - Assign { + ), + ], + }, + ], + orelse: [], + finalbody: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 3120, + end: 3161, + }, + targets: [ + Name( + Name { node: Node { start: 3120, - end: 3161, + end: 3122, }, - targets: [ - Name( - Name { + id: "df", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 3150, + end: 3161, + }, + func: Attribute( + Attribute { + node: Node { + start: 3138, + end: 3150, + }, + value: Subscript( + Subscript { node: Node { - start: 3120, - end: 3122, + start: 3132, + end: 3138, }, - id: "df", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 3150, - end: 3161, - }, - func: Attribute( - Attribute { - node: Node { - start: 3138, - end: 3150, - }, - value: Subscript( - Subscript { - node: Node { - start: 3132, - end: 3138, + value: Attribute( + Attribute { + node: Node { + start: 3125, + end: 3132, + }, + value: Name( + Name { + node: Node { + start: 3125, + end: 3127, + }, + id: "df", }, - value: Attribute( - Attribute { + ), + attr: "iloc", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 3133, + end: 3137, + }, + lower: None, + upper: Some( + UnaryOp( + UnaryOperation { node: Node { - start: 3125, - end: 3132, + start: 3135, + end: 3137, }, - value: Name( - Name { + op: USub, + operand: Constant( + Constant { node: Node { - start: 3125, - end: 3127, + start: 3136, + end: 3137, }, - id: "df", + value: Int( + "1", + ), }, ), - attr: "iloc", - }, - ), - slice: Slice( - Slice { - node: Node { - start: 3133, - end: 3137, - }, - lower: None, - upper: Some( - UnaryOp( - UnaryOperation { - node: Node { - start: 3135, - end: 3137, - }, - op: USub, - operand: Constant( - Constant { - node: Node { - start: 3136, - end: 3137, - }, - value: Int( - "1", - ), - }, - ), - }, - ), - ), - step: None, }, ), - }, - ), - attr: "reset_index", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 3151, - end: 3160, + ), + step: None, }, - arg: Some( - "drop", - ), - value: Constant( - Constant { - node: Node { - start: 3156, - end: 3160, - }, - value: Bool( - true, - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, + ), + }, + ), + attr: "reset_index", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 3151, + end: 3160, }, - ), - }, - ), - AssignStatement( - Assign { + arg: Some( + "drop", + ), + value: Constant( + Constant { + node: Node { + start: 3156, + end: 3160, + }, + value: Bool( + true, + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 3174, + end: 3233, + }, + targets: [ + Name( + Name { node: Node { start: 3174, - end: 3233, + end: 3176, }, - targets: [ - Name( + id: "df", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 3188, + end: 3233, + }, + func: Attribute( + Attribute { + node: Node { + start: 3179, + end: 3188, + }, + value: Name( Name { node: Node { - start: 3174, - end: 3176, + start: 3179, + end: 3181, }, id: "df", }, ), - ], - value: Call( - Call { - node: Node { - start: 3188, - end: 3233, - }, - func: Attribute( - Attribute { - node: Node { - start: 3179, - end: 3188, - }, - value: Name( - Name { - node: Node { - start: 3179, - end: 3181, - }, - id: "df", - }, - ), - attr: "rename", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 3189, - end: 3232, - }, - arg: Some( - "columns", - ), - value: Attribute( - Attribute { - node: Node { - start: 3197, - end: 3232, - }, - value: Name( - Name { - node: Node { - start: 3197, - end: 3209, - }, - id: "translations", - }, - ), - attr: "HISTORY_FIELD_MAPPINGS", - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 3246, - end: 3289, + attr: "rename", }, - targets: [ - Name( - Name { + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 3189, + end: 3232, + }, + arg: Some( + "columns", + ), + value: Attribute( + Attribute { node: Node { - start: 3246, - end: 3248, + start: 3197, + end: 3232, }, - id: "df", + value: Name( + Name { + node: Node { + start: 3197, + end: 3209, + }, + id: "translations", + }, + ), + attr: "HISTORY_FIELD_MAPPINGS", }, ), - ], - value: Call( - Call { - node: Node { - start: 3258, - end: 3289, + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 3246, + end: 3289, + }, + targets: [ + Name( + Name { + node: Node { + start: 3246, + end: 3248, + }, + 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: 3251, + end: 3253, + }, + id: "df", }, - func: Attribute( - Attribute { - node: Node { - start: 3251, - end: 3258, - }, - value: Name( - Name { + ), + attr: "drop", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 3259, + end: 3288, + }, + arg: Some( + "columns", + ), + value: List( + List { + node: Node { + start: 3267, + end: 3288, + }, + elements: [ + Constant( + Constant { node: Node { - start: 3251, - end: 3253, + start: 3268, + end: 3275, }, - id: "df", + value: Str( + "", + ), }, ), - attr: "drop", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 3259, - end: 3288, - }, - arg: Some( - "columns", - ), - value: List( - List { + Constant( + Constant { node: Node { - start: 3267, - end: 3288, + start: 3277, + end: 3287, }, - elements: [ - Constant( - Constant { - node: Node { - start: 3268, - end: 3275, - }, - value: Str( - "", - ), - }, - ), - Constant( - Constant { - node: Node { - start: 3277, - end: 3287, - }, - value: Str( - "", - ), - }, - ), - ], + value: Str( + "", + ), }, ), - }, - ], - starargs: None, - kwargs: None, - }, - ), + ], + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 3302, + end: 3339, + }, + func: Name( + Name { + node: Node { + start: 3302, + end: 3320, + }, + id: "_adjust_data_frame", }, ), - ExpressionStatement( - Call( - Call { + args: [ + Name( + Name { node: Node { - start: 3302, - end: 3339, + start: 3321, + end: 3323, }, - func: Name( - Name { - node: Node { - start: 3302, - end: 3320, - }, - id: "_adjust_data_frame", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 3321, - end: 3323, - }, - id: "df", - }, - ), - Name( - Name { - node: Node { - start: 3325, - end: 3338, - }, - id: "include_jdate", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "df", }, ), - ), - IfStatement( - If { - node: Node { - start: 3353, - end: 3712, + Name( + Name { + node: Node { + start: 3325, + end: 3338, + }, + id: "include_jdate", }, - test: Compare( - Compare { + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + IfStatement( + If { + node: Node { + start: 3353, + end: 3712, + }, + test: Compare( + Compare { + node: Node { + start: 3356, + end: 3373, + }, + left: Name( + Name { + node: Node { + start: 3356, + end: 3362, + }, + id: "symbol", + }, + ), + ops: [ + In, + ], + comparators: [ + Name( + Name { node: Node { - start: 3356, + start: 3366, end: 3373, }, - left: Name( - Name { - node: Node { - start: 3356, - end: 3362, - }, - id: "symbol", + id: "df_list", + }, + ), + ], + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 3391, + end: 3643, + }, + targets: [ + Subscript( + Subscript { + node: Node { + start: 3391, + end: 3406, }, - ), - ops: [ - In, - ], - comparators: [ - Name( + value: Name( Name { node: Node { - start: 3366, - end: 3373, + start: 3391, + end: 3398, }, id: "df_list", }, ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 3391, - end: 3643, - }, - targets: [ - Subscript( - Subscript { + slice: Name( + Name { + node: Node { + start: 3399, + end: 3405, + }, + id: "symbol", + }, + ), + }, + ), + ], + value: Call( + Call { + node: Node { + start: 3614, + end: 3625, + }, + func: Attribute( + Attribute { + node: Node { + start: 3602, + end: 3614, + }, + value: Call( + Call { node: Node { - start: 3391, - end: 3406, + start: 3573, + end: 3581, }, - value: Name( - Name { - node: Node { - start: 3391, - end: 3398, - }, - id: "df_list", - }, - ), - slice: Name( - Name { + func: Attribute( + Attribute { node: Node { - start: 3399, - end: 3405, + start: 3561, + end: 3573, }, - id: "symbol", - }, - ), - }, - ), - ], - value: Call( - Call { - node: Node { - start: 3614, - end: 3625, - }, - func: Attribute( - Attribute { - node: Node { - start: 3602, - end: 3614, - }, - value: Call( - Call { - node: Node { - start: 3573, - end: 3581, - }, - func: Attribute( - Attribute { - node: Node { - start: 3561, - end: 3573, + value: Call( + Call { + node: Node { + start: 3440, + end: 3540, + }, + func: Attribute( + Attribute { + node: Node { + start: 3431, + end: 3440, + }, + value: Name( + Name { + node: Node { + start: 3431, + end: 3433, + }, + id: "pd", + }, + ), + attr: "concat", }, - value: Call( - Call { + ), + args: [ + List( + List { node: Node { - start: 3440, - end: 3540, + start: 3466, + end: 3487, }, - func: Attribute( - Attribute { - node: Node { - start: 3431, - end: 3440, - }, - value: Name( - Name { - node: Node { - start: 3431, - end: 3433, - }, - id: "pd", - }, - ), - attr: "concat", - }, - ), - args: [ - List( - List { + elements: [ + Subscript( + Subscript { node: Node { - start: 3466, - end: 3487, + start: 3467, + end: 3482, }, - elements: [ - Subscript( - Subscript { - node: Node { - start: 3467, - end: 3482, - }, - value: Name( - Name { - node: Node { - start: 3467, - end: 3474, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 3475, - end: 3481, - }, - id: "symbol", - }, - ), + value: Name( + Name { + node: Node { + start: 3467, + end: 3474, }, - ), - Name( - Name { - node: Node { - start: 3484, - end: 3486, - }, - id: "df", + id: "df_list", + }, + ), + slice: Name( + Name { + node: Node { + start: 3475, + end: 3481, }, - ), - ], + id: "symbol", + }, + ), }, ), - ], - keywords: [ - Keyword { - node: Node { - start: 3489, - end: 3506, - }, - arg: Some( - "ignore_index", - ), - value: Constant( - Constant { - node: Node { - start: 3502, - end: 3506, - }, - value: Bool( - true, - ), + Name( + Name { + node: Node { + start: 3484, + end: 3486, }, - ), - }, - Keyword { - node: Node { - start: 3508, - end: 3518, + id: "df", }, - arg: Some( - "sort", - ), - value: Constant( - Constant { - node: Node { - start: 3513, - end: 3518, - }, - value: Bool( - false, - ), - }, - ), - }, + ), ], - starargs: None, - kwargs: None, }, ), - attr: "sort_values", - }, - ), - args: [ - Constant( - Constant { + ], + keywords: [ + Keyword { node: Node { - start: 3574, - end: 3580, + start: 3489, + end: 3506, }, - value: Str( - "date", + arg: Some( + "ignore_index", + ), + value: Constant( + Constant { + node: Node { + start: 3502, + end: 3506, + }, + value: Bool( + true, + ), + }, ), }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "reset_index", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 3615, - end: 3624, + Keyword { + node: Node { + start: 3508, + end: 3518, + }, + arg: Some( + "sort", + ), + value: Constant( + Constant { + node: Node { + start: 3513, + end: 3518, + }, + value: Bool( + false, + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + attr: "sort_values", }, - arg: Some( - "drop", - ), - value: Constant( + ), + args: [ + Constant( Constant { node: Node { - start: 3620, - end: 3624, + start: 3574, + end: 3580, }, - value: Bool( - true, + value: Str( + "date", ), }, ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - orelse: [ - AssignStatement( - Assign { - node: Node { - start: 3678, - end: 3698, + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + attr: "reset_index", }, - targets: [ - Subscript( - Subscript { + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 3615, + end: 3624, + }, + arg: Some( + "drop", + ), + value: Constant( + Constant { node: Node { - start: 3678, - end: 3693, + start: 3620, + end: 3624, }, - value: Name( - Name { - node: Node { - start: 3678, - end: 3685, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 3686, - end: 3692, - }, - id: "symbol", - }, + value: Bool( + true, ), }, ), - ], + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ], + orelse: [ + AssignStatement( + Assign { + node: Node { + start: 3678, + end: 3698, + }, + targets: [ + Subscript( + Subscript { + node: Node { + start: 3678, + end: 3693, + }, value: Name( Name { node: Node { - start: 3696, - end: 3698, + start: 3678, + end: 3685, }, - id: "df", + id: "df_list", + }, + ), + slice: Name( + Name { + node: Node { + start: 3686, + end: 3692, + }, + id: "symbol", }, ), }, ), ], - }, - ), - IfStatement( - If { - node: Node { - start: 3712, - end: 3800, - }, - test: Name( + value: Name( Name { node: Node { - start: 3715, - end: 3721, + start: 3696, + end: 3698, }, - id: "adjust", + id: "df", }, ), - body: [ - AssignStatement( - Assign { + }, + ), + ], + }, + ), + IfStatement( + If { + node: Node { + start: 3712, + end: 3800, + }, + test: Name( + Name { + node: Node { + start: 3715, + end: 3721, + }, + id: "adjust", + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 3739, + end: 3786, + }, + targets: [ + Subscript( + Subscript { node: Node { start: 3739, - end: 3786, + end: 3754, }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 3739, - end: 3754, - }, - value: Name( - Name { - node: Node { - start: 3739, - end: 3746, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 3747, - end: 3753, - }, - id: "symbol", - }, - ), + value: Name( + Name { + node: Node { + start: 3739, + end: 3746, }, - ), - ], - value: Call( - Call { + id: "df_list", + }, + ), + slice: Name( + Name { node: Node { - start: 3757, - end: 3786, + start: 3747, + end: 3753, }, - func: Name( - 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, + id: "symbol", }, ), }, ), ], - orelse: [], - }, - ), - IfStatement( - If { - node: Node { - start: 3800, - end: 4203, - }, - test: Name( - Name { + value: Call( + Call { node: Node { - start: 3803, - end: 3815, + start: 3757, + end: 3786, }, - id: "write_to_csv", - }, - ), - body: [ - ExpressionStatement( - Call( - Call { + func: Name( + Name { node: Node { - start: 3854, - end: 3883, + 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: 3848, - end: 3854, + start: 3946, + end: 3953, }, - value: Call( - Call { + value: Subscript( + Subscript { node: Node { - start: 3833, - end: 3848, + start: 3931, + end: 3946, }, - func: Name( + value: Name( Name { node: Node { - start: 3833, - end: 3837, + start: 3931, + end: 3938, }, - id: "Path", + id: "df_list", }, ), - args: [ - Name( - Name { - node: Node { - start: 3838, - end: 3847, - }, - id: "base_path", + slice: Name( + Name { + node: Node { + start: 3939, + end: 3945, }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, + id: "symbol", + }, + ), }, ), - attr: "mkdir", + attr: "to_csv", }, ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 3855, - end: 3867, - }, - arg: Some( - "parents", - ), - value: Constant( - Constant { - node: Node { - start: 3863, - end: 3867, - }, - value: Bool( - true, - ), + 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: 3869, - end: 3882, + start: 4011, + end: 4022, }, arg: Some( - "exist_ok", + "index", ), value: Constant( Constant { node: Node { - start: 3878, - end: 3882, + start: 4017, + end: 4022, }, value: Bool( - true, + false, ), }, ), @@ -4284,897 +4425,1192 @@ Module { }, ), ), - IfStatement( - If { - node: Node { - start: 3900, - end: 4203, - }, - test: Name( - Name { - node: Node { - start: 3903, - end: 3909, - }, - id: "adjust", + ], + orelse: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 4109, + end: 4197, }, - ), - 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", + func: Attribute( + Attribute { + node: Node { + start: 4102, + end: 4109, + }, + value: Subscript( + Subscript { + node: Node { + start: 4087, + end: 4102, }, - ), - args: [ - JoinedStr( - JoinedStr { + value: Name( + Name { node: Node { - start: 3979, - end: 4009, + start: 4087, + end: 4094, }, - 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", - ), - }, - ), - ], + id: "df_list", }, ), - ], - keywords: [ - Keyword { - node: Node { - start: 4011, - end: 4022, - }, - arg: Some( - "index", - ), - value: Constant( - Constant { - node: Node { - start: 4017, - end: 4022, - }, - value: Bool( - false, - ), + slice: Name( + Name { + node: Node { + start: 4095, + end: 4101, }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), + id: "symbol", + }, + ), + }, + ), + attr: "to_csv", + }, ), - ], - orelse: [ - ExpressionStatement( - Call( - Call { + args: [ + JoinedStr( + JoinedStr { node: Node { - start: 4109, - end: 4197, + start: 4135, + end: 4162, }, - 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", - }, - ), + values: [ + Name( + Name { + node: Node { + start: 4138, + end: 4147, }, - ), - attr: "to_csv", - }, - ), - args: [ - JoinedStr( - JoinedStr { + id: "base_path", + }, + ), + Constant( + Constant { node: Node { - start: 4135, - end: 4162, + start: 4149, + end: 0, }, - 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", - ), - }, - ), - ], + value: Str( + "/", + ), }, ), - ], - keywords: [ - Keyword { - node: Node { - start: 4164, - end: 4175, + Name( + Name { + node: Node { + start: 4150, + end: 4156, + }, + id: "symbol", }, - arg: Some( - "index", - ), - value: Constant( - Constant { - node: Node { - start: 4170, - end: 4175, - }, - value: Bool( - false, - ), + ), + Constant( + Constant { + node: Node { + start: 4161, + end: 0, }, - ), - }, + value: Str( + ".csv", + ), + }, + ), ], - 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", + keywords: [ + Keyword { + node: Node { + start: 4164, + end: 4175, }, - ), - args: [ - Name( - Name { + arg: Some( + "index", + ), + value: Constant( + Constant { node: Node { - start: 4226, - end: 4233, + start: 4170, + end: 4175, }, - id: "symbols", + value: Bool( + false, + ), }, ), - ], - 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 { + ], + 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: 4346, - end: 6805, + start: 4206, + end: 4209, }, - name: "adjust_price", - args: Arguments { + id: "len", + }, + ), + args: [ + Name( + Name { node: Node { - start: 4363, - end: 4379, + start: 4210, + end: 4217, }, - 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: [], + id: "df_list", }, - 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 ", - ), - }, - ), + ), + ], + 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", ), - IfStatement( - If { + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + orelse: [], + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 4322, + end: 4324, + }, + func: Attribute( + Attribute { + node: Node { + start: 4309, + end: 4322, + }, + value: Name( + Name { + node: Node { + start: 4309, + end: 4316, + }, + id: "session", + }, + ), + attr: "close", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + Return( + Return { + node: Node { + start: 4329, + end: 4343, + }, + value: Some( + Name( + Name { + node: Node { + start: 4336, + end: 4343, + }, + id: "df_list", + }, + ), + ), + }, + ), + ], + decorator_list: [], + returns: Some( + Subscript( + Subscript { + node: Node { + start: 1637, + end: 1660, + }, + value: Name( + Name { + node: Node { + start: 1637, + end: 1641, + }, + id: "Dict", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 1642, + end: 1660, + }, + elements: [ + Name( + Name { + node: Node { + start: 1642, + end: 1645, + }, + id: "str", + }, + ), + Attribute( + Attribute { + node: Node { + start: 1647, + end: 1659, + }, + value: Name( + Name { + node: Node { + start: 1647, + end: 1649, + }, + id: "pd", + }, + ), + attr: "DataFrame", + }, + ), + ], + }, + ), + }, + ), + ), + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 4346, + end: 6805, + }, + name: "adjust_price", + args: Arguments { + node: Node { + start: 4363, + end: 4379, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 4363, + end: 4379, + }, + arg: "df", + annotation: Some( + Attribute( + Attribute { + node: Node { + start: 4367, + end: 4379, + }, + value: Name( + Name { + node: Node { + start: 4367, + end: 4369, + }, + 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: 5593, - end: 5691, + start: 5612, + end: 5622, }, - test: BoolOp( - BoolOperation { - node: Node { - start: 5596, - end: 5666, + id: "isinstance", + }, + ), + args: [ + Attribute( + Attribute { + node: Node { + start: 5623, + end: 5631, + }, + value: Name( + Name { + node: Node { + start: 5623, + end: 5625, + }, + id: "df", }, - 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 { + ), + 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: 5608, - end: 5666, + start: 5633, + end: 5648, }, - op: Not, - operand: Call( - Call { + value: Attribute( + Attribute { node: Node { - start: 5612, - end: 5666, + start: 5633, + end: 5640, }, - func: Name( + value: Name( Name { node: Node { - start: 5612, - end: 5622, + start: 5633, + end: 5635, }, - id: "isinstance", + id: "pd", }, ), - 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, + attr: "core", }, ), + attr: "indexes", }, ), - ], - }, - ), - body: [ - Return( - Return { - node: Node { - start: 5676, - end: 5685, - }, - value: Some( - Name( - Name { - node: Node { - start: 5683, - end: 5685, - }, - id: "df", - }, - ), - ), + attr: "range", }, ), - ], - orelse: [], + 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", }, ), - AssignStatement( - Assign { + attr: "index", + }, + ), + slice: Compare( + Compare { + node: Node { + start: 5768, + end: 5812, + }, + left: Attribute( + Attribute { node: Node { - start: 5691, - end: 5709, + start: 5783, + end: 5792, }, - targets: [ - Name( - Name { - node: Node { - start: 5691, - end: 5697, - }, - id: "new_df", - }, - ), - ], value: Call( Call { node: Node { - start: 5707, - end: 5709, + start: 5780, + end: 5783, }, func: Attribute( Attribute { node: Node { - start: 5700, - end: 5707, + start: 5768, + end: 5780, }, value: Name( Name { node: Node { - start: 5700, - end: 5702, + start: 5768, + end: 5774, }, - id: "df", + id: "new_df", }, ), - attr: "copy", + attr: "shift", }, ), - args: [], + args: [ + Constant( + Constant { + node: Node { + start: 5781, + end: 5782, + }, + value: Int( + "1", + ), + }, + ), + ], keywords: [], starargs: None, kwargs: None, }, ), + attr: "adjClose", }, ), - AssignStatement( - Assign { - node: Node { - start: 5714, - end: 5738, - }, - targets: [ - Name( + ops: [ + NotEq, + ], + comparators: [ + Attribute( + Attribute { + node: Node { + start: 5796, + end: 5812, + }, + value: Name( Name { node: Node { - start: 5714, - end: 5718, + start: 5796, + end: 5802, }, - id: "step", + id: "new_df", }, ), - ], - 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 { + 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: 5743, - end: 5814, + start: 5912, + end: 5913, }, - targets: [ + 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: 5743, - end: 5747, + start: 5958, + end: 5959, + }, + id: "i", + }, + ), + Constant( + Constant { + node: Node { + start: 5961, + end: 5972, }, - id: "diff", + 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: 5750, - end: 5814, + start: 5988, + end: 5991, }, - func: Name( - Name { + func: Attribute( + Attribute { node: Node { - start: 5750, - end: 5754, + start: 5976, + end: 5988, }, - id: "list", + value: Name( + Name { + node: Node { + start: 5976, + end: 5982, + }, + id: "new_df", + }, + ), + attr: "shift", }, ), args: [ - Subscript( - Subscript { + Constant( + Constant { node: Node { - start: 5767, - end: 5813, + start: 5989, + end: 5990, }, - 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", - }, - ), - ], - }, + value: Int( + "1", ), }, ), @@ -5184,9347 +5620,8876 @@ Module { kwargs: None, }, ), + attr: "loc", }, ), - 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 { + slice: Tuple( + Tuple { node: Node { - start: 5861, - end: 5870, + start: 5996, + end: 6010, }, - targets: [ + elements: [ Name( Name { node: Node { - start: 5861, - end: 5866, + start: 5996, + end: 5997, }, - id: "ratio", + id: "i", }, ), - ], - value: Constant( - Constant { - node: Node { - start: 5869, - end: 5870, + Constant( + Constant { + node: Node { + start: 5999, + end: 6009, + }, + value: Str( + "adjClose", + ), }, - value: Int( - "1", - ), - }, - ), + ), + ], }, ), - AssignStatement( - Assign { + }, + ), + }, + ), + }, + ), + 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: 5875, - end: 5890, + start: 6121, + end: 6126, }, - targets: [ - Name( + 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: 5875, - end: 5885, + start: 6129, + end: 6135, }, - id: "ratio_list", + id: "new_df", }, ), - ], - value: List( - List { - node: Node { - start: 5888, - end: 5890, - }, - elements: [], + 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", }, ), - ForStatement( - For { + slice: Name( + Name { node: Node { - start: 5895, - end: 6061, + start: 6213, + end: 6214, }, - target: Name( - Name { + 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: 5899, - end: 5900, + start: 6260, + end: 6264, }, - id: "i", + 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, }, ), - iter: Subscript( - Subscript { + List( + List { node: Node { - start: 5904, - end: 5914, + start: 6278, + end: 6446, }, - value: Name( - Name { - node: Node { - start: 5904, - end: 5908, + elements: [ + Constant( + Constant { + node: Node { + start: 6296, + end: 6302, + }, + value: Str( + "open", + ), }, - id: "diff", - }, - ), - slice: Slice( - Slice { - node: Node { - start: 5909, - end: 5913, + ), + Constant( + Constant { + node: Node { + start: 6320, + end: 6326, + }, + value: Str( + "high", + ), }, - 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", - ), - }, - ), - }, + ), + Constant( + Constant { + node: Node { + start: 6344, + end: 6349, + }, + value: Str( + "low", ), - ), - step: None, - }, - ), + }, + ), + Constant( + Constant { + node: Node { + start: 6367, + end: 6374, + }, + value: Str( + "close", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 6392, + end: 6402, + }, + value: Str( + "adjClose", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 6420, + end: 6431, + }, + value: Str( + "yesterday", + ), + }, + ), + ], }, ), - body: [ - AugAssignStatement( - AugAssign { + ], + }, + ), + }, + ), + ], + 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: 5924, - end: 6020, + start: 6479, + end: 6489, }, - target: Name( + value: Name( Name { node: Node { - start: 5924, - end: 5929, + start: 6479, + end: 6485, }, - id: "ratio", + id: "new_df", }, ), - 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 { + 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: 5947, - end: 5957, + start: 6507, + end: 6512, }, - value: Name( - Name { - node: Node { - start: 5947, - end: 5953, - }, - id: "new_df", - }, - ), - attr: "loc", + id: "start", }, ), - slice: Tuple( - Tuple { + ), + upper: Some( + Name( + Name { node: Node { - start: 5958, - end: 5973, + start: 6513, + end: 6516, }, - elements: [ - Name( - Name { - node: Node { - start: 5958, - end: 5959, - }, - id: "i", - }, - ), - Constant( - Constant { - node: Node { - start: 5961, - end: 5972, - }, - value: Str( - "yesterday", - ), - }, - ), - ], + id: "end", }, ), + ), + step: None, + }, + ), + List( + List { + node: Node { + start: 6534, + end: 6730, }, - ), - right: Subscript( - Subscript { - node: Node { - start: 5995, - end: 6010, - }, - value: Attribute( - Attribute { + elements: [ + Constant( + Constant { node: Node { - start: 5991, - end: 5995, + start: 6556, + end: 6562, }, - 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, - }, + value: Str( + "open", ), - attr: "loc", }, ), - slice: Tuple( - Tuple { + Constant( + Constant { node: Node { - start: 5996, - end: 6010, + start: 6584, + end: 6590, }, - elements: [ - Name( - Name { - node: Node { - start: 5996, - end: 5997, - }, - id: "i", - }, - ), - Constant( - Constant { - node: Node { - start: 5999, - end: 6009, - }, - value: Str( - "adjClose", - ), - }, - ), - ], + value: Str( + "high", + ), }, ), - }, - ), - }, - ), - }, - ), - 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, + Constant( + Constant { + node: Node { + start: 6612, + end: 6617, + }, + value: Str( + "low", + ), }, - 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 { + Constant( + Constant { node: Node { - start: 6121, - end: 6126, + start: 6639, + end: 6646, }, - id: "start", + value: Str( + "close", + ), }, ), - ], - 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", + Constant( + Constant { + node: Node { + start: 6668, + end: 6678, }, - ), - attr: "start", - }, - ), - }, - ), - ], - orelse: [ - AssignStatement( - Assign { - node: Node { - start: 6174, - end: 6193, - }, - targets: [ - Name( - Name { + value: Str( + "adjClose", + ), + }, + ), + Constant( + Constant { node: Node { - start: 6174, - end: 6179, + start: 6700, + end: 6711, }, - id: "start", + value: Str( + "yesterday", + ), }, ), ], - 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 { + }, + ), + right: Subscript( + Subscript { + node: Node { + start: 6760, + end: 6773, + }, + value: Name( + Name { node: Node { - start: 6202, - end: 6222, + start: 6760, + end: 6770, }, - 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, - }, - ), + id: "ratio_list", }, ), - ], - orelse: [], - }, - ), - Return( - Return { - node: Node { - start: 6789, - end: 6802, - }, - value: Some( - Name( + slice: Name( Name { node: Node { - start: 6796, - end: 6802, + start: 6771, + end: 6772, }, - id: "new_df", + id: "i", }, ), - ), - }, - ), - ], - 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, - }, - ), + ), + ], + 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, }, - ), - 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: [], + 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, }, - ), - ExpressionStatement( - Call( - Call { + id: "logger", + }, + ), + attr: "error", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 7221, + end: 7275, + }, + values: [ + Constant( + Constant { node: Node { - start: 7394, - end: 7396, + start: 7269, + end: 0, }, - func: Attribute( - Attribute { - node: Node { - start: 7369, - end: 7394, - }, - value: Name( - Name { - node: Node { - start: 7369, - end: 7377, - }, - id: "response", - }, - ), - attr: "raise_for_status", - }, + value: Str( + "Cannot read daily trade records from the url: ", ), - args: [], - keywords: [], - starargs: None, - kwargs: None, }, ), - ), - AssignStatement( - Assign { - node: Node { - start: 7402, - end: 7432, + Name( + Name { + node: Node { + start: 7270, + end: 7273, + }, + id: "url", }, - targets: [ - Name( - Name { - node: Node { - start: 7402, - end: 7406, - }, - id: "data", - }, - ), - ], - value: Call( - Call { + ), + ], + }, + ), + ], + 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: 7409, - end: 7432, + start: 7296, + end: 7306, }, - func: Name( - Name { - node: Node { - start: 7409, - end: 7417, - }, - id: "StringIO", - }, + value: Str( + "response", ), - 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 { + Constant( + Constant { node: Node { - start: 6817, - end: 6857, + start: 7323, + end: 7329, }, - 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, - }, + value: Str( + "code", ), }, - Keyword { + ), + ], + values: [ + Attribute( + Attribute { node: Node { - start: 6863, - end: 6893, + start: 7308, + end: 7321, }, - arg: Some( - "wait", - ), - value: Call( - Call { + value: Name( + Name { node: Node { - start: 6868, - end: 6893, + start: 7308, + end: 7316, }, - 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, + id: "response", }, ), + attr: "text", }, - Keyword { + ), + Attribute( + Attribute { node: Node { - start: 6899, - end: 6951, + start: 7331, + end: 7351, }, - arg: Some( - "before_sleep", - ), - value: Call( - Call { + value: Name( + Name { node: Node { - start: 6912, - end: 6951, + start: 7331, + end: 7339, }, - 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: "response", }, ), + attr: "status_code", }, - ], - starargs: None, - kwargs: None, - }, - ), - ], - returns: None, - type_comment: None, + ), + ], + }, + ), }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 7614, - end: 8358, - }, - name: "download_fIndex_record", - args: Arguments { + ], + 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: 7641, - end: 7670, + start: 7418, + end: 7426, }, - 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", - }, - ), - ), + 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, }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], + value: Int( + "1", + ), + }, + ), + }, + Keyword { + node: Node { + start: 6887, + end: 6892, }, - 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, - }, - ), + arg: Some( + "max", + ), + value: Constant( + Constant { + node: Node { + start: 6891, + end: 6892, }, - ), - AssignStatement( - Assign { + 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: 7755, - end: 7794, + start: 6937, + end: 6944, }, - 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, - }, - ), + id: "logging", }, ), - IfStatement( - If { - node: Node { - start: 7799, - end: 8019, + 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: ", + ), }, - test: Compare( - Compare { + ), + 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: 7802, - end: 7835, + start: 7946, + end: 7956, }, - left: Constant( - Constant { - node: Node { - start: 7802, - end: 7805, - }, - value: Int( - "400", - ), - }, + value: Str( + "response", ), - 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 { + 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: 7857, - end: 8013, + start: 7958, + end: 7966, }, - 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, + id: "response", }, ), - ), - ], - orelse: [], - }, - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 8044, - end: 8046, + attr: "text", }, - 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( Attribute { node: Node { - start: 8058, - end: 8071, + start: 7981, + end: 8001, }, value: Name( Name { node: Node { - start: 8058, - end: 8066, + start: 7981, + end: 7989, }, id: "response", }, ), - attr: "text", + 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, }, - ), - IfStatement( - If { - node: Node { - start: 8076, - end: 8288, + left: Constant( + Constant { + node: Node { + start: 8091, + end: 8094, + }, + value: Str( + ";", + ), }, - test: BoolOp( - BoolOperation { + ), + ops: [ + NotIn, + ], + comparators: [ + Name( + Name { node: Node { - start: 8079, - end: 8125, + start: 8102, + end: 8106, }, - 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", - }, - ), - ], - }, - ), - ], - }, - ), - ], + 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: [], + ], + }, + ), + Compare( + Compare { + node: Node { + start: 8110, + end: 8125, }, - ), - AssignStatement( - Assign { - node: Node { - start: 8288, - end: 8341, - }, - targets: [ - Name( - Name { - node: Node { - start: 8288, - end: 8290, - }, - id: "df", - }, + left: Constant( + Constant { + node: Node { + start: 8110, + end: 8113, + }, + value: Str( + ",", ), - ], - value: Call( - Call { + }, + ), + ops: [ + NotIn, + ], + comparators: [ + Name( + Name { node: Node { - start: 8293, - end: 8341, + start: 8121, + end: 8125, }, - 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: "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, }, - ), - Return( - Return { + id: "ValueError", + }, + ), + args: [ + JoinedStr( + JoinedStr { node: Node { - start: 8346, - end: 8355, + start: 8165, + end: 8273, }, - value: Some( + values: [ + Constant( + Constant { + node: Node { + start: 8200, + end: 0, + }, + value: Str( + "Invalid response from the url: ", + ), + }, + ), Name( Name { node: Node { - start: 8353, - end: 8355, + start: 8201, + end: 8204, }, - id: "df", + id: "url", }, ), - ), + Constant( + Constant { + node: Node { + start: 8270, + end: 0, + }, + value: Str( + ".\n \\nExpected valid financial index data.", + ), + }, + ), + ], }, ), ], - 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, + keywords: [], + starargs: None, + kwargs: None, }, ), - FunctionDef( - FunctionDef { + ), + 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: 8358, - end: 15273, + start: 7482, + end: 7505, }, - name: "download_financial_indexes", - args: Arguments { + id: "retry_if_exception_type", + }, + ), + args: [ + Name( + Name { node: Node { - start: 8394, - end: 8540, + start: 7506, + end: 7515, }, - 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", - }, - ), - ], - }, - ), - }, - ), - ), + 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, }, - Arg { - node: Node { - start: 8425, - end: 8451, - }, - arg: "write_to_csv", - annotation: Some( - Name( - Name { - node: Node { - start: 8439, - end: 8443, - }, - id: "bool", - }, - ), - ), + value: Int( + "1", + ), + }, + ), + }, + Keyword { + node: Node { + start: 7546, + end: 7551, + }, + arg: Some( + "max", + ), + value: Constant( + Constant { + node: Node { + start: 7550, + end: 7551, }, - Arg { + 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: 8457, - end: 8484, + start: 7596, + end: 7603, }, - arg: "include_jdate", - annotation: Some( - Name( - Name { - node: Node { - start: 8472, - end: 8476, - }, - id: "bool", - }, - ), - ), + id: "logging", }, - Arg { - node: Node { - start: 8490, - end: 8539, - }, - arg: "base_path", - annotation: Some( - Name( - Name { - node: Node { - start: 8501, - end: 8504, - }, - id: "str", - }, - ), - ), + ), + attr: "DEBUG", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + ], + returns: None, + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 8358, + end: 10374, + }, + name: "download_financial_indexes", + args: Arguments { + node: Node { + start: 8394, + end: 8540, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 8394, + end: 8419, + }, + arg: "symbols", + annotation: Some( + Subscript( + Subscript { + node: Node { + start: 8403, + end: 8419, + }, + value: Name( + Name { + node: Node { + start: 8403, + end: 8408, + }, + id: "Union", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 8409, + end: 8419, + }, + elements: [ + Name( + Name { + node: Node { + start: 8409, + end: 8413, }, - ], - 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", - }, - ), - ], + 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, }, - body: [ - IfStatement( - If { + 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: 8575, - end: 8717, + start: 8614, + end: 8626, }, - 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: [], - }, - ), - ], + id: "symbols_data", }, ), - 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: [], - }, - ), + 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, }, - ), - AssignStatement( - Assign { + 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: 8734, - end: 8755, + start: 8692, + end: 8699, }, - targets: [ - Name( - Name { - node: Node { - start: 8734, - end: 8750, - }, - id: "future_to_symbol", - }, - ), - ], - value: Dict( - Dict { - node: Node { - start: 8753, - end: 8755, - }, - keys: [], - values: [], - }, - ), + id: "symbols", }, ), - WithStatement( - With { - node: Node { - start: 8760, - end: 10374, - }, - items: [ - WithItem { + ], + value: List( + List { + node: Node { + start: 8702, + end: 8711, + }, + elements: [ + Name( + Name { node: Node { - start: 8765, - end: 8819, + start: 8703, + end: 8710, }, - 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", - }, - ), - ), + id: "symbols", }, - ], - 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 { + ), + ], + }, + ), + }, + ), + ], + orelse: [], + }, + ), + ], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 8717, + end: 8729, + }, + targets: [ + Name( + Name { + node: Node { + start: 8717, + end: 8724, + }, + id: "df_list", + }, + ), + ], + value: Dict( + Dict { + node: Node { + start: 8727, + end: 8729, + }, + keys: [], + values: [], + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 8734, + end: 8755, + }, + targets: [ + Name( + Name { + node: Node { + start: 8734, + end: 8750, + }, + id: "future_to_symbol", + }, + ), + ], + value: Dict( + Dict { + node: Node { + start: 8753, + end: 8755, + }, + keys: [], + values: [], + }, + ), + }, + ), + WithStatement( + With { + node: Node { + start: 8760, + end: 10231, + }, + items: [ + WithItem { + node: Node { + start: 8765, + end: 8819, + }, + context_expr: Call( + Call { + node: Node { + start: 8791, + end: 8807, + }, + func: Attribute( + Attribute { + node: Node { + start: 8765, + end: 8791, + }, + value: Name( + Name { + node: Node { + start: 8765, + end: 8772, + }, + id: "futures", + }, + ), + attr: "ThreadPoolExecutor", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 8792, + end: 8806, + }, + arg: Some( + "max_workers", + ), + value: Constant( + Constant { + node: Node { + start: 8804, + end: 8806, + }, + value: Int( + "10", + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + optional_vars: Some( + Name( + Name { + node: Node { + start: 8811, + end: 8819, + }, + id: "executor", + }, + ), + ), + }, + ], + body: [ + AssignStatement( + Assign { + node: Node { + start: 8829, + end: 8863, + }, + targets: [ + Name( + Name { + node: Node { + start: 8829, + end: 8836, + }, + id: "session", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 8839, + end: 8863, + }, + func: Name( + Name { + node: Node { + start: 8839, + end: 8861, + }, + id: "requests_retry_session", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ForStatement( + For { + node: Node { + start: 8872, + end: 9506, + }, + target: Name( + Name { + node: Node { + start: 8876, + end: 8882, + }, + id: "symbol", + }, + ), + iter: Name( + Name { + node: Node { + start: 8886, + end: 8893, + }, + id: "symbols", + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 8907, + end: 8947, + }, + targets: [ + Name( + Name { + node: Node { + start: 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: 8872, - end: 9506, + start: 8916, + end: 8923, }, - target: Name( - Name { - node: Node { - start: 8876, - end: 8882, - }, - id: "symbol", - }, - ), - iter: Name( - Name { - node: Node { - start: 8886, - end: 8893, - }, - id: "symbols", + 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, }, - ), - body: [ - AssignStatement( - Assign { + value: Name( + Name { node: Node { - start: 8907, - end: 8947, + start: 8981, + end: 8987, }, - 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, - }, - ), + id: "symbol", }, ), - IfStatement( - If { + 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: 8960, - end: 9230, + start: 9020, + end: 9052, }, - test: BoolOp( - BoolOperation { + value: Name( + Name { node: Node { - start: 8981, - end: 9068, + start: 9020, + end: 9032, }, - 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, - }, - ), - ], - }, - ), - ], + id: "symbols_data", }, ), - body: [ - AssignStatement( - Assign { + 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: 9100, - end: 9124, + start: 9321, + end: 0, }, - targets: [ - Name( - Name { - node: Node { - start: 9100, - end: 9115, - }, - id: "financial_index", - }, - ), - ], - value: Name( - Name { - node: Node { - start: 9118, - end: 9124, - }, - id: "symbol", - }, + value: Str( + "Cannot find financial index: ", ), }, ), - ], - orelse: [ - AssignStatement( - Assign { + Name( + Name { node: Node { - start: 9159, - end: 9217, + start: 9322, + end: 9328, }, - 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, - }, - ), + id: "symbol", }, ), ], }, ), - 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: [], + keywords: [], + starargs: None, + kwargs: None, }, ), - ForStatement( - For { + ), + 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: 9506, - end: 10231, + start: 9354, + end: 9362, }, - 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, - }, - }, - ), - ], + 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", + }, + ), + 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, }, - ], - orelse: [], - finalbody: [], + 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", }, ), - ExpressionStatement( - Call( - Call { + 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: 9928, - end: 9976, + start: 9741, + end: 9747, }, - func: Name( + 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: 9928, - end: 9957, + start: 9822, + end: 9828, }, - id: "_adjust_data_frame_for_fIndex", + id: "symbol", }, ), - args: [ - Name( - Name { + ], + }, + ), + ], + 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: 9958, - end: 9960, + start: 9859, + end: 9866, }, - id: "df", + value: Str( + "Error", + ), }, ), + ], + values: [ Name( Name { node: Node { - start: 9962, - end: 9975, + start: 9868, + end: 9870, }, - id: "include_jdate", + id: "ex", }, ), ], - keywords: [], - starargs: None, - kwargs: None, }, ), - ), - AssignStatement( - Assign { - node: Node { - start: 9989, - end: 10009, + }, + ], + 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", }, - 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( + ), + args: [ + Name( Name { node: Node { - start: 10007, - end: 10009, + start: 10061, + end: 10070, }, - id: "df", + 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, }, - ), - IfStatement( - If { - node: Node { - start: 10023, - end: 10231, + 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", }, - test: Name( - Name { - node: Node { - start: 10026, - end: 10038, - }, - id: "write_to_csv", + ), + slice: Name( + Name { + node: Node { + start: 10131, + end: 10137, }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 10077, - end: 10106, - }, - func: Attribute( - Attribute { - node: Node { - start: 10071, - end: 10077, - }, - value: Call( - Call { - node: Node { - start: 10056, - end: 10071, - }, - func: Name( - Name { - node: Node { - start: 10056, - end: 10060, - }, - id: "Path", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 10061, - end: 10070, - }, - id: "base_path", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "mkdir", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 10078, - end: 10090, - }, - arg: Some( - "parents", - ), - value: Constant( - Constant { - node: Node { - start: 10086, - end: 10090, - }, - value: Bool( - true, - ), - }, - ), - }, - Keyword { - node: Node { - start: 10092, - end: 10105, - }, - arg: Some( - "exist_ok", - ), - value: Constant( - Constant { - node: Node { - start: 10101, - end: 10105, - }, - value: Bool( - true, - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 10145, - end: 10225, - }, - func: Attribute( - Attribute { - node: Node { - start: 10138, - end: 10145, - }, - value: Subscript( - Subscript { - node: Node { - start: 10123, - end: 10138, - }, - value: Name( - Name { - node: Node { - start: 10123, - end: 10130, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 10131, - end: 10137, - }, - id: "symbol", - }, - ), - }, - ), - attr: "to_csv", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 10167, - end: 10194, - }, - values: [ - Name( - Name { - node: Node { - start: 10170, - end: 10179, - }, - id: "base_path", - }, - ), - Constant( - Constant { - node: Node { - start: 10181, - end: 0, - }, - value: Str( - "/", - ), - }, - ), - Name( - Name { - node: Node { - start: 10182, - end: 10188, - }, - id: "symbol", - }, - ), - Constant( - Constant { - node: Node { - start: 10193, - end: 0, - }, - value: Str( - ".csv", - ), - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 10196, - end: 10207, - }, - arg: Some( - "index", - ), - value: Constant( - Constant { - node: Node { - start: 10202, - end: 10207, - }, - value: Bool( - false, - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], - }, - ), - ], - orelse: [], + id: "symbol", + }, + ), + }, + ), + attr: "to_csv", }, ), - IfStatement( - If { - node: Node { - start: 10231, - end: 10337, - }, - test: Compare( - Compare { - node: Node { - start: 10234, - end: 10262, - }, - left: Call( - Call { + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 10167, + end: 10194, + }, + values: [ + Name( + Name { node: Node { - start: 10234, - end: 10246, + start: 10170, + end: 10179, }, - 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: "base_path", }, ), - 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 { + Constant( + Constant { node: Node { - start: 10272, - end: 10332, + start: 10181, + end: 0, }, - func: Name( - Name { - node: Node { - start: 10272, - end: 10277, - }, - id: "print", - }, + value: Str( + "/", ), - 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", + Name( + Name { + node: Node { + start: 10182, + end: 10188, }, - ), - 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, + id: "symbol", }, - 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", - }, - ), - ], + ), + Constant( + Constant { + node: Node { + start: 10193, + end: 0, }, - ), - }, - ), - ), - }, - Arg { - node: Node { - start: 10444, - end: 10470, - }, - arg: "write_to_csv", - annotation: Some( - Name( - Name { - node: Node { - start: 10458, - end: 10462, + value: Str( + ".csv", + ), }, - 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 { + ), + ], + keywords: [ + Keyword { node: Node { - start: 10509, - end: 10560, + start: 10196, + end: 10207, }, - arg: "base_path", - annotation: Some( - Name( - Name { - node: Node { - start: 10520, - end: 10523, - }, - id: "str", + arg: Some( + "index", + ), + value: Constant( + Constant { + node: Node { + start: 10202, + end: 10207, }, - ), + value: Bool( + false, + ), + }, ), }, ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [ - Constant( - Constant { - node: Node { - start: 10465, - end: 10470, - }, - value: Bool( - false, - ), - }, - ), - Constant( - Constant { - node: Node { - start: 10498, - end: 10503, - }, - value: Bool( - false, - ), - }, - ), - Attribute( - Attribute { - node: Node { - start: 10526, - end: 10560, - }, - value: Name( - Name { - node: Node { - start: 10526, - end: 10532, - }, - id: "config", - }, - ), - attr: "CLIENT_TYPES_DATA_BASE_PATH", - }, - ), - ], + starargs: None, + kwargs: None, }, - body: [ - IfStatement( - If { - node: Node { - start: 10569, - end: 10703, - }, - test: Compare( - Compare { - node: Node { - start: 10572, - end: 10588, - }, - left: Name( - Name { - node: Node { - start: 10572, - end: 10579, - }, - id: "symbols", - }, - ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 10583, - end: 10588, - }, - value: Str( - "all", - ), - }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 10598, - end: 10634, - }, - targets: [ - Name( - Name { - node: Node { - start: 10598, - end: 10605, - }, - id: "symbols", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 10632, - end: 10634, - }, - func: Attribute( - Attribute { - node: Node { - start: 10608, - end: 10632, - }, - value: Name( - Name { - node: Node { - start: 10608, - end: 10620, - }, - id: "symbols_data", - }, - ), - attr: "all_symbols", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - orelse: [ - IfStatement( - If { - node: Node { - start: 10639, - end: 10703, - }, - test: Call( - Call { - node: Node { - start: 10644, - end: 10668, - }, - func: Name( - Name { - node: Node { - start: 10644, - end: 10654, - }, - id: "isinstance", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 10655, - end: 10662, - }, - id: "symbols", - }, - ), - Name( - Name { - node: Node { - start: 10664, - end: 10667, - }, - id: "str", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 10678, - end: 10697, - }, - targets: [ - Name( - Name { - node: Node { - start: 10678, - end: 10685, - }, - id: "symbols", - }, - ), - ], - value: List( - List { - node: Node { - start: 10688, - end: 10697, - }, - elements: [ - Name( - Name { - node: Node { - start: 10689, - end: 10696, - }, - id: "symbols", - }, - ), - ], - }, - ), - }, - ), - ], - orelse: [], - }, - ), - ], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 10703, - end: 10715, - }, - targets: [ - Name( - Name { - node: Node { - start: 10703, - end: 10710, - }, - id: "df_list", - }, - ), - ], - value: Dict( - Dict { - node: Node { - start: 10713, - end: 10715, - }, - keys: [], - values: [], - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 10720, - end: 10741, - }, - targets: [ - Name( - Name { - node: Node { - start: 10720, - end: 10736, - }, - id: "future_to_symbol", - }, - ), - ], - value: Dict( - Dict { - node: Node { - start: 10739, - end: 10741, - }, - keys: [], - values: [], - }, - ), - }, - ), - WithStatement( - With { - node: Node { - start: 10746, - end: 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: 10751, - end: 10777, - }, - value: Name( - Name { - node: Node { - start: 10751, - end: 10758, - }, - id: "futures", - }, - ), - attr: "ThreadPoolExecutor", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 10778, - end: 10792, - }, - arg: Some( - "max_workers", - ), - value: Constant( - Constant { - node: Node { - start: 10790, - end: 10792, - }, - value: Int( - "10", - ), - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - optional_vars: Some( - Name( - Name { - node: Node { - start: 10797, - end: 10805, - }, - id: "executor", - }, - ), - ), - }, - ], - body: [ - ForStatement( - For { - node: Node { - start: 10815, - end: 11168, - }, - target: Name( - Name { - node: Node { - start: 10819, - end: 10825, - }, - id: "symbol", - }, - ), - iter: Name( - Name { - node: Node { - start: 10829, - end: 10836, - }, - id: "symbols", - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 10850, - end: 10893, - }, - targets: [ - Name( - Name { - node: Node { - start: 10850, - end: 10862, - }, - id: "ticker_index", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 10865, - end: 10893, - }, - func: Name( - Name { - node: Node { - start: 10865, - end: 10885, - }, - id: "_handle_ticker_index", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 10886, - end: 10892, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 10906, - end: 11008, - }, - test: Compare( - Compare { - node: Node { - start: 10909, - end: 10929, - }, - left: Name( - Name { - node: Node { - start: 10909, - end: 10921, - }, - id: "ticker_index", - }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 10925, - end: 10929, - }, - 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: [], - }, - ), - ForStatement( - For { - node: Node { - start: 11168, - end: 11636, - }, - target: Name( - Name { - node: Node { - start: 11172, - end: 11178, - }, - id: "future", - }, - ), - iter: Call( - Call { - node: Node { - start: 11202, - end: 11220, - }, - func: Attribute( - Attribute { - node: Node { - start: 11182, - end: 11202, - }, - value: Name( - Name { - node: Node { - start: 11182, - end: 11189, - }, - id: "futures", - }, - ), - attr: "as_completed", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11203, - end: 11219, - }, - id: "future_to_symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 11234, - end: 11267, - }, - targets: [ - Name( - Name { - node: Node { - start: 11234, - end: 11240, - }, - id: "symbol", - }, - ), - ], - value: Subscript( - Subscript { - node: Node { - start: 11243, - end: 11267, - }, - value: Name( - Name { - node: Node { - start: 11243, - end: 11259, - }, - id: "future_to_symbol", - }, - ), - slice: Name( - Name { - node: Node { - start: 11260, - end: 11266, - }, - id: "future", - }, - ), - }, - ), - }, - ), - AnnAssignStatement( - AnnAssign { - node: Node { - start: 11280, - end: 11314, - }, - target: Name( - Name { - node: Node { - start: 11280, - end: 11282, - }, - id: "df", - }, - ), - annotation: Attribute( - Attribute { - node: Node { - start: 11284, - end: 11296, - }, - value: Name( - Name { - node: Node { - start: 11284, - end: 11286, - }, - id: "pd", - }, - ), - attr: "DataFrame", - }, - ), - value: Some( - Call( - Call { - node: Node { - start: 11312, - end: 11314, - }, - func: Attribute( - Attribute { - node: Node { - start: 11299, - end: 11312, - }, - 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: [], - }, - ), - ], - orelse: [], - }, - ), - IfStatement( - If { - node: Node { - start: 11636, - end: 11832, - }, - test: Compare( - Compare { - node: Node { - start: 11639, - end: 11667, - }, - left: Call( - Call { - node: Node { - start: 11639, - end: 11651, - }, - func: Name( - Name { - node: Node { - start: 11639, - end: 11642, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11643, - end: 11650, - }, - id: "df_list", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - NotEq, - ], - comparators: [ - Call( - Call { - node: Node { - start: 11655, - end: 11667, - }, - func: Name( - Name { - node: Node { - start: 11655, - end: 11658, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11659, - end: 11666, - }, - id: "symbols", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 11677, - end: 11827, - }, - func: Name( - Name { - node: Node { - start: 11677, - end: 11682, - }, - id: "print", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 11696, - end: 11817, - }, - value: Str( - "could not download client types for all the symbols make\n sure you have what you need or re-run the function", - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], - }, - ), - Return( - Return { - node: Node { - start: 11832, - end: 11846, - }, - value: Some( - Name( - Name { - node: Node { - start: 11839, - end: 11846, - }, - id: "df_list", - }, - ), - ), - }, - ), - ], - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 11999, - end: 13481, - }, - name: "download_ticker_client_types_record", - args: Arguments { - node: Node { - start: 12039, - end: 12066, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 12039, - end: 12066, - }, - arg: "ticker_index", - annotation: Some( - Subscript( - Subscript { - node: Node { - start: 12053, - end: 12066, - }, - value: Name( - Name { - node: Node { - start: 12053, - end: 12061, - }, - id: "Optional", - }, - ), - slice: Name( - Name { - node: Node { - start: 12062, - end: 12065, - }, - id: "str", - }, - ), - }, - ), - ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - AssignStatement( - Assign { - node: Node { - start: 12073, - end: 12127, - }, - targets: [ - Name( - Name { - node: Node { - start: 12073, - end: 12077, - }, - id: "data", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 12080, - end: 12127, - }, - func: Name( - Name { - node: Node { - start: 12080, - end: 12113, - }, - id: "_extract_ticker_client_types_data", - }, - ), - 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: [], + ), + ), + ], + orelse: [], + }, + ), + ], + orelse: [], + }, + ), + ], + }, + ), + IfStatement( + If { + node: Node { + start: 10231, + end: 10337, + }, + test: Compare( + Compare { + node: Node { + start: 10234, + end: 10262, + }, + left: Call( + Call { + node: Node { + start: 10234, + end: 10246, + }, + func: Name( + Name { + node: Node { + start: 10234, + end: 10237, + }, + id: "len", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 10238, + end: 10245, + }, + id: "df_list", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ops: [ + NotEq, + ], + comparators: [ + Call( + Call { + node: Node { + start: 10250, + end: 10262, + }, + func: Name( + Name { + node: Node { + start: 10250, + end: 10253, + }, + id: "len", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 10254, + end: 10261, + }, + id: "symbols", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 10272, + end: 10332, + }, + func: Name( + Name { + node: Node { + start: 10272, + end: 10277, + }, + id: "print", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 10278, + end: 10331, + }, + value: Str( + "Warning, download did not complete, re-run the code", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + orelse: [], + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 10350, + end: 10352, + }, + func: Attribute( + Attribute { + node: Node { + start: 10337, + end: 10350, + }, + value: Name( + Name { + node: Node { + start: 10337, + end: 10344, + }, + id: "session", + }, + ), + attr: "close", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + Return( + Return { + node: Node { + start: 10357, + end: 10371, + }, + value: Some( + Name( + Name { + node: Node { + start: 10364, + end: 10371, + }, + id: "df_list", + }, + ), + ), + }, + ), + ], + decorator_list: [], + returns: Some( + Subscript( + Subscript { + node: Node { + start: 8546, + end: 8569, + }, + value: Name( + Name { + node: Node { + start: 8546, + end: 8550, + }, + id: "Dict", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 8551, + end: 8569, + }, + elements: [ + Name( + Name { + node: Node { + start: 8551, + end: 8554, + }, + id: "str", + }, + ), + Attribute( + Attribute { + node: Node { + start: 8556, + end: 8568, + }, + value: Name( + Name { + node: Node { + start: 8556, + end: 8558, + }, + id: "pd", + }, + ), + attr: "DataFrame", + }, + ), + ], + }, + ), + }, + ), + ), + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 10374, + end: 11849, + }, + name: "download_client_types_records", + args: Arguments { + node: Node { + start: 10413, + end: 10561, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 10413, + end: 10438, + }, + arg: "symbols", + annotation: Some( + Subscript( + Subscript { + node: Node { + start: 10422, + end: 10438, + }, + value: Name( + Name { + node: Node { + start: 10422, + end: 10427, + }, + id: "Union", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 10428, + end: 10438, + }, + elements: [ + Name( + Name { + node: Node { + start: 10428, + end: 10432, + }, + id: "List", + }, + ), + Name( + Name { + node: Node { + start: 10434, + end: 10437, + }, + id: "str", + }, + ), + ], + }, + ), + }, + ), + ), + }, + Arg { + node: Node { + start: 10444, + end: 10470, + }, + arg: "write_to_csv", + annotation: Some( + Name( + Name { + node: Node { + start: 10458, + end: 10462, + }, + id: "bool", + }, + ), + ), + }, + Arg { + node: Node { + start: 10476, + end: 10503, + }, + arg: "include_jdate", + annotation: Some( + Name( + Name { + node: Node { + start: 10491, + end: 10495, + }, + id: "bool", + }, + ), + ), + }, + Arg { + node: Node { + start: 10509, + end: 10560, + }, + arg: "base_path", + annotation: Some( + Name( + Name { + node: Node { + start: 10520, + end: 10523, + }, + id: "str", + }, + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [ + Constant( + Constant { + node: Node { + start: 10465, + end: 10470, + }, + value: Bool( + false, + ), + }, + ), + Constant( + Constant { + node: Node { + start: 10498, + end: 10503, + }, + value: Bool( + false, + ), + }, + ), + Attribute( + Attribute { + node: Node { + start: 10526, + end: 10560, + }, + value: Name( + Name { + node: Node { + start: 10526, + end: 10532, + }, + id: "config", + }, + ), + attr: "CLIENT_TYPES_DATA_BASE_PATH", + }, + ), + ], + }, + body: [ + IfStatement( + If { + node: Node { + start: 10569, + end: 10703, + }, + test: Compare( + Compare { + node: Node { + start: 10572, + end: 10588, + }, + left: Name( + Name { + node: Node { + start: 10572, + end: 10579, + }, + id: "symbols", + }, + ), + ops: [ + Eq, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 10583, + end: 10588, + }, + value: Str( + "all", + ), + }, + ), + ], + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 10598, + end: 10634, + }, + targets: [ + Name( + Name { + node: Node { + start: 10598, + end: 10605, + }, + id: "symbols", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 10632, + end: 10634, + }, + func: Attribute( + Attribute { + node: Node { + start: 10608, + end: 10632, + }, + value: Name( + Name { + node: Node { + start: 10608, + end: 10620, + }, + id: "symbols_data", + }, + ), + attr: "all_symbols", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ], + orelse: [ + IfStatement( + If { + node: Node { + start: 10639, + end: 10703, + }, + test: Call( + Call { + node: Node { + start: 10644, + end: 10668, + }, + func: Name( + Name { + node: Node { + start: 10644, + end: 10654, + }, + id: "isinstance", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 10655, + end: 10662, + }, + id: "symbols", + }, + ), + Name( + Name { + node: Node { + start: 10664, + end: 10667, + }, + id: "str", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 10678, + end: 10697, + }, + targets: [ + Name( + Name { + node: Node { + start: 10678, + end: 10685, + }, + id: "symbols", + }, + ), + ], + value: List( + List { + node: Node { + start: 10688, + end: 10697, + }, + elements: [ + Name( + Name { + node: Node { + start: 10689, + end: 10696, + }, + id: "symbols", + }, + ), + ], + }, + ), + }, + ), + ], + orelse: [], + }, + ), + ], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 10703, + end: 10715, + }, + targets: [ + Name( + Name { + node: Node { + start: 10703, + end: 10710, + }, + id: "df_list", + }, + ), + ], + value: Dict( + Dict { + node: Node { + start: 10713, + end: 10715, + }, + keys: [], + values: [], + }, + ), + }, + ), + AssignStatement( + Assign { + node: Node { + start: 10720, + end: 10741, + }, + targets: [ + Name( + Name { + node: Node { + start: 10720, + end: 10736, + }, + id: "future_to_symbol", + }, + ), + ], + value: Dict( + Dict { + node: Node { + start: 10739, + end: 10741, + }, + keys: [], + values: [], + }, + ), + }, + ), + WithStatement( + With { + node: Node { + start: 10746, + end: 11636, + }, + items: [ + WithItem { + node: Node { + start: 10751, + end: 10805, + }, + context_expr: Call( + Call { + node: Node { + start: 10777, + end: 10793, + }, + func: Attribute( + Attribute { + node: Node { + start: 10751, + end: 10777, + }, + value: Name( + Name { + node: Node { + start: 10751, + end: 10758, + }, + id: "futures", + }, + ), + attr: "ThreadPoolExecutor", + }, + ), + args: [], + keywords: [ + Keyword { + node: Node { + start: 10778, + end: 10792, + }, + arg: Some( + "max_workers", + ), + value: Constant( + Constant { + node: Node { + start: 10790, + end: 10792, + }, + value: Int( + "10", + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + optional_vars: Some( + Name( + Name { + node: Node { + start: 10797, + end: 10805, + }, + id: "executor", + }, + ), + ), + }, + ], + body: [ + ForStatement( + For { + node: Node { + start: 10815, + end: 11168, + }, + target: Name( + Name { + node: Node { + start: 10819, + end: 10825, + }, + id: "symbol", + }, + ), + iter: Name( + Name { + node: Node { + start: 10829, + end: 10836, + }, + id: "symbols", + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 10850, + end: 10893, + }, + targets: [ + Name( + Name { + node: Node { + start: 10850, + end: 10862, + }, + id: "ticker_index", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 10865, + end: 10893, + }, + func: Name( + Name { + node: Node { + start: 10865, + end: 10885, + }, + id: "_handle_ticker_index", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 10886, + end: 10892, + }, + id: "symbol", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 10906, + end: 11008, + }, + test: Compare( + Compare { + node: Node { + start: 10909, + end: 10929, + }, + left: Name( + Name { + node: Node { + start: 10909, + end: 10921, + }, + id: "ticker_index", + }, + ), + ops: [ + Is, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 10925, + end: 10929, + }, + 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, }, - ), - AssignStatement( - Assign { + id: "Exception", + }, + ), + args: [ + JoinedStr( + JoinedStr { node: Node { - start: 13210, - end: 13443, + start: 10963, + end: 10994, }, - targets: [ - Subscript( - Subscript { + values: [ + Constant( + Constant { node: Node { - start: 13210, - end: 13278, + start: 10985, + end: 0, }, - 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: Str( + "Cannot find symbol: ", ), }, ), - ], - 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, + start: 10986, + end: 10992, }, - id: "client_types_data_frame", + 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: [], + }, + ), + ForStatement( + For { + node: Node { + start: 11168, + end: 11636, + }, + target: Name( + Name { + node: Node { + start: 11172, + end: 11178, + }, + id: "future", + }, + ), + iter: Call( + Call { + node: Node { + start: 11202, + end: 11220, + }, + func: Attribute( + Attribute { + node: Node { + start: 11182, + end: 11202, + }, + value: Name( + Name { + node: Node { + start: 11182, + end: 11189, + }, + id: "futures", + }, + ), + attr: "as_completed", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 11203, + end: 11219, + }, + id: "future_to_symbol", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 11234, + end: 11267, + }, + targets: [ + Name( + Name { + node: Node { + start: 11234, + end: 11240, + }, + id: "symbol", + }, + ), + ], + value: Subscript( + Subscript { + node: Node { + start: 11243, + end: 11267, + }, + value: Name( + Name { + node: Node { + start: 11243, + end: 11259, + }, + id: "future_to_symbol", + }, + ), + slice: Name( + Name { + node: Node { + start: 11260, + end: 11266, + }, + id: "future", + }, + ), + }, + ), + }, + ), + AnnAssignStatement( + AnnAssign { + node: Node { + start: 11280, + end: 11314, + }, + target: Name( + Name { + node: Node { + start: 11280, + end: 11282, + }, + id: "df", + }, + ), + annotation: Attribute( + Attribute { + node: Node { + start: 11284, + end: 11296, + }, + value: Name( + Name { + node: Node { + start: 11284, + end: 11286, + }, + id: "pd", + }, + ), + attr: "DataFrame", + }, + ), + value: Some( + Call( + Call { + node: Node { + start: 11312, + end: 11314, + }, + func: Attribute( + Attribute { + node: Node { + start: 11299, + end: 11312, + }, + 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, }, - ), - ], - 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, - }, - ), + func: Name( + Name { + node: Node { + start: 11525, + end: 11529, }, - Keyword { + id: "Path", + }, + ), + args: [ + Name( + Name { node: Node { - start: 11943, - end: 11995, + start: 11530, + end: 11539, }, - 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, - }, - ), + id: "base_path", }, - ], - starargs: None, - kwargs: None, + ), + ], + 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, }, - ), - ], - returns: None, - type_comment: None, + 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: [], + }, + ), + ], + orelse: [], + }, + ), + ], + }, + ), + IfStatement( + If { + node: Node { + start: 11636, + end: 11832, + }, + test: Compare( + Compare { + node: Node { + start: 11639, + end: 11667, + }, + left: Call( + Call { + node: Node { + start: 11639, + end: 11651, + }, + func: Name( + Name { + node: Node { + start: 11639, + end: 11642, + }, + id: "len", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 11643, + end: 11650, + }, + id: "df_list", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ops: [ + NotEq, + ], + comparators: [ + Call( + Call { + node: Node { + start: 11655, + end: 11667, + }, + func: Name( + Name { + node: Node { + start: 11655, + end: 11658, + }, + id: "len", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 11659, + end: 11666, + }, + id: "symbols", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 11677, + end: 11827, + }, + func: Name( + Name { + node: Node { + start: 11677, + end: 11682, + }, + id: "print", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 11696, + end: 11817, + }, + value: Str( + "could not download client types for all the symbols make\n sure you have what you need or re-run the function", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + ], + orelse: [], + }, + ), + Return( + Return { + node: Node { + start: 11832, + end: 11846, + }, + value: Some( + Name( + Name { + node: Node { + start: 11839, + end: 11846, + }, + id: "df_list", + }, + ), + ), + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 11999, + end: 13481, + }, + name: "download_ticker_client_types_record", + args: Arguments { + node: Node { + start: 12039, + end: 12066, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 12039, + end: 12066, + }, + arg: "ticker_index", + annotation: Some( + Subscript( + Subscript { + node: Node { + start: 12053, + end: 12066, + }, + value: Name( + Name { + node: Node { + start: 12053, + end: 12061, + }, + id: "Optional", + }, + ), + slice: Name( + Name { + node: Node { + start: 12062, + end: 12065, + }, + id: "str", + }, + ), + }, + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 12073, + end: 12127, + }, + targets: [ + Name( + Name { + node: Node { + start: 12073, + end: 12077, + }, + id: "data", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 12080, + end: 12127, + }, + func: Name( + Name { + node: Node { + start: 12080, + end: 12113, + }, + id: "_extract_ticker_client_types_data", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 12114, + end: 12126, + }, + id: "ticker_index", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + IfStatement( + If { + node: Node { + start: 12132, + end: 12367, + }, + test: Compare( + Compare { + node: Node { + start: 12135, + end: 12149, + }, + left: Call( + Call { + node: Node { + start: 12135, + end: 12144, + }, + func: Name( + Name { + node: Node { + start: 12135, + end: 12138, + }, + id: "len", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 12139, + end: 12143, + }, + id: "data", + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ops: [ + Eq, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 12148, + end: 12149, + }, + value: Int( + "1", + ), + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 12173, + end: 12342, + }, + func: Attribute( + Attribute { + node: Node { + start: 12159, + end: 12173, + }, + value: Name( + Name { + node: Node { + start: 12159, + end: 12165, + }, + id: "logger", + }, + ), + attr: "warning", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 12187, + end: 12281, + }, + values: [ + Constant( + Constant { + node: Node { + start: 12233, + end: 0, + }, + value: Str( + "Cannot create client types data for ticker", + ), + }, + ), + Name( + Name { + node: Node { + start: 12234, + end: 12246, + }, + id: "ticker_index", + }, + ), + Constant( + Constant { + node: Node { + start: 12272, + end: 0, + }, + value: Str( + "\n from data: ", + ), + }, + ), + Name( + Name { + node: Node { + start: 12273, + end: 12277, + }, + id: "data", + }, + ), + ], + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 12295, + end: 12331, + }, + arg: Some( + "extra", + ), + value: Dict( + Dict { + node: Node { + start: 12301, + end: 12331, + }, + keys: [ + Constant( + Constant { + node: Node { + start: 12302, + end: 12316, + }, + value: Str( + "ticker_index", + ), + }, + ), + ], + values: [ + Name( + Name { + node: Node { + start: 12318, + end: 12330, + }, + id: "ticker_index", + }, + ), + ], + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + ), + Return( + Return { + node: Node { + start: 12351, + end: 12362, + }, + value: Some( + Constant( + Constant { + node: Node { + start: 12358, + end: 12362, + }, + value: None, + }, + ), + ), + }, + ), + ], + orelse: [], + }, + ), + AssignStatement( + Assign { + node: Node { + start: 12367, + end: 12899, + }, + targets: [ + Name( + Name { + node: Node { + start: 12367, + end: 12390, + }, + id: "client_types_data_frame", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 12405, + end: 12899, + }, + func: Attribute( + Attribute { + node: Node { + start: 12393, + end: 12405, + }, + value: Name( + Name { + node: Node { + start: 12393, + end: 12395, + }, + id: "pd", + }, + ), + attr: "DataFrame", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 12415, + end: 12419, + }, + id: "data", + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 12429, + end: 12892, + }, + arg: Some( + "columns", + ), + value: List( + List { + node: Node { + start: 12437, + end: 12892, + }, + elements: [ + Constant( + Constant { + node: Node { + start: 12451, + end: 12457, + }, + value: Str( + "date", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12471, + end: 12493, + }, + value: Str( + "individual_buy_count", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12507, + end: 12528, + }, + value: Str( + "corporate_buy_count", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12542, + end: 12565, + }, + value: Str( + "individual_sell_count", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12579, + end: 12601, + }, + value: Str( + "corporate_sell_count", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12615, + end: 12635, + }, + value: Str( + "individual_buy_vol", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12649, + end: 12668, + }, + value: Str( + "corporate_buy_vol", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12682, + end: 12703, + }, + value: Str( + "individual_sell_vol", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12717, + end: 12737, + }, + value: Str( + "corporate_sell_vol", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12751, + end: 12773, + }, + value: Str( + "individual_buy_value", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12787, + end: 12808, + }, + value: Str( + "corporate_buy_value", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12822, + end: 12845, + }, + value: Str( + "individual_sell_value", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12859, + end: 12881, + }, + value: Str( + "corporate_sell_value", + ), + }, + ), + ], + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ForStatement( + For { + node: Node { + start: 12904, + end: 13210, + }, + target: Name( + Name { + node: Node { + start: 12908, + end: 12909, + }, + id: "i", + }, + ), + iter: List( + List { + node: Node { + start: 12913, + end: 13028, + }, + elements: [ + Constant( + Constant { + node: Node { + start: 12923, + end: 12940, + }, + value: Str( + "individual_buy_", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12950, + end: 12968, + }, + value: Str( + "individual_sell_", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 12978, + end: 12994, + }, + value: Str( + "corporate_buy_", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 13004, + end: 13021, + }, + value: Str( + "corporate_sell_", + ), + }, + ), + ], + }, + ), + body: [ + AssignStatement( + Assign { + node: Node { + start: 13038, + end: 13205, + }, + targets: [ + Subscript( + Subscript { + node: Node { + start: 13038, + end: 13079, + }, + value: Name( + Name { + node: Node { + start: 13038, + end: 13061, + }, + id: "client_types_data_frame", + }, + ), + slice: JoinedStr( + JoinedStr { + node: Node { + start: 13062, + end: 13078, + }, + values: [ + Name( + Name { + node: Node { + start: 13065, + end: 13066, }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 13481, - end: 13980, - }, - name: "get_symbol_id", - args: Arguments { + 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: 13499, - end: 13515, + start: 13082, + end: 13105, }, - 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: [], + id: "client_types_data_frame", }, - 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, + ), + slice: JoinedStr( + JoinedStr { + node: Node { + start: 13119, + end: 13130, + }, + values: [ + Name( + Name { + node: Node { + start: 13122, + end: 13123, }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 13591, - end: 13647, + id: "i", }, - 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, + ), + Constant( + Constant { + node: Node { + start: 13129, + end: 0, }, - ), - }, - ), - 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, - }, - ), + value: Str( + "value", ), - ], - 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, + ), + ], + }, + ), + }, + ), + 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, }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 13843, - end: 13966, + id: "i", }, - 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, - }, - ), - ], + ), + Constant( + Constant { + node: Node { + start: 13189, + end: 0, }, - ), - body: [ - Return( - Return { - node: Node { - start: 13922, - end: 13961, - }, - value: Some( - Subscript( - Subscript { - node: Node { - start: 13929, - end: 13961, - }, - value: Name( - Name { - node: Node { - start: 13929, - end: 13945, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13946, - end: 13947, - }, - value: Int( - "2", - ), - }, - ), - }, - ), - ), - }, + value: Str( + "vol", ), - ], - orelse: [], + }, + ), + ], + }, + ), + }, + ), + 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: 13961, + }, + value: Some( + Subscript( + Subscript { + node: Node { + start: 13929, + end: 13961, + }, + value: Name( + Name { + node: Node { + start: 13929, + end: 13945, + }, + id: "symbol_full_info", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 13946, + end: 13947, + }, + value: Int( + "2", + ), + }, + ), + }, + ), + ), + }, + ), + ], + orelse: [], + }, + ), + Return( + Return { + node: Node { + start: 13966, + end: 13977, + }, + value: Some( + Constant( + Constant { + node: Node { + start: 13973, + end: 13977, + }, + value: None, + }, + ), + ), + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + }, + ), + FunctionDef( + FunctionDef { + node: Node { + start: 13980, + end: 15273, + }, + name: "get_symbol_info", + args: Arguments { + node: Node { + start: 14000, + end: 14016, + }, + posonlyargs: [], + args: [ + Arg { + node: Node { + start: 14000, + end: 14016, + }, + arg: "symbol_name", + annotation: Some( + Name( + Name { + node: Node { + start: 14013, + end: 14016, + }, + id: "str", + }, + ), + ), + }, + ], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 14023, + end: 14087, + }, + targets: [ + Name( + Name { + node: Node { + start: 14023, + end: 14026, + }, + id: "url", + }, + ), + ], + value: Call( + Call { + node: Node { + start: 14066, + end: 14087, + }, + func: Attribute( + Attribute { + node: Node { + start: 14029, + end: 14066, + }, + value: Attribute( + Attribute { + node: Node { + start: 14029, + end: 14059, + }, + value: Name( + Name { + node: Node { + start: 14029, + end: 14041, + }, + id: "tse_settings", + }, + ), + attr: "TSE_SYMBOL_ID_URL", + }, + ), + attr: "format", + }, + ), + args: [ + Call( + Call { + node: Node { + start: 14084, + end: 14086, + }, + func: Attribute( + Attribute { + node: Node { + start: 14067, + end: 14084, + }, + value: Name( + Name { + node: Node { + start: 14067, + end: 14078, + }, + 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, }, - ), - Return( - Return { - node: Node { - start: 13966, - end: 13977, - }, - value: Some( - Constant( - Constant { - node: Node { - start: 13973, - end: 13977, - }, - value: None, - }, - ), - ), + id: "symbol_name", + }, + ), + Constant( + Constant { + node: Node { + start: 14290, + end: 0, }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, + 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: 15195, + }, + target: Name( + Name { + node: Node { + start: 14476, + end: 14492, + }, + id: "symbol_full_info", + }, + ), + iter: Name( + Name { + node: Node { + start: 14496, + end: 14503, + }, + id: "symbols", + }, + ), + body: [ + IfStatement( + If { + node: Node { + start: 14513, + end: 14577, + }, + test: Compare( + Compare { + node: Node { + start: 14516, + end: 14546, + }, + left: Call( + Call { + node: Node { + start: 14538, + end: 14540, + }, + func: Attribute( + Attribute { + node: Node { + start: 14516, + end: 14538, + }, + value: Name( + Name { + node: Node { + start: 14516, + end: 14532, + }, + 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: 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: 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", }, ), - FunctionDef( - FunctionDef { + slice: Constant( + Constant { 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: [], + start: 14764, + end: 14765, }, - 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, - }, - ), + 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, }, - ), - ForStatement( - For { + 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: 14472, - end: 15273, + start: 14814, + end: 14821, }, - 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: 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: 14635, - end: 14657, - }, - value: Name( - Name { - node: Node { - start: 14635, - end: 14642, - }, - id: "persian", - }, - ), - attr: "replace_arabic", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 14658, - end: 14677, - }, - value: Name( - Name { - node: Node { - start: 14658, - end: 14674, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 14675, - end: 14676, - }, - value: Int( - "0", - ), - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - Eq, - ], - comparators: [ - Name( - Name { - node: Node { - start: 14682, - end: 14693, - }, - id: "symbol_name", - }, - ), - ], - }, - ), - body: [ - IfStatement( - If { - node: Node { - start: 14744, - end: 15195, - }, - test: Compare( - Compare { - node: Node { - start: 14747, - end: 14773, - }, - left: Subscript( - Subscript { - node: Node { - start: 14747, - end: 14766, - }, - value: Name( - Name { - node: Node { - start: 14747, - end: 14763, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 14764, - end: 14765, - }, - value: Int( - "7", - ), - }, - ), - }, - ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 14770, - end: 14773, - }, - value: Str( - "1", - ), - }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 14791, - end: 14895, - }, - targets: [ - Attribute( - Attribute { - node: Node { - start: 14791, - end: 14811, - }, - value: Name( - Name { - node: Node { - start: 14791, - end: 14804, - }, - id: "market_symbol", - }, - ), - attr: "symbol", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 14836, - end: 14895, - }, - func: Attribute( - Attribute { - node: Node { - start: 14814, - end: 14836, - }, - value: Name( - Name { - node: Node { - start: 14814, - end: 14821, - }, - id: "persian", - }, - ), - attr: "replace_arabic", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 14858, - end: 14877, - }, - value: Name( - Name { - node: Node { - start: 14858, - end: 14874, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 14875, - end: 14876, - }, - value: Int( - "0", - ), - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 14912, - end: 15014, - }, - targets: [ - Attribute( - Attribute { - node: Node { - start: 14912, - end: 14930, - }, - value: Name( - Name { - node: Node { - start: 14912, - end: 14925, - }, - id: "market_symbol", - }, - ), - attr: "name", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 14955, - end: 15014, - }, - func: Attribute( - Attribute { - node: Node { - start: 14933, - end: 14955, - }, - value: Name( - Name { - node: Node { - start: 14933, - end: 14940, - }, - id: "persian", - }, - ), - attr: "replace_arabic", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 14977, - end: 14996, - }, - value: Name( - Name { - node: Node { - start: 14977, - end: 14993, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 14994, - end: 14995, - }, - value: Int( - "1", - ), - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 15031, - end: 15092, - }, - targets: [ - Attribute( - Attribute { - node: Node { - start: 15031, - end: 15050, - }, - value: Name( - Name { - node: Node { - start: 15031, - end: 15044, - }, - id: "market_symbol", - }, - ), - attr: "index", - }, - ), - ], - value: Subscript( - Subscript { - node: Node { - start: 15053, - end: 15092, - }, - value: Name( - Name { - node: Node { - start: 15053, - end: 15069, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 15070, - end: 15071, - }, - value: Int( - "2", - ), - }, - ), - }, - ), - }, - ), - ], - orelse: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 15151, - end: 15189, - }, - func: Attribute( - Attribute { - node: Node { - start: 15127, - end: 15151, - }, - value: Attribute( - Attribute { - node: Node { - start: 15127, - end: 15144, - }, - value: Name( - Name { - node: Node { - start: 15127, - end: 15140, - }, - id: "market_symbol", - }, - ), - attr: "old", - }, - ), - attr: "append", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 15152, - end: 15171, - }, - value: Name( - Name { - node: Node { - start: 15152, - end: 15168, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 15169, - end: 15170, - }, - value: Int( - "2", - ), - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - }, - ), - ], - orelse: [], - }, - ), - 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: [], + id: "persian", }, ), - ], - decorator_list: [], - returns: None, - type_comment: None, - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, + 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, + }, + ), }, ), - ], - decorator_list: [], - returns: Some( - Subscript( - Subscript { + AssignStatement( + Assign { node: Node { - start: 8546, - end: 8569, + start: 14912, + end: 15014, }, - value: Name( - Name { + 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: 8546, - end: 8550, + start: 14955, + end: 15014, }, - id: "Dict", + 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, }, ), - slice: Tuple( - Tuple { - node: Node { - start: 8551, - end: 8569, - }, - elements: [ - Name( + }, + ), + AssignStatement( + Assign { + node: Node { + start: 15031, + end: 15092, + }, + targets: [ + Attribute( + Attribute { + node: Node { + start: 15031, + end: 15050, + }, + value: Name( Name { node: Node { - start: 8551, - end: 8554, + start: 15031, + end: 15044, }, - id: "str", + id: "market_symbol", }, ), - Attribute( + attr: "index", + }, + ), + ], + value: Subscript( + Subscript { + node: Node { + start: 15053, + end: 15092, + }, + value: Name( + Name { + node: Node { + start: 15053, + end: 15069, + }, + id: "symbol_full_info", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 15070, + end: 15071, + }, + value: Int( + "2", + ), + }, + ), + }, + ), + }, + ), + ], + orelse: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 15151, + end: 15189, + }, + func: Attribute( + Attribute { + node: Node { + start: 15127, + end: 15151, + }, + value: Attribute( Attribute { node: Node { - start: 8556, - end: 8568, + start: 15127, + end: 15144, }, value: Name( Name { node: Node { - start: 8556, - end: 8558, + start: 15127, + end: 15140, }, - id: "pd", + id: "market_symbol", }, ), - attr: "DataFrame", + attr: "old", }, ), - ], - }, - ), - }, + attr: "append", + }, + ), + args: [ + Subscript( + Subscript { + node: Node { + start: 15152, + end: 15171, + }, + value: Name( + Name { + node: Node { + start: 15152, + end: 15168, + }, + id: "symbol_full_info", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 15169, + end: 15170, + }, + value: Int( + "2", + ), + }, + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), ), - ), - type_comment: None, + ], }, ), ], @@ -14532,66 +14497,101 @@ Module { }, ), ], + orelse: [], }, ), - ], - decorator_list: [], - returns: Some( - Subscript( - Subscript { + IfStatement( + If { node: Node { - start: 1637, - end: 1660, + start: 15195, + end: 15251, }, - value: Name( - Name { - node: Node { - start: 1637, - end: 1641, - }, - id: "Dict", - }, - ), - slice: Tuple( - Tuple { + test: Compare( + Compare { node: Node { - start: 1642, - end: 1660, + start: 15198, + end: 15225, }, - elements: [ - Name( - Name { - node: Node { - start: 1642, - end: 1645, - }, - id: "str", + left: Attribute( + Attribute { + node: Node { + start: 15198, + end: 15217, }, - ), - Attribute( - Attribute { + value: Name( + Name { + node: Node { + start: 15198, + end: 15211, + }, + id: "market_symbol", + }, + ), + attr: "index", + }, + ), + ops: [ + Is, + ], + comparators: [ + Constant( + Constant { node: Node { - start: 1647, - end: 1659, + start: 15221, + end: 15225, }, - value: Name( - Name { - node: Node { - start: 1647, - end: 1649, - }, - id: "pd", - }, - ), - attr: "DataFrame", + value: None, }, ), ], }, ), + body: [ + Return( + Return { + node: Node { + start: 15235, + end: 15246, + }, + value: Some( + Constant( + Constant { + node: Node { + start: 15242, + end: 15246, + }, + value: None, + }, + ), + ), + }, + ), + ], + orelse: [], }, ), - ), + Return( + Return { + node: Node { + start: 15251, + end: 15271, + }, + value: Some( + Name( + Name { + node: Node { + start: 15258, + end: 15271, + }, + id: "market_symbol", + }, + ), + ), + }, + ), + ], + decorator_list: [], + returns: None, type_comment: None, }, ), diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@try.py.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@try.py.snap index 43369a02..9e4c39db 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@try.py.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@try.py.snap @@ -1,12 +1,12 @@ --- source: parser/src/parser/parser.rs -description: "# in some cases last price or adj price is undefined\ntry:\n last_price = int(price_section[2])\n# when instead of number value is `F`\nexcept (ValueError, IndexError):\n last_price = None\ntry:\n adj_close = int(price_section[3])\nexcept (ValueError, IndexError):\n adj_close = None\ntry:\n market_cap = adj_close * self.total_shares\nexcept ValueError:\n market_cap = None\n\n" +description: "# in some cases last price or adj price is undefined\ntry:\n last_price = int(price_section[2])\n# when instead of number value is `F`\nexcept (ValueError, IndexError):\n last_price = None\ntry:\n adj_close = int(price_section[3])\nexcept (ValueError, IndexError):\n adj_close = None\ntry:\n market_cap = adj_close * self.total_shares\nexcept ValueError:\n market_cap = None\n\n\ntry:\n async with session.get(\n url, headers=TRADE_DETAILS_HEADER, timeout=100\n ) as response:\n if response.status == 503:\n logger.info(\n f\"Received 503 Service Unavailable on {date_obj}. Retrying...\"\n )\n retry_count += 1\n await asyncio.sleep(1)\n else:\n response.raise_for_status()\n data = await response.json()\n logger.info(\n f\"Successfully fetched trade details on {date_obj} from tse\"\n )\n return [date_obj, pd.json_normalize(data[\"tradeHistory\"])]\nexcept (aiohttp.ClientError, asyncio.TimeoutError):\n logger.error(f\"Request failed for {date_obj}. Retrying...\")\n retry_count += 1\n await asyncio.sleep(1)\n" input_file: parser/test_data/inputs/try.py --- Module { node: Node { start: 0, - end: 381, + end: 1152, }, body: [ TryStatement( @@ -313,7 +313,7 @@ Module { Try { node: Node { start: 287, - end: 381, + end: 382, }, body: [ AssignStatement( @@ -376,7 +376,7 @@ Module { ExceptHandler { node: Node { start: 339, - end: 381, + end: 382, }, typ: Some( Name( @@ -426,5 +426,799 @@ Module { finalbody: [], }, ), + TryStatement( + Try { + node: Node { + start: 382, + end: 1152, + }, + body: [ + AsyncWithStatement( + AsyncWith { + node: Node { + start: 391, + end: 988, + }, + items: [ + WithItem { + node: Node { + start: 402, + end: 487, + }, + context_expr: Call( + Call { + node: Node { + start: 413, + end: 475, + }, + func: Attribute( + Attribute { + node: Node { + start: 402, + end: 413, + }, + value: Name( + Name { + node: Node { + start: 402, + end: 409, + }, + id: "session", + }, + ), + attr: "get", + }, + ), + args: [ + Name( + Name { + node: Node { + start: 423, + end: 426, + }, + id: "url", + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 428, + end: 456, + }, + arg: Some( + "headers", + ), + value: Name( + Name { + node: Node { + start: 436, + end: 456, + }, + id: "TRADE_DETAILS_HEADER", + }, + ), + }, + Keyword { + node: Node { + start: 458, + end: 469, + }, + arg: Some( + "timeout", + ), + value: Constant( + Constant { + node: Node { + start: 466, + end: 469, + }, + value: Int( + "100", + ), + }, + ), + }, + ], + starargs: None, + kwargs: None, + }, + ), + optional_vars: Some( + Name( + Name { + node: Node { + start: 479, + end: 487, + }, + id: "response", + }, + ), + ), + }, + ], + body: [ + IfStatement( + If { + node: Node { + start: 497, + end: 988, + }, + test: Compare( + Compare { + node: Node { + start: 500, + end: 522, + }, + left: Attribute( + Attribute { + node: Node { + start: 500, + end: 515, + }, + value: Name( + Name { + node: Node { + start: 500, + end: 508, + }, + id: "response", + }, + ), + attr: "status", + }, + ), + ops: [ + Eq, + ], + comparators: [ + Constant( + Constant { + node: Node { + start: 519, + end: 522, + }, + value: Int( + "503", + ), + }, + ), + ], + }, + ), + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 547, + end: 641, + }, + func: Attribute( + Attribute { + node: Node { + start: 536, + end: 547, + }, + value: Name( + Name { + node: Node { + start: 536, + end: 542, + }, + id: "logger", + }, + ), + attr: "info", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 565, + end: 627, + }, + values: [ + Constant( + Constant { + node: Node { + start: 603, + end: 0, + }, + value: Str( + "Received 503 Service Unavailable on ", + ), + }, + ), + Name( + Name { + node: Node { + start: 604, + end: 612, + }, + id: "date_obj", + }, + ), + Constant( + Constant { + node: Node { + start: 626, + end: 0, + }, + value: Str( + ". Retrying...", + ), + }, + ), + ], + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + AugAssignStatement( + AugAssign { + node: Node { + start: 654, + end: 670, + }, + target: Name( + Name { + node: Node { + start: 654, + end: 665, + }, + id: "retry_count", + }, + ), + op: Add, + value: Constant( + Constant { + node: Node { + start: 669, + end: 670, + }, + value: Int( + "1", + ), + }, + ), + }, + ), + ExpressionStatement( + Await( + Await { + node: Node { + start: 683, + end: 705, + }, + value: Call( + Call { + node: Node { + start: 702, + end: 705, + }, + func: Attribute( + Attribute { + node: Node { + start: 689, + end: 702, + }, + value: Name( + Name { + node: Node { + start: 689, + end: 696, + }, + id: "asyncio", + }, + ), + attr: "sleep", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 703, + end: 704, + }, + value: Int( + "1", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ), + ], + orelse: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 757, + end: 759, + }, + func: Attribute( + Attribute { + node: Node { + start: 732, + end: 757, + }, + value: Name( + Name { + node: Node { + start: 732, + end: 740, + }, + id: "response", + }, + ), + attr: "raise_for_status", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + AssignStatement( + Assign { + node: Node { + start: 772, + end: 800, + }, + targets: [ + Name( + Name { + node: Node { + start: 772, + end: 776, + }, + id: "data", + }, + ), + ], + value: Await( + Await { + node: Node { + start: 779, + end: 800, + }, + value: Call( + Call { + node: Node { + start: 798, + end: 800, + }, + func: Attribute( + Attribute { + node: Node { + start: 785, + end: 798, + }, + value: Name( + Name { + node: Node { + start: 785, + end: 793, + }, + id: "response", + }, + ), + attr: "json", + }, + ), + args: [], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + }, + ), + ExpressionStatement( + Call( + Call { + node: Node { + start: 824, + end: 916, + }, + func: Attribute( + Attribute { + node: Node { + start: 813, + end: 824, + }, + value: Name( + Name { + node: Node { + start: 813, + end: 819, + }, + id: "logger", + }, + ), + attr: "info", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 842, + end: 902, + }, + values: [ + Constant( + Constant { + node: Node { + start: 882, + end: 0, + }, + value: Str( + "Successfully fetched trade details on ", + ), + }, + ), + Name( + Name { + node: Node { + start: 883, + end: 891, + }, + id: "date_obj", + }, + ), + Constant( + Constant { + node: Node { + start: 901, + end: 0, + }, + value: Str( + " from tse", + ), + }, + ), + ], + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + Return( + Return { + node: Node { + start: 929, + end: 987, + }, + value: Some( + List( + List { + node: Node { + start: 936, + end: 987, + }, + elements: [ + Name( + Name { + node: Node { + start: 937, + end: 945, + }, + id: "date_obj", + }, + ), + Call( + Call { + node: Node { + start: 964, + end: 986, + }, + func: Attribute( + Attribute { + node: Node { + start: 947, + end: 964, + }, + value: Name( + Name { + node: Node { + start: 947, + end: 949, + }, + id: "pd", + }, + ), + attr: "json_normalize", + }, + ), + args: [ + Subscript( + Subscript { + node: Node { + start: 965, + end: 985, + }, + value: Name( + Name { + node: Node { + start: 965, + end: 969, + }, + id: "data", + }, + ), + slice: Constant( + Constant { + node: Node { + start: 970, + end: 984, + }, + value: Str( + "tradeHistory", + ), + }, + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ], + }, + ), + ), + }, + ), + ], + }, + ), + ], + }, + ), + ], + handlers: [ + ExceptHandler { + node: Node { + start: 988, + end: 1152, + }, + typ: Some( + Tuple( + Tuple { + node: Node { + start: 995, + end: 1037, + }, + elements: [ + Attribute( + Attribute { + node: Node { + start: 996, + end: 1015, + }, + value: Name( + Name { + node: Node { + start: 996, + end: 1003, + }, + id: "aiohttp", + }, + ), + attr: "ClientError", + }, + ), + Attribute( + Attribute { + node: Node { + start: 1017, + end: 1037, + }, + value: Name( + Name { + node: Node { + start: 1017, + end: 1024, + }, + id: "asyncio", + }, + ), + attr: "TimeoutError", + }, + ), + ], + }, + ), + ), + name: None, + body: [ + ExpressionStatement( + Call( + Call { + node: Node { + start: 1056, + end: 1103, + }, + func: Attribute( + Attribute { + node: Node { + start: 1044, + end: 1056, + }, + value: Name( + Name { + node: Node { + start: 1044, + end: 1050, + }, + id: "logger", + }, + ), + attr: "error", + }, + ), + args: [ + JoinedStr( + JoinedStr { + node: Node { + start: 1057, + end: 1102, + }, + values: [ + Constant( + Constant { + node: Node { + start: 1078, + end: 0, + }, + value: Str( + "Request failed for ", + ), + }, + ), + Name( + Name { + node: Node { + start: 1079, + end: 1087, + }, + id: "date_obj", + }, + ), + Constant( + Constant { + node: Node { + start: 1101, + end: 0, + }, + value: Str( + ". Retrying...", + ), + }, + ), + ], + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + ), + AugAssignStatement( + AugAssign { + node: Node { + start: 1108, + end: 1124, + }, + target: Name( + Name { + node: Node { + start: 1108, + end: 1119, + }, + id: "retry_count", + }, + ), + op: Add, + value: Constant( + Constant { + node: Node { + start: 1123, + end: 1124, + }, + value: Int( + "1", + ), + }, + ), + }, + ), + ExpressionStatement( + Await( + Await { + node: Node { + start: 1129, + end: 1151, + }, + value: Call( + Call { + node: Node { + start: 1148, + end: 1151, + }, + func: Attribute( + Attribute { + node: Node { + start: 1135, + end: 1148, + }, + value: Name( + Name { + node: Node { + start: 1135, + end: 1142, + }, + id: "asyncio", + }, + ), + attr: "sleep", + }, + ), + args: [ + Constant( + Constant { + node: Node { + start: 1149, + end: 1150, + }, + value: Int( + "1", + ), + }, + ), + ], + keywords: [], + starargs: None, + kwargs: None, + }, + ), + }, + ), + ), + ], + }, + ], + orelse: [], + finalbody: [], + }, + ), ], } diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-10.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-10.snap new file mode 100644 index 00000000..f647bc3a --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-10.snap @@ -0,0 +1,122 @@ +--- +source: parser/src/parser/parser.rs +description: "di = {1: \"name\", **{2: \"name2\"}, 3: \"name3\"}\n" +input_file: parser/test_data/inputs/one_liners/dict.py +--- +Module { + node: Node { + start: 0, + end: 45, + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 0, + end: 44, + }, + targets: [ + Name( + Name { + node: Node { + start: 0, + end: 2, + }, + id: "di", + }, + ), + ], + value: Dict( + Dict { + node: Node { + start: 5, + end: 44, + }, + keys: [ + Constant( + Constant { + node: Node { + start: 6, + end: 7, + }, + value: Int( + "1", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 33, + end: 34, + }, + value: Int( + "3", + ), + }, + ), + ], + values: [ + Constant( + Constant { + node: Node { + start: 9, + end: 15, + }, + value: Str( + "name", + ), + }, + ), + Dict( + Dict { + node: Node { + start: 19, + end: 31, + }, + keys: [ + Constant( + Constant { + node: Node { + start: 20, + end: 21, + }, + value: Int( + "2", + ), + }, + ), + ], + values: [ + Constant( + Constant { + node: Node { + start: 23, + end: 30, + }, + value: Str( + "name2", + ), + }, + ), + ], + }, + ), + Constant( + Constant { + node: Node { + start: 36, + end: 43, + }, + value: Str( + "name3", + ), + }, + ), + ], + }, + ), + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-8.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-8.snap index 6af46f8d..20f13444 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-8.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-8.snap @@ -1,12 +1,12 @@ --- source: parser/src/parser/parser.rs -description: "{1: \"name\" for name in get_names()\n}\n" +description: "{1: \"name\" for name in get_names()\n}" input_file: parser/test_data/inputs/one_liners/dict.py --- Module { node: Node { start: 0, - end: 37, + end: 36, }, body: [ ExpressionStatement( diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap new file mode 100644 index 00000000..7a262209 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@dict.py-9.snap @@ -0,0 +1,137 @@ +--- +source: parser/src/parser/parser.rs +description: "aggregated_key_stats[idx_stat] = {\n **filter_value_NONE,\n **filter_key_found,\n **client_types,\n **market_watch,\n \"symbol\": symbol,\n \"name\": name,\n}" +input_file: parser/test_data/inputs/one_liners/dict.py +--- +Module { + node: Node { + start: 0, + end: 165, + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 0, + end: 165, + }, + targets: [ + Subscript( + Subscript { + node: Node { + start: 0, + end: 30, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 20, + }, + id: "aggregated_key_stats", + }, + ), + slice: Name( + Name { + node: Node { + start: 21, + end: 29, + }, + id: "idx_stat", + }, + ), + }, + ), + ], + value: Dict( + Dict { + node: Node { + start: 33, + end: 165, + }, + keys: [ + Constant( + Constant { + node: Node { + start: 128, + end: 136, + }, + value: Str( + "symbol", + ), + }, + ), + Constant( + Constant { + node: Node { + start: 150, + end: 156, + }, + value: Str( + "name", + ), + }, + ), + ], + values: [ + Name( + Name { + node: Node { + start: 41, + end: 58, + }, + id: "filter_value_NONE", + }, + ), + Name( + Name { + node: Node { + start: 66, + end: 82, + }, + id: "filter_key_found", + }, + ), + Name( + Name { + node: Node { + start: 90, + end: 102, + }, + id: "client_types", + }, + ), + Name( + Name { + node: Node { + start: 110, + end: 122, + }, + id: "market_watch", + }, + ), + Name( + Name { + node: Node { + start: 138, + end: 144, + }, + id: "symbol", + }, + ), + Name( + Name { + node: Node { + start: 158, + end: 162, + }, + id: "name", + }, + ), + ], + }, + ), + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-10.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-10.snap new file mode 100644 index 00000000..e6effe04 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-10.snap @@ -0,0 +1,53 @@ +--- +source: parser/src/parser/parser.rs +description: "a[::d,]\n" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 8, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 7, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 2, + end: 5, + }, + lower: None, + upper: Some( + Name( + Name { + node: Node { + start: 4, + end: 5, + }, + id: "d", + }, + ), + ), + step: None, + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-11.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-11.snap new file mode 100644 index 00000000..a488b6fd --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-11.snap @@ -0,0 +1,101 @@ +--- +source: parser/src/parser/parser.rs +description: "a[b, c:d:e, f]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 14, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 14, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 2, + end: 14, + }, + elements: [ + Name( + Name { + node: Node { + start: 2, + end: 3, + }, + id: "b", + }, + ), + Slice( + Slice { + node: Node { + start: 6, + end: 10, + }, + lower: Some( + Name( + Name { + node: Node { + start: 5, + end: 6, + }, + id: "c", + }, + ), + ), + upper: Some( + Name( + Name { + node: Node { + start: 7, + end: 8, + }, + id: "d", + }, + ), + ), + step: Some( + Name( + Name { + node: Node { + start: 9, + end: 10, + }, + id: "e", + }, + ), + ), + }, + ), + Name( + Name { + node: Node { + start: 12, + end: 13, + }, + id: "f", + }, + ), + ], + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-12.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-12.snap new file mode 100644 index 00000000..e6effe04 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-12.snap @@ -0,0 +1,53 @@ +--- +source: parser/src/parser/parser.rs +description: "a[::d,]\n" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 8, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 7, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 2, + end: 5, + }, + lower: None, + upper: Some( + Name( + Name { + node: Node { + start: 4, + end: 5, + }, + id: "d", + }, + ), + ), + step: None, + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-2.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-2.snap new file mode 100644 index 00000000..d19e5558 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-2.snap @@ -0,0 +1,84 @@ +--- +source: parser/src/parser/parser.rs +description: "values = list_of_key_stats[1::2]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 32, + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 0, + end: 32, + }, + targets: [ + Name( + Name { + node: Node { + start: 0, + end: 6, + }, + id: "values", + }, + ), + ], + value: Subscript( + Subscript { + node: Node { + start: 9, + end: 32, + }, + value: Name( + Name { + node: Node { + start: 9, + end: 26, + }, + id: "list_of_key_stats", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 28, + end: 31, + }, + lower: Some( + Constant( + Constant { + node: Node { + start: 27, + end: 28, + }, + value: Int( + "1", + ), + }, + ), + ), + upper: None, + step: Some( + Constant( + Constant { + node: Node { + start: 30, + end: 31, + }, + value: Int( + "2", + ), + }, + ), + ), + }, + ), + }, + ), + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-3.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-3.snap new file mode 100644 index 00000000..8302210f --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-3.snap @@ -0,0 +1,41 @@ +--- +source: parser/src/parser/parser.rs +description: "a[b]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 4, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 4, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Name( + Name { + node: Node { + start: 2, + end: 3, + }, + id: "b", + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-4.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-4.snap new file mode 100644 index 00000000..9b8cd4c2 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-4.snap @@ -0,0 +1,63 @@ +--- +source: parser/src/parser/parser.rs +description: "a[b:c]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 6, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 6, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 3, + end: 5, + }, + lower: Some( + Name( + Name { + node: Node { + start: 2, + end: 3, + }, + id: "b", + }, + ), + ), + upper: Some( + Name( + Name { + node: Node { + start: 4, + end: 5, + }, + id: "c", + }, + ), + ), + step: None, + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-5.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-5.snap new file mode 100644 index 00000000..b57c0ba9 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-5.snap @@ -0,0 +1,73 @@ +--- +source: parser/src/parser/parser.rs +description: "a[b:c:d]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 8, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 8, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 3, + end: 7, + }, + lower: Some( + Name( + Name { + node: Node { + start: 2, + end: 3, + }, + id: "b", + }, + ), + ), + upper: Some( + Name( + Name { + node: Node { + start: 4, + end: 5, + }, + id: "c", + }, + ), + ), + step: Some( + Name( + Name { + node: Node { + start: 6, + end: 7, + }, + id: "d", + }, + ), + ), + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-6.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-6.snap new file mode 100644 index 00000000..24106aee --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-6.snap @@ -0,0 +1,69 @@ +--- +source: parser/src/parser/parser.rs +description: "a[b, c, d]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 10, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 10, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 2, + end: 10, + }, + elements: [ + Name( + Name { + node: Node { + start: 2, + end: 3, + }, + id: "b", + }, + ), + Name( + Name { + node: Node { + start: 5, + end: 6, + }, + id: "c", + }, + ), + Name( + Name { + node: Node { + start: 8, + end: 9, + }, + id: "d", + }, + ), + ], + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-7.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-7.snap new file mode 100644 index 00000000..3c58f61c --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-7.snap @@ -0,0 +1,91 @@ +--- +source: parser/src/parser/parser.rs +description: "a[b, c: d, e]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 13, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 13, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 2, + end: 13, + }, + elements: [ + Name( + Name { + node: Node { + start: 2, + end: 3, + }, + id: "b", + }, + ), + Slice( + Slice { + node: Node { + start: 6, + end: 9, + }, + lower: Some( + Name( + Name { + node: Node { + start: 5, + end: 6, + }, + id: "c", + }, + ), + ), + upper: Some( + Name( + Name { + node: Node { + start: 8, + end: 9, + }, + id: "d", + }, + ), + ), + step: None, + }, + ), + Name( + Name { + node: Node { + start: 11, + end: 12, + }, + id: "e", + }, + ), + ], + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-8.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-8.snap new file mode 100644 index 00000000..097bd0b1 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-8.snap @@ -0,0 +1,43 @@ +--- +source: parser/src/parser/parser.rs +description: "a[::]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 5, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 5, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 2, + end: 4, + }, + lower: None, + upper: None, + step: None, + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-9.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-9.snap new file mode 100644 index 00000000..a488b6fd --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py-9.snap @@ -0,0 +1,101 @@ +--- +source: parser/src/parser/parser.rs +description: "a[b, c:d:e, f]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 14, + }, + body: [ + ExpressionStatement( + Subscript( + Subscript { + node: Node { + start: 0, + end: 14, + }, + value: Name( + Name { + node: Node { + start: 0, + end: 1, + }, + id: "a", + }, + ), + slice: Tuple( + Tuple { + node: Node { + start: 2, + end: 14, + }, + elements: [ + Name( + Name { + node: Node { + start: 2, + end: 3, + }, + id: "b", + }, + ), + Slice( + Slice { + node: Node { + start: 6, + end: 10, + }, + lower: Some( + Name( + Name { + node: Node { + start: 5, + end: 6, + }, + id: "c", + }, + ), + ), + upper: Some( + Name( + Name { + node: Node { + start: 7, + end: 8, + }, + id: "d", + }, + ), + ), + step: Some( + Name( + Name { + node: Node { + start: 9, + end: 10, + }, + id: "e", + }, + ), + ), + }, + ), + Name( + Name { + node: Node { + start: 12, + end: 13, + }, + id: "f", + }, + ), + ], + }, + ), + }, + ), + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py.snap new file mode 100644 index 00000000..20c87811 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@subscript.py.snap @@ -0,0 +1,84 @@ +--- +source: parser/src/parser/parser.rs +description: "indices = list_of_key_stats[0::2]" +input_file: parser/test_data/inputs/one_liners/subscript.py +--- +Module { + node: Node { + start: 0, + end: 33, + }, + body: [ + AssignStatement( + Assign { + node: Node { + start: 0, + end: 33, + }, + targets: [ + Name( + Name { + node: Node { + start: 0, + end: 7, + }, + id: "indices", + }, + ), + ], + value: Subscript( + Subscript { + node: Node { + start: 10, + end: 33, + }, + value: Name( + Name { + node: Node { + start: 10, + end: 27, + }, + id: "list_of_key_stats", + }, + ), + slice: Slice( + Slice { + node: Node { + start: 29, + end: 32, + }, + lower: Some( + Constant( + Constant { + node: Node { + start: 28, + end: 29, + }, + value: Int( + "0", + ), + }, + ), + ), + upper: None, + step: Some( + Constant( + Constant { + node: Node { + start: 31, + end: 32, + }, + value: Int( + "2", + ), + }, + ), + ), + }, + ), + }, + ), + }, + ), + ], +} diff --git a/parser/test_data/inputs/one_liners/dict.py b/parser/test_data/inputs/one_liners/dict.py index d4c3d54b..8e332403 100644 --- a/parser/test_data/inputs/one_liners/dict.py +++ b/parser/test_data/inputs/one_liners/dict.py @@ -19,3 +19,14 @@ {1: "name" for name in get_names() } + +aggregated_key_stats[idx_stat] = { + **filter_value_NONE, + **filter_key_found, + **client_types, + **market_watch, + "symbol": symbol, + "name": name, +} + +di = {1: "name", **{2: "name2"}, 3: "name3"} diff --git a/parser/test_data/inputs/one_liners/subscript.py b/parser/test_data/inputs/one_liners/subscript.py new file mode 100644 index 00000000..c9679902 --- /dev/null +++ b/parser/test_data/inputs/one_liners/subscript.py @@ -0,0 +1,19 @@ +indices = list_of_key_stats[0::2] + +values = list_of_key_stats[1::2] + +a[b] + +a[b:c] + +a[b:c:d] + +a[b, c, d] + +a[b, c: d, e] + +a[::] + +a[b, c:d:e, f] + +a[::d,] diff --git a/parser/test_data/inputs/try.py b/parser/test_data/inputs/try.py index d6aeb892..455ceab4 100644 --- a/parser/test_data/inputs/try.py +++ b/parser/test_data/inputs/try.py @@ -13,3 +13,25 @@ except ValueError: market_cap = None + +try: + async with session.get( + url, headers=TRADE_DETAILS_HEADER, timeout=100 + ) as response: + if response.status == 503: + logger.info( + f"Received 503 Service Unavailable on {date_obj}. Retrying..." + ) + retry_count += 1 + await asyncio.sleep(1) + else: + response.raise_for_status() + data = await response.json() + logger.info( + f"Successfully fetched trade details on {date_obj} from tse" + ) + return [date_obj, pd.json_normalize(data["tradeHistory"])] +except (aiohttp.ClientError, asyncio.TimeoutError): + logger.error(f"Request failed for {date_obj}. Retrying...") + retry_count += 1 + await asyncio.sleep(1)