Live data from Hacker News

Python For Finance: Algorithmic Trading

medium.com

91–100 of 164 posts

Re: Python For Finance: Algorithmic Trading

#91
So, I got semi-seriously interested in this around the end of last year.

My takeaway is: it's not about implementing a couple of trading strategies. It's about implementing a pipeline that rapidly allows you to test what-if scenarios.

I might have like 10 ideas a day for strategies. How many of those can I rigorously validate per week? What about variations? I.e. tuning various hyper-parameters? Combinations?

How quickly can I recombine data from various sources into exactly the layout I need to train and test this or that strat?

Me:

1) Build some simple forecasting NNs.

2) Realize I need to be able to generate and test ideas waaay faster. Start working on infrastructure.

3) Get impatient -- get some "bright" ideas, do some manual trading.

4) Make some money on the first day, lose double that on the next two days.

5) Decide to ban myself from manual trading as obviously I'm an addict. Resolve to only do algorithmic trading.

6) Back to coding infrastructure. Get bored ... do some manual trades.

7) After losing around $20k, stop the trading madness, and go back to buying and holding great tech companies.

8) Enjoy my 25% returns.

Re: Python For Finance: Algorithmic Trading

#92
post #38

Earlier quoted context omitted.

This is utterly the wrong way to learn finance for quantitative trading. That would be an unproductive use of time. Read Options, Futures and Other Derivatives and Algorithmic Trading and DMA and you basically know everything you'll get from public sources that could be meaningful for trading. If he knows how to code and is looking for "mathematics of finance" he should start with those, not the CFA.

That is your opinion, but if you look at the resumes of scientific active equity fund managers and quants, they all have it. Just understanding the quantitative side leads to vast underperformance over the course of market cycles...

Quants don't usually have CFAs. A phD in physics is more common to see. CFAs help you working in a real financial environment where you need to be aware of a lot of stuff. If you want to day trade at home, it's close to useless. Please nobody gets a CFA if what you want to do is learning day trading.

Re: Python For Finance: Algorithmic Trading

#93
post #42

Earlier quoted context omitted.

I have a mean reversion strategy based on the comparing the results of several types of sentiment analysis in real time. It earns between 3 - 15% in options trading every few days with a win rate of around 70% and an average holding time of a few hours. Stop losses are at -70% or so. Algorithmic trading is very difficult, but it is empirical. Information asymmetry exists in the market, and if you can capture it you p…

> Stop losses are at -70% or so. Am I reading that right, you lose one trade you lose 70% of your capital? Sounds like a very very dangerous strategy with a near 100% certainty of blowing up the account. The optimal trade size for equity growth (which is itself hugely risky) is vastly smaller than that.

Hah, no that's a typo, sorry my mind was a bit scattered in this thread. I meant to type that stop losses are at -15% or so (of the position, not the portfolio).

There is a separate risk management metric in play that automatically closes positions and pauses the strategy after a specific number of losses in a row, or after the strategy's capital allocation drops below a certain percentage (whichever comes first).

The other metrics are as stated.

Re: Python For Finance: Algorithmic Trading

#94
post #74

Earlier quoted context omitted.

Futures have millisecond timestamps (trades/quotes), equity trade ticks are rounded to the nearest second, cfd/forex are millisecond quote bars. For options we have minute resolution data =)

Worth noting though that Options data is super hard to get running on QuantConnect due to the memory limits and lack of index options.

Agree, we're working on making it easier now. We patched a bug today which should make it more efficient.

Re: Python For Finance: Algorithmic Trading

#95
post #93

Earlier quoted context omitted.

> Stop losses are at -70% or so. Am I reading that right, you lose one trade you lose 70% of your capital? Sounds like a very very dangerous strategy with a near 100% certainty of blowing up the account. The optimal trade size for equity growth (which is itself hugely risky) is vastly smaller than that.

Hah, no that's a typo, sorry my mind was a bit scattered in this thread. I meant to type that stop losses are at -15% or so (of the position, not the portfolio). There is a separate risk management metric in play that automatically closes positions and pauses the strategy after a specific number of losses in a row, or after the strategy's capital allocation drops below a certain percentage (whichever comes first). Th…

> -15% or so (of the position, not the portfolio).

Oh... HUGE difference. What percentage of the portfolio is the position? How long have you run this strategy; I ask because those are huge returns that indicate to me you're taking huge risk which can work short term but nearly always wipes you out over a sufficient amount of time.

> It earns between 3 - 15% in options trading every few days with a win rate of around 70% and an average holding time of a few hours.

If those returns could be held for any length of time you'd be wealthy in no time.

Re: Python For Finance: Algorithmic Trading

#96

Earlier quoted context omitted.

Algo trading typically utilises technical analysis which is basically patterns proven to repeat in markets for a variety of fundamental reasons, or fundamental analysis (e.g. algorithmically valuing and pricing options based on underlying fundamental data, sentiment analysis, etc.), and buying/shorting as appropriate. It is based on scientific methods: empirical evidence being used to validate hypothesis that produce…

> technical analysis which is basically patterns proven to repeat in markets for a variety of fundamental reasons Technical analysis is merely another name for hindsight bias. Those patterns only look like they repeat in hindsight because you're ignoring all the failed patterns that setup right but failed to play out and thus don't look like the pattern in hindsight. Technical analysis is exactly like astrology and i…

Can you provide sources that back up your claim with studies of inefficiency of technical analysis?

I'm not busting your balls, I actually agree with you but I haven't seen it really proven.

Re: Python For Finance: Algorithmic Trading

#97
post #45

The main issue I found in algo and financial aspects of programming is that the market is a zero sum game, and my intro knowledge of finance and algorithms, even when I know python, are no match for MIT PHD Quants who does it full time. There's no real way to compete with that, and therefore I would lose money, even if the data showed it might be successful in the future, firms and full time workers on algo trading w…

I'm curious to know who the loser was with the cryptocurrency rally this year?

You've forgotten you can introduce new units of whatever is being traded and quite often is & there are additional complications such as dividends, stock options, etc which makes your oversimplification lacking substance.

Re: Python For Finance: Algorithmic Trading

#98
post #66
post #40

Earlier quoted context omitted.

This commenter comes into every single thread about trading and talks about buying data from ebay, then consistently demonstrates that he doesn't know the first thing about due diligence on financial data. Each time I try to ask him about his data quality or methodology at even a high level, he responds by accusing me of wanting to steal his work or stop the democratization of data. I'm going to reiterate this right…

Unless you are day trading you don't need such a granular data format, so please stop saying you need to spend thousands and thousands of dollars to be able to back test a trading strategy

As far as I understand historical daily data is easy to get from yahoo, google, etc. Data is only difficult to find/expensive when you need tick data.

Re: Python For Finance: Algorithmic Trading

#99
post #93

Earlier quoted context omitted.

Hah, no that's a typo, sorry my mind was a bit scattered in this thread. I meant to type that stop losses are at -15% or so (of the position, not the portfolio). There is a separate risk management metric in play that automatically closes positions and pauses the strategy after a specific number of losses in a row, or after the strategy's capital allocation drops below a certain percentage (whichever comes first). Th…

> -15% or so (of the position, not the portfolio). Oh... HUGE difference. What percentage of the portfolio is the position? How long have you run this strategy; I ask because those are huge returns that indicate to me you're taking huge risk which can work short term but nearly always wipes you out over a sufficient amount of time. > It earns between 3 - 15% in options trading every few days with a win rate of around…

> Oh... HUGE difference. What percentage of the portfolio is the position? How long have you run this strategy; I ask because those are huge returns that indicate to me you're taking huge risk which can work short term but nearly always wipes you out over a sufficient amount of time.

No single position can be more than 10% of the portfolio, there is no limit on concurrent positions, and the strategy cannot use more than 20% of the account's capital. Each position has a profit target, normally a 5% increase on the cost basis, and when it's opened a GTC order is immediately submitted to flip it. But this isn't a market-making algorithm or something that requires serious latency considerations - the target holding period for each position is less than five days, after which if the position is still open it's flagged. The strategy has been running continuously for only eight months; prior to that it was backtested with historical data before launching live. It used to be that the mean holding time was around 2 days, but lately it's been flipping positions in fairly short intraday scales (an hour or less), which means I'll be adding more risk accountability to it.

> If those returns could be held for any length of time you'd be wealthy in no time.

Yes...however this strategy has generated less than $30,000 in profits since its launch (on an initial outlay of $10,000), and I don't reinvest profits.

This is an options trading algorithm, and I don't think there is enough liquidity available in the targets to significantly ramp up capital from here without adding on more leverage (and risk). The other difficulty is that a confluence of factors needs to happen somewhat simultaneously in order for a candidate equity to become a target.

Due to this, it's more accurate to say that the strategy generates a few hundred dollars weekly to biweekly (on average). I may be overcautious, but this is primarily a research project for me. I would not actually be trading with real capital were it not for the fact that I'd like to demonstrate the results in the future.

Re: Python For Finance: Algorithmic Trading

#100
post #81
post #45

The main issue I found in algo and financial aspects of programming is that the market is a zero sum game, and my intro knowledge of finance and algorithms, even when I know python, are no match for MIT PHD Quants who does it full time. There's no real way to compete with that, and therefore I would lose money, even if the data showed it might be successful in the future, firms and full time workers on algo trading w…

An economist and a normal person are walking down the street together. The normal person says “Hey, look, there’s a $20 bill on the sidewalk!” The economist replies by saying “That’s impossible- if it were really a $20 bill, it would have been picked up by now.”

This quiq seems to support the original posters thesis, though, no? No one's going to make a living wandering the streets in search of $20 bills.
Post reply on HN