00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <qlayout.h>
00023 #include <qvgroupbox.h>
00024 #include <qlabel.h>
00025 #include <qvalidator.h>
00026 #include "TesterTestPage.h"
00027 #include "BarData.h"
00028 #include "Config.h"
00029
00030
00031 TesterTestPage::TesterTestPage (QWidget *p) : QWidget (p)
00032 {
00033 fieldList.append(tr("Open"));
00034 fieldList.append(tr("Close"));
00035 fieldList.append(tr("Mid Point"));
00036
00037 QHBoxLayout *hbox = new QHBoxLayout(this);
00038 hbox->setMargin(5);
00039 hbox->setSpacing(10);
00040
00041
00042
00043 QGridLayout *grid = new QGridLayout(hbox);
00044 grid->setColStretch(1, 1);
00045 grid->setSpacing(5);
00046
00047
00048
00049 tradeLong = new QCheckBox(tr("Long"), this);
00050 grid->addWidget(tradeLong, 0, 0);
00051
00052 tradeShort = new QCheckBox(tr("Short"), this);
00053 grid->addWidget(tradeShort, 1, 0);
00054
00055 QLabel *label = new QLabel(tr("Trade Delay"), this);
00056 grid->addWidget(label, 2, 0);
00057
00058 tradeDelay = new QSpinBox(1, 999999, 1, this);
00059 tradeDelay->setValue(1);
00060 grid->addWidget(tradeDelay, 2, 1);
00061
00062 grid->setRowSpacing(grid->numRows(), 25);
00063
00064
00065
00066 label = new QLabel(tr("Account Balance"), this);
00067 grid->addWidget(label, 4, 0);
00068
00069 account = new QSpinBox(0, 999999, 1, this);
00070 account->setValue(10000);
00071 grid->addWidget(account, 4, 1);
00072
00073 label = new QLabel(tr("Futures Margin"), this);
00074 grid->addWidget(label, 5, 0);
00075
00076 margin = new QSpinBox(0, 999999, 1, this);
00077 grid->addWidget(margin, 5, 1);
00078
00079 label = new QLabel(tr("Volume %"), this);
00080 grid->addWidget(label, 6, 0);
00081
00082 volumePercent = new QSpinBox(0, 100, 1, this);
00083 grid->addWidget(volumePercent, 6, 1);
00084
00085 grid->setRowSpacing(grid->numRows(), 25);
00086
00087
00088
00089 commissionType = new QCheckBox(tr("Use Commission %"), this);
00090 grid->addWidget(commissionType, 8, 0);
00091
00092 label = new QLabel(tr("Entry"), this);
00093 grid->addWidget(label, 9, 0);
00094
00095 QDoubleValidator *dv = new QDoubleValidator(0, 99999999.0, 4, this, 0);
00096 entryCom = new QLineEdit(QString::number(10), this);
00097 entryCom->setValidator(dv);
00098 grid->addWidget(entryCom, 9, 1);
00099
00100 label = new QLabel(tr("Exit"), this);
00101 grid->addWidget(label, 10, 0);
00102
00103 QDoubleValidator *dv2 = new QDoubleValidator(0, 99999999.0, 4, this, 0);
00104 exitCom = new QLineEdit(QString::number(10), this);
00105 exitCom->setValidator(dv2);
00106 grid->addWidget(exitCom, 10, 1);
00107
00108 grid->setRowStretch(grid->numRows() + 1, 1);
00109
00110
00111
00112 QFrame *line = new QFrame(this);
00113 line->setFrameStyle(QFrame::VLine | QFrame::Plain);
00114 hbox->addWidget(line);
00115
00116
00117
00118 grid = new QGridLayout(hbox);
00119 grid->setColStretch(1, 1);
00120 grid->setSpacing(5);
00121
00122
00123
00124 label = new QLabel(tr("Symbol"), this);
00125 grid->addWidget(label, 0, 0);
00126
00127 Config config;
00128 QString s, s2;
00129 config.getData(Config::DataPath, s);
00130 symbolButton = new SymbolButton(this, s, s2);
00131 connect(symbolButton, SIGNAL(symbolChanged()), this, SLOT(symbolButtonPressed()));
00132 grid->addWidget(symbolButton, 0, 1);
00133
00134 label = new QLabel(tr("Bar Length"), this);
00135 grid->addWidget(label, 1, 0);
00136
00137 BarData bd(s);
00138 barLength = new QComboBox(this);
00139 bd.getBarLengthList(barLengthList);
00140 barLength->insertStringList(barLengthList, -1);
00141 barLength->setCurrentItem(6);
00142 grid->addWidget(barLength, 1, 1);
00143
00144 label = new QLabel(tr("Bars"), this);
00145 grid->addWidget(label, 2, 0);
00146
00147 bars = new QSpinBox(1, 99999999, 1, this);
00148 bars->setValue(275);
00149 grid->addWidget(bars, 2, 1);
00150
00151 label = new QLabel(tr("Entry/Exit Price"), this);
00152 grid->addWidget(label, 3, 0);
00153
00154 priceField = new QComboBox(this);
00155 priceField->insertStringList(fieldList,-1);
00156 grid->addWidget(priceField, 3, 1);
00157
00158 grid->setRowStretch(grid->numRows() + 1, 1);
00159 }
00160
00161 TesterTestPage::~TesterTestPage ()
00162 {
00163 }
00164
00165 void TesterTestPage::symbolButtonPressed ()
00166 {
00167 QString symbol;
00168 symbolButton->getPath(symbol);
00169 }
00170
00171 bool TesterTestPage::getTradeLong ()
00172 {
00173 return tradeLong->isChecked();
00174 }
00175
00176 void TesterTestPage::setTradeLong (bool d)
00177 {
00178 tradeLong->setChecked(d);
00179 }
00180
00181 bool TesterTestPage::getTradeShort ()
00182 {
00183 return tradeShort->isChecked();
00184 }
00185
00186 void TesterTestPage::setTradeShort (bool d)
00187 {
00188 tradeShort->setChecked(d);
00189 }
00190
00191 int TesterTestPage::getVolumePercent ()
00192 {
00193 return volumePercent->value();
00194 }
00195
00196 void TesterTestPage::setVolumePercent (int d)
00197 {
00198 volumePercent->setValue(d);
00199 }
00200
00201 double TesterTestPage::getEntryCom ()
00202 {
00203 return entryCom->text().toDouble();
00204 }
00205
00206 void TesterTestPage::setEntryCom (double d)
00207 {
00208 entryCom->setText(QString::number(d));
00209 }
00210
00211 double TesterTestPage::getExitCom ()
00212 {
00213 return exitCom->text().toDouble();
00214 }
00215
00216 void TesterTestPage::setExitCom (double d)
00217 {
00218 exitCom->setText(QString::number(d));
00219 }
00220
00221 int TesterTestPage::getTradeDelay ()
00222 {
00223 return tradeDelay->value();
00224 }
00225
00226 void TesterTestPage::setTradeDelay (int d)
00227 {
00228 tradeDelay->setValue(d);
00229 }
00230
00231 QString TesterTestPage::getPriceField ()
00232 {
00233 return priceField->currentText();
00234 }
00235
00236 void TesterTestPage::setPriceField (QString d)
00237 {
00238 priceField->setCurrentText(d);
00239 }
00240
00241 int TesterTestPage::getBars ()
00242 {
00243 return bars->value();
00244 }
00245
00246 void TesterTestPage::setBars (int d)
00247 {
00248 bars->setValue(d);
00249 }
00250
00251 QString TesterTestPage::getSymbolPath ()
00252 {
00253 QString s;
00254 symbolButton->getPath(s);
00255 return s;
00256 }
00257
00258 void TesterTestPage::setSymbol (QString d)
00259 {
00260 symbolButton->setSymbol(d);
00261 }
00262
00263 QString TesterTestPage::getSymbol ()
00264 {
00265 QString s;
00266 symbolButton->getSymbol(s);
00267 return s;
00268 }
00269
00270 int TesterTestPage::getAccount ()
00271 {
00272 return account->value();
00273 }
00274
00275 void TesterTestPage::setAccount (int d)
00276 {
00277 account->setValue(d);
00278 }
00279
00280 QString TesterTestPage::getBarLength ()
00281 {
00282 return barLength->currentText();
00283 }
00284
00285 void TesterTestPage::setBarLength (QString d)
00286 {
00287 barLength->setCurrentText(d);
00288 }
00289
00290 int TesterTestPage::getBarLengthIndex ()
00291 {
00292 return barLengthList.findIndex(barLength->currentText());
00293 }
00294
00295 int TesterTestPage::getMargin ()
00296 {
00297 return margin->value();
00298 }
00299
00300 void TesterTestPage::setMargin (int d)
00301 {
00302 margin->setValue(d);
00303 }
00304
00305 bool TesterTestPage::getCommissionType ()
00306 {
00307 return commissionType->isChecked();
00308 }
00309
00310 void TesterTestPage::setCommissionType (bool d)
00311 {
00312 commissionType->setChecked(d);
00313 }
00314
00315