From 5a0db4d7662ed9118715ec3ba0baca2397f2e9b7 Mon Sep 17 00:00:00 2001 From: djbadders <34887832+djbadders@users.noreply.github.com> Date: Wed, 25 Mar 2020 18:02:59 +0000 Subject: [PATCH 01/31] Fixes + overall gain percentage update --- Core/Main/PTMagic.cs | 2 +- Core/ProfitTrailer/StrategyHelper.cs | 2 +- Monitor/Pages/_get/DashboardBottom.cshtml | 12 +- Monitor/Pages/_get/DashboardTop.cshtml | 2 +- PTMagic/_presets/Default/DCA.PROPERTIES | 125 ++++++++------- .../_presets/Default/INDICATORS.PROPERTIES | 63 ++++++-- PTMagic/_presets/Default/PAIRS.PROPERTIES | 151 ++++++++++++------ .../ElDorado-V4-INDICATORS.properties | 78 +++++++++ .../ElDorado-V4-INDICATORS.properties | 78 +++++++++ 9 files changed, 382 insertions(+), 131 deletions(-) create mode 100644 PTMagic/_presets/Sideways/ElDorado-V4-INDICATORS.properties create mode 100644 PTMagic/_presets/SidewaysUp/ElDorado-V4-INDICATORS.properties diff --git a/Core/Main/PTMagic.cs b/Core/Main/PTMagic.cs index 305b49c..7bdf293 100644 --- a/Core/Main/PTMagic.cs +++ b/Core/Main/PTMagic.cs @@ -2564,7 +2564,7 @@ namespace Core.Main } } - this.LastRuntimeSummary.MarketSummary.Add(marketPair, mpSummary); + this.LastRuntimeSummary.MarketSummary.TryAdd(marketPair, mpSummary); } this.Log.DoLogInfo("Summary: Current single market properties saved."); diff --git a/Core/ProfitTrailer/StrategyHelper.cs b/Core/ProfitTrailer/StrategyHelper.cs index 0b205ba..a260308 100644 --- a/Core/ProfitTrailer/StrategyHelper.cs +++ b/Core/ProfitTrailer/StrategyHelper.cs @@ -252,7 +252,7 @@ namespace Core.ProfitTrailer result = leverage + " X"; } - // buy/sell strategies beginning with PT 2.3.3 contain the stragegy designation letter followed by a colon and space. + // buy/sell strategies beginning with PT 2.3.3 contain the strategy designation letter followed by a colon and space. // remove the letter and colon, change to shortcut, then reapply the letter and colon if (strategyName.Contains(":")) { diff --git a/Monitor/Pages/_get/DashboardBottom.cshtml b/Monitor/Pages/_get/DashboardBottom.cshtml index 137f0e9..47be0f8 100644 --- a/Monitor/Pages/_get/DashboardBottom.cshtml +++ b/Monitor/Pages/_get/DashboardBottom.cshtml @@ -30,9 +30,17 @@ currentBalanceString = Math.Round(currentBalance, 2).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")); } } -
TCV:   @currentBalanceString   @Model.Summary.MainMarket  
+
+ + Start balence:   @Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance @Model.Summary.MainMarket +
+ Current value:   @currentBalanceString @Model.Summary.MainMarket +
+ Gain:   @Math.Round(((currentBalance - Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance) / Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance) * 100, 2) % +
+
- +
diff --git a/Monitor/Pages/_get/DashboardTop.cshtml b/Monitor/Pages/_get/DashboardTop.cshtml index e2c77f9..94f8b8e 100644 --- a/Monitor/Pages/_get/DashboardTop.cshtml +++ b/Monitor/Pages/_get/DashboardTop.cshtml @@ -131,7 +131,7 @@ } bool isSellStrategyTrue = false; - if (dcaLogEntry.BuyStrategies.Count > 0) { + if (dcaLogEntry.SellStrategies.Count > 0) { isSellStrategyTrue = (dcaLogEntry.SellStrategies.FindAll(ss => !ss.IsTrue).Count == 0); } diff --git a/PTMagic/_presets/Default/DCA.PROPERTIES b/PTMagic/_presets/Default/DCA.PROPERTIES index 7fac35f..0d96f51 100644 --- a/PTMagic/_presets/Default/DCA.PROPERTIES +++ b/PTMagic/_presets/Default/DCA.PROPERTIES @@ -1,68 +1,75 @@ # #################################### # ####### PTMagic Current Setting ######## # PTMagic_ActiveSetting = Default -# PTMagic_LastChanged = 3/26/2018 11:52 AM +# PTMagic_LastChanged = 17/02/2019 18:11 # #################################### -# + +############################ +##### General Settings ##### +DEFAULT_DCA_ignore_sell_only_mode = true +SOM_DCA_buy_trigger = 0 +DEFAULT_DCA_enabled = true DCA_keep_balance = 0 DCA_keep_balance_percentage = 0 -# -DEFAULT_DCA_max_cost = 0 -DEFAULT_DCA_max_buy_times = 20 -# -DEFAULT_DCA_A_buy_strategy = LOWBB -DEFAULT_DCA_A_buy_value = 5 -DEFAULT_DCA_A_buy_value_limit = -2.5 -# -DEFAULT_DCA_B_buy_strategy = RSI -DEFAULT_DCA_B_buy_value = 33 -DEFAULT_DCA_B_buy_value_limit = 5 -# -DEFAULT_DCA_trailing_buy = 0 -# -DEFAULT_DCA_buy_trigger = 0 -# -DEFAULT_DCA_buy_percentage_1 = 100 -DEFAULT_DCA_buy_percentage_2 = 50 -DEFAULT_DCA_buy_percentage_3 = 50 -DEFAULT_DCA_buy_percentage_4 = 25 -DEFAULT_DCA_buy_percentage_5 = 30 -DEFAULT_DCA_buy_percentage_6 = 25 -DEFAULT_DCA_buy_percentage_7 = 20 -DEFAULT_DCA_buy_percentage_8 = 15.5 -DEFAULT_DCA_buy_percentage_9 = 12.11 -DEFAULT_DCA_buy_percentage_10 = 10 -DEFAULT_DCA_buy_percentage_11 = 8 -DEFAULT_DCA_buy_percentage_12 = 7 -DEFAULT_DCA_buy_percentage_13 = 6 -DEFAULT_DCA_buy_percentage_14 = 6 -DEFAULT_DCA_buy_percentage_15 = 5 -DEFAULT_DCA_buy_percentage_16 = 5 -DEFAULT_DCA_buy_percentage_17 = 5 -DEFAULT_DCA_buy_percentage_18 = 5 -DEFAULT_DCA_buy_percentage_19 = 5 -DEFAULT_DCA_buy_percentage_20 = 5 -# -DEFAULT_DCA_A_sell_strategy = GAIN -DEFAULT_DCA_A_sell_value = 1 -# -DEFAULT_DCA_B_sell_strategy = RSI -DEFAULT_DCA_B_sell_value = 40 -# -DEFAULT_DCA_trailing_profit = 0.147 + +############################ +##### Selling Strategy ##### + +# Find the best price with enough volume +DCA_orderbook_profit_calculation = true +# Sell at this percentage always DEFAULT_DCA_max_profit = 0 -# -DEFAULT_DCA_min_order_book_volume_percentage = 100 -# -DEFAULT_DCA_ignore_sell_only_mode = true -# -DEFAULT_DCA_max_buy_spread = 2 -DEFAULT_DCA_rebuy_timeout = 10 -# DEFAULT_DCA_stop_loss_trigger = 0 -DEFAULT_DCA_stop_loss_timeout = 0 DEFAULT_DCA_pending_order_wait_time = 0 -# -DEFAULT_DCA_buy_min_price_increase = 0 -DEFAULT_DCA_buy_max_price_increase = 0 -# \ No newline at end of file + +# Sell if stalled +DEFAULT_DCA_take_profit_percentage = 1.0 +DEFAULT_DCA_take_profit_reset_percentage_move = 0.1 +DEFAULT_DCA_take_profit_wait_time = 15 + +# Sell strat A +DEFAULT_DCA_A_sell_strategy = GAIN +DEFAULT_DCA_A_sell_value = 0.25 +DEFAULT_DCA_trailing_profit = 0.1 + +#DEFAULT_DCA_B_sell_strategy = STOCHRSID +#DEFAULT_DCA_B_sell_value = 0.9 + +######################## +##### Buy Strategy ##### +DEFAULT_DCA_A_buy_value = -0.5 +DEFAULT_DCA_A_buy_value_1 = -0.5 +DEFAULT_DCA_A_buy_value_2 = -0.5 +DEFAULT_DCA_A_buy_value_3 = -0.5 +DEFAULT_DCA_A_buy_value_4 = -0.5 +DEFAULT_DCA_A_buy_value_5 = -0.5 +DEFAULT_DCA_A_buy_value_6 = -0.5 + +DEFAULT_DCA_buy_percentage = 100 + +DEFAULT_DCA_min_buy_balance_percentage = 0 +DEFAULT_DCA_max_cost = 0 +DEFAULT_DCA_max_buy_times = 4 +DEFAULT_DCA_rebuy_timeout = 0 +DEFAULT_DCA_trailing_buy = 0.1 +DEFAULT_DCA_min_buy_volume = 0 +DEFAULT_DCA_max_buy_spread = 0 +DEFAULT_DCA_buy_min_change_percentage = 0 +DEFAULT_DCA_buy_max_change_percentage = 0 + +# Buy strats +DEFAULT_DCA_A_buy_strategy = PROFITPERCENTAGE + +DEFAULT_DCA_B_buy_strategy = EMAGAIN +DEFAULT_DCA_B_buy_value = 0.1 +DEFAULT_DCA_B_buy_value_limit = 0 + +DEFAULT_DCA_C_buy_strategy = MACD +DEFAULT_DCA_C_buy_value = 0.00000002 +DEFAULT_DCA_C_buy_value_limit = 0 + +######################### +# Reversal trading +DEFAULT_DCA_reversal_start_trigger = -2 +DEFAULT_DCA_reversal_rebuy_drop_trigger = -5 +DEFAULT_DCA_reversal_rebuy_rise_trigger = -0.5 \ No newline at end of file diff --git a/PTMagic/_presets/Default/INDICATORS.PROPERTIES b/PTMagic/_presets/Default/INDICATORS.PROPERTIES index a6ecba4..72ae01e 100644 --- a/PTMagic/_presets/Default/INDICATORS.PROPERTIES +++ b/PTMagic/_presets/Default/INDICATORS.PROPERTIES @@ -1,30 +1,65 @@ -# #################################### -# ####### PTMagic Current Setting ######## -# PTMagic_ActiveSetting = Default -# PTMagic_LastChanged = 3/26/2018 11:52 AM -# #################################### -# +#Always uses 5 minute candles. 288 = 24 hours +SOM_trigger_length = 288 + BB_std = 2 BB_candle_period = 300 BB_length = 20 -# + SMA_cross_candles = 2 SMA_candle_period = 300 SMA_fast_length = 12 SMA_slow_length = 24 -# + EMA_cross_candles = 3 EMA_candle_period = 300 -EMA_fast_length = 3 -EMA_slow_length = 24 -# +EMA_fast_length = 6 +EMA_slow_length = 20 + +HMA_cross_candles = 3 +HMA_candle_period = 300 +HMA_fast_length = 3 +HMA_slow_length = 24 + +DEMA_cross_candles = 3 +DEMA_candle_period = 300 +DEMA_fast_length = 3 +DEMA_slow_length = 24 + RSI_candle_period = 300 RSI_length = 14 -# + +STOCH_candle_period = 300 STOCH_length = 14 -# +STOCH_K = 1 +STOCH_D = 1 + +STOCHRSID_candle_period = 300 +STOCHRSID_rsi_length = 14 +STOCHRSID_stoch_length = 14 +STOCHRSID_K = 3 +STOCHRSID_D = 3 + +STOCHRSIK_candle_period = 300 +STOCHRSIK_rsi_length = 14 +STOCHRSIK_stoch_length = 14 +STOCHRSIK_K = 3 + +STOCHRSICROSS_candle_period = 300 +STOCHRSICROSS_rsi_length = 14 +STOCHRSICROSS_stoch_length = 14 +STOCHRSICROSS_K = 3 +STOCHRSICROSS_D = 3 +STOCHRSICROSS_cross_candles = 2 + MACD_candle_period = 300 MACD_fast_length = 12 MACD_slow_length = 26 MACD_signal = 9 -# \ No newline at end of file + +OBV_candle_period = 300 +OBV_length = 5 +OBV_signal = 1 + +PDHIGH_candle_period = 300 + +FIXEDPRICE_source = ASK \ No newline at end of file diff --git a/PTMagic/_presets/Default/PAIRS.PROPERTIES b/PTMagic/_presets/Default/PAIRS.PROPERTIES index 35670dc..e8da079 100644 --- a/PTMagic/_presets/Default/PAIRS.PROPERTIES +++ b/PTMagic/_presets/Default/PAIRS.PROPERTIES @@ -1,67 +1,112 @@ # #################################### # ####### PTMagic Current Setting ######## # PTMagic_ActiveSetting = Default -# PTMagic_LastChanged = 23.05.2018 07:29 +# PTMagic_LastChanged = 17/02/2019 18:11 # #################################### +############################ +##### General Settings ##### +market = BTC +price_trigger_market = BTC +DEFAULT_sell_only_mode_enabled = false +DEFAULT_panic_sell_enabled = false -# -market = USDT -# -start_balance = 1105.17429444 -USDT_dust = 3.50 -# -enabled_pairs = ADA, BCC, BTC, BTG, ETH, LTC, NEO, OMG, XMR, XRP, ZEC -hidden_pairs = ALL -# -max_trading_pairs = 5 -# +enabled_pairs = ALL +start_balance = 1.5 keep_balance = 0 keep_balance_percentage = 0 -# + +max_trading_pairs = 14 +pair_min_listed_days = 0 +DEFAULT_DCA_enabled = -2.0 + +#DEFAULT_pending_order_wait_time = 2880 +DEFAULT_combined_cancel_pending_trigger = 0.1 + +#----- Protection ----- +#price_drop_trigger = 10 +#price_drop_recover_trigger = 8 + +#price_rise_trigger = 10 +#price_rise_recover_trigger = 8 + consecutive_buy_trigger = 0 consecutive_sell_trigger = 0 -# -DEFAULT_trading_enabled = true -DEFAULT_sell_only_mode_enabled = true -# -pair_min_listed_days = 14 -DEFAULT_DCA_enabled = true -# -DEFAULT_initial_cost = 10 -DEFAULT_initial_cost_percentage = 0 -DEFAULT_min_buy_volume = 300000 -DEFAULT_min_buy_price = 0 -DEFAULT_max_buy_spread = 1 -DEFAULT_min_order_book_volume_percentage = 100 -# -DEFAULT_A_buy_strategy = LOWBB -DEFAULT_A_buy_value = 5 -DEFAULT_A_buy_value_limit = -2.5 -# -DEFAULT_B_buy_strategy = RSI -DEFAULT_B_buy_value = 33 + +######################## +##### Buy Strategy ##### +DEFAULT_A_buy_strategy = EMAGAIN +DEFAULT_A_buy_value = -0.2 +DEFAULT_A_buy_value_limit = 0 + +DEFAULT_B_buy_strategy = LOWBB +DEFAULT_B_buy_value = 15 DEFAULT_B_buy_value_limit = 0 -# -DEFAULT_trailing_buy = 0 -# -DEFAULT_A_sell_strategy = GAIN -DEFAULT_A_sell_value = 1 -# -DEFAULT_B_sell_strategy = RSI -DEFAULT_B_sell_value = 40 -# -DEFAULT_trailing_profit = 0.16 + +DEFAULT_initial_cost = 0 +DEFAULT_initial_cost_percentage = 0.25 +DEFAULT_trailing_buy = 0.1 +DEFAULT_rebuy_timeout = 0 +DEFAULT_buy_min_change_percentage = 0 +DEFAULT_buy_max_change_percentage = 0 + +orderbook_profit_calculation = true +DEFAULT_min_orderbook_volume_percentage = 105 + +DEFAULT_trading_enabled = false +BNB_trading_enabled = true + +####################### +# Reversal trading +DEFAULT_reversal_start_trigger = -0.5 +DEFAULT_reversal_rebuy_drop_trigger = -1 +DEFAULT_reversal_rebuy_rise_trigger = -0.5 + +####################### +# Black list +DEFAULT_trading_enabled = true +BNB_trading_enabled = false + +BCN_sell_only_mode_enabled = true +CHAT_sell_only_mode_enabled = true +ICN_sell_only_mode_enabled = true +ICX_sell_only_mode_enabled = true +NCASH_sell_only_mode_enabled = true +TRIG_sell_only_mode_enabled = true +XVG_sell_only_mode_enabled = true + +hidden_pairs = CTR +pair_min_listed_days = 7 + +############################ +##### Selling Strategy ##### +DEFAULT_trailing_profit = 0.1 DEFAULT_max_profit = 0 -# DEFAULT_stop_loss_trigger = 0 DEFAULT_stop_loss_timeout = 0 -DEFAULT_panic_sell_enabled = false -DEFAULT_rebuy_timeout = 5 -# -DEFAULT_buy_min_price_increase = 0 -DEFAULT_buy_max_price_increase = 0 -# -DEFAULT_pending_order_wait_time = 0 -DEFAULT_combined_cancel_pending_trigger = 0 -# + +#------- Stalled coins ------- +DEFAULT_take_profit_percentage = 1.0 +DEFAULT_take_profit_reset_percentage_move = 0.01 +DEFAULT_take_profit_wait_time = 15 + +#------- Pair minimums ------ +DEFAULT_min_buy_volume = 50 +DEFAULT_min_buy_price = 0.0 + +#------- Optional ------ +DEFAULT_max_buy_spread = 0 + +#------- Sell Strat A ------- +DEFAULT_A_sell_strategy = GAIN +DEFAULT_A_sell_value = 0.25 + +#DEFAULT_B_sell_strategy = STOCHRSID +#DEFAULT_B_sell_value = 0.9 + +################ +##### Dust ##### +BTC_dust = 0.000999 +ETH_dust = 0.00999 +BNB_dust = 0.0105 +USDT_dust = 9.99 \ No newline at end of file diff --git a/PTMagic/_presets/Sideways/ElDorado-V4-INDICATORS.properties b/PTMagic/_presets/Sideways/ElDorado-V4-INDICATORS.properties new file mode 100644 index 0000000..6c56eb3 --- /dev/null +++ b/PTMagic/_presets/Sideways/ElDorado-V4-INDICATORS.properties @@ -0,0 +1,78 @@ +# #################################### +# ####### PTMagic Current Setting ######## +# PTMagic_ActiveSetting = ElDorado-V4 +# PTMagic_LastChanged = 11/30/2018 16:41 +# #################################### +# +# Standard Deviation +BB_std = 2 +# Define how many candles back to look back +BB_length = 20 +# Define the period (in seconds) used by all BB calculation of ProfitTrailer. +BB_candle_period = 900 +# Define how many candles back to look and see if the SMA lines just crossed. +SMA_cross_candles = 4 +# Define the period (in seconds) used to calculate the SMA lines +SMA_candle_period = 3600 +# Define the SMA time frame (in candles) used to calculate the fast SMA line. +SMA_fast_length = 21 +# Define the SMA time frame (in candles) used to calculate the slow SMA line. +SMA_slow_length = 55 +# Define how many candles back to look and see if the EMA lines just crossed. +EMA_cross_candles = 12 +# Define the period (in seconds) used to calculate the EMA lines. +EMA_candle_period = 900 +# Define the EMA time frame (in candles) used to calculate the fast EMA line. +EMA_fast_length = 8 +# Define the EMA time frame (in candles) used to calculate the slow EMA line. +EMA_slow_length = 13 +# Define the period (in seconds) used to calculate the RSI lines. +RSI_candle_period = 900 +# Define the RSI time frame (in candles) used by all RSI calculations +RSI_length = 2 +# Define the period (in seconds) used to calculate the STOCH. +STOCH_candle_period = 900 +# Define the Stochastics RSI time frame (in candles) used by all STOCHRSI calculations +STOCH_length = 14 +# The Stochastic Oscillator (STOCH) is range bound between 0 and 100. +# Both K and D represent lines on a price action chart. +# The first line (known as K) displays the current close (ie. the percentage of the +# price at closing) in relation to the price range (high/low) along the number of +# candles used to look back along the price action chart. +STOCH_K = 1 +# The second line (known as D) is a simple moving average of the first line, typically +# based on the last three candle periods for smoothing. +STOCH_D = 1 +# Define the period (in seconds) used to calculate the MACD lines. +MACD_candle_period = 900 +# Define the MA time frame (in candles) used to calculate the fast MACD line. +MACD_fast_length = 12 +# Define the MA time frame (in candles) used to calculate the slow MACD line. +MACD_slow_length = 26 +# Define the time frame (in days) of the EMA (Exponential Moving Average) of the MACD +MACD_signal = 9 +# Define the period (in seconds) used to calculate the RSI lines. +OBV_candle_period = 900 +# Total count of candles used to calculate the OBV values, e.g. 15 means we have 15 OBV values +OBV_length = 50 +# The number (integer) of the first OBV value used for the calculation of the percentage change. +OBV_signal = 1 +# Always uses 5 minute candles +SOM_trigger_length = 288 +# +# +STOCHRSI_candle_period = 900 +STOCHRSIK_candle_period = 900 +STOCHRSID_candle_period = 900 +# +STOCHRSI_stoch_length = 14 +STOCHRSIK_stoch_length = 14 +STOCHRSID_stoch_length = 14 +# +STOCHRSI_rsi_length = 14 +STOCHRSIK_rsi_length = 14 +STOCHRSID_rsi_length = 14 +# +STOCHRSIK_K = 3 +STOCHRSID_K = 3 +STOCHRSID_D = 3 \ No newline at end of file diff --git a/PTMagic/_presets/SidewaysUp/ElDorado-V4-INDICATORS.properties b/PTMagic/_presets/SidewaysUp/ElDorado-V4-INDICATORS.properties new file mode 100644 index 0000000..d47a85b --- /dev/null +++ b/PTMagic/_presets/SidewaysUp/ElDorado-V4-INDICATORS.properties @@ -0,0 +1,78 @@ +# #################################### +# ####### PTMagic Current Setting #### +# PTMagic_ActiveSetting = ElDorado-V4 +# PTMagic_LastChanged = 11/30/2018 16:41 +# #################################### + +# Standard Deviation +BB_std = 2 +# Define how many candles back to look back +BB_length = 20 +# Define the period (in seconds) used by all BB calculation of ProfitTrailer. +BB_candle_period = 900 +# Define how many candles back to look and see if the SMA lines just crossed. +SMA_cross_candles = 4 +# Define the period (in seconds) used to calculate the SMA lines +SMA_candle_period = 3600 +# Define the SMA time frame (in candles) used to calculate the fast SMA line. +SMA_fast_length = 21 +# Define the SMA time frame (in candles) used to calculate the slow SMA line. +SMA_slow_length = 55 +# Define how many candles back to look and see if the EMA lines just crossed. +EMA_cross_candles = 12 +# Define the period (in seconds) used to calculate the EMA lines. +EMA_candle_period = 900 +# Define the EMA time frame (in candles) used to calculate the fast EMA line. +EMA_fast_length = 8 +# Define the EMA time frame (in candles) used to calculate the slow EMA line. +EMA_slow_length = 13 +# Define the period (in seconds) used to calculate the RSI lines. +RSI_candle_period = 900 +# Define the RSI time frame (in candles) used by all RSI calculations +RSI_length = 2 +# Define the period (in seconds) used to calculate the STOCH. +STOCH_candle_period = 900 +# Define the Stochastics RSI time frame (in candles) used by all STOCHRSI calculations +STOCH_length = 14 +# The Stochastic Oscillator (STOCH) is range bound between 0 and 100. +# Both K and D represent lines on a price action chart. +# The first line (known as K) displays the current close (ie. the percentage of the +# price at closing) in relation to the price range (high/low) along the number of +# candles used to look back along the price action chart. +STOCH_K = 1 +# The second line (known as D) is a simple moving average of the first line, typically +# based on the last three candle periods for smoothing. +STOCH_D = 1 +# Define the period (in seconds) used to calculate the MACD lines. +MACD_candle_period = 900 +# Define the MA time frame (in candles) used to calculate the fast MACD line. +MACD_fast_length = 12 +# Define the MA time frame (in candles) used to calculate the slow MACD line. +MACD_slow_length = 26 +# Define the time frame (in days) of the EMA (Exponential Moving Average) of the MACD +MACD_signal = 9 +# Define the period (in seconds) used to calculate the RSI lines. +OBV_candle_period = 900 +# Total count of candles used to calculate the OBV values, e.g. 15 means we have 15 OBV values +OBV_length = 50 +# The number (integer) of the first OBV value used for the calculation of the percentage change. +OBV_signal = 1 +# Always uses 5 minute candles +SOM_trigger_length = 288 +# +# +STOCHRSI_candle_period = 900 +STOCHRSIK_candle_period = 900 +STOCHRSID_candle_period = 900 +# +STOCHRSI_stoch_length = 14 +STOCHRSIK_stoch_length = 14 +STOCHRSID_stoch_length = 14 +# +STOCHRSI_rsi_length = 14 +STOCHRSIK_rsi_length = 14 +STOCHRSID_rsi_length = 14 +# +STOCHRSIK_K = 3 +STOCHRSID_K = 3 +STOCHRSID_D = 3 From a5faee8603d4db0451bc2dc0a569e1ae6b2ca9f1 Mon Sep 17 00:00:00 2001 From: djbadders <34887832+djbadders@users.noreply.github.com> Date: Wed, 25 Mar 2020 22:55:47 +0000 Subject: [PATCH 02/31] Target profit column introduced in the dashboard --- Core/DataObjects/PTMagicData.cs | 1 + Core/DataObjects/ProfitTrailerData.cs | 311 +++++-------------- Core/ProfitTrailer/StrategyHelper.cs | 403 ++++++++++++------------- Monitor/Pages/_get/DashboardTop.cshtml | 11 +- PTMagic/Program.cs | 2 +- 5 files changed, 289 insertions(+), 439 deletions(-) diff --git a/Core/DataObjects/PTMagicData.cs b/Core/DataObjects/PTMagicData.cs index 4e3cad5..d0a0c8c 100644 --- a/Core/DataObjects/PTMagicData.cs +++ b/Core/DataObjects/PTMagicData.cs @@ -456,6 +456,7 @@ namespace Core.Main.DataObjects.PTMagicData public double AverageBuyPrice { get; set; } public double TotalCost { get; set; } public double CurrentValue { get; set; } + public double? TargetGainValue { get; set; } public double Amount { get; set; } public double CurrentPrice { get; set; } public double SellTrigger { get; set; } diff --git a/Core/DataObjects/ProfitTrailerData.cs b/Core/DataObjects/ProfitTrailerData.cs index 07d146f..631d812 100644 --- a/Core/DataObjects/ProfitTrailerData.cs +++ b/Core/DataObjects/ProfitTrailerData.cs @@ -338,69 +338,91 @@ namespace Core.Main.DataObjects private void BuildDCALogData(dynamic rawDCALogData, dynamic rawPairsLogData, dynamic rawPendingLogData, dynamic rawWatchModeLogData) { - foreach (var rdld in rawDCALogData) + // Parse DCA data + _dcaLog.AddRange(ParsePairsData(rawDCALogData, true)); + + // Parse Pairs data + _dcaLog.AddRange(ParsePairsData(rawPairsLogData, false)); + + // Parse pending pairs data + _dcaLog.AddRange(ParsePairsData(rawPendingLogData, false)); + + // Parse watch only pairs data + _dcaLog.AddRange(ParsePairsData(rawWatchModeLogData, false)); + + } + + // Parse the pairs data from PT to our own common data structure. + private List ParsePairsData(dynamic pairsData, bool processBuyStrategies) + { + List pairs = new List(); + + foreach (var pair in pairsData) { DCALogData dcaLogData = new DCALogData(); - dcaLogData.Amount = rdld.totalAmount; - dcaLogData.BoughtTimes = rdld.boughtTimes; - dcaLogData.Market = rdld.market; - dcaLogData.ProfitPercent = rdld.profit; - dcaLogData.AverageBuyPrice = rdld.avgPrice; - dcaLogData.TotalCost = rdld.totalCost; - dcaLogData.BuyTriggerPercent = rdld.buyProfit; - dcaLogData.CurrentLowBBValue = rdld.bbLow == null ? 0 : rdld.bbLow; - dcaLogData.CurrentHighBBValue = rdld.highBb == null ? 0 : rdld.highBb; - dcaLogData.BBTrigger = rdld.bbTrigger == null ? 0 : rdld.bbTrigger; - dcaLogData.CurrentPrice = rdld.currentPrice; - dcaLogData.SellTrigger = rdld.triggerValue == null ? 0 : rdld.triggerValue; - dcaLogData.PercChange = rdld.percChange; - dcaLogData.BuyStrategy = rdld.buyStrategy == null ? "" : rdld.buyStrategy; - dcaLogData.SellStrategy = rdld.sellStrategy == null ? "" : rdld.sellStrategy; + dcaLogData.Amount = pair.totalAmount; + dcaLogData.BoughtTimes = pair.boughtTimes; + dcaLogData.Market = pair.market; + dcaLogData.ProfitPercent = pair.profit; + dcaLogData.AverageBuyPrice = pair.avgPrice; + dcaLogData.TotalCost = pair.totalCost; + dcaLogData.BuyTriggerPercent = pair.buyProfit; + dcaLogData.CurrentLowBBValue = pair.bbLow == null ? 0 : pair.bbLow; + dcaLogData.CurrentHighBBValue = pair.highBb == null ? 0 : pair.highBb; + dcaLogData.BBTrigger = pair.bbTrigger == null ? 0 : pair.bbTrigger; + dcaLogData.CurrentPrice = pair.currentPrice; + dcaLogData.SellTrigger = pair.triggerValue == null ? 0 : pair.triggerValue; + dcaLogData.PercChange = pair.percChange; + dcaLogData.BuyStrategy = pair.buyStrategy == null ? "" : pair.buyStrategy; + dcaLogData.SellStrategy = pair.sellStrategy == null ? "" : pair.sellStrategy; + dcaLogData.IsTrailing = false; - if (rdld.positive != null) + if (pair.buyStrategies != null && processBuyStrategies) { - dcaLogData.IsTrailing = ((string)rdld.positive).IndexOf("trailing", StringComparison.InvariantCultureIgnoreCase) > -1; - dcaLogData.IsTrue = ((string)rdld.positive).IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1; - } - else - { - if (rdld.buyStrategies != null) + foreach (var bs in pair.buyStrategies) { - foreach (var bs in rdld.buyStrategies) - { - Strategy buyStrategy = new Strategy(); - buyStrategy.Type = bs.type; - buyStrategy.Name = bs.name; - buyStrategy.EntryValue = bs.entryValue; - buyStrategy.EntryValueLimit = bs.entryValueLimit; - buyStrategy.TriggerValue = bs.triggerValue; - buyStrategy.CurrentValue = bs.currentValue; - buyStrategy.CurrentValuePercentage = bs.currentValuePercentage; - buyStrategy.Decimals = bs.decimals; - buyStrategy.IsTrailing = ((string)bs.positive).IndexOf("trailing", StringComparison.InvariantCultureIgnoreCase) > -1; - buyStrategy.IsTrue = ((string)bs.positive).IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1; + Strategy buyStrategy = new Strategy(); + buyStrategy.Type = bs.type; + buyStrategy.Name = bs.name; + buyStrategy.EntryValue = bs.entryValue; + buyStrategy.EntryValueLimit = bs.entryValueLimit; + buyStrategy.TriggerValue = bs.triggerValue; + buyStrategy.CurrentValue = bs.currentValue; + buyStrategy.CurrentValuePercentage = bs.currentValuePercentage; + buyStrategy.Decimals = bs.decimals; + buyStrategy.IsTrailing = ((string)bs.positive).IndexOf("trailing", StringComparison.InvariantCultureIgnoreCase) > -1; + buyStrategy.IsTrue = ((string)bs.positive).IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1; - dcaLogData.BuyStrategies.Add(buyStrategy); - } + dcaLogData.BuyStrategies.Add(buyStrategy); } + } - if (rdld.sellStrategies != null) + if (pair.sellStrategies != null) + { + foreach (var ss in pair.sellStrategies) { - foreach (var ss in rdld.sellStrategies) - { - Strategy sellStrategy = new Strategy(); - sellStrategy.Type = ss.type; - sellStrategy.Name = ss.name; - sellStrategy.EntryValue = ss.entryValue; - sellStrategy.EntryValueLimit = ss.entryValueLimit; - sellStrategy.TriggerValue = ss.triggerValue; - sellStrategy.CurrentValue = ss.currentValue; - sellStrategy.CurrentValuePercentage = ss.currentValuePercentage; - sellStrategy.Decimals = ss.decimals; - sellStrategy.IsTrailing = ((string)ss.positive).IndexOf("trailing", StringComparison.InvariantCultureIgnoreCase) > -1; - sellStrategy.IsTrue = ((string)ss.positive).IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1; + Strategy sellStrategy = new Strategy(); + sellStrategy.Type = ss.type; + sellStrategy.Name = ss.name; + sellStrategy.EntryValue = ss.entryValue; + sellStrategy.EntryValueLimit = ss.entryValueLimit; + sellStrategy.TriggerValue = ss.triggerValue; + sellStrategy.CurrentValue = ss.currentValue; + sellStrategy.CurrentValuePercentage = ss.currentValuePercentage; + sellStrategy.Decimals = ss.decimals; + sellStrategy.IsTrailing = ((string)ss.positive).IndexOf("trailing", StringComparison.InvariantCultureIgnoreCase) > -1; + sellStrategy.IsTrue = ((string)ss.positive).IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1; - dcaLogData.SellStrategies.Add(sellStrategy); + dcaLogData.SellStrategies.Add(sellStrategy); + + // Find the target percentage gain to sell. + if (sellStrategy.Name.Contains("GAIN", StringComparison.InvariantCultureIgnoreCase)) + { + if (!dcaLogData.TargetGainValue.HasValue || dcaLogData.TargetGainValue.Value > sellStrategy.EntryValue) + { + // Set the target sell percentage + dcaLogData.TargetGainValue = sellStrategy.EntryValue; + } } } } @@ -408,12 +430,12 @@ namespace Core.Main.DataObjects // Calculate current value dcaLogData.CurrentValue = dcaLogData.CurrentPrice * dcaLogData.Amount; - //Convert Unix Timestamp to Datetime + // Convert Unix Timestamp to Datetime System.DateTime rdldDateTime = new DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc); - rdldDateTime = rdldDateTime.AddSeconds((double)rdld.firstBoughtDate).ToUniversalTime(); + rdldDateTime = rdldDateTime.AddSeconds((double)pair.firstBoughtDate).ToUniversalTime(); // Profit Trailer bought times are saved in UTC - if (rdld.firstBoughtDate > 0) + if (pair.firstBoughtDate > 0) { DateTimeOffset ptFirstBoughtDate = DateTimeOffset.Parse(rdldDateTime.Year.ToString() + "-" + rdldDateTime.Month.ToString("00") + "-" + rdldDateTime.Day.ToString("00") + "T" + rdldDateTime.Hour.ToString("00") + ":" + rdldDateTime.Minute.ToString("00") + ":" + rdldDateTime.Second.ToString("00"), CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); @@ -430,182 +452,7 @@ namespace Core.Main.DataObjects _dcaLog.Add(dcaLogData); } - foreach (var rpld in rawPairsLogData) - { - DCALogData dcaLogData = new DCALogData(); - dcaLogData.Amount = rpld.totalAmount; - dcaLogData.BoughtTimes = 0; - dcaLogData.Market = rpld.market; - dcaLogData.ProfitPercent = rpld.profit; - dcaLogData.AverageBuyPrice = rpld.avgPrice; - dcaLogData.TotalCost = rpld.totalCost; - dcaLogData.BuyTriggerPercent = rpld.buyProfit; - dcaLogData.CurrentPrice = rpld.currentPrice; - dcaLogData.SellTrigger = rpld.triggerValue == null ? 0 : rpld.triggerValue; - dcaLogData.PercChange = rpld.percChange; - dcaLogData.BuyStrategy = rpld.buyStrategy == null ? "" : rpld.buyStrategy; - dcaLogData.SellStrategy = rpld.sellStrategy == null ? "" : rpld.sellStrategy; - dcaLogData.IsTrailing = false; - - if (rpld.sellStrategies != null) - { - foreach (var ss in rpld.sellStrategies) - { - Strategy sellStrategy = new Strategy(); - sellStrategy.Type = ss.type; - sellStrategy.Name = ss.name; - sellStrategy.EntryValue = ss.entryValue; - sellStrategy.EntryValueLimit = ss.entryValueLimit; - sellStrategy.TriggerValue = ss.triggerValue; - sellStrategy.CurrentValue = ss.currentValue; - sellStrategy.CurrentValuePercentage = ss.currentValuePercentage; - sellStrategy.Decimals = ss.decimals; - sellStrategy.IsTrailing = ((string)ss.positive).IndexOf("trailing", StringComparison.InvariantCultureIgnoreCase) > -1; - sellStrategy.IsTrue = ((string)ss.positive).IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1; - - dcaLogData.SellStrategies.Add(sellStrategy); - } - } - - //Convert Unix Timestamp to Datetime - System.DateTime rpldDateTime = new DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc); - rpldDateTime = rpldDateTime.AddSeconds((double)rpld.firstBoughtDate).ToUniversalTime(); - - // Profit Trailer bought times are saved in UTC - if (rpld.firstBoughtDate > 0) - { - DateTimeOffset ptFirstBoughtDate = DateTimeOffset.Parse(rpldDateTime.Year.ToString() + "-" + rpldDateTime.Month.ToString("00") + "-" + rpldDateTime.Day.ToString("00") + "T" + rpldDateTime.Hour.ToString("00") + ":" + rpldDateTime.Minute.ToString("00") + ":" + rpldDateTime.Second.ToString("00"), CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); - - // Convert UTC bought time to local offset time - ptFirstBoughtDate = ptFirstBoughtDate.ToOffset(OffsetTimeSpan); - - dcaLogData.FirstBoughtDate = ptFirstBoughtDate.DateTime; - } - else - { - dcaLogData.FirstBoughtDate = Constants.confMinDate; - } - - _dcaLog.Add(dcaLogData); - } - - foreach (var rpld in rawPendingLogData) - { - DCALogData dcaLogData = new DCALogData(); - dcaLogData.Amount = rpld.totalAmount; - dcaLogData.BoughtTimes = 0; - dcaLogData.Market = rpld.market; - dcaLogData.ProfitPercent = rpld.profit; - dcaLogData.AverageBuyPrice = rpld.avgPrice; - dcaLogData.TotalCost = rpld.totalCost; - dcaLogData.BuyTriggerPercent = rpld.buyProfit; - dcaLogData.CurrentPrice = rpld.currentPrice; - dcaLogData.SellTrigger = rpld.triggerValue == null ? 0 : rpld.triggerValue; - dcaLogData.PercChange = rpld.percChange; - dcaLogData.BuyStrategy = rpld.buyStrategy == null ? "" : rpld.buyStrategy; - dcaLogData.SellStrategy = rpld.sellStrategy == null ? "" : rpld.sellStrategy; - dcaLogData.IsTrailing = false; - - if (rpld.sellStrategies != null) - { - foreach (var ss in rpld.sellStrategies) - { - Strategy sellStrategy = new Strategy(); - sellStrategy.Type = ss.type; - sellStrategy.Name = ss.name; - sellStrategy.EntryValue = ss.entryValue; - sellStrategy.EntryValueLimit = ss.entryValueLimit; - sellStrategy.TriggerValue = ss.triggerValue; - sellStrategy.CurrentValue = ss.currentValue; - sellStrategy.CurrentValuePercentage = ss.currentValuePercentage; - sellStrategy.Decimals = ss.decimals; - sellStrategy.IsTrailing = ((string)ss.positive).IndexOf("trailing", StringComparison.InvariantCultureIgnoreCase) > -1; - sellStrategy.IsTrue = ((string)ss.positive).IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1; - - dcaLogData.SellStrategies.Add(sellStrategy); - } - } - - //Convert Unix Timestamp to Datetime - System.DateTime rpldDateTime = new DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc); - rpldDateTime = rpldDateTime.AddSeconds((double)rpld.firstBoughtDate).ToUniversalTime(); - - // Profit Trailer bought times are saved in UTC - if (rpld.firstBoughtDate > 0) - { - DateTimeOffset ptFirstBoughtDate = DateTimeOffset.Parse(rpldDateTime.Year.ToString() + "-" + rpldDateTime.Month.ToString("00") + "-" + rpldDateTime.Day.ToString("00") + "T" + rpldDateTime.Hour.ToString("00") + ":" + rpldDateTime.Minute.ToString("00") + ":" + rpldDateTime.Second.ToString("00"), CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); - - // Convert UTC bought time to local offset time - ptFirstBoughtDate = ptFirstBoughtDate.ToOffset(OffsetTimeSpan); - - dcaLogData.FirstBoughtDate = ptFirstBoughtDate.DateTime; - } - else - { - dcaLogData.FirstBoughtDate = Constants.confMinDate; - } - - _dcaLog.Add(dcaLogData); - } - - foreach (var rpld in rawWatchModeLogData) - { - DCALogData dcaLogData = new DCALogData(); - dcaLogData.Amount = rpld.totalAmount; - dcaLogData.BoughtTimes = 0; - dcaLogData.Market = rpld.market; - dcaLogData.ProfitPercent = rpld.profit; - dcaLogData.AverageBuyPrice = rpld.avgPrice; - dcaLogData.TotalCost = rpld.totalCost; - dcaLogData.BuyTriggerPercent = rpld.buyProfit; - dcaLogData.CurrentPrice = rpld.currentPrice; - dcaLogData.SellTrigger = rpld.triggerValue == null ? 0 : rpld.triggerValue; - dcaLogData.PercChange = rpld.percChange; - dcaLogData.BuyStrategy = rpld.buyStrategy == null ? "" : rpld.buyStrategy; - dcaLogData.SellStrategy = rpld.sellStrategy == null ? "" : rpld.sellStrategy; - dcaLogData.IsTrailing = false; - - if (rpld.sellStrategies != null) - { - foreach (var ss in rpld.sellStrategies) - { - Strategy sellStrategy = new Strategy(); - sellStrategy.Type = ss.type; - sellStrategy.Name = ss.name; - sellStrategy.EntryValue = ss.entryValue; - sellStrategy.EntryValueLimit = ss.entryValueLimit; - sellStrategy.TriggerValue = ss.triggerValue; - sellStrategy.CurrentValue = ss.currentValue; - sellStrategy.CurrentValuePercentage = ss.currentValuePercentage; - sellStrategy.Decimals = ss.decimals; - sellStrategy.IsTrailing = ((string)ss.positive).IndexOf("trailing", StringComparison.InvariantCultureIgnoreCase) > -1; - sellStrategy.IsTrue = ((string)ss.positive).IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1; - - dcaLogData.SellStrategies.Add(sellStrategy); - } - } - - //Convert Unix Timestamp to Datetime - System.DateTime rpldDateTime = new DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc); - rpldDateTime = rpldDateTime.AddSeconds((double)rpld.firstBoughtDate).ToUniversalTime(); - - // Profit Trailer bought times are saved in UTC - if (rpld.firstBoughtDate > 0) - { - DateTimeOffset ptFirstBoughtDate = DateTimeOffset.Parse(rpldDateTime.Year.ToString() + "-" + rpldDateTime.Month.ToString("00") + "-" + rpldDateTime.Day.ToString("00") + "T" + rpldDateTime.Hour.ToString("00") + ":" + rpldDateTime.Minute.ToString("00") + ":" + rpldDateTime.Second.ToString("00"), CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); - - // Convert UTC bought time to local offset time - ptFirstBoughtDate = ptFirstBoughtDate.ToOffset(OffsetTimeSpan); - - dcaLogData.FirstBoughtDate = ptFirstBoughtDate.DateTime; - } - else - { - dcaLogData.FirstBoughtDate = Constants.confMinDate; - } - - _dcaLog.Add(dcaLogData); - } + return pairs; } private void BuildBuyLogData(dynamic rawBuyLogData) diff --git a/Core/ProfitTrailer/StrategyHelper.cs b/Core/ProfitTrailer/StrategyHelper.cs index a260308..2a902be 100644 --- a/Core/ProfitTrailer/StrategyHelper.cs +++ b/Core/ProfitTrailer/StrategyHelper.cs @@ -1,222 +1,215 @@ using System; using System.Collections.Generic; -using System.Linq; using System.IO; -using System.Net; -using System.Net.Security; -using System.Security.Cryptography.X509Certificates; -using System.Net.Http; using System.Text; -using System.Threading.Tasks; using Core.Main; using Core.Helper; using Core.Main.DataObjects.PTMagicData; -using Newtonsoft.Json; using System.Text.RegularExpressions; namespace Core.ProfitTrailer { public class OperandToken : Token + { + } + public class OrToken : OperandToken + { + } + + public class AndToken : OperandToken + { + } + + public class BooleanValueToken : Token + { + } + + public class FalseToken : BooleanValueToken + { + } + + public class TrueToken : BooleanValueToken + { + } + + public class ParenthesisToken : Token + { + } + + public class ClosedParenthesisToken : ParenthesisToken + { + } + + public class OpenParenthesisToken : ParenthesisToken + { + } + + public class NegationToken : Token + { + } + + public abstract class Token + { + } + + public class Tokenizer + { + private readonly StringReader _reader; + private string _text; + + public Tokenizer(string text) { - } - public class OrToken : OperandToken - { + _text = text; + _reader = new StringReader(text); } - public class AndToken : OperandToken + public IEnumerable Tokenize() { - } - - public class BooleanValueToken : Token - { - } - - public class FalseToken : BooleanValueToken - { - } - - public class TrueToken : BooleanValueToken - { - } - - public class ParenthesisToken : Token - { - } - - public class ClosedParenthesisToken : ParenthesisToken - { - } - - public class OpenParenthesisToken : ParenthesisToken - { - } - - public class NegationToken : Token - { - } - - public abstract class Token - { - } - - public class Tokenizer - { - private readonly StringReader _reader; - private string _text; - - public Tokenizer(string text) + var tokens = new List(); + while (_reader.Peek() != -1) + { + while (Char.IsWhiteSpace((char)_reader.Peek())) { - _text = text; - _reader = new StringReader(text); + _reader.Read(); } - public IEnumerable Tokenize() + if (_reader.Peek() == -1) + break; + + var c = (char)_reader.Peek(); + switch (c) { - var tokens = new List(); - while (_reader.Peek() != -1) + case '!': + tokens.Add(new NegationToken()); + _reader.Read(); + break; + case '(': + tokens.Add(new OpenParenthesisToken()); + _reader.Read(); + break; + case ')': + tokens.Add(new ClosedParenthesisToken()); + _reader.Read(); + break; + default: + if (Char.IsLetter(c)) { - while (Char.IsWhiteSpace((char) _reader.Peek())) - { - _reader.Read(); - } - - if (_reader.Peek() == -1) - break; - - var c = (char) _reader.Peek(); - switch (c) - { - case '!': - tokens.Add(new NegationToken()); - _reader.Read(); - break; - case '(': - tokens.Add(new OpenParenthesisToken()); - _reader.Read(); - break; - case ')': - tokens.Add(new ClosedParenthesisToken()); - _reader.Read(); - break; - default: - if (Char.IsLetter(c)) - { - var token = ParseKeyword(); - tokens.Add(token); - } - else - { - var remainingText = _reader.ReadToEnd() ?? string.Empty; - throw new Exception(string.Format("Unknown grammar found at position {0} : '{1}'", _text.Length - remainingText.Length, remainingText)); - } - break; - } - } - return tokens; - } - - private Token ParseKeyword() - { - var text = new StringBuilder(); - while (Char.IsLetter((char) _reader.Peek())) - { - text.Append((char) _reader.Read()); - } - - var potentialKeyword = text.ToString().ToLower(); - - switch (potentialKeyword) - { - case "true": - return new TrueToken(); - case "false": - return new FalseToken(); - case "and": - return new AndToken(); - case "or": - return new OrToken(); - default: - throw new Exception("Expected keyword (True, False, and, or) but found "+ potentialKeyword); + var token = ParseKeyword(); + tokens.Add(token); } + else + { + var remainingText = _reader.ReadToEnd() ?? string.Empty; + throw new Exception(string.Format("Unknown grammar found at position {0} : '{1}'", _text.Length - remainingText.Length, remainingText)); + } + break; } + } + return tokens; } - public class Parser + + private Token ParseKeyword() { - private readonly IEnumerator _tokens; + var text = new StringBuilder(); + while (Char.IsLetter((char)_reader.Peek())) + { + text.Append((char)_reader.Read()); + } - public Parser(IEnumerable tokens) - { - _tokens = tokens.GetEnumerator(); - _tokens.MoveNext(); - } + var potentialKeyword = text.ToString().ToLower(); - public bool Parse() - { - while (_tokens.Current != null) - { - var isNegated = _tokens.Current is NegationToken; - if (isNegated) - _tokens.MoveNext(); - - var boolean = ParseBoolean(); - if (isNegated) - boolean = !boolean; - - while (_tokens.Current is OperandToken) - { - var operand = _tokens.Current; - if (!_tokens.MoveNext()) - { - throw new Exception("Missing expression after operand"); - } - var nextBoolean = ParseBoolean(); - - if (operand is AndToken) - boolean = boolean && nextBoolean; - else - boolean = boolean || nextBoolean; - - } - - return boolean; - } - - throw new Exception("Empty expression"); - } - - private bool ParseBoolean() - { - if (_tokens.Current is BooleanValueToken) - { - var current = _tokens.Current; - _tokens.MoveNext(); - - if (current is TrueToken) - return true; - - return false; - } - if (_tokens.Current is OpenParenthesisToken) - { - _tokens.MoveNext(); - - var expInPars = Parse(); - - if (!(_tokens.Current is ClosedParenthesisToken)) - throw new Exception("Expecting Closing Parenthesis"); - - _tokens.MoveNext(); - - return expInPars; - } - if (_tokens.Current is ClosedParenthesisToken) - throw new Exception("Unexpected Closed Parenthesis"); - - // since its not a BooleanConstant or Expression in parenthesis, it must be a expression again - var val = Parse(); - return val; - } + switch (potentialKeyword) + { + case "true": + return new TrueToken(); + case "false": + return new FalseToken(); + case "and": + return new AndToken(); + case "or": + return new OrToken(); + default: + throw new Exception("Expected keyword (True, False, and, or) but found " + potentialKeyword); + } } + } + public class Parser + { + private readonly IEnumerator _tokens; + + public Parser(IEnumerable tokens) + { + _tokens = tokens.GetEnumerator(); + _tokens.MoveNext(); + } + + public bool Parse() + { + while (_tokens.Current != null) + { + var isNegated = _tokens.Current is NegationToken; + if (isNegated) + _tokens.MoveNext(); + + var boolean = ParseBoolean(); + if (isNegated) + boolean = !boolean; + + while (_tokens.Current is OperandToken) + { + var operand = _tokens.Current; + if (!_tokens.MoveNext()) + { + throw new Exception("Missing expression after operand"); + } + var nextBoolean = ParseBoolean(); + + if (operand is AndToken) + boolean = boolean && nextBoolean; + else + boolean = boolean || nextBoolean; + + } + + return boolean; + } + + throw new Exception("Empty expression"); + } + + private bool ParseBoolean() + { + if (_tokens.Current is BooleanValueToken) + { + var current = _tokens.Current; + _tokens.MoveNext(); + + if (current is TrueToken) + return true; + + return false; + } + if (_tokens.Current is OpenParenthesisToken) + { + _tokens.MoveNext(); + + var expInPars = Parse(); + + if (!(_tokens.Current is ClosedParenthesisToken)) + throw new Exception("Expecting Closing Parenthesis"); + + _tokens.MoveNext(); + + return expInPars; + } + if (_tokens.Current is ClosedParenthesisToken) + throw new Exception("Unexpected Closed Parenthesis"); + + // since its not a BooleanConstant or Expression in parenthesis, it must be a expression again + var val = Parse(); + return val; + } + } public static class StrategyHelper { @@ -238,7 +231,7 @@ namespace Core.ProfitTrailer // strategy labels that are variable, so can't be caught by the switch statement if (result.Contains("REBUY")) { - time = strategyName.Remove(0,14); + time = strategyName.Remove(0, 14); result = "REBUY " + time; } if (result.Contains("CHANGE PERC")) @@ -247,8 +240,8 @@ namespace Core.ProfitTrailer } if (result.Contains("LEVERAGE")) { - leverage = strategyName.Remove(0,10); - leverage = leverage.Remove(leverage.Length -1, 1); + leverage = strategyName.Remove(0, 10); + leverage = leverage.Remove(leverage.Length - 1, 1); result = leverage + " X"; } @@ -256,7 +249,7 @@ namespace Core.ProfitTrailer // remove the letter and colon, change to shortcut, then reapply the letter and colon if (strategyName.Contains(":")) { - int strategyLength = strategyName.Length-3; + int strategyLength = strategyName.Length - 3; strategyLetter = strategyName.Remove(3, strategyLength); strategyNameOnly = strategyName.Remove(0, 3); } @@ -580,8 +573,9 @@ namespace Core.ProfitTrailer } public static string GetStrategyText(Summary summary, List strategies, string strategyText, bool isTrue, bool isTrailingBuyActive) - { + { bool isValidStrategy = false; + Regex regx = new Regex(@"[ABCDEFGHIJKLMNOPQRSTUVWXYZ]", RegexOptions.Compiled); if (strategies.Count > 0) { @@ -591,24 +585,25 @@ namespace Core.ProfitTrailer isValidStrategy = StrategyHelper.IsValidStrategy(strategy.Name); - if (!isValidStrategy ) + if (!isValidStrategy) { // Parse Formulas if (strategy.Name.Contains("FORMULA") && !strategy.Name.Contains("STATS")) { string expression = strategy.Name.Remove(0, 10); - expression = expression.Replace("","true").Replace("","false").Replace("","").Replace("&&","and").Replace("||","or"); - expression = Regex.Replace(expression, @"[ABCDEFGHIJKLMNOPQRSTUVWXYZ]", String.Empty); + expression = expression.Replace("", "true").Replace("", "false").Replace("", "").Replace("&&", "and").Replace("||", "or"); + expression = regx.Replace(expression, String.Empty); var tokens = new Tokenizer(expression).Tokenize(); var parser = new Parser(tokens); - if (parser.Parse()) { + if (parser.Parse()) + { strategyText += "(FORM) "; } else { - strategyText += "(FORM) "; + strategyText += "(FORM) "; } - + } else { @@ -639,14 +634,14 @@ namespace Core.ProfitTrailer } else { - + isValidStrategy = StrategyHelper.IsValidStrategy(strategyText); if (isValidStrategy) { strategyText = "" + StrategyHelper.GetStrategyShortcut(strategyText, true) + ""; } - + else if (strategyText.Equals("") && isValidStrategy == false) { strategyText = ""; diff --git a/Monitor/Pages/_get/DashboardTop.cshtml b/Monitor/Pages/_get/DashboardTop.cshtml index 94f8b8e..b417b9a 100644 --- a/Monitor/Pages/_get/DashboardTop.cshtml +++ b/Monitor/Pages/_get/DashboardTop.cshtml @@ -98,6 +98,7 @@ DCA Buy Strats Sell Strats + Target Profit Profit @@ -201,6 +202,8 @@ @Html.Raw(sellStrategyText) + @Html.Raw(dcaLogEntry.TargetGainValue.HasValue ? dcaLogEntry.TargetGainValue.Value.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%" : " ") + @if(!@lostValue) { @dcaLogEntry.ProfitPercent.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))% @@ -214,9 +217,13 @@ } - Totals: + Totals: + @Html.Raw(Model.TotalBagCost.ToString("#,#0.000000", new System.Globalization.CultureInfo("en-US"))) - + + + + @Html.Raw((((Model.TotalBagValue - Model.TotalBagCost) / Model.TotalBagCost) * 100).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")))% diff --git a/PTMagic/Program.cs b/PTMagic/Program.cs index 6af53a0..2489c1c 100644 --- a/PTMagic/Program.cs +++ b/PTMagic/Program.cs @@ -6,7 +6,7 @@ using Core.Helper; using Microsoft.Extensions.DependencyInjection; -[assembly: AssemblyVersion("2.4.3")] +[assembly: AssemblyVersion("2.4.4")] [assembly: AssemblyProduct("PT Magic")] namespace PTMagic From 9364fc70c85acdaf78e4c8b047c45a90bc639896 Mon Sep 17 00:00:00 2001 From: djbadders <34887832+djbadders@users.noreply.github.com> Date: Wed, 25 Mar 2020 23:09:19 +0000 Subject: [PATCH 03/31] Revert accidental preset file changes --- PTMagic/_presets/Default/DCA.PROPERTIES | 129 +++++++-------- .../_presets/Default/INDICATORS.PROPERTIES | 63 ++------ PTMagic/_presets/Default/PAIRS.PROPERTIES | 151 ++++++------------ .../ElDorado-V4-INDICATORS.properties | 78 --------- .../ElDorado-V4-INDICATORS.properties | 78 --------- 5 files changed, 128 insertions(+), 371 deletions(-) delete mode 100644 PTMagic/_presets/Sideways/ElDorado-V4-INDICATORS.properties delete mode 100644 PTMagic/_presets/SidewaysUp/ElDorado-V4-INDICATORS.properties diff --git a/PTMagic/_presets/Default/DCA.PROPERTIES b/PTMagic/_presets/Default/DCA.PROPERTIES index 0d96f51..7fac35f 100644 --- a/PTMagic/_presets/Default/DCA.PROPERTIES +++ b/PTMagic/_presets/Default/DCA.PROPERTIES @@ -1,75 +1,68 @@ # #################################### # ####### PTMagic Current Setting ######## # PTMagic_ActiveSetting = Default -# PTMagic_LastChanged = 17/02/2019 18:11 +# PTMagic_LastChanged = 3/26/2018 11:52 AM # #################################### - -############################ -##### General Settings ##### -DEFAULT_DCA_ignore_sell_only_mode = true -SOM_DCA_buy_trigger = 0 -DEFAULT_DCA_enabled = true +# DCA_keep_balance = 0 DCA_keep_balance_percentage = 0 - -############################ -##### Selling Strategy ##### - -# Find the best price with enough volume -DCA_orderbook_profit_calculation = true -# Sell at this percentage always -DEFAULT_DCA_max_profit = 0 -DEFAULT_DCA_stop_loss_trigger = 0 -DEFAULT_DCA_pending_order_wait_time = 0 - -# Sell if stalled -DEFAULT_DCA_take_profit_percentage = 1.0 -DEFAULT_DCA_take_profit_reset_percentage_move = 0.1 -DEFAULT_DCA_take_profit_wait_time = 15 - -# Sell strat A -DEFAULT_DCA_A_sell_strategy = GAIN -DEFAULT_DCA_A_sell_value = 0.25 -DEFAULT_DCA_trailing_profit = 0.1 - -#DEFAULT_DCA_B_sell_strategy = STOCHRSID -#DEFAULT_DCA_B_sell_value = 0.9 - -######################## -##### Buy Strategy ##### -DEFAULT_DCA_A_buy_value = -0.5 -DEFAULT_DCA_A_buy_value_1 = -0.5 -DEFAULT_DCA_A_buy_value_2 = -0.5 -DEFAULT_DCA_A_buy_value_3 = -0.5 -DEFAULT_DCA_A_buy_value_4 = -0.5 -DEFAULT_DCA_A_buy_value_5 = -0.5 -DEFAULT_DCA_A_buy_value_6 = -0.5 - -DEFAULT_DCA_buy_percentage = 100 - -DEFAULT_DCA_min_buy_balance_percentage = 0 +# DEFAULT_DCA_max_cost = 0 -DEFAULT_DCA_max_buy_times = 4 -DEFAULT_DCA_rebuy_timeout = 0 -DEFAULT_DCA_trailing_buy = 0.1 -DEFAULT_DCA_min_buy_volume = 0 -DEFAULT_DCA_max_buy_spread = 0 -DEFAULT_DCA_buy_min_change_percentage = 0 -DEFAULT_DCA_buy_max_change_percentage = 0 - -# Buy strats -DEFAULT_DCA_A_buy_strategy = PROFITPERCENTAGE - -DEFAULT_DCA_B_buy_strategy = EMAGAIN -DEFAULT_DCA_B_buy_value = 0.1 -DEFAULT_DCA_B_buy_value_limit = 0 - -DEFAULT_DCA_C_buy_strategy = MACD -DEFAULT_DCA_C_buy_value = 0.00000002 -DEFAULT_DCA_C_buy_value_limit = 0 - -######################### -# Reversal trading -DEFAULT_DCA_reversal_start_trigger = -2 -DEFAULT_DCA_reversal_rebuy_drop_trigger = -5 -DEFAULT_DCA_reversal_rebuy_rise_trigger = -0.5 \ No newline at end of file +DEFAULT_DCA_max_buy_times = 20 +# +DEFAULT_DCA_A_buy_strategy = LOWBB +DEFAULT_DCA_A_buy_value = 5 +DEFAULT_DCA_A_buy_value_limit = -2.5 +# +DEFAULT_DCA_B_buy_strategy = RSI +DEFAULT_DCA_B_buy_value = 33 +DEFAULT_DCA_B_buy_value_limit = 5 +# +DEFAULT_DCA_trailing_buy = 0 +# +DEFAULT_DCA_buy_trigger = 0 +# +DEFAULT_DCA_buy_percentage_1 = 100 +DEFAULT_DCA_buy_percentage_2 = 50 +DEFAULT_DCA_buy_percentage_3 = 50 +DEFAULT_DCA_buy_percentage_4 = 25 +DEFAULT_DCA_buy_percentage_5 = 30 +DEFAULT_DCA_buy_percentage_6 = 25 +DEFAULT_DCA_buy_percentage_7 = 20 +DEFAULT_DCA_buy_percentage_8 = 15.5 +DEFAULT_DCA_buy_percentage_9 = 12.11 +DEFAULT_DCA_buy_percentage_10 = 10 +DEFAULT_DCA_buy_percentage_11 = 8 +DEFAULT_DCA_buy_percentage_12 = 7 +DEFAULT_DCA_buy_percentage_13 = 6 +DEFAULT_DCA_buy_percentage_14 = 6 +DEFAULT_DCA_buy_percentage_15 = 5 +DEFAULT_DCA_buy_percentage_16 = 5 +DEFAULT_DCA_buy_percentage_17 = 5 +DEFAULT_DCA_buy_percentage_18 = 5 +DEFAULT_DCA_buy_percentage_19 = 5 +DEFAULT_DCA_buy_percentage_20 = 5 +# +DEFAULT_DCA_A_sell_strategy = GAIN +DEFAULT_DCA_A_sell_value = 1 +# +DEFAULT_DCA_B_sell_strategy = RSI +DEFAULT_DCA_B_sell_value = 40 +# +DEFAULT_DCA_trailing_profit = 0.147 +DEFAULT_DCA_max_profit = 0 +# +DEFAULT_DCA_min_order_book_volume_percentage = 100 +# +DEFAULT_DCA_ignore_sell_only_mode = true +# +DEFAULT_DCA_max_buy_spread = 2 +DEFAULT_DCA_rebuy_timeout = 10 +# +DEFAULT_DCA_stop_loss_trigger = 0 +DEFAULT_DCA_stop_loss_timeout = 0 +DEFAULT_DCA_pending_order_wait_time = 0 +# +DEFAULT_DCA_buy_min_price_increase = 0 +DEFAULT_DCA_buy_max_price_increase = 0 +# \ No newline at end of file diff --git a/PTMagic/_presets/Default/INDICATORS.PROPERTIES b/PTMagic/_presets/Default/INDICATORS.PROPERTIES index 72ae01e..a6ecba4 100644 --- a/PTMagic/_presets/Default/INDICATORS.PROPERTIES +++ b/PTMagic/_presets/Default/INDICATORS.PROPERTIES @@ -1,65 +1,30 @@ -#Always uses 5 minute candles. 288 = 24 hours -SOM_trigger_length = 288 - +# #################################### +# ####### PTMagic Current Setting ######## +# PTMagic_ActiveSetting = Default +# PTMagic_LastChanged = 3/26/2018 11:52 AM +# #################################### +# BB_std = 2 BB_candle_period = 300 BB_length = 20 - +# SMA_cross_candles = 2 SMA_candle_period = 300 SMA_fast_length = 12 SMA_slow_length = 24 - +# EMA_cross_candles = 3 EMA_candle_period = 300 -EMA_fast_length = 6 -EMA_slow_length = 20 - -HMA_cross_candles = 3 -HMA_candle_period = 300 -HMA_fast_length = 3 -HMA_slow_length = 24 - -DEMA_cross_candles = 3 -DEMA_candle_period = 300 -DEMA_fast_length = 3 -DEMA_slow_length = 24 - +EMA_fast_length = 3 +EMA_slow_length = 24 +# RSI_candle_period = 300 RSI_length = 14 - -STOCH_candle_period = 300 +# STOCH_length = 14 -STOCH_K = 1 -STOCH_D = 1 - -STOCHRSID_candle_period = 300 -STOCHRSID_rsi_length = 14 -STOCHRSID_stoch_length = 14 -STOCHRSID_K = 3 -STOCHRSID_D = 3 - -STOCHRSIK_candle_period = 300 -STOCHRSIK_rsi_length = 14 -STOCHRSIK_stoch_length = 14 -STOCHRSIK_K = 3 - -STOCHRSICROSS_candle_period = 300 -STOCHRSICROSS_rsi_length = 14 -STOCHRSICROSS_stoch_length = 14 -STOCHRSICROSS_K = 3 -STOCHRSICROSS_D = 3 -STOCHRSICROSS_cross_candles = 2 - +# MACD_candle_period = 300 MACD_fast_length = 12 MACD_slow_length = 26 MACD_signal = 9 - -OBV_candle_period = 300 -OBV_length = 5 -OBV_signal = 1 - -PDHIGH_candle_period = 300 - -FIXEDPRICE_source = ASK \ No newline at end of file +# \ No newline at end of file diff --git a/PTMagic/_presets/Default/PAIRS.PROPERTIES b/PTMagic/_presets/Default/PAIRS.PROPERTIES index e8da079..35670dc 100644 --- a/PTMagic/_presets/Default/PAIRS.PROPERTIES +++ b/PTMagic/_presets/Default/PAIRS.PROPERTIES @@ -1,112 +1,67 @@ # #################################### # ####### PTMagic Current Setting ######## # PTMagic_ActiveSetting = Default -# PTMagic_LastChanged = 17/02/2019 18:11 +# PTMagic_LastChanged = 23.05.2018 07:29 # #################################### -############################ -##### General Settings ##### -market = BTC -price_trigger_market = BTC -DEFAULT_sell_only_mode_enabled = false -DEFAULT_panic_sell_enabled = false -enabled_pairs = ALL -start_balance = 1.5 +# +market = USDT +# +start_balance = 1105.17429444 +USDT_dust = 3.50 +# +enabled_pairs = ADA, BCC, BTC, BTG, ETH, LTC, NEO, OMG, XMR, XRP, ZEC +hidden_pairs = ALL +# +max_trading_pairs = 5 +# keep_balance = 0 keep_balance_percentage = 0 - -max_trading_pairs = 14 -pair_min_listed_days = 0 -DEFAULT_DCA_enabled = -2.0 - -#DEFAULT_pending_order_wait_time = 2880 -DEFAULT_combined_cancel_pending_trigger = 0.1 - -#----- Protection ----- -#price_drop_trigger = 10 -#price_drop_recover_trigger = 8 - -#price_rise_trigger = 10 -#price_rise_recover_trigger = 8 - +# consecutive_buy_trigger = 0 consecutive_sell_trigger = 0 - -######################## -##### Buy Strategy ##### -DEFAULT_A_buy_strategy = EMAGAIN -DEFAULT_A_buy_value = -0.2 -DEFAULT_A_buy_value_limit = 0 - -DEFAULT_B_buy_strategy = LOWBB -DEFAULT_B_buy_value = 15 -DEFAULT_B_buy_value_limit = 0 - -DEFAULT_initial_cost = 0 -DEFAULT_initial_cost_percentage = 0.25 -DEFAULT_trailing_buy = 0.1 -DEFAULT_rebuy_timeout = 0 -DEFAULT_buy_min_change_percentage = 0 -DEFAULT_buy_max_change_percentage = 0 - -orderbook_profit_calculation = true -DEFAULT_min_orderbook_volume_percentage = 105 - -DEFAULT_trading_enabled = false -BNB_trading_enabled = true - -####################### -# Reversal trading -DEFAULT_reversal_start_trigger = -0.5 -DEFAULT_reversal_rebuy_drop_trigger = -1 -DEFAULT_reversal_rebuy_rise_trigger = -0.5 - -####################### -# Black list +# DEFAULT_trading_enabled = true -BNB_trading_enabled = false - -BCN_sell_only_mode_enabled = true -CHAT_sell_only_mode_enabled = true -ICN_sell_only_mode_enabled = true -ICX_sell_only_mode_enabled = true -NCASH_sell_only_mode_enabled = true -TRIG_sell_only_mode_enabled = true -XVG_sell_only_mode_enabled = true - -hidden_pairs = CTR -pair_min_listed_days = 7 - -############################ -##### Selling Strategy ##### -DEFAULT_trailing_profit = 0.1 +DEFAULT_sell_only_mode_enabled = true +# +pair_min_listed_days = 14 +DEFAULT_DCA_enabled = true +# +DEFAULT_initial_cost = 10 +DEFAULT_initial_cost_percentage = 0 +DEFAULT_min_buy_volume = 300000 +DEFAULT_min_buy_price = 0 +DEFAULT_max_buy_spread = 1 +DEFAULT_min_order_book_volume_percentage = 100 +# +DEFAULT_A_buy_strategy = LOWBB +DEFAULT_A_buy_value = 5 +DEFAULT_A_buy_value_limit = -2.5 +# +DEFAULT_B_buy_strategy = RSI +DEFAULT_B_buy_value = 33 +DEFAULT_B_buy_value_limit = 0 +# +DEFAULT_trailing_buy = 0 +# +DEFAULT_A_sell_strategy = GAIN +DEFAULT_A_sell_value = 1 +# +DEFAULT_B_sell_strategy = RSI +DEFAULT_B_sell_value = 40 +# +DEFAULT_trailing_profit = 0.16 DEFAULT_max_profit = 0 +# DEFAULT_stop_loss_trigger = 0 DEFAULT_stop_loss_timeout = 0 - -#------- Stalled coins ------- -DEFAULT_take_profit_percentage = 1.0 -DEFAULT_take_profit_reset_percentage_move = 0.01 -DEFAULT_take_profit_wait_time = 15 - -#------- Pair minimums ------ -DEFAULT_min_buy_volume = 50 -DEFAULT_min_buy_price = 0.0 - -#------- Optional ------ -DEFAULT_max_buy_spread = 0 - -#------- Sell Strat A ------- -DEFAULT_A_sell_strategy = GAIN -DEFAULT_A_sell_value = 0.25 - -#DEFAULT_B_sell_strategy = STOCHRSID -#DEFAULT_B_sell_value = 0.9 - -################ -##### Dust ##### -BTC_dust = 0.000999 -ETH_dust = 0.00999 -BNB_dust = 0.0105 -USDT_dust = 9.99 \ No newline at end of file +DEFAULT_panic_sell_enabled = false +DEFAULT_rebuy_timeout = 5 +# +DEFAULT_buy_min_price_increase = 0 +DEFAULT_buy_max_price_increase = 0 +# +DEFAULT_pending_order_wait_time = 0 +DEFAULT_combined_cancel_pending_trigger = 0 +# diff --git a/PTMagic/_presets/Sideways/ElDorado-V4-INDICATORS.properties b/PTMagic/_presets/Sideways/ElDorado-V4-INDICATORS.properties deleted file mode 100644 index 6c56eb3..0000000 --- a/PTMagic/_presets/Sideways/ElDorado-V4-INDICATORS.properties +++ /dev/null @@ -1,78 +0,0 @@ -# #################################### -# ####### PTMagic Current Setting ######## -# PTMagic_ActiveSetting = ElDorado-V4 -# PTMagic_LastChanged = 11/30/2018 16:41 -# #################################### -# -# Standard Deviation -BB_std = 2 -# Define how many candles back to look back -BB_length = 20 -# Define the period (in seconds) used by all BB calculation of ProfitTrailer. -BB_candle_period = 900 -# Define how many candles back to look and see if the SMA lines just crossed. -SMA_cross_candles = 4 -# Define the period (in seconds) used to calculate the SMA lines -SMA_candle_period = 3600 -# Define the SMA time frame (in candles) used to calculate the fast SMA line. -SMA_fast_length = 21 -# Define the SMA time frame (in candles) used to calculate the slow SMA line. -SMA_slow_length = 55 -# Define how many candles back to look and see if the EMA lines just crossed. -EMA_cross_candles = 12 -# Define the period (in seconds) used to calculate the EMA lines. -EMA_candle_period = 900 -# Define the EMA time frame (in candles) used to calculate the fast EMA line. -EMA_fast_length = 8 -# Define the EMA time frame (in candles) used to calculate the slow EMA line. -EMA_slow_length = 13 -# Define the period (in seconds) used to calculate the RSI lines. -RSI_candle_period = 900 -# Define the RSI time frame (in candles) used by all RSI calculations -RSI_length = 2 -# Define the period (in seconds) used to calculate the STOCH. -STOCH_candle_period = 900 -# Define the Stochastics RSI time frame (in candles) used by all STOCHRSI calculations -STOCH_length = 14 -# The Stochastic Oscillator (STOCH) is range bound between 0 and 100. -# Both K and D represent lines on a price action chart. -# The first line (known as K) displays the current close (ie. the percentage of the -# price at closing) in relation to the price range (high/low) along the number of -# candles used to look back along the price action chart. -STOCH_K = 1 -# The second line (known as D) is a simple moving average of the first line, typically -# based on the last three candle periods for smoothing. -STOCH_D = 1 -# Define the period (in seconds) used to calculate the MACD lines. -MACD_candle_period = 900 -# Define the MA time frame (in candles) used to calculate the fast MACD line. -MACD_fast_length = 12 -# Define the MA time frame (in candles) used to calculate the slow MACD line. -MACD_slow_length = 26 -# Define the time frame (in days) of the EMA (Exponential Moving Average) of the MACD -MACD_signal = 9 -# Define the period (in seconds) used to calculate the RSI lines. -OBV_candle_period = 900 -# Total count of candles used to calculate the OBV values, e.g. 15 means we have 15 OBV values -OBV_length = 50 -# The number (integer) of the first OBV value used for the calculation of the percentage change. -OBV_signal = 1 -# Always uses 5 minute candles -SOM_trigger_length = 288 -# -# -STOCHRSI_candle_period = 900 -STOCHRSIK_candle_period = 900 -STOCHRSID_candle_period = 900 -# -STOCHRSI_stoch_length = 14 -STOCHRSIK_stoch_length = 14 -STOCHRSID_stoch_length = 14 -# -STOCHRSI_rsi_length = 14 -STOCHRSIK_rsi_length = 14 -STOCHRSID_rsi_length = 14 -# -STOCHRSIK_K = 3 -STOCHRSID_K = 3 -STOCHRSID_D = 3 \ No newline at end of file diff --git a/PTMagic/_presets/SidewaysUp/ElDorado-V4-INDICATORS.properties b/PTMagic/_presets/SidewaysUp/ElDorado-V4-INDICATORS.properties deleted file mode 100644 index d47a85b..0000000 --- a/PTMagic/_presets/SidewaysUp/ElDorado-V4-INDICATORS.properties +++ /dev/null @@ -1,78 +0,0 @@ -# #################################### -# ####### PTMagic Current Setting #### -# PTMagic_ActiveSetting = ElDorado-V4 -# PTMagic_LastChanged = 11/30/2018 16:41 -# #################################### - -# Standard Deviation -BB_std = 2 -# Define how many candles back to look back -BB_length = 20 -# Define the period (in seconds) used by all BB calculation of ProfitTrailer. -BB_candle_period = 900 -# Define how many candles back to look and see if the SMA lines just crossed. -SMA_cross_candles = 4 -# Define the period (in seconds) used to calculate the SMA lines -SMA_candle_period = 3600 -# Define the SMA time frame (in candles) used to calculate the fast SMA line. -SMA_fast_length = 21 -# Define the SMA time frame (in candles) used to calculate the slow SMA line. -SMA_slow_length = 55 -# Define how many candles back to look and see if the EMA lines just crossed. -EMA_cross_candles = 12 -# Define the period (in seconds) used to calculate the EMA lines. -EMA_candle_period = 900 -# Define the EMA time frame (in candles) used to calculate the fast EMA line. -EMA_fast_length = 8 -# Define the EMA time frame (in candles) used to calculate the slow EMA line. -EMA_slow_length = 13 -# Define the period (in seconds) used to calculate the RSI lines. -RSI_candle_period = 900 -# Define the RSI time frame (in candles) used by all RSI calculations -RSI_length = 2 -# Define the period (in seconds) used to calculate the STOCH. -STOCH_candle_period = 900 -# Define the Stochastics RSI time frame (in candles) used by all STOCHRSI calculations -STOCH_length = 14 -# The Stochastic Oscillator (STOCH) is range bound between 0 and 100. -# Both K and D represent lines on a price action chart. -# The first line (known as K) displays the current close (ie. the percentage of the -# price at closing) in relation to the price range (high/low) along the number of -# candles used to look back along the price action chart. -STOCH_K = 1 -# The second line (known as D) is a simple moving average of the first line, typically -# based on the last three candle periods for smoothing. -STOCH_D = 1 -# Define the period (in seconds) used to calculate the MACD lines. -MACD_candle_period = 900 -# Define the MA time frame (in candles) used to calculate the fast MACD line. -MACD_fast_length = 12 -# Define the MA time frame (in candles) used to calculate the slow MACD line. -MACD_slow_length = 26 -# Define the time frame (in days) of the EMA (Exponential Moving Average) of the MACD -MACD_signal = 9 -# Define the period (in seconds) used to calculate the RSI lines. -OBV_candle_period = 900 -# Total count of candles used to calculate the OBV values, e.g. 15 means we have 15 OBV values -OBV_length = 50 -# The number (integer) of the first OBV value used for the calculation of the percentage change. -OBV_signal = 1 -# Always uses 5 minute candles -SOM_trigger_length = 288 -# -# -STOCHRSI_candle_period = 900 -STOCHRSIK_candle_period = 900 -STOCHRSID_candle_period = 900 -# -STOCHRSI_stoch_length = 14 -STOCHRSIK_stoch_length = 14 -STOCHRSID_stoch_length = 14 -# -STOCHRSI_rsi_length = 14 -STOCHRSIK_rsi_length = 14 -STOCHRSID_rsi_length = 14 -# -STOCHRSIK_K = 3 -STOCHRSID_K = 3 -STOCHRSID_D = 3 From 023acc0e57a9d874a9791bf7f4afc7d28f634d58 Mon Sep 17 00:00:00 2001 From: djbadders <34887832+djbadders@users.noreply.github.com> Date: Mon, 30 Mar 2020 23:34:05 +0100 Subject: [PATCH 04/31] Updates timers for dashboard bottom --- Monitor/Pages/_Layout.cshtml | 1 + Monitor/Pages/_get/DashboardBottom.cshtml | 14 +- Monitor/wwwroot/assets/css/custom.css | 71 +- Monitor/wwwroot/assets/css/style.css | 9340 +++++++++++++-------- Monitor/wwwroot/assets/js/circlos.js | 62 + 5 files changed, 5968 insertions(+), 3520 deletions(-) create mode 100644 Monitor/wwwroot/assets/js/circlos.js diff --git a/Monitor/Pages/_Layout.cshtml b/Monitor/Pages/_Layout.cshtml index a4ab6fc..3108b41 100644 --- a/Monitor/Pages/_Layout.cshtml +++ b/Monitor/Pages/_Layout.cshtml @@ -209,5 +209,6 @@ + diff --git a/Monitor/Pages/_get/DashboardBottom.cshtml b/Monitor/Pages/_get/DashboardBottom.cshtml index 47be0f8..2e0bd56 100644 --- a/Monitor/Pages/_get/DashboardBottom.cshtml +++ b/Monitor/Pages/_get/DashboardBottom.cshtml @@ -12,9 +12,11 @@
+
+ @if (!Model.TrendChartDataJSON.Equals("")) {
- +
} else {

Unable to load graph, no market trend data found.

@@ -23,6 +25,7 @@
+
@{ double currentBalance = Model.PTData.GetCurrentBalance(); string currentBalanceString = currentBalance.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")); @@ -45,6 +48,8 @@
+
+
@if (!Model.ProfitChartDataJSON.Equals("")) {
@@ -60,7 +65,10 @@
+
+
+

Market Trends at @Model.PTMagicConfiguration.GeneralSettings.Application.Exchangemore

@@ -100,7 +108,10 @@
+
+
+

Sales Overviewmore

@{ double totalProfit = Model.PTData.SellLog.Sum(s => s.Profit); @@ -189,6 +200,7 @@ - \ No newline at end of file diff --git a/Monitor/Pages/_get/DashboardTop.cshtml.cs b/Monitor/Pages/_get/DashboardTop.cshtml.cs index 06a63ca..0efd6e9 100644 --- a/Monitor/Pages/_get/DashboardTop.cshtml.cs +++ b/Monitor/Pages/_get/DashboardTop.cshtml.cs @@ -6,16 +6,15 @@ namespace Monitor.Pages { public class DashboardTopModel : _Internal.BasePageModelSecureAJAX { public ProfitTrailerData PTData = null; public DateTimeOffset DateTimeNow = Constants.confMinDate; - public void OnGet() { // Initialize Config base.Init(); BindData(); } - public double TotalBagCost = 0; public double TotalBagValue = 0; + public double TotalBagGain = 0; private void BindData() { PTData = this.PtDataObject; From 40501be5dcf2b6bd06b2256596703460dcba19d5 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Sun, 26 Jul 2020 23:57:58 +0900 Subject: [PATCH 30/31] Remove debug value --- Monitor/Pages/_get/DashboardTop.cshtml | 1 - 1 file changed, 1 deletion(-) diff --git a/Monitor/Pages/_get/DashboardTop.cshtml b/Monitor/Pages/_get/DashboardTop.cshtml index db7c2ba..22d3ff4 100644 --- a/Monitor/Pages/_get/DashboardTop.cshtml +++ b/Monitor/Pages/_get/DashboardTop.cshtml @@ -242,7 +242,6 @@
- From 4d1ab9e06144397fb4d12600b8bd6db9c08b7185 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Fri, 7 Aug 2020 01:33:53 +0900 Subject: [PATCH 31/31] Binance USD market error --- Core/MarketAnalyzer/BinanceUS.cs | 88 ++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 39 deletions(-) diff --git a/Core/MarketAnalyzer/BinanceUS.cs b/Core/MarketAnalyzer/BinanceUS.cs index 070fe77..63b1318 100644 --- a/Core/MarketAnalyzer/BinanceUS.cs +++ b/Core/MarketAnalyzer/BinanceUS.cs @@ -20,27 +20,32 @@ namespace Core.MarketAnalyzer public static double GetMainCurrencyPrice(string mainMarket, PTMagicConfiguration systemConfiguration, LogHelper log) { double result = 0; - - try + if (mainMarket != "USD") { - string baseUrl = "https://api.binance.us/api/v1/ticker/24hr?symbol=" + mainMarket + "USDT"; - - log.DoLogInfo("BinanceUS - Getting main market price..."); - Newtonsoft.Json.Linq.JObject jsonObject = GetSimpleJsonObjectFromURL(baseUrl, log, null); - if (jsonObject != null) + try { - log.DoLogInfo("BinanceUS - Market data received for " + mainMarket + "USDT"); + string baseUrl = "https://api.binance.us/api/v1/ticker/24hr?symbol=" + mainMarket + "USDT"; - result = (double)jsonObject.GetValue("lastPrice"); - log.DoLogInfo("BinanceUS - Current price for " + mainMarket + "USDT: " + result.ToString("#,#0.00") + " USD"); + log.DoLogInfo("BinanceUS - Getting main market price..."); + Newtonsoft.Json.Linq.JObject jsonObject = GetSimpleJsonObjectFromURL(baseUrl, log, null); + if (jsonObject != null) + { + log.DoLogInfo("BinanceUS - Market data received for " + mainMarket + "USDT"); + + result = (double)jsonObject.GetValue("lastPrice"); + log.DoLogInfo("BinanceUS - Current price for " + mainMarket + "USDT: " + result.ToString("#,#0.00") + " USD"); + } } - } - catch (Exception ex) + catch (Exception ex) + { + log.DoLogCritical(ex.Message, ex); + } + return result; + } + else { - log.DoLogCritical(ex.Message, ex); + return 1.0; } - - return result; } public static List GetMarketData(string mainMarket, Dictionary marketInfos, PTMagicConfiguration systemConfiguration, LogHelper log) @@ -58,7 +63,7 @@ namespace Core.MarketAnalyzer if (jsonArray.Count > 0) { double mainCurrencyPrice = 1; - if (!mainMarket.Equals("USDT", StringComparison.InvariantCultureIgnoreCase)) + if (!mainMarket.Equals("USDT", StringComparison.InvariantCultureIgnoreCase) && !mainMarket.Equals("USD", StringComparison.InvariantCultureIgnoreCase)) { mainCurrencyPrice = BinanceUS.GetMainCurrencyPrice(mainMarket, systemConfiguration, log); } @@ -238,40 +243,45 @@ namespace Core.MarketAnalyzer } bool go = true; - while (ticksFetched < ticksNeeded && go) + if (!(marketName == "USDUSDT")) { - baseUrl = "https://api.binance.us/api/v1/klines?interval=1m&symbol=" + marketName + "&endTime=" + endTime.ToString() + "&limit=" + ticksLimit.ToString(); - - log.DoLogDebug("BinanceUS - Getting " + ticksLimit.ToString() + " ticks for '" + marketName + "'..."); - Newtonsoft.Json.Linq.JArray jsonArray = GetSimpleJsonArrayFromURL(baseUrl, log); - if (jsonArray.Count > 0) + while (ticksFetched < ticksNeeded && go) { - log.DoLogDebug("BinanceUS - " + jsonArray.Count.ToString() + " ticks received."); + + baseUrl = "https://api.binance.us/api/v1/klines?interval=1m&symbol=" + marketName + "&endTime=" + endTime.ToString() + "&limit=" + ticksLimit.ToString(); - foreach (Newtonsoft.Json.Linq.JArray marketTick in jsonArray) + log.DoLogDebug("BinanceUS - Getting " + ticksLimit.ToString() + " ticks for '" + marketName + "'..."); + Newtonsoft.Json.Linq.JArray jsonArray = GetSimpleJsonArrayFromURL(baseUrl, log); + if (jsonArray.Count > 0) { + log.DoLogDebug("BinanceUS - " + jsonArray.Count.ToString() + " ticks received."); - MarketTick tick = new MarketTick(); - tick.Price = (double)marketTick[4]; - tick.Volume24h = (double)marketTick[7]; - tick.Time = Constants.Epoch.AddMilliseconds((Int64)marketTick[0]); + foreach (Newtonsoft.Json.Linq.JArray marketTick in jsonArray) + { - result.Add(tick); + MarketTick tick = new MarketTick(); + tick.Price = (double)marketTick[4]; + tick.Volume24h = (double)marketTick[7]; + tick.Time = Constants.Epoch.AddMilliseconds((Int64)marketTick[0]); + + result.Add(tick); + } + + ticksFetched = ticksFetched + jsonArray.Count; + endTime = endTime - ticksLimit * 60 * 1000; + if (ticksNeeded - ticksFetched < ticksLimit) + { + ticksLimit = ticksNeeded - ticksFetched; + } } - - ticksFetched = ticksFetched + jsonArray.Count; - endTime = endTime - ticksLimit * 60 * 1000; - if (ticksNeeded - ticksFetched < ticksLimit) + else { - ticksLimit = ticksNeeded - ticksFetched; + log.DoLogDebug("BinanceUS - No ticks received."); + go = false; } } - else - { - log.DoLogDebug("BinanceUS - No ticks received."); - go = false; - } } + } catch (WebException ex) {
Totals: @Html.Raw(Model.TotalBagCost.ToString("#,#0.000000", new System.Globalization.CultureInfo("en-US")))@Html.Raw(Model.TotalBagValue.ToString("#,#0.000000", new System.Globalization.CultureInfo("en-US")))