Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f44b81f
commit 53dd652
Showing
3 changed files
with
35 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import numpy as np | ||
import numpy.lib.recfunctions as rfn | ||
import pandas as pd | ||
|
||
#The logic in this file takes many the data files generated by IBCombineHistoricalData | ||
#"joins" them by datetime to create a file with one date-time column and numerous data columns | ||
if __name__ == "__main__": | ||
#MANUALLY SET THESE FILES FOR JOINING | ||
filesToJoin = [ | ||
"C:/Dropbox/CninSrc/JTS/TWS API/samples/Java/Data/CAD_BID.txt", | ||
"C:/Dropbox/CninSrc/JTS/TWS API/samples/Java/Data/CAD_ASK.txt" | ||
] | ||
#MANUALLY SET THIS FOR OUTPUT FILE | ||
outFile = "C:/Dropbox/CninSrc/JTS/TWS API/samples/Java/Data/JOINED.txt" | ||
#MANUALLY SET THIS HEADER SO EASIER TO REMEMBER COLUMNS | ||
headerTxt = "Time,CAD_BID,CAD_ASK" | ||
|
||
joined = [] | ||
for file in filesToJoin: | ||
print "Handing: " + file | ||
data = np.genfromtxt(file, delimiter = ',', dtype=np.dtype([('time',np.long), ('price', np.float)])) | ||
print "Joining" | ||
if len(joined) == 0: | ||
joined = data | ||
else: | ||
joined = rfn.join_by('time', joined, data, jointype='inner', usemask=False) | ||
|
||
np.savetxt(outFile, joined, delimiter=',', fmt="%s", header=headerTxt, comments="") |