Skip to content

Commit

Permalink
Merge pull request #1126 from Drakkar-Software/dev
Browse files Browse the repository at this point in the history
Dev merge
  • Loading branch information
GuillaumeDSM authored Dec 15, 2023
2 parents 494569f + d953ed7 commit 50a9007
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 25 deletions.
1 change: 1 addition & 0 deletions Services/Interfaces/web_interface/static/js/common/cst.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const profitability_update_interval = 5000;
const portfolio_update_interval = 60000;

const mobile_width_breakpoint = 1024;
const medium_width_breakpoint = 1400;

const material_colors = ["#2962ff", "#00b8d4", "#00c853", "#aeea00", "#ffab00",
"#dd2c00", "#d50000", "#6200ea"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function create_doughnut_chart(element, data, title, fontColor='white', animate=
});
}

function create_line_chart(element, data, title, fontColor='white', update=true){
function create_line_chart(element, data, title, fontColor='white', update=true, height=undefined){
const trace = {
x: data.map((e) => new Date(e.time*1000)),
y: data.map((e) => e.value),
Expand All @@ -105,6 +105,7 @@ function create_line_chart(element, data, title, fontColor='white', update=true)
const minDisplayY = Math.max(0, minY - ((maxDisplayY - minY) / 2));
const layout = {
title: title,
height: height,
dragmode: isMobileDisplay() ? false : 'zoom',
margin: {
l: 30,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ $(document).ready(function() {
const success = (updated_data, update_url, dom_root_element, msg, status) => {
const graphDiv = $(`#profitability_graph`);
const defaultDiv = $(`#no_profitability_graph`);
const height = isMobileDisplay()? 250 : isMediumDisplay() ? 450 : undefined;
if(msg.length > 1){
graphDiv.removeClass(hidden_class);
defaultDiv.addClass(hidden_class);
create_line_chart(document.getElementById(element_id), msg, title, 'white', update);
create_line_chart(document.getElementById(element_id), msg, title, 'white', update, height);
}else{
graphDiv.addClass(hidden_class);
defaultDiv.removeClass(hidden_class);
Expand Down
4 changes: 4 additions & 0 deletions Services/Interfaces/web_interface/static/js/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ function isMobileDisplay() {
return $(window).width() < mobile_width_breakpoint;
}

function isMediumDisplay() {
return $(window).width() < medium_width_breakpoint;
}

const handle_rounded_numbers_display = () => {
$(".rounded-number").each(function (){
const text = $(this).text().trim();
Expand Down
9 changes: 5 additions & 4 deletions Services/Interfaces/web_interface/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{% extends "layout.html" %}
{% set active_page = "home" %}
{% block body %}
<br>
<div update-url="{{ url_for('api.announcements') }}" class="alert alert-danger text-center d-none" role="alert" id="annoncementsAlert"></div>
{% if not IS_CLOUD %}
<div class="d-none alert alert-success text-center mt-2" role="alert">
<div class="d-none alert alert-success text-center my-2" role="alert">
<h5 class="d-none d-sm-inline"><span class="d-none d-md-inline"><i class="far fa-bell"></i> Good news ! </span>OctoBot version <span update-url="{{ url_for('api.upgrade_version') }}" id="upgradeVersion"></span> is available.</h5><button route="{{ url_for('commands', cmd='update') }}" type="button" class="btn btn-warning waves-effect">Upgrade now <i class="fas fa-cloud-download-alt"></i></button>
</div>
{% endif %}
Expand All @@ -17,7 +18,7 @@ <h5 class="d-none d-sm-inline"><span class="d-none d-md-inline"><i class="far fa
</div>
{% endif %}
{% if is_in_stating_community_env() %}
<div class="card mt-2 mt-md-4">
<div class="card my-2 my-md-4">
<div class="card-header"><h2>
Welcome to the OctoBot beta environment
</h2>
Expand All @@ -36,7 +37,7 @@ <h5 class="d-none d-sm-inline"><span class="d-none d-md-inline"><i class="far fa
</div>
</div>
{% endif %}
<div class="card mt-2 mt-md-4" id="profitability-display">
<div class="card" id="profitability-display">
<div class="card-header">
<h4>
<div class="row">
Expand Down Expand Up @@ -78,7 +79,7 @@ <h4>
<div id="portfolio_historyChart"
data-url="{{url_for('api.historical_portfolio_value', currency=reference_unit, time_frame='')}}"
data-reference-market="{{reference_unit}}"
class="h-100 w-100">
class="w-100">
</div>
</div>
</div>
Expand Down
6 changes: 0 additions & 6 deletions Trading/Exchange/binance/binance_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,6 @@ class BinanceCCXTAdapter(exchanges.CCXTAdapter):

def fix_order(self, raw, symbol=None, **kwargs):
fixed = super().fix_order(raw, **kwargs)
if self.connector.exchange_manager.is_future \
and fixed[trading_enums.ExchangeConstantsOrderColumns.AMOUNT.value] is not None:
# amount is in contact, multiply by contract value to get the currency amount (displayed to the user)
contract_size = self.connector.get_contract_size(symbol)
fixed[trading_enums.ExchangeConstantsOrderColumns.AMOUNT.value] = \
fixed[trading_enums.ExchangeConstantsOrderColumns.AMOUNT.value] * float(contract_size)
self._adapt_order_type(fixed)
return fixed

Expand Down
9 changes: 2 additions & 7 deletions Trading/Exchange/kucoin/kucoin_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,8 @@ class KucoinCCXTAdapter(exchanges.CCXTAdapter):
def fix_order(self, raw, symbol=None, **kwargs):
raw_order_info = raw[ccxt_enums.ExchangePositionCCXTColumns.INFO.value]
fixed = super().fix_order(raw, **kwargs)
if self.connector.exchange_manager.is_future \
and fixed[trading_enums.ExchangeConstantsOrderColumns.AMOUNT.value] is not None:
# amount is in contact, multiply by contract value to get the currency amount (displayed to the user)
contract_size = self.connector.get_contract_size(symbol)
fixed[trading_enums.ExchangeConstantsOrderColumns.AMOUNT.value] = \
fixed[trading_enums.ExchangeConstantsOrderColumns.AMOUNT.value] * float(contract_size)
if fixed[trading_enums.ExchangeConstantsOrderColumns.COST.value] is not None:
if self.connector.exchange_manager.is_future and \
fixed[trading_enums.ExchangeConstantsOrderColumns.COST.value] is not None:
fixed[trading_enums.ExchangeConstantsOrderColumns.COST.value] = \
fixed[trading_enums.ExchangeConstantsOrderColumns.COST.value] * \
float(raw_order_info.get(self.KUCOIN_LEVERAGE, 1))
Expand Down
6 changes: 0 additions & 6 deletions Trading/Exchange/okx/okx_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,6 @@ class OKXCCXTAdapter(exchanges.CCXTAdapter):

def fix_order(self, raw, symbol=None, **kwargs):
fixed = super().fix_order(raw, **kwargs)
if self.connector.exchange_manager.is_future \
and fixed[trading_enums.ExchangeConstantsOrderColumns.AMOUNT.value] is not None:
# amount is in contact, multiply by contract value to get the currency amount (displayed to the user)
contract_size = self.connector.get_contract_size(symbol)
fixed[trading_enums.ExchangeConstantsOrderColumns.AMOUNT.value] = \
fixed[trading_enums.ExchangeConstantsOrderColumns.AMOUNT.value] * float(contract_size)
self._adapt_order_type(fixed)
return fixed

Expand Down

0 comments on commit 50a9007

Please sign in to comment.