Pages:
Author

Topic: CryptoTrader.org - First Web-based Algorithmic Trading Platform for Bitcoin - page 7. (Read 37918 times)

member
Activity: 90
Merit: 10
This is great!
Thanks

How do I set the name for a Trader?
Can you add something similar for Backtests as well, so one can have a collection of trading strategies? Right now bookmarking everything manually is kind of tedious ..
full member
Activity: 220
Merit: 100
New update
  • fixed the problem with connection via websockets that caused poor performance and errors in many browser configurations.
  • Live mode that provides very basic support for Paper trading. Any backtested algorithm can be executed in Paper trading mode by clicking 'Live' button. Once started, an algorithm(trader) handles real-time market data to simulate trading and trigger alerts. Trading algorithms can be managed at https://cryptotrader.org/live page.
  • API: Email alerts -  allows email messages to be sent from your code.
Quote
sendEmail(message) (only Live mode)
Sends an email message to the user who started the algorithm in Live mode. The user's email address must be valid and verified. In the simulation mode does nothing.

Example:
Code:
# simple price alert
handle: (contex,data)->
  ...
  if data.btc_usd.price >= 100
    sendEmail 'The price hit $100'
sr. member
Activity: 287
Merit: 250
As most candlestick generators assume open price to be equal the close price from the previous bar, it turns out the algorithms at Cryptotrader handle market data correctly.

In traditional trading (markets that open in the morning and close in the afternoon) it happens quite often that the close of the previous day is lower / higher than the open of the new day.



Markets like BTC/USD don't close at all but I have seen candles where the open and the close were not the same at all.
full member
Activity: 220
Merit: 100
first. by lag I meant lag of executing signal after time period is closed and ready to calculate.
second. I prefer to use next bar price from the very clear reason: your buy/sell action price will be aggregated to the next bar period, not to the previous on which signal was calculated. "Open" price of the next bar should be more correct in your case. Another thing you should keep in mind that signal calculations might be much more time consuming than just EMA crossing and would not be executed right after the period is closed.

As most candlestick generators assume open price to be equal the close price from the previous bar, it turns out the algorithms at Cryptotrader handle market data correctly.
sr. member
Activity: 287
Merit: 250
I think there has been misunderstanding about my explanation, as i tried to explain how internal calculation of a simulated purchase is done, but not how trends are detected.

Oops my bad, I read it to quick probably Sad
full member
Activity: 175
Merit: 100
Once the bar is closed, an algorithm handles it immediately.
if you will have bars in 1min or 30s? it will not be as immediate as it is now.
you cannot buy for average price of current bar because that period is just closed, you buy on the next bar avg price, your trade is being aggregated to this next bar.
That's why you are counting the price as next bar. You can perform simulation based on real executed price of orders ~ estimated by both methods with lag/with no lag.

When you have 30 minutes bar the engine will trigger when a bar closes, within a very short amount the engine will determine whether it needs to change the portfolio (and if to buy or sell to reflect this). This will all probably happen within 1 second after the bar closed, with the low liquidity in the BTC market I really don't think the effects are big. And if they are I don't see how the average price of the next bar is any better price indicator as a lot can happen after in the 29 minutes and 59 seconds after the decision (maybe the open of the next candle would be a little better but I really don't see it right now).

About the lag: I don't know if this data is available at all, but it is not going to help you much: when there is a 10 second lag it means the trading engine is lagging 10 seconds behind. All orders from between 10 seconds ago and now are queued and they are probably not available, so they are unknown at the time you make your decision (not 100% sure, maybe there are in the order book already).

If I got your question correctly:
Code:
Trade price = Close price for the current bar + Trading fee

Remember, this is only a simulation so the formula does not consider slippage and other real trading costs.

I don't agree on your price calculation: While the trading fee obviously needs to be payed while ordering, the alpha (EMA/MACD indicator) is only responsible for detecting the trend, you are now manipulating the data so that trends happening do not get properly detected IMO (difference is pretty small, but it's there).

This is a hard problem because the current alpha (a simple trend indicator) can't tell you anything about how long a trend will probably last (statistically) or how much the price will change. If you would have a model predicting this you can better determine if you should reposition your portfolio while taking fees into account. My bot only uses the fees to simulate the profit, it does not use them to determine what position to take.
first. by lag I meant lag of executing signal after time period is closed and ready to calculate.
second. I prefer to use next bar price from the very clear reason: your buy/sell action price will be aggregated to the next bar period, not to the previous on which signal was calculated. "Open" price of the next bar should be more correct in your case. Another thing you should keep in mind that signal calculations might be much more time consuming than just EMA crossing and would not be executed right after the period is closed.
full member
Activity: 220
Merit: 100
I don't agree on your price calculation: While the trading fee obviously needs to be payed while ordering, the alpha (EMA/MACD indicator) is only responsible for detecting the trend, you are now manipulating the data so that trends happening do not get properly detected IMO (difference is pretty small, but it's there).

This is a hard problem because the current alpha (a simple trend indicator) can't tell you anything about how long a trend will probably last (statistically) or how much the price will change. If you would have a model predicting this you can better determine if you should reposition your portfolio while taking fees into account. My bot only uses the fees to simulate the profit, it does not use them to determine what position to take.

I think there has been misunderstanding about my explanation, as i tried to explain how internal calculation of a simulated purchase is done, but not how trends are detected. By default EMA is calculated based on Close price as it is suggested in TA-lib documenation:
Code:
instrument = data.btc_usd
result = talib.EMA
  startIdx: 0
  endIdx: instrument.close.length-1
  inReal: instrument.close
  optInTimePeriod: period
value = _.last(result)

However, in your algorithm at Cryptotrader you can use any market data from the past as the inputs for TA-Lib functions.
sr. member
Activity: 287
Merit: 250
Once the bar is closed, an algorithm handles it immediately.
if you will have bars in 1min or 30s? it will not be as immediate as it is now.
you cannot buy for average price of current bar because that period is just closed, you buy on the next bar avg price, your trade is being aggregated to this next bar.
That's why you are counting the price as next bar. You can perform simulation based on real executed price of orders ~ estimated by both methods with lag/with no lag.

When you have 30 minutes bar the engine will trigger when a bar closes, within a very short amount the engine will determine whether it needs to change the portfolio (and if to buy or sell to reflect this). This will all probably happen within 1 second after the bar closed, with the low liquidity in the BTC market I really don't think the effects are big. And if they are I don't see how the average price of the next bar is any better price indicator as a lot can happen after in the 29 minutes and 59 seconds after the decision (maybe the open of the next candle would be a little better but I really don't see it right now).

About the lag: I don't know if this data is available at all, but it is not going to help you much: when there is a 10 second lag it means the trading engine is lagging 10 seconds behind. All orders from between 10 seconds ago and now are queued and they are probably not available, so they are unknown at the time you make your decision (not 100% sure, maybe there are in the order book already).

If I got your question correctly:
Code:
Trade price = Close price for the current bar + Trading fee

Remember, this is only a simulation so the formula does not consider slippage and other real trading costs.

I don't agree on your price calculation: While the trading fee obviously needs to be payed while ordering, the alpha (EMA/MACD indicator) is only responsible for detecting the trend, you are now manipulating the data so that trends happening do not get properly detected IMO (difference is pretty small, but it's there).

This is a hard problem because the current alpha (a simple trend indicator) can't tell you anything about how long a trend will probably last (statistically) or how much the price will change. If you would have a model predicting this you can better determine if you should reposition your portfolio while taking fees into account. My bot only uses the fees to simulate the profit, it does not use them to determine what position to take.


EDIT: It appears I failed to read properly.
full member
Activity: 175
Merit: 100
Once the bar is closed, an algorithm handles it immediately.
if you will have bars in 1min or 30s? it will not be as immediate as it is now.
you cannot buy for average price of current bar because that period is just closed, you buy on the next bar avg price, your trade is being aggregated to this next bar.
That's why you are counting the price as next bar. You can perform simulation based on real executed price of orders ~ estimated by both methods with lag/with no lag.
full member
Activity: 220
Merit: 100
what is the logical formula to estimate the price of executed buy/sell for particular buy/sell signals?

If I got your question correctly:
Code:
Trade price = Close price for the current bar + Trading fee

Remember, this is only a simulation so the formula does not consider slippage and other real trading costs.
so I think you should alter this formula, when you got your buy/sell signal the current bar is already closed one (you cannot calculate signal for not closed period), so you get a signal while next bar is the "current bar", the more correct formula would be to use average price from the next bar, it is still not sure if you will be able to buy/sell all the BTC you are placing order during the time of the next bar, but it is the most correct estimation imo.

Once the bar is closed, an algorithm handles it immediately. At this point:
- Close price is the most recent price (simulation engine uses it to calculate simulated purchase prices internally)
- The next bar is not calculated yet. Allowing an algorithm to access trading data from the future, contradicts the idea of technical analysis in my opinion.

By the way, we have an ongoing contest for those who are interested in algorithmic trading https://bitcointalksearch.org/topic/automated-trading-contest-prize-05-btc-best-automated-strategies-261086.
full member
Activity: 175
Merit: 100
what is the logical formula to estimate the price of executed buy/sell for particular buy/sell signals?

If I got your question correctly:
Code:
Trade price = Close price for the current bar + Trading fee

Remember, this is only a simulation so the formula does not consider slippage and other real trading costs.
so I think you should alter this formula, when you got your buy/sell signal the current bar is already closed one (you cannot calculate signal for not closed period), so you get a signal while next bar is the "current bar", the more correct formula would be to use average price from the next bar, it is still not sure if you will be able to buy/sell all the BTC you are placing order during the time of the next bar, but it is the most correct estimation imo.
full member
Activity: 220
Merit: 100
what is the logical formula to estimate the price of executed buy/sell for particular buy/sell signals?

If I got your question correctly:
Code:
Trade price = Close price for the current bar + Trading fee

Remember, this is only a simulation so the formula does not consider slippage and other real trading costs.
full member
Activity: 175
Merit: 100
what is the logical formula to estimate the price of executed buy/sell for particular buy/sell signals?
member
Activity: 90
Merit: 10
Very interesting, the H4 almost doubles return over H2. 

I think for the next few weeks / months we can still expect a bear market or at least a consolidation, so it doesn't make so much sense to backtest strategies on old data from pre bubble bull market times if your primary aim is to avoid losses rather than maximize profits. If you limit it to the past 2 months instead you will see that the H2 outperforms the H4 again, at least with your settings: http://cryptotrader.org/backtests/CaSqHQo4yMmWsfGDf
hero member
Activity: 560
Merit: 500
I am the one who knocks
full member
Activity: 220
Merit: 100
Update
- Support for 2H bars
- Web client reloads gracefully upon the server restart
- Fixed bug in portfolio that caused wrong calculations for balanced portfolios
- API: Finalize  - an optional hook method called after a simulation ends. Credit to Diabolicus for this idea.
- Documentation update
full member
Activity: 220
Merit: 100
wohoo, works :-)

Here's another one:
Say I would want to output some kind of additional statistics at the end of the simulation (total number of trades, trades triggererd by each mechanism, number of successful / unsuccessful trades etc..) I could add context.counter values for each of these.
Is there a method that gets called at the end of the simulation to finally output these values?

No, but i agree this is a feature worth adding.
member
Activity: 90
Merit: 10
wohoo, works :-)

Here's another one:
Say I would want to output some kind of additional statistics at the end of the simulation (total number of trades, trades triggererd by each mechanism, number of successful / unsuccessful trades etc..) I could add context.counter values for each of these.
Is there a method that gets called at the end of the simulation to finally output these values?
full member
Activity: 220
Merit: 100
        
Code:
       ...
        buy instrument # Spend all amount of cash for BTC
        if buy instrument #<< how do I check if  a buy was executed this tick?
        ...

As the 'buy' is a function, the above code make it called twice, so that the second call returns undefined value. The right way to do it:
Code:
       ...
        orderId = buy instrument # Spend all amount of cash for BTC
        if orderId
           # a buy was executed
           context.buy_price = instrument.price
           ...
Pages:
Jump to: