Time series for intraday charts (mon-fri, 9.30 - 4.00pm)

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Jii
Posts: 128
Joined: Thu Apr 21, 2005 11:17 am

Post by Jii » Tue Aug 22, 2006 8:01 am

What you say !!!

Jii
Posts: 128
Joined: Thu Apr 21, 2005 11:17 am

Post by Jii » Mon Aug 28, 2006 2:43 pm

8)

Jii
Posts: 128
Joined: Thu Apr 21, 2005 11:17 am

Post by Jii » Mon Sep 11, 2006 1:08 pm

Another week, another bump.

Jii
Posts: 128
Joined: Thu Apr 21, 2005 11:17 am

Post by Jii » Wed Oct 11, 2006 8:15 am

Badda bump

Jii
Posts: 128
Joined: Thu Apr 21, 2005 11:17 am

Post by Jii » Wed Oct 18, 2006 1:50 pm

bumo

Jii
Posts: 128
Joined: Thu Apr 21, 2005 11:17 am

Post by Jii » Wed Dec 13, 2006 1:52 pm

Jii wrote:bumo

williamt
Posts: 13
Joined: Thu Dec 14, 2006 1:22 pm

Post by williamt » Thu Dec 14, 2006 4:43 pm

i would like a solution for that too :D

williamt
Posts: 13
Joined: Thu Dec 14, 2006 1:22 pm

Post by williamt » Tue Dec 26, 2006 5:28 pm

Anyone?!
I really need this working... ;D

Thanks!

nonlinear5
Posts: 6
Joined: Wed Dec 27, 2006 1:03 am

Post by nonlinear5 » Wed Dec 27, 2006 3:15 am

See if this works for you. Although the weekend gap is removed with this code, I find that zoom-in/zoom-out doesn't work quite right, and the labels sometimes overlap. There also appears to be a performance issue with the SegmentedTimeline that has too many base time exclusions, although I have not investigated it fully. I think those are the bugs in the SegmentedTimeline itself.

Code: Select all

package com.jsystemtrader.chart;

import java.util.*;

import org.jfree.chart.axis.*;

public class MarketTimeLine {
    private static final long MILLIS_IN_MINUTE = 60 * 1000;
    private static final long MILLIS_IN_DAY = MILLIS_IN_MINUTE * 60 * 24;
    private static final long MARKET_OPEN_TIME = (9 * 60 + 30) * MILLIS_IN_MINUTE;
    private static final int TRADING_MINUTES = 6 * 60 + 30;    
    private static final int NON_TRADING_MINUTES = 17 * 60 + 30;        
    private static final int WEEKEND_MINUTES = 65 * 60 + 20; // from 16:05 Fri to 9:25 Mon          

    private final int barSizeInMinutes;
    private final long startTime, endTime;

    public MarketTimeLine(int barSizeInMinutes, long startTime, long endTime) {
        this.barSizeInMinutes = barSizeInMinutes;
        this.startTime = startTime;
        this.endTime = endTime;
    }

    public SegmentedTimeline getNormalHoursTimeline() {
        long segmentSize = barSizeInMinutes * MILLIS_IN_MINUTE;
        int segmentsIncluded = TRADING_MINUTES / barSizeInMinutes;
        int segmentsExcluded = NON_TRADING_MINUTES / barSizeInMinutes;
        SegmentedTimeline timeline = new SegmentedTimeline(segmentSize, segmentsIncluded, segmentsExcluded);
        timeline.setAdjustForDaylightSaving(true);

        timeline.setStartTime(startTime);
        timeline.setBaseTimeline(SegmentedTimeline.newMondayThroughFridayTimeline());

        Calendar lastBarDate = Calendar.getInstance();
        lastBarDate.setTimeInMillis(endTime);

        Calendar now = Calendar.getInstance();
        now.setTimeInMillis(startTime);
        now.set(Calendar.HOUR_OF_DAY, 16);
        now.set(Calendar.MINUTE, 5);
        now.set(Calendar.SECOND, 0);
        now.set(Calendar.MILLISECOND, 0);

        // find the first Friday
        while (now.get(Calendar.DAY_OF_WEEK) != Calendar.FRIDAY) {
            now.add(Calendar.DAY_OF_YEAR, 1);
        }

        // exclude weekends
        while (now.before(lastBarDate)) {
            long excludeFrom = now.getTimeInMillis();
            long excludeTo = excludeFrom + WEEKEND_MINUTES * MILLIS_IN_MINUTE;
            timeline.addBaseTimelineExclusions(excludeFrom, excludeTo);

            now.add(Calendar.DAY_OF_YEAR, 7); // move to next Friday
        }

        return timeline;
    }

    public SegmentedTimeline getAllHoursTimeline() {
        SegmentedTimeline timeline = new SegmentedTimeline(SegmentedTimeline.DAY_SEGMENT_SIZE, 7, 0);
        return timeline;
    }
}


williamt
Posts: 13
Joined: Thu Dec 14, 2006 1:22 pm

Post by williamt » Thu Jan 04, 2007 2:09 pm

Ok, thank you!
I will try it now. I will let you know how it went.

clam61
Posts: 66
Joined: Tue Jul 03, 2007 9:59 pm

Post by clam61 » Sat Jul 28, 2007 8:33 am

dave, any ideas about periodaxis class?



david.gilbert wrote:I will look at this when I get time. I didn't write the segmented timeline code, so I don't know it so well. I know it works well for some people and not well for others - in the medium term, I'd like to find an alternative implementation that's easier to debug (for me anyway), perhaps based on the PeriodAxis class.

lama_lel
Posts: 2
Joined: Thu Jan 10, 2013 2:58 pm
antibot: No, of course not.

Re: Time series for intraday charts (mon-fri, 9.30 - 4.00pm)

Post by lama_lel » Wed Jan 22, 2014 2:22 pm

As in documentation it is said:
"

Code: Select all

/**
     * Factory method to create a 15-min, 9:00 AM thought 4:00 PM, Monday
     * through Friday SegmentedTimeline.
     * <P>
     * This timeline uses a segmentSize of FIFTEEN_MIN_SEGMENT_SIZE. The
     * segment group is defined as 28 included segments (9:00 AM through
     * 4:00 PM) and 68 excluded segments (4:00 PM through 9:00 AM the next day).
     * <P>
     * In order to exclude Saturdays and Sundays it uses a baseTimeline that
     * only includes Monday through Friday days.
     * <P>
     * The <code>startTime</code> of the resulting timeline will be 9:00 AM
     * after the startTime of the baseTimeline. This will correspond to 9:00 AM
     * of the first Monday after 1/1/1900.
     *
     * @return A fully initialized SegmentedTimeline.
     */
     public static SegmentedTimeline newFifteenMinuteTimeline()
"

in code of this method is:
"

Code: Select all

timeline.setBaseTimeline(newMondayThroughFridayTimeline());
"

and if you just search where the

Code: Select all

SegmentedTimeline baseTimeline
is used, you will see, that is uesed in 3 other methods:

Code: Select all

public void addBaseTimelineException(long domainValue)
- which adds some exception to baseTimeline,

Code: Select all

public void addBaseTimelineExclusions(long fromBaseDomainValue,
                                          long toBaseDomainValue)
- same here, and

Code: Select all

public SegmentedTimeline getBaseTimeline()
.
Note that this getter is not used anywhere else.

So my question is, where is implementation, that allows to add weekends as an exceptions to segmentedTimeline, which is above baseTimeline?
Summary: Adding baseTimeline to any timeline does nothing.

Why???????

Locked