Trading Logic with Sentiment Analysis Signals - Python for Finance 10 | Forex
Information | Currency | Markets | Fx | Video | Assets | Lesson | Trading
In this Python for finance tutorial with Quantopian and Zipline, we cover how to build trading logic based on using the fetch_csv fetcher with Quantopian. In our case, we're building trading logic using the sentiment analysis trading signals from sentdex.com sample code: http://pythonprogramming.net http://hkinsley.com https://twitter.com/sentdex http://sentdex.com http://seaofbtc.com
Comments
-
Since context.investment_size is set to 10% of context.portfolio.cash, isn't it the case that cash will always be greater than investment_size? So why do we make an if statement to check before making an order?
-
I get: "There was a problem starting your backtest. Please try again.", not sure what logging can I add to see where's the problem. I dont see anything in Logs or runtime errors.
-
This code does not longer seems to work :( It produces a runtime error because the data can't be processed in 360 seconds.
-
Needs remove 'ACE' remove from the symbols list. otherwise there will pop-up error
-
It seems your sentiment indicator code no longer works as described on your site and in this video and the one previous. Can you check to see what is going wrong? I pasted your exact code in and it is crashing on the fetcher line. Thanks and great videos!
-
83% returns but beta is more than 1. So maybe this method wont work for a larger set.
-
Using the same code in your video, can't get it to compile/run all the time. It takes forever to fetch the data from your site, not sure if its Quantopian problem or yours.
Here's the error: "TimeoutException: Fetcher data not processed in 360 seconds" -
Why didn't you do.. cash += current_price * current_position at the end of the first elif clause? When you sell, does the cash go out of the portfolio? Thanks so much, videos have been extremely helpful!
-
I get different results when running the backtest on the same dates. What do you think is the reason behind this might be? I also got different results on a prior backtest that did not pull csv data. I checked the code several times and am confident there is no difference.
Though the differences seem minor, I'm not sure why there should be any difference at all. -
Hi, sorry but for me it bought i think just AAPL twice and kept it, it looks like it has loaded only apple stock symbol or it spent all the cash to buy it..cant really figure it out whats wrong, i did this code tut twice and still the same output, make sense as apple sentiment did not go below 0 ever , any idea?
for i in data:
if 'sentiment_signal' in data[i]:
sentiment = data[i]['sentiment_signal']
current_position = context.portfolio.positions[i].amount
current_price = data[i].price
if (sentiment > 5) and (current_position==0):
if cash>context.investment_size:
order_value(i, context.investment_size, style = StopOrder(context.stop_loss_pct*current_price))
cash -= context.investment_size
elif (sentiment <= -1) and (current_position > 0):
order_target(i,0)
Also preview log shows AAPL loaded only and the rest dumped