All Currency ability
Closed this issue · 1 comments
coltoneshaw commented
We need the ability to select ALL currency and have this update across the sheet. Right now it's doing this based on a selection change
// Store sheet name in instructions H1 for query reference
function onSelectionChange(e) {
const prop = PropertiesService.getScriptProperties();
const previousSheet = prop.getProperty("previousSheet");
const sheetName = e.range.getSheet().getSheetName();
if (sheetName != previousSheet) {
SpreadsheetApp.getActive().getRange("Instructions!H1").setValue(sheetName);
}
prop.setProperty("previousSheet", sheetName);
}
Proposed Solution
onEdit
Add to OnEdit. When you edit a sheet with the denomination or account, it pulls that data off the sheet and stores it in a script property.
Script Functions
We create a account_id
, currency
, and AccountName
custom function for GAS. These can populate data in the instructions sheet
Tasks
- - Update the onEdit to pull the currency based on the editing of those sheets.
- - Store this in a sheet value
- - Create the custom functions to pull the value
- - Update the formulas to use this.
coltoneshaw commented
If taking profits in something other than USD this becomes an issue to merge the currencies.
API Response when trading in ETH
{ id: 583761554,
bot_id: 4750245,
max_safety_orders: 5,
from_currency_id: 0,
to_currency_id: 0,
account_id: 30030251,
active_safety_orders_count: 1,
created_at: '2021-06-11T00:52:08.324Z',
updated_at: '2021-06-11T00:52:08.524Z',
closed_at: null,
'finished?': false,
current_active_safety_orders_count: 1,
current_active_safety_orders: 1,
completed_safety_orders_count: 0,
completed_manual_safety_orders_count: 0,
'cancellable?': true,
'panic_sellable?': true,
trailing_enabled: false,
tsl_enabled: false,
stop_loss_timeout_enabled: false,
stop_loss_timeout_in_seconds: 0,
active_manual_safety_orders: 0,
pair: 'ETH_ADA',
status: 'active',
localized_status: 'Bought',
take_profit: '1.0',
base_order_volume: '1.0',
safety_order_volume: '2.0',
safety_order_step_percentage: '1.0',
leverage_type: 'not_specified',
leverage_custom_value: null,
bought_amount: '1624.0',
bought_volume: '1.00128684656',
bought_average_price: '0.00061655594',
base_order_average_price: '0.00061655594',
sold_amount: '0.0',
sold_volume: '0.0',
sold_average_price: '0',
take_profit_type: 'total',
final_profit: '-0.00273064',
martingale_coefficient: '1.0',
martingale_volume_coefficient: '1.0',
martingale_step_coefficient: '1.0',
stop_loss_percentage: '0.0',
error_message: null,
profit_currency: 'base_currency',
stop_loss_type: 'stop_loss',
safety_order_volume_type: 'quote_currency',
base_order_volume_type: 'quote_currency',
from_currency: 'ETH',
to_currency: 'ADA',
current_price: '0.00061671',
take_profit_price: '0.00062335',
stop_loss_price: null,
final_profit_percentage: '0',
actual_profit_percentage: '0.02',
usd_final_profit: '-6.67',
actual_profit: '-0.0007513436',
actual_usd_profit: '-1.83635889276',
failed_message: null,
reserved_base_coin: '1.00128684656',
reserved_second_coin: '1624.0',
trailing_deviation: '0.2',
tsl_max_price: null,
strategy: 'long' }
Script response
{ id: 583761554,
status: 'active',
max_safety_orders: 5,
account_id: 30030251,
bot_id: 4750245,
'created_at (UTC)': '06-11-2021',
open_1: null,
'closed_at (UTC)': null,
deal_hours: '0.02',
completed_safety_orders_count: 0,
pair: 'ADA',
from_currency: 'ETH',
take_profit: '1.0',
base_order_volume: 1,
safety_order_volume: 2,
max_deal_funds: '11.00',
bought_amount: 1624,
bought_volume: 1.00128684656,
bought_average_price: 0.00061655594,
sold_amount: 0,
sold_volume: 0,
martingale_coefficient: 1,
martingale_volume_coefficient: 1,
martingale_step_coefficient: 1,
current_price: 0.00061582,
take_profit_price: 0.00062335,
bot_name: 'Paper trading account USDT Long Bot',
actual_profit: '-0.00219525824',
actual_usd_profit: '-5.3814999547008',
Impact_Factor: 1.1920964953706215,
hourly_per_unit_profit_percent: -0.10948096030805272 }
Market Order
{ order_id: '364739581',
order_type: 'BUY',
deal_order_type: 'Base',
cancellable: false,
status_string: 'Filled',
created_at: '2021-06-11T00:52:08.470Z',
updated_at: '2021-06-11T00:52:08.470Z',
quantity: '1624.0',
quantity_remaining: '0.0',
total: '1.00128684656',
rate: '0.0',
average_price: '0.00061594' }