Tag Info

New answers tagged

4

It is not TimeSeriesWindow that is making your code slow. What is slowing down your function is the conversion of the data received from FinancialData from a List to a TimeSeries object. If this conversion is done before TimeSeriesWindow is applied, e.g. by tsData=TimeSeries[data] Than TimeSeriesWindow[tsData,{{2013,8,22},{2013,8,26}}] is even faster ...


1

I don't have MMA 10, so I can't reproduce TimeSeriesWindow. This is relatively fast: Cases[data, {{y_, m_, d_}, __} /; y >= 2013 && y <= 2013 && m >= 8 && m <= 8 && d >= 22 && d <= 26]; // Timing {0.031200, Null} DateInterval[data_, {y1_, m1_, d1_}, {y2_, m2_, d2_}] := Cases[data, {{y_, ...


5

Two solutions: Use the listability of Interpreter to parallelize calls to WR servers: In[1]:= AbsoluteTiming[Interpreter["Time"][timeData]] // First Out[1]= 6.551647 Use Structured interpreters to avoid calling WR servers altogether: In[2]:= AbsoluteTiming[Interpreter["StructuredTime"][timeData]] // First Out[2]= 0.165715 In general you might ...


4

Read what you quoted from the docs carefully. The phase "addition and subtraction of time quantities" does not mean "addition and subtraction of time objects". Subtraction works because it produces a time quantity, i.e., an interval. But what sense can be made of adding two time object? What would you expect to get from the sum of July 6, 1944 and July 4, ...


3

There is a very quick way to arrive at this. If you are new to Mathematica then maybe this is a starting point. lineData = {allData[[All, {1, 2}]], allData[[All, {1, 3}]], allData[[All, {1, 4}]], allData[[All, {1, 5}]], allData[[All, {1, 6}]], allData[[All, {1, 7}]]} volume = allData[[All, {1, -1}]] p1 = DateListPlot[lineData, Joined -> True, ...


3

Some further observations: data = Cases[DayRange[{401, 1, 1}, {2400, 12, 31}, Friday], {y_, _, 13} -> y]; x = Length /@ Split[data]; {Min@x, Max@x, N[Mean@x, 10]} {1, 3, 1.720000000} There are EXACTLY 1.72 Fridays 13th per year over a 400 year period. This can be calculated as follows: The Gregorian calendar follows a pattern of leap years ...


4

Sort@Tally[DayRange[{2000, 1, 1}, {2399, 12, 31}, Friday][[All, 3]]] % == data (* from rasher's post *) (* True *) or Tally[Sort[DayRange[{2000, 1, 1}, {2399, 12, 31}, Friday][[All, 3]]]] or Through[{First, Length}[#]] & /@ Split[Sort[DayRange[{2000, 1, 1}, {2399, 12, 31}, Friday][[All, 3]]]] or Through[{First, Length}[#]] & /@ ...


11

data = Cases[DayRange[{2000, 1, 1}, {2399, 12, 31}, Friday], {y_, m_, d_} :>d] // Tally // Sort; TableForm[data[[ ;; ;; 2]], TableHeadings -> {None, {"Day", "Number of Fri."}}] (Reverse@SortBy[data, Last])[[;; 5]] {{27, 688}, {20, 688}, {13, 688}, {6, 688}, {25, 687}}



Top 50 recent answers are included