Skip to content

Commit

Permalink
fixed bug in twitter agent
Browse files Browse the repository at this point in the history
  • Loading branch information
guifre committed Jul 6, 2014
1 parent 87f5d69 commit f46ba1e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
What's BTCWolf?
-------------
BTCWolf a simple automated bitcoin trading robot. I is aimed at monitoring bitcoin exchange markets to automatically take trade decisions and raise the user's capital. It supports multiple exchange markets, it comes out of the box with multiple trading strategies and a testing framework for those.
BTCWolf a simple automated bitcoin trading robot. It is aimed at automatically take trading decisions by monitoring bitcoin exchange markets and raise the user's capital. It supports multiple exchange markets, it comes out of the box with multiple trading strategies and a testing framework for those.

How BTCWolf works?
-------------
Expand Down
3 changes: 2 additions & 1 deletion src/org/btcwolf/BTCWolf.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ public class BTCWolf {
private static final Logger LOGGER = Logger.getLogger(BTCWolf.class);
private static final String LOG4J_PATH = "./resources/log4j.properties";
private static final long POLLING_TIME = 10000;
private static final boolean TWITTER_AGENT = true;

public static void main(String[] args) {

PropertyConfigurator.configure(LOG4J_PATH);

TraderAgent traderAgent = AgentsFactory.buildTraderAgent();
TradingStrategyFactory tradingStrategyFactory = new TradingStrategyFactory(traderAgent, true);
TradingStrategyFactory tradingStrategyFactory = new TradingStrategyFactory(traderAgent, TWITTER_AGENT);

Ticker previousTicker = traderAgent.pollTicker();
while(true) {
Expand Down
13 changes: 8 additions & 5 deletions src/org/btcwolf/strategy/TradingStrategyFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,13 @@
public class TradingStrategyFactory {

private final boolean useTwitter;

private final TraderAgent traderAgent;
private TradingStrategy strategy;

public TradingStrategyFactory(TraderAgent traderAgent, boolean useTwitter) {
this.traderAgent = traderAgent;
//this.strategy = buildTurtleStrategy(traderAgent);
//this.strategy = getDefaultWinWinStrategy();
this.strategy = buildExponentialMovingAverageStrategy();
this.useTwitter = useTwitter;
this.traderAgent = traderAgent;
initDefaultTradingStrategy();
}

public TradingStrategy buildWinWinStrategy() {
Expand Down Expand Up @@ -70,4 +67,10 @@ public void switchStrategy(TradingStrategy tradingStrategy) {
public TradingStrategy getTradingStrategy() {
return this.strategy;
}

private void initDefaultTradingStrategy() {
//this.strategy = buildTurtleStrategy(traderAgent);
//this.strategy = getDefaultWinWinStrategy();
this.strategy = buildExponentialMovingAverageStrategy();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ExponentialMovingAverageStrategy extends TradingStrategyMonitorDeco

private static final int MIN_TICKERS_BETWEEN_ORDERS = 25;

private static final BigDecimal MIN_DIFFERENCE_SHORT_LONG_EMA_TO_OP = valueOf(1);
private static final BigDecimal MIN_DIFFERENCE_SHORT_LONG_EMA_TO_OP = valueOf(0.8);

private static final int CHECK_DEAD_ORDERS_FREQ = 10; // every 10 tickers check hard limits
private static final int MAX_MINUTES_ORDER_TO_PROCESSED = 15;
Expand Down Expand Up @@ -240,9 +240,9 @@ private void checkDeadLimitOrders() {
int minutesSincePlacedLimit = timeSincePlaced / 60 / 1000;
if (minutesSincePlacedLimit > MAX_MINUTES_ORDER_TO_PROCESSED) {
boolean cancelled = traderAgent.cancelLimitOrder(limitOrder);
logger.info("Limit placed [" + minutesSincePlacedLimit + "] mins ago, cancelled [" + cancelled + "] limit [" + limitOrder);
logger.info("Limit placed [" + minutesSincePlacedLimit + "] mins ago, cancelled [" + cancelled + "] [" + limitOrder);
} else {
logger.debug("Limit placed [" + minutesSincePlacedLimit + "] mins ago, on time, limit [" + limitOrder);
logger.debug("Limit placed [" + minutesSincePlacedLimit + "] mins ago, on time [" + limitOrder);
}
}
}
Expand Down

0 comments on commit f46ba1e

Please sign in to comment.