diff --git a/src/DataCache_v2.py b/src/DataCache_v2.py index 1bbc460..d8f0a74 100644 --- a/src/DataCache_v2.py +++ b/src/DataCache_v2.py @@ -157,11 +157,13 @@ class DataCache: result = fetch_method(**kwargs) if not result.empty: - combined_data = pd.concat([combined_data, result]).drop_duplicates() + # Drop the 'id' column if it exists in the result + if 'id' in result.columns: + result = result.drop(columns=['id']) - if not combined_data.empty and 'open_time' in combined_data.columns: - combined_data = combined_data.sort_values(by='open_time').drop_duplicates(subset='open_time', - keep='first') + # Concatenate, drop duplicates based on 'open_time', and sort + combined_data = pd.concat([combined_data, result]).drop_duplicates(subset='open_time').sort_values( + by='open_time') is_complete, request_criteria = self.data_complete(combined_data, **request_criteria) if is_complete: diff --git a/src/static/Strategies.js b/src/static/Strategies.js index 5fce3d6..e5c1712 100644 --- a/src/static/Strategies.js +++ b/src/static/Strategies.js @@ -7,7 +7,24 @@ class Strategies { this.target_id = target_id; // The html element that displays the the strategies. this.target = null; + } + createWorkspace() { + // Dispose of the existing workspace before creating a new one + if (this.workspace) {this.workspace.dispose();} + this.workspace = Blockly.inject('blocklyDiv', { + toolbox: document.getElementById('toolbox'), + scrollbars: true, + trashcan: true, + }); + + } + generateStrategyJson() { + var code = Blockly.JavaScript.workspaceToCode(this.workspace); + var json = { + strategy: code + }; + return JSON.stringify(json); } // Call to display Create new signal dialog. open_form() { document.getElementById("new_strat_form").style.display = "grid"; } @@ -114,7 +131,7 @@ class Strategies { } open_stg_form(){ this.open_form(); - this.fill_field('strat_opt', 'in-out'); + this.createWorkspace() } clear_innerHTML(el){ el.innerHTML=""; diff --git a/src/templates/index.html b/src/templates/index.html index 36d6982..8cdab63 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -1,10 +1,14 @@ + + {{ title }} + +