本文整理汇总了Java中com.dukascopy.api.OfferSide类的典型用法代码示例。如果您正苦于以下问题:Java OfferSide类的具体用法?Java OfferSide怎么用?Java OfferSide使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OfferSide类属于com.dukascopy.api包,在下文中一共展示了OfferSide类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: check
import com.dukascopy.api.OfferSide; //导入依赖的package包/类
@Override
protected void check(Signal challenge) {
IIndicators indicators = StateMachine.getInstance().getContext().getIndicators();
double adx = 0;
try {
adx = indicators.adx(challenge.getInstrument(), challenge.getPeriod(), OfferSide.ASK, 13, 1);
} catch (JFException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
switch (trend) {
case StateMachine.TREND:
if (adx < limit) {
setExclusion();
}
break;
case StateMachine.CHAOS:
if (adx > limit) {
setExclusion();
}
default:
break;
}
}
示例2: marginForCrossCurrency
import com.dukascopy.api.OfferSide; //导入依赖的package包/类
private double marginForCrossCurrency(final ICurrency crossCurrency) {
final double conversionLot = calculationUtil.convertAmount(lotSize(),
crossCurrency,
currency(),
OfferSide.ASK);
return conversionLot / leverage();
}
示例3: createParams
import com.dukascopy.api.OfferSide; //导入依赖的package包/类
private BarParams createParams(final Instrument instrument,
final BrokerHistoryData brokerHistoryData) {
final Period period = TimeConvert.getPeriodFromMinutes(brokerHistoryData.periodInMinutes());
return BarParams
.forInstrument(instrument)
.period(period)
.offerSide(OfferSide.ASK);
}
示例4: pipCostCalculationIsCorrect
import com.dukascopy.api.OfferSide; //导入依赖的package包/类
@Test
public void pipCostCalculationIsCorrect() {
final double mockedPipCost = 42.42;
when(calculationUtilMock.pipValueInCurrency(lotSize,
tradeInstrument,
accountCurrency,
OfferSide.ASK))
.thenReturn(mockedPipCost);
assertThat(accountInfo.pipCost(tradeInstrument), equalTo(mockedPipCost));
}
示例5: marginPerLotCalculationIsCorrect
import com.dukascopy.api.OfferSide; //导入依赖的package包/类
@Test
public void marginPerLotCalculationIsCorrect() {
final Instrument instrumentForCalculation = Instrument.GBPAUD;
final double mockedConversionAmount = 0.123;
when(calculationUtilMock.convertAmount(lotSize,
CurrencyFactory.GBP,
accountCurrency,
OfferSide.ASK))
.thenReturn(mockedConversionAmount);
assertThat(accountInfo.marginPerLot(instrumentForCalculation),
equalTo(mockedConversionAmount / leverage));
}
示例6: Bars
import com.dukascopy.api.OfferSide; //导入依赖的package包/类
public Object Bars(String instrument, String per, String nb) throws ParseException, JFException{
Period period = parsePeriod(per);
int n= Integer.parseInt(nb);
Instrument inst = parseInstrument(instrument);
return history.getBars(inst, period, OfferSide.BID, Filter.NO_FILTER, n, history.getStartTimeOfCurrentBar(inst, period) , 0);
}
示例7: calc
import com.dukascopy.api.OfferSide; //导入依赖的package包/类
@Override
protected double calc(Signal challenge, Period period, IBar askBar, IBar bidBar, State actual) {
IIndicators indicators = StateMachine.getInstance().getContext().getIndicators();
try {
/*
* ASK
*/
double sma55weekly = indicators.sma(challenge.getInstrument(), Period.WEEKLY, OfferSide.ASK, AppliedPrice.MEDIAN_PRICE, 55, 0);
double sma21daily = indicators.sma(challenge.getInstrument(), Period.DAILY, OfferSide.ASK, AppliedPrice.MEDIAN_PRICE, 21, 0);
double sma34fhours = indicators.sma(challenge.getInstrument(), Period.FOUR_HOURS, OfferSide.ASK, AppliedPrice.CLOSE, 34, 0);
double price = askBar.getClose();
if ( price > sma55weekly && price > sma21daily && price > sma34fhours ) {
challenge.setType(OrderCommand.SELL);
return this.max;
}
sma55weekly = indicators.sma(challenge.getInstrument(), Period.WEEKLY, OfferSide.BID, AppliedPrice.MEDIAN_PRICE, 55, 0);
sma21daily = indicators.sma(challenge.getInstrument(), Period.DAILY, OfferSide.BID, AppliedPrice.MEDIAN_PRICE, 21, 0);
sma34fhours = indicators.sma(challenge.getInstrument(), Period.FOUR_HOURS, OfferSide.BID, AppliedPrice.CLOSE, 34, 0);
price = bidBar.getClose();
if ( price < sma55weekly && price < sma21daily && price < sma34fhours ) {
challenge.setType(OrderCommand.BUY);
return this.max;
}
} catch (JFException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return 0;
}
示例8: pipCost
import com.dukascopy.api.OfferSide; //导入依赖的package包/类
public double pipCost(final Instrument instrument) {
return calculationUtil.pipValueInCurrency(lotSize(),
instrument,
currency(),
OfferSide.ASK);
}
示例9: assertSetSLParamsValues
import com.dukascopy.api.OfferSide; //导入依赖的package包/类
@Test
public void assertSetSLParamsValues() {
assertThat(setSLParams.order(), equalTo(orderMockA));
assertThat(setSLParams.offerSide(), equalTo(OfferSide.ASK));
assertThat(setSLParams.priceOrPips(), equalTo(slPrice));
}