Skip to content

Commit

Permalink
Diverse improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
QTinman committed Apr 9, 2021
1 parent da961b2 commit 639732e
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 28 deletions.
8 changes: 6 additions & 2 deletions coinfilterdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>393</width>
<width>431</width>
<height>257</height>
</rect>
</property>
Expand Down Expand Up @@ -243,7 +243,11 @@
</widget>
</item>
<item row="6" column="4">
<widget class="QDoubleSpinBox" name="volum_min"/>
<widget class="QDoubleSpinBox" name="volum_min">
<property name="maximum">
<double>1000000000.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
Expand Down
40 changes: 28 additions & 12 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ QString crypt="BTC";
QString exchange,dbfile="coinhistory.db",dbtable="coins";
QSqlDatabase db;
int colums=8,maxcoins=0;
QString appgroup="coinbrowser";
QString appgroup="coinbrowser",profile;
double from1h=-2,to1h=5,from24h=0,to24h=100,from7d=-2,to7d=100,btc_price=58338,markedcap_percent,volume_percent,price_change_from,price_change_to,volum_min;
bool change_1h,change_24h,change_7d,volume,marked_cap,use_volume,show_only_blacklisted,change_price,create_db=false;

Expand Down Expand Up @@ -45,8 +45,15 @@ MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
int row=0,i=0;
ui->setupUi(this);
QSettings appsettings("QTinman",appgroup);
appsettings.beginGroup("General");
profile = appsettings.value("profile").toString();
if (profile == "") {
profile = appgroup;
appsettings.setValue("profile",QVariant::fromValue(profile));
}
appsettings.endGroup();
setGeometry(loadsettings("position").toRect());
change_1h = loadsettings("change_1h").toBool();
change_24h = loadsettings("change_24h").toBool();
Expand All @@ -69,6 +76,7 @@ MainWindow::MainWindow(QWidget *parent)
volume_percent = loadsettings("volume_percent").toDouble();
volum_min = loadsettings("volum_min").toDouble();
crypt = loadsettings("crypt").toString();
dbfile=crypt+"_coinhistory.db";
btc_price = loadsettings("stake_coin_price").toDouble();
db = QSqlDatabase::addDatabase("QSQLITE"); //db start config
qDebug() << "db just configured";
Expand All @@ -83,7 +91,7 @@ MainWindow::MainWindow(QWidget *parent)
ui->comboBox->clear();
ui->comboBox->addItems(exchanges);
ui->messages->setText("");
this->setWindowTitle(tr("Cryptocurrency tool for Freqtrade"));
this->setWindowTitle("Cryptocurrency tool for Freqtrade, active stake coin "+crypt);
exchange = ui->comboBox->currentText();
QStringList modellist = initializemodel();
//QModelIndex index;
Expand Down Expand Up @@ -144,7 +152,7 @@ QVariant MainWindow::loadsettings(QString settings)
{
QVariant returnvar;
QSettings appsettings("QTinman",appgroup);
appsettings.beginGroup(appgroup);
appsettings.beginGroup(profile);
returnvar = appsettings.value(settings);
appsettings.endGroup();
return returnvar;
Expand All @@ -153,7 +161,7 @@ QVariant MainWindow::loadsettings(QString settings)
void MainWindow::savesettings(QString settings, QVariant attr)
{
QSettings appsettings("QTinman",appgroup);
appsettings.beginGroup(appgroup);
appsettings.beginGroup(profile);
appsettings.setValue(settings,QVariant::fromValue(attr));
appsettings.endGroup();
}
Expand Down Expand Up @@ -194,8 +202,8 @@ QStringList MainWindow::readpairs()

//QStringList data {"AKRO","FOR","DATA","GO","HIVE"};
//QStringList data {"DMT","AKRO","SPND","META","RDD","NPXS","MARO","SC","GLM","VLX","BORA","NKN","BTT","STPT","ORBS","GLEEC","MCO","DNT","PART","EXP","CVT","FLETA","GEO","KLAY","NLG","IOST","CND","PINK","CTXC","SHR","AKN","TUBE","VEE","BNT","REPv2","CELO","ELAMA","XST","IOC","CKB","KAI","FTC","REVV","APM","PI","OST","GBYTE","RCN","REV","SENSO","REN","OXT","MEME","BLOCK","NLC2","CURE","SKM","IOTX","GNO","FSN","DUSK","CPC","PHNX","ABBC","ADK","ROOM","JOB","LRC","OK","XTP","DCT","BTE","MORE","MER","SPHR","XEL","ONG","MDT","MYST","SUTER","STPT","BAL","VBK","WICC","HEDG","NGC","ENG","ABYSS","GTO","HDAC","ELF","ION","UMA","APIX","USDS","YOU","DAWN","EDG","GO","HMQ","UKG","RVC","LBA","BFT","LUCY","EXCL","HDAO","POT","AGRS","ART","GNC","AEON","SPC","THC","SIB","NKN","CHR","VRC","MTC","ECOC","IRIS","BOA","INSTAR","XSR","WINGS","DEP","CNTM","CTC","FOR","IHT","FCT2","GRIN","PXL","BWX","INX","BWF","ZEC","SUKU","VDX","HXRO","GXC","STC","LOON","TSHP","USDN","TSLA","PTOY","BLTV","URAC","DNA","SMBSWAP","FME","WBTC","SLS","KRT","ADT","BRZ","COSM","PROM","BTU","UPT","PLA","YFL"};
QSettings appsettings("QTinman","coinbrowser");
appsettings.beginGroup(appgroup);
QSettings appsettings("QTinman",appgroup);
appsettings.beginGroup(profile);
//appsettings.setValue("bittrex_blacklist", QVariant::fromValue(data));
QStringList blacklist_binance = appsettings.value("binance_blacklist").value<QStringList>();
QStringList blacklist_bittrex = appsettings.value("bittrex_blacklist").value<QStringList>();
Expand Down Expand Up @@ -289,6 +297,8 @@ QStringList MainWindow::initializemodel()
csv_file.setFileName(reportPath+"/"+csv_filename);
csv_file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream outStream(&csv_file);
QString stake=crypt;
if (stake.contains("USD")) stake="USD";
outStream << csv_string+"\n";

if (ui->maxcoins->text() == "") ui->maxcoins->setText(QString::number(maxcoins));
Expand All @@ -303,7 +313,7 @@ QStringList MainWindow::initializemodel()
symbol = data["symbol"].toString();
QString name = data["name"].toString();
QJsonObject quote = value["quote"].toObject();
QJsonObject coin = quote[crypt].toObject();
QJsonObject coin = quote[stake].toObject();
double price = coin["price"].toDouble();
double volume_24h = coin["volume_24h"].toDouble();
double percent_change_1h = coin["percent_change_1h"].toDouble();
Expand Down Expand Up @@ -354,13 +364,19 @@ QStringList MainWindow::initializemodel()



double startprice = ((100/btc_price)/db_price);
startprice = btc_price*db_price;
//double startprice = ((100/btc_price)/db_price);
double startprice = btc_price*db_price;
double endprice = btc_price*price;
price_change = endprice-startprice;
price_change = price_change/startprice*100;
price_change = 100/db_price*btc_price*(price-db_price);
price_change = 100/startprice;
price_change = price_change*(endprice-startprice);
if (price_change < -100 || price_change > 100) price_change=0;
//qDebug() << db_price << " " << price;

if ((json_date > db_date || (json_date == db_date && json_h >= db_h+10)) && symbol == "ETH") ui->messages->setText("DB is over 10h old! From " +QString::number(db_date)+"/"+QString::number(db_mo)+", time "+QString::number(db_h)+":"+QString::number(db_min));
ui->messages->setText("Database is from "+QString::number(db_date)+"/"+QString::number(db_mo)+", time "+QString::number(db_h,'G',2)+":"+QString::number(db_min));
if (ui->updatedb->isChecked())
{
QSqlQuery update_qry(db);
Expand Down Expand Up @@ -448,7 +464,7 @@ QStringList MainWindow::initializemodel()
hourplus = false;
dayplus = false;
priceplus = false;
create_db = false;

unique = 0;
marked_cap_ok = false;
coincounts++;
Expand All @@ -457,7 +473,7 @@ QStringList MainWindow::initializemodel()

}
csv_file.close();

create_db = false;
ui->updatedb->setChecked(false);
ui->messages->setText(ui->messages->text()+", Found and added to list "+QString::number(coininlist));
return modeldatalist;
Expand Down
38 changes: 31 additions & 7 deletions settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,27 @@
#include <QUrl>
#include <QtWidgets>


QString profill;
settingsDialog::settingsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::settingsDialog)
{
ui->setupUi(this);
//MainWindow main;
int index=0;
QStringList blacklist,cryptolist;
QStringList blacklist,cryptolist,profilelist;
QStringList exchanges={"Binance","Bittrex"}, maincoins={"BTC","ETH","USTD"};
ui->exchanges->clear();
ui->exchanges->addItems(exchanges);

QSettings appsettings("QTinman",appgroup);
appsettings.beginGroup("General");
profill = appsettings.value("profile").toString();
profilelist = appsettings.value("profilelist").toStringList();
ui->profilelist->addItems(profilelist);
ui->profilelist->setCurrentText(profill);
appsettings.endGroup();
ui->profile->setText(profill);
ui->maincoins->clear();
cryptolist = loadsettings("cryptolist").toStringList();
if (cryptolist.isEmpty()) cryptolist = maincoins;
Expand Down Expand Up @@ -56,12 +64,23 @@ settingsDialog::settingsDialog(QWidget *parent) :
settingsDialog::~settingsDialog()
{


//profill = ui->profile->text();
//qDebug() << ui->blacklist->toPlainText();
QStringList profilelist;
for (int i=0; i<ui->profilelist->count();i++) {
ui->profilelist->setCurrentIndex(i);
profilelist.append(ui->profilelist->currentText());
}
if (!profilelist.contains(ui->profile->text())) profilelist.append(ui->profile->text());
QSettings appsettings("QTinman",appgroup);
appsettings.beginGroup("General");
appsettings.setValue("profile",QVariant::fromValue(ui->profile->text()));
appsettings.setValue("profilelist", QVariant::fromValue(profilelist));
appsettings.endGroup();
QString ex=ui->exchanges->currentText();
QStringList blacklist=ui->blacklist->toPlainText().split("\n"),cryptolist=ui->maincoinslist->toPlainText().split("\n");
QSettings appsettings("QTinman",appgroup);
appsettings.beginGroup(appgroup);

appsettings.beginGroup(profill);
appsettings.setValue("cryptolist", QVariant::fromValue(cryptolist));
if (ui->exchanges->currentText()=="Binance") appsettings.setValue("binance_blacklist", QVariant::fromValue(blacklist));
if (ui->exchanges->currentText()=="Bittrex") appsettings.setValue("bittrex_blacklist", QVariant::fromValue(blacklist));
Expand All @@ -85,7 +104,7 @@ QVariant settingsDialog::loadsettings(QString settings)
{
QVariant returnvar;
QSettings appsettings("QTinman",appgroup);
appsettings.beginGroup(appgroup);
appsettings.beginGroup(profill);
returnvar = appsettings.value(settings);
appsettings.endGroup();
return returnvar;
Expand All @@ -94,7 +113,7 @@ QVariant settingsDialog::loadsettings(QString settings)
void settingsDialog::savesettings(QString settings, QVariant attr)
{
QSettings appsettings("QTinman",appgroup);
appsettings.beginGroup(appgroup);
appsettings.beginGroup(profill);
appsettings.setValue(settings,QVariant::fromValue(attr));
appsettings.endGroup();
}
Expand Down Expand Up @@ -139,3 +158,8 @@ void settingsDialog::on_pushButton_clicked()
{
QMessageBox::about(this,"Donate","If you find this program useful please donate to.\nPaypal to jonssofh@hotmail.com\nBTC 1HJ5xJmePkfrYwixbZJaMUcXosiJhYRLbo\nADA addr1q9h424fgyqw3y0zer34myqn9lyr303nxcyvzttk8nyqmr7r0242jsgqazg79j8rtkgpxt7g8zlrxdsgcykhv0xgpk8uqh49hnw\nVET 0x136349A99A5a56617e7E7AdbE8c55a0712B0068F\nSupport is most appreciated.");
}

void settingsDialog::on_profilelist_activated(int index)
{
ui->profile->setText(ui->profilelist->currentText());
}
2 changes: 2 additions & 0 deletions settingsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ private slots:

void savesettings(QString settings, QVariant attr);

void on_profilelist_activated(int index);

private:
Ui::settingsDialog *ui;
};
Expand Down
31 changes: 24 additions & 7 deletions settingsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@
</widget>
</item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Profile</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="profile"/>
</item>
<item>
<widget class="QComboBox" name="profilelist"/>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="jsonpath">
Expand All @@ -56,7 +73,7 @@
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_2">
Expand All @@ -77,7 +94,7 @@
</item>
</layout>
</item>
<item row="3" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
Expand All @@ -98,7 +115,7 @@
</item>
</layout>
</item>
<item row="4" column="0" colspan="2">
<item row="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
Expand All @@ -119,7 +136,7 @@
</item>
</layout>
</item>
<item row="5" column="0">
<item row="6" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_4">
Expand All @@ -136,7 +153,7 @@
</item>
</layout>
</item>
<item row="5" column="1" colspan="2">
<item row="6" column="1" colspan="2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_6">
Expand All @@ -163,15 +180,15 @@
<item>
<widget class="QSpinBox" name="stake_coin_price">
<property name="maximum">
<number>1000000</number>
<number>10000000</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="QLabel" name="message">
<property name="text">
<string>TextLabel</string>
Expand Down

0 comments on commit 639732e

Please # to comment.