StrategyParams.java

注意事項:
サンプルソースコードには実際にオーダーを発注するものがあります。
サンプルソースコードのストラテジーを起動する場合は、注意して下さい。



// Copyright (c) 2009 Dukascopy (Suisse) SA. All Rights Reserved.
package jforex.params;

import com.dukascopy.api.*;
import com.dukascopy.api.feed.IFeedDescriptor;
import com.dukascopy.api.feed.util.RenkoFeedDescriptor;

import java.awt.Color;
import java.io.File;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashSet;
import java.util.List;
import java.util.Set;



// ストラテジーの各パラメータタイプと、Date宣言についての複数の使用方法のサンプルです

public class StrategyParams implements IStrategy {

    @Configurable(value = "int パラメータ", stepSize = 3)
    public int intParam = 1;
    @Configurable(value = "double パラメータ", stepSize = 0.5)
    public double doubleParam = 0.5;
    @Configurable("bool パラメータ")
    public boolean boolParam = true;
    @Configurable("テキスト パラメータ")
    public String textParam = "some text";
    @Configurable("")
    public File file = new File(".");
    @Configurable(value="現在日時", description="default is current time")
    public Calendar currentTime = Calendar.getInstance();
    @Configurable("")
    public Color color = new Color(100, 100, 100);
    @Configurable("通貨ペア(enum)")
    public Instrument instrument = Instrument.EURUSD;
    @Configurable("")
    public Set<Instrument> instruments = new HashSet<Instrument>( 
            Arrays.asList(new Instrument[] {Instrument.EURUSD, Instrument.AUDCAD}) 
    );
    @Configurable("")
    public IFeedDescriptor renkoFeedDescriptor = new RenkoFeedDescriptor(Instrument.EURUSD, PriceRange.TWO_PIPS, OfferSide.ASK);
    
    // 日付/時間の使用方法
    
    private static Calendar myCalendar;
    static {
        myCalendar = Calendar.getInstance();
        myCalendar.set(2012, Calendar.JULY, 17, 14, 30, 00);
    }
    
    @Configurable(value="指定日時", description="17th july 14:30")    
    public Calendar particularTime = myCalendar;
    
    private static Calendar calTodayAt5am;
    static {
        calTodayAt5am = Calendar.getInstance();
        calTodayAt5am.set(Calendar.HOUR_OF_DAY, 5);
        calTodayAt5am.set(Calendar.MINUTE, 0);
        calTodayAt5am.set(Calendar.SECOND, 0);
    }
    
    @Configurable(value="msec単位の日時", description="default is today at 5am", datetimeAsLong=true)    
    public long timeInMillis = calTodayAt5am.getTimeInMillis();
    
    // カスタム列挙
    
    enum Mode { 
        BUY,
        SELL,
        NONE
    }
    @Configurable("モード (enum param)")
    public Mode mode = Mode.BUY;

    // self-typed定数カスタムクラス 
    
    static class Person {
        
        public static final Person FOO = new Person("foo");
        
        public static final Person BAR = new Person("bar");
        
        public final String name;
        
        public Person(String name){
            this.name = name;
        }
        
        @Override 
        public String toString(){
            return name;
        }
    }
    
    @Configurable("")
    public Person person;
    
    @Configurable("")
    public ListList<Person> persons;
    
    
    @Override
    public void onStart(IContext context) throws JFException {}
    @Override
    public void onTick(Instrument instrument, ITick tick) throws JFException {}
    @Override
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}
    @Override
    public void onMessage(IMessage message) throws JFException {}
    @Override
    public void onAccount(IAccount account) throws JFException {}
    @Override
    public void onStop() throws JFException {}

}






スポンサーリンク

スポンサーリンク
検索
リファレンスツリー


Copyright ©2016 JForexAPIで自動売買させ隊! All Rights Reserved.


Top

inserted by FC2 system