Fixed an issue inserting candles into the database. I realized I want to get rid of the id column in the market(candles) tables. Began integrating Blockly into the client.
This commit is contained in:
parent
439c852cf5
commit
fc407708ba
|
|
@ -157,11 +157,13 @@ class DataCache:
|
||||||
result = fetch_method(**kwargs)
|
result = fetch_method(**kwargs)
|
||||||
|
|
||||||
if not result.empty:
|
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:
|
# Concatenate, drop duplicates based on 'open_time', and sort
|
||||||
combined_data = combined_data.sort_values(by='open_time').drop_duplicates(subset='open_time',
|
combined_data = pd.concat([combined_data, result]).drop_duplicates(subset='open_time').sort_values(
|
||||||
keep='first')
|
by='open_time')
|
||||||
|
|
||||||
is_complete, request_criteria = self.data_complete(combined_data, **request_criteria)
|
is_complete, request_criteria = self.data_complete(combined_data, **request_criteria)
|
||||||
if is_complete:
|
if is_complete:
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,24 @@ class Strategies {
|
||||||
this.target_id = target_id;
|
this.target_id = target_id;
|
||||||
// The html element that displays the the strategies.
|
// The html element that displays the the strategies.
|
||||||
this.target = null;
|
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.
|
// Call to display Create new signal dialog.
|
||||||
open_form() { document.getElementById("new_strat_form").style.display = "grid"; }
|
open_form() { document.getElementById("new_strat_form").style.display = "grid"; }
|
||||||
|
|
@ -114,7 +131,7 @@ class Strategies {
|
||||||
}
|
}
|
||||||
open_stg_form(){
|
open_stg_form(){
|
||||||
this.open_form();
|
this.open_form();
|
||||||
this.fill_field('strat_opt', 'in-out');
|
this.createWorkspace()
|
||||||
}
|
}
|
||||||
clear_innerHTML(el){
|
clear_innerHTML(el){
|
||||||
el.innerHTML="";
|
el.innerHTML="";
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<link rel="icon" href="{{ url_for('static', filename='brightertrades_favicon.ico') }}" type="image/x-icon">
|
||||||
|
|
||||||
<!-- Load style sheets and set the title -->
|
<!-- Load style sheets and set the title -->
|
||||||
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='brighterStyles.css') }}">
|
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='brighterStyles.css') }}">
|
||||||
<title>{{ title }}</title>
|
<title>{{ title }}</title>
|
||||||
<!-- Load lightweight charts -->
|
<!-- Load lightweight charts -->
|
||||||
<script src="{{ url_for('static', filename='lightweight-charts.standalone.production.js') }}"></script>
|
<script src="{{ url_for('static', filename='lightweight-charts.standalone.production.js') }}"></script>
|
||||||
|
<!-- Load Blockly -->
|
||||||
|
<script src="https://unpkg.com/blockly/blockly.min.js"></script>
|
||||||
<!-- The server passed initiation data to the HTML. This loads it into the DOM. -->
|
<!-- The server passed initiation data to the HTML. This loads it into the DOM. -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function get_init_data(vars) {return vars}
|
function get_init_data(vars) {return vars}
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,16 @@
|
||||||
<div class="form-popup" id="new_strat_form">
|
<div class="form-popup" id="new_strat_form" style="overflow: auto;">
|
||||||
<form action="/new_strategy" class="form-container">
|
<form action="/new_strategy" class="form-container" style="display: grid; grid-template-columns: 1fr; grid-template-rows: auto;">
|
||||||
<!-- Panel 1 of 1 (5 rows, 2 columns) -->
|
<!-- Panel 1 of 1 (5 rows, 2 columns) -->
|
||||||
<div id="strat_pan_1" class="form_panels" style="grid-template-columns:repeat(2,1fr);grid-template-rows: repeat(5,1fr);">
|
<div id="strat_pan_1" class="form_panels" style="display: grid; grid-template-columns:repeat(2,1fr); grid-template-rows: repeat(5,1fr); gap: 10px;">
|
||||||
|
|
||||||
<!-- Panel title (row 1/5)-->
|
<!-- Panel title (row 1/5)-->
|
||||||
<h1 style="grid-column: 1 / span 2; grid-row: 1;">Create New Strategy</h1>
|
<h1 style="grid-column: 1 / span 2; grid-row: 1;">Create New Strategy</h1>
|
||||||
<!-- Name Input field (row 2/5)-->
|
|
||||||
<div id = "strat_name_div" style="grid-column: 1 / span 2; grid_row:2;">
|
<!-- Workspace (row 2-4/5)-->
|
||||||
<label for='stg_name' >Strategy Name:</label>
|
<div id="blocklyDiv" style="grid-column: 1 / span 2; grid-row: 2 / span 3; height: 300px; width: 100%;"></div>
|
||||||
<input type="text" id="stg_name" name="strat_name" />
|
|
||||||
</div>
|
<!-- Buttons (row 5/5)-->
|
||||||
<!-- Source Input field (row 3/5)-->
|
<div style="grid-column: 1 / span 2; grid-row: 5; text-align: center;">
|
||||||
<label for="strat_type" style="grid-column: 1; grid-row: 3;"><b>Strategy type</b></label>
|
|
||||||
<select name="strat_type" id="strat_type" style="grid-column: 2; grid-row: 3;" onchange= "UI.strats.fill_field('strat_opt', this.value)">
|
|
||||||
<option>in-out</option>
|
|
||||||
<option>incremental_profits</option>
|
|
||||||
<option>swing</option>
|
|
||||||
</select>
|
|
||||||
<div id="strat_opt"></div>
|
|
||||||
<div style="grid-column: 1 / span 2; grid-row: 5;">
|
|
||||||
<button type="button" class="btn cancel" onclick="UI.strats.close_form()">Close</button>
|
<button type="button" class="btn cancel" onclick="UI.strats.close_form()">Close</button>
|
||||||
<button type="button" class="btn next" onclick="UI.strats.submit()">Create Strategy</button>
|
<button type="button" class="btn next" onclick="UI.strats.submit()">Create Strategy</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -25,3 +18,42 @@
|
||||||
</div><!----End panel 1--------->
|
</div><!----End panel 1--------->
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<xml id="toolbox" style="display: none">
|
||||||
|
<!-- Define your custom blocks here -->
|
||||||
|
<category name="Logic" colour="210">
|
||||||
|
<block type="controls_if"></block>
|
||||||
|
<block type="logic_compare"></block>
|
||||||
|
</category>
|
||||||
|
<category name="Math" colour="230">
|
||||||
|
<block type="math_number"></block>
|
||||||
|
<block type="math_arithmetic"></block>
|
||||||
|
</category>
|
||||||
|
<!-- Add more blocks as needed -->
|
||||||
|
</xml>
|
||||||
|
|
||||||
|
<!-- <form action="/new_strategy" class="form-container">-->
|
||||||
|
<!-- <!– Panel 1 of 1 (5 rows, 2 columns) –>-->
|
||||||
|
<!-- <div id="strat_pan_1" class="form_panels" style="grid-template-columns:repeat(2,1fr);grid-template-rows: repeat(5,1fr);">-->
|
||||||
|
<!-- <!– Panel title (row 1/5)–>-->
|
||||||
|
<!-- <h1 style="grid-column: 1 / span 2; grid-row: 1;">Create New Strategy</h1>-->
|
||||||
|
<!-- <!– Name Input field (row 2/5)–>-->
|
||||||
|
<!-- <div id = "strat_name_div" style="grid-column: 1 / span 2; grid_row:2;">-->
|
||||||
|
<!-- <label for='stg_name' >Strategy Name:</label>-->
|
||||||
|
<!-- <input type="text" id="stg_name" name="strat_name" />-->
|
||||||
|
<!-- </div>-->
|
||||||
|
<!-- <!– Source Input field (row 3/5)–>-->
|
||||||
|
<!-- <label for="strat_type" style="grid-column: 1; grid-row: 3;"><b>Strategy type</b></label>-->
|
||||||
|
<!-- <select name="strat_type" id="strat_type" style="grid-column: 2; grid-row: 3;" onchange= "UI.strats.fill_field('strat_opt', this.value)">-->
|
||||||
|
<!-- <option>in-out</option>-->
|
||||||
|
<!-- <option>incremental_profits</option>-->
|
||||||
|
<!-- <option>swing</option>-->
|
||||||
|
<!-- </select>-->
|
||||||
|
<!-- <div id="strat_opt"></div>-->
|
||||||
|
<!-- <div style="grid-column: 1 / span 2; grid-row: 5;">-->
|
||||||
|
<!-- <button type="button" class="btn cancel" onclick="UI.strats.close_form()">Close</button>-->
|
||||||
|
<!-- <button type="button" class="btn next" onclick="UI.strats.submit()">Create Strategy</button>-->
|
||||||
|
<!-- </div>-->
|
||||||
|
|
||||||
|
<!-- </div><!–--End panel 1-------–>-->
|
||||||
|
<!-- </form>-->
|
||||||
Loading…
Reference in New Issue