More fixes
- Fixed checking file timestamps to use UTC - Added better debug info on failed calls for market data - Fixed failure to get currency exchange rates
This commit is contained in:
parent
bfae59193f
commit
cb4f0a01ed
|
@ -45,7 +45,7 @@ namespace Core.Helper
|
|||
|
||||
FileInfo file = new FileInfo(filePath);
|
||||
|
||||
string backupFilePath = backupFolder + DateTime.UtcNow.ToString("yyyy-MM-dd_HH.mm.ss") + "_" + file.Name;
|
||||
string backupFilePath = backupFolder + DateTime.Now.ToString("yyyy-MM-dd_HH.mm.ss") + "_" + file.Name;
|
||||
if (!backupFileName.Equals(""))
|
||||
{
|
||||
backupFilePath = backupFolder + backupFileName;
|
||||
|
@ -66,7 +66,7 @@ namespace Core.Helper
|
|||
{
|
||||
DateTime maxAge = DateTime.UtcNow.AddMinutes(-maxMinutes);
|
||||
|
||||
if (file.LastWriteTime < maxAge)
|
||||
if (file.LastWriteTimeUtc < maxAge)
|
||||
{
|
||||
File.Delete(file.FullName);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ namespace Core.Helper
|
|||
{
|
||||
DateTime maxAge = DateTime.UtcNow.AddHours(-(maxHours + 1));
|
||||
|
||||
if (file.LastWriteTime < maxAge)
|
||||
if (file.LastWriteTimeUtc < maxAge)
|
||||
{
|
||||
File.Delete(file.FullName);
|
||||
}
|
||||
|
|
|
@ -893,7 +893,7 @@ namespace Core.Main
|
|||
if (File.Exists(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + Constants.PTMagicPathData + Path.DirectorySeparatorChar + "LastRuntimeSummary.json"))
|
||||
{
|
||||
FileInfo fiLastSummary = new FileInfo(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + Constants.PTMagicPathData + Path.DirectorySeparatorChar + "LastRuntimeSummary.json");
|
||||
if (fiLastSummary.LastWriteTime < DateTime.UtcNow.AddMinutes(-(this.PTMagicConfiguration.AnalyzerSettings.MarketAnalyzer.IntervalMinutes * 2)))
|
||||
if (fiLastSummary.LastWriteTimeUtc < DateTime.UtcNow.AddMinutes(-(this.PTMagicConfiguration.AnalyzerSettings.MarketAnalyzer.IntervalMinutes * 2)))
|
||||
{
|
||||
Log.DoLogWarn("PTMagic seems to have frozen after raid " + this.RunCount.ToString() + ", but don't worry I will sacrifice some Magicbots to get this running again...");
|
||||
this.State = Constants.PTMagicBotState_Idle;
|
||||
|
@ -916,7 +916,7 @@ namespace Core.Main
|
|||
|
||||
FileInfo generalSettingsFile = new FileInfo(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "settings.general.json");
|
||||
FileInfo analyzerSettingsFile = new FileInfo(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "settings.analyzer.json");
|
||||
if (generalSettingsFile.LastWriteTime > this.LastSettingFileCheck || analyzerSettingsFile.LastWriteTime > this.LastSettingFileCheck || EnforceSettingsReapply)
|
||||
if (generalSettingsFile.LastWriteTimeUtc > this.LastSettingFileCheck || analyzerSettingsFile.LastWriteTimeUtc > this.LastSettingFileCheck || EnforceSettingsReapply)
|
||||
{
|
||||
Log.DoLogInfo("Detected configuration changes. Reloading settings...");
|
||||
|
||||
|
|
|
@ -27,9 +27,11 @@ namespace Core.MarketAnalyzer
|
|||
request.UserAgent = "PTMagic.Import";
|
||||
request.KeepAlive = true;
|
||||
|
||||
HttpWebResponse httpResponse = null;
|
||||
|
||||
try
|
||||
{
|
||||
HttpWebResponse httpResponse = (HttpWebResponse)request.GetResponse();
|
||||
httpResponse = (HttpWebResponse)request.GetResponse();
|
||||
|
||||
StreamReader jsonReader = new StreamReader(httpResponse.GetResponseStream());
|
||||
string jsonString = jsonReader.ReadToEnd();
|
||||
|
@ -41,7 +43,18 @@ namespace Core.MarketAnalyzer
|
|||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
log.DoLogCritical(ex.Message, ex);
|
||||
// Error calling the service but we got a response so dump it.
|
||||
string responseString = string.Empty;
|
||||
var encoding = httpResponse.CharacterSet == "" ? Encoding.UTF8 : Encoding.GetEncoding(httpResponse.CharacterSet);
|
||||
|
||||
using (var stream = httpResponse.GetResponseStream())
|
||||
{
|
||||
var reader = new StreamReader(stream, encoding);
|
||||
responseString = reader.ReadToEnd();
|
||||
}
|
||||
|
||||
log.DoLogCritical(String.Format("{0} - Response: ({1}) {2} : {3}", ex.Message, httpResponse.StatusCode, httpResponse.StatusDescription, responseString), ex);
|
||||
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -199,7 +212,7 @@ namespace Core.MarketAnalyzer
|
|||
{
|
||||
double result = 1;
|
||||
|
||||
string baseUrl = "http://free.currencyconverterapi.com/api/v5/convert?q=USD_" + currency + "&compact=y";
|
||||
string baseUrl = "http://free.currencyconverterapi.com/api/v5/convert?q=USD_" + currency + "&compact=y&apiKey=sample-api-key";
|
||||
|
||||
log.DoLogDebug("http://free.currencyconverterapi.com - Getting latest exchange rates...");
|
||||
Newtonsoft.Json.Linq.JObject jsonObject = GetSimpleJsonObjectFromURL(baseUrl, log, false);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# ####################################
|
||||
# ####### PTMagic Current Setting ########
|
||||
# PTMagic_ActiveSetting = Default
|
||||
# PTMagic_LastChanged = 7/30/18 10:58 PM
|
||||
# PTMagic_LastChanged = 17/02/2019 18:11
|
||||
# ####################################
|
||||
|
||||
############################
|
||||
|
@ -72,10 +72,3 @@ DEFAULT_DCA_A_buy_value_limit = 0
|
|||
DEFAULT_DCA_B_buy_strategy = STOCHRSI
|
||||
DEFAULT_DCA_B_buy_value = 0.2
|
||||
DEFAULT_DCA_B_buy_value_limit = 0
|
||||
|
||||
################
|
||||
##### Dust #####
|
||||
BTC_dust = 0.000999
|
||||
ETH_dust = 0.00999
|
||||
BNB_dust = 0.0105
|
||||
USDT_dust = 9.99
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# ####################################
|
||||
# ####### PTMagic Current Setting ########
|
||||
# PTMagic_ActiveSetting = Default
|
||||
# PTMagic_LastChanged = 7/30/18 10:58 PM
|
||||
# PTMagic_LastChanged = 17/02/2019 18:11
|
||||
# ####################################
|
||||
|
||||
OBV_candle_period = 300
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# ####################################
|
||||
# ####### PTMagic Current Setting ########
|
||||
# PTMagic_ActiveSetting = Default
|
||||
# PTMagic_LastChanged = 7/30/18 10:58 PM
|
||||
# PTMagic_LastChanged = 17/02/2019 18:11
|
||||
# ####################################
|
||||
|
||||
############################
|
||||
|
|
Loading…
Reference in New Issue