Friday, April 15, 2016

2016-04-15 Trading Top5s Securities: RF

Markets Top5s analysis for 2016-04-15

Created snapshot 20160416-054718; shunted to google drive

scrape
2016-04-15
Mkt_Cap:GOOG,INFY,GOOGL,AMZN,AAPL|PTR,FB,SNP,WFC
Price:EBIX,CNV,AG,SMCI,SSYS|MITL,TERP,UWTI
Volume:ESV,BAC,CHK,AAPL,JAH,RF,NWL,C,PBR,PFE
Updated /Users/geophf/Documents/OneDrive/work/1HaskellADay/Seer/data/top5s.csv with 2016-04-15 data
bubbles





let's analyze RF for the first time:
geophf:writing geophf$ analyze RF
Wrote analysis files for RF

RF SMA

RF EMA

RF Stochastic Oscillators

Thursday, April 14, 2016

2016-04-14 Trading Top5s Securities: JPM

Markets top5s analysis for 2016-04-14

Created snapshot 20160415-002433; shunted to google drive

scrape
2016-04-14
Mkt_Cap:BUD,BAC,JPM,AMZN,TSM|VALE.P,STX,VALE,ITUB
Price:OIBR,DDD,BBDO,STX,BOFI|SID,GGB,NUGT
Volume:BAC,CHK,VALE,STX,SIRI,PBR,FCX,RF,GDX,VRX
Updated /Users/geophf/Documents/OneDrive/work/1HaskellADay/Seer/data/top5s.csv with 2016-04-14 data
bubbles





let's analyze JPM
geophf:writing geophf$ analyze JPM
Wrote analysis files for JPM

JPM SMA

JPM EMA

JPM Stochastic Oscillators

Wednesday, April 13, 2016

Gap analysis of stocks: clustering and visualization

We have about a year's-worth of top 5s stocks from the markets as data available for analysis:
The Top5s stocks graph database

This is great! It tells us which stocks were the market leaders (and market losers) for today in the categories of market capitalization, price, and volume (just leaders for volume). And, because these data form a graph over time, you can query the system as to how many times such-and-so stock has been on a top5s-list, which days, then, going meta: what gaps in appearances for stocks.

We've done studies before showing the frequency of a stock on the top5s-lists and then correlating that to the probability that a stock would show up more than once, ever (not a very good probability for most stocks, as was shown).

Stock Frequency, in general

Uh, actually, that study has not yet been published here, but here are a couple of charts showing frequencies of stocks as top5s shows:
Vast majority of stocks show up on the top5s less than ten times

Here we zoom on the distribution of stocks showing less than ten times on the top5s

Okay, so we are able to see 'stocks' as a 'thing' in its behavior, but what if we wish to focus on individual stocks? What makes one stock in particular like, or not like, others? What are the measure that determine 'likeness'?

Likeness

For this study we measure the data we have: stocks, their appearances on the top5s-lists, and gaps in those appearances. So, for each stock we queried the system for this information (which resulted in this horribly-quoted mess ... lesson learned: just query the endpoint and work with data directly as opposed to exporting via the clunky CSV-export interface). From that query, we reduced those raw data down to a set of 'ScoreCard' metadata, resulting in the following ScoreCard CSV-output.

Much better: much more concise.

But what does it all mean? Yes, individually we know the min, max and mean gaps in appearances on the top5s for a particular stock. That's fine. Are there other stocks like this one? If so, are there groups?

Yes, there are.

Clustering

A good way to cluster related data is to use the K-Means algorithm. The k-means algorithm we use uses ScoreCards (which, as you see above, are simply vectors) to classify the data.

So, step 1: Convert the stocks' data into scorecards:


Step 2: label these scorecards:


Step 3: compact


... all the above is render using a system that converts ScoreCards to Cells in SVG.

Now we're ready for clustering. As you can see above, there are lots of scores of similar ilk (and similar ink). So now we cluster, then upload these clusters to our graph database for visualization:
Stocks clustered by gap-likeness

And, now that these clusters are in the graph database, you can query this system, asking, e.g.: show me the clusters that contain AAPL, NFLX and TWTR. It turns out there are two such clusters:


We can now find 'like'-stocks based on similarity from shows (and gaps) on the top5s-lists.

Future Work

There are several directions we can go from here, both in data analysis and in data visualization. For data analysis: is shows on the top5s telling? To me, this is not a very fruitful area of research: AAPL shows up to be 'like' 85 other stocks? TWTR is 'like' 110 other stocks? This is unhelpful for me. These stocks are outstanding in their own right and so should be in a rarified cluster, not a common one. So other indicators, outside top5s appearances, are what makes these stocks special: beta? p/e? EPS? market cap? div/yield? I don't know. This requires further research and insights, but it appears not from the top5s,* which are helpful to show a stock is outstanding by the number of its appearances (more frequent appearances tend to show better performers).

For data visualization, the clusters themselves can be distinguished visually by their size (number of members) and by their 'heat' (the common cluster color). Furthermore, each stock has it's own 'color' based on its score and so each stock can be colored individually. I am researching if neo4j can programmatically color nodes based on indicated properties (e.g.: a property, such as { color: 13541067 }). If they don't provide it as a plugin or unmanaged extension, the I'll have to use another framework, e.g. Linkurious, sigma,js, or D3.

Other areas of improvement entail incorporating the scorecard metadata into the cell nodes here. There exists work along this line already as ColoredScoreCard, but it needs to be brought up to date with the new indexible scorecard properties, in this way color and the other properties are automatically and meaningfully labeled. The next step is then to link the scorecard node to the actual security, so that once a desirable stock scorecard is found in a cluster, the stock itself can be further explored directly from the linked relationship to that scorecard. These two improvements are simple extensions: the work just simply needs be updated or undertaken.

Update: Scaling Scoring Factors

* Epilogue: I spoke too quickly. The score cards measure a data point (a stock) along several factors which may (and, in fact, do) have significantly different ranges from each other. This being the case, a factor with a large magnitude can dominate the clustering of the score cards leading to clusters informed only by these large values.

But is that what we want? No. Large values are just large valued, it doesn't mean that they are more important for clustering.

So, to linearize the impact of the factors, so that each factor contributes weight to the clustering algorithm, I've employed a scaling algorithm that maps each factor to the range [0..1].  When I apply scaling, we see an entirely new set of clusters:
rescaled clusters

The smallest cluster has all the heavy-hitters in the Markets, and we see this simply from analytics of their shows on the top5s-lists, whereas before clustering was not yielding meaningful results.

Scale factors to get meaningful input to clustering from all factor-types.

2016-04-13 Trading Top5s Securities: MEET

Markets Top5s analysis for 2016-04-13

Created snapshot 20160413-224137; shunted to google drive

scrape
2016-04-13
Mkt_Cap:JPM,AAPL,PTR,C,MO|RAI,VZ,T,KO
Price:GPRO,SID,JOY,NUGT,EPE|CIE,LTRPB,PDCE
Volume:BAC,CHK,FB,SIRI,FCX,VALE,PBR,AA,MT,WLL
Updated /Users/geophf/Documents/OneDrive/work/1HaskellADay/Seer/data/top5s.csv with 2016-04-13 data
bubbles





let's analyze MEET based off of FB to TWTR to MEET deep-dive

geophf:writing geophf$ analyze MEET
Wrote analysis files for MEET
MEET SMA

MEET EMA

MEET Stochastic Oscillators

Ah! The life of a mid-cap stock!

tweet

Monday, April 11, 2016

2016-04-11 Trading Top5s Securities: AA

Markets Top5s analysis for 2016-04-11

Created snapshot 20160411-215122; shunted to google drive

Scrape:
2016-04-11
Mkt_Cap:RIO,BBL,RDS.A,BBD,FB|TM,PFE,AGN,NKE
Price:CHK,NUGT,CHK-D,INSY,HTZ|CIG.C,CAR,ENDP
Volume:PFE,BAC,CHK,SIRI,VALE,GDX,AA,VRX,FB,PBR
Updated /Users/geophf/Documents/OneDrive/work/1HaskellADay/Seer/data/top5s.csv with 2016-04-11 data
bubbles





let's analyze a company that's been around forever (hat's off to them) $AA

geophf:writing geophf$ analyze AA
Wrote analysis files for AA
AA SMA

AA EMA

AA Stochastic Oscillators

Friday, April 8, 2016

2016-04-08 Trading Top5s Securities: BAC

Markets Top5s analysis for 2016-04-08

Created graph database snapshot 20160408-220345; shunted to google drive

scrape
2016-04-08
Mkt_Cap:RDS.A,RDS.B,PTR,ITUB,UA|FB,AGN,LMCB,NKE
Price:GGB,ETE,DEPO,UA,GPS|LMCB,RLYP,ALDR
Volume:BAC,SIRI,PFE,FB,EMC,FCX,AA,GPS,VALE,VRX
Updated /Users/geophf/Documents/OneDrive/work/1HaskellADay/Seer/data/top5s.csv with 2016-04-08 data

bubbles





let's analyze BAC because @blackbearpaw says so:


geophf:writing geophf$ analyze BAC
Wrote analysis files for BAC
BAC SMA

BAC EMA

BAC Stochastic Oscillators

Thursday, April 7, 2016

2016-04-07 Trading Top5s Securities: WYNN

Markets Top5s analysis for 2016-04-07

Created snapshot 20160407-225053; shunted to google drive

scrape
2016-04-07
Mkt_Cap:DCM,NTT,WYNN,AAPL,PTR|VZ,WFC,JPM
Price:RLYP,FCE.B,WYNN,BKE,IONS|TCK,FCX,MMS
Volume:BAC,SIRI,VRX,PFE,FCX,YHOO,FTR,F,GE,SPY
Updated /Users/geophf/Documents/OneDrive/work/1HaskellADay/Seer/data/top5s.csv with 2016-04-07 data
Bubbles





Let's analyze WYNN, because wow!

geophf:writing geophf$ analyze WYNN
Wrote analysis files for WYNN
WYNN SMA

WYNN EMA

WYNN Stochastic Oscillators