ipython notebook example - Matlab, R project and Python | futures.io
futures.io futures trading

Go Back   futures.io

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > Matlab, R project and Python

ipython notebook example
Started:January 16th, 2014 (09:53 AM) by enjoyaol Views / Replies:690 / 1
Last Reply:January 16th, 2014 (09:54 AM) Attachments:0

Welcome to futures.io.

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

ipython notebook example

Old January 16th, 2014, 09:53 AM   #1 (permalink)
Elite Member
Paris, France
Futures Experience: Intermediate
Platform: MT4, Amibroker, Custom
Favorite Futures: EUR/USD
Posts: 44 since Jan 2012
Thanks: 5 given, 22 received

ipython notebook example

Hi, for those who love python and ipython, here is a small example of how to use it.
This notebook loads some CSV ohcl data and makes statistics about days of the week and month, etc..

It's a simple example to show you the power of ipython and pandas.


Have fun !

import datetime
import pandas as pd
import numpy as np

def dateparse(s):
    return datetime.datetime.strptime(s, "%d.%m.%Y %H:%M:%S.%f")

# <codecell>

INPUT_FILE = r"data/EURUSD_Candlestick_1_D_BID_01.12.2011-04.01.2014.csv"

tab = pd.read_csv(INPUT_FILE, date_parser = dateparse, parse_dates=True, index_col=[0])
tab['O-C'] = ((tab['Close'] - tab['Open']) * 100) / tab['Close']
tab['L-H'] = ((tab['High'] - tab['Low']) * 100) / tab['High']

# <codecell>

grouped = tab.groupby(tab.index.weekday)

# <headingcell level=3>

# Sum of percent changes per DAY of the week sorted by LH desc

# <codecell>

perdays = tab.groupby(tab.index.weekday).agg({'O-C': np.sum, 'L-H' : np.sum})
perdays.columns = ['Sum of OC % change', 'Sum of LH % change']
perdays.sort(columns = 'Sum of LH % change', ascending = False)

# <headingcell level=3>

# Sum of percent changes per WEEK of the year

# <codecell>

perweeks = tab.groupby(tab.index.weekofyear).agg({'O-C': np.sum, 'L-H' : np.sum})
perweeks.columns = ['Sum of OC % change', 'Sum of LH % change']
perweeks.sort(columns = 'Sum of LH % change', ascending = False)
#displays the 10 best weeks

# <headingcell level=3>

# Most traded day of the week (by volume)

# <codecell>

perdays = tab.groupby(tab.index.weekday).agg({'Volume': np.sum})
perdays.columns = ['Sum of Volume']
perdays.sort(columns='Sum of Volume', ascending = False)

# <headingcell level=3>

# Most traded WEEK of the year (by volume)

# <codecell>

perweeks = tab.groupby(tab.index.weekofyear).agg({'Volume': np.sum})
perweeks.columns = ['Sum of Volume']
perweeks.sort(columns='Sum of Volume', ascending = False)

Last edited by enjoyaol; January 16th, 2014 at 10:05 AM.
Reply With Quote
The following 3 users say Thank You to enjoyaol for this post:

Old January 16th, 2014, 09:54 AM   #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.



futures.io > Futures Trading, News, Charts and Platforms > Platforms and Indicators > Matlab, R project and Python > ipython notebook example

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

An Afternoon with FIO trader bobwest

Elite only

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
bare bones day trading notebook KillerDana Trading Journals 3 September 20th, 2012 09:12 AM

All times are GMT -4. The time now is 02:38 PM.

Copyright © 2016 by futures.io. All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts

Page generated 2016-10-21 in 0.07 seconds with 19 queries on phoenix via your IP