ROOT_Application  2.0
C++ Core modules and GUIStock
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Functions | Variables
wrapPyStock.cpp File Reference

Source file for the library wrapPyStock.so imported by the python modules to access Stock functions. More...

#include <python2.7/Python.h>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <vector>
#include "Stock.h"
#include "ListDataStock.h"
Include dependency graph for wrapPyStock.cpp:

Go to the source code of this file.

Macros

#define Python_for_stock
 

Functions

int helloworld (int x)
 
long int wrapLastCSVUpdate (const char *symbol, bool btest)
 Get last date available from file. More...
 
static PyObject * wrap_LastCSVUpdate (PyObject *, PyObject *args)
 Get last date available from file (only DAY at this stage). More...
 
int wrapUpdateCSV (const char *symbol, std::vector< DataCSV > &new_csv, std::vector< SimpleData > &new_vol, bool btest)
 Uses to add data from yahoo (DAY) for StockCSV and Volume. More...
 
static PyObject * wrap_hello (PyObject *, PyObject *args)
 
static PyObject * wrap_UpdateCSV (PyObject *, PyObject *args)
 Python wrapper to Stock::wrapUpdateCSV(). More...
 
static PyObject * wrap_SaveInst (PyObject *, PyObject *args)
 Save instantaneous data into file. More...
 
PyMODINIT_FUNC initwrapPyStock (void)
 

Variables

static PyObject * WrapError
 
static PyMethodDef WrapMethods []
 

Detailed Description

Source file for the library wrapPyStock.so imported by the python modules to access Stock functions.

wrapper to functions:

Not a API to Stock.
Ideally Python should have equivalent python functions to be able to be used without this module.

Last Changed

Id:
wrapPyStock.cpp 511 2014-12-07 15:42:15Z martinml

Definition in file wrapPyStock.cpp.

Macro Definition Documentation

#define Python_for_stock

Definition at line 16 of file wrapPyStock.cpp.

Function Documentation

int helloworld ( int  x)

Definition at line 33 of file wrapPyStock.cpp.

Referenced by wrap_hello().

Here is the caller graph for this function:

PyMODINIT_FUNC initwrapPyStock ( void  )

Definition at line 419 of file wrapPyStock.cpp.

References WrapError, and WrapMethods.

static PyObject* wrap_hello ( PyObject *  ,
PyObject *  args 
)
static

Definition at line 190 of file wrapPyStock.cpp.

References helloworld().

Here is the call graph for this function:

static PyObject* wrap_LastCSVUpdate ( PyObject *  ,
PyObject *  args 
)
static

Get last date available from file (only DAY at this stage).

Called by python: wrapPyStock.LastCSVUpdate()
Call from python:

date_time = wrapPyStock.LastCSVUpdate( self.symbol, GlobalDicts.TEST_MODE ) 


symbol name, symbol of the stock
boolean true will read file from data_test directory, false from data

Definition at line 97 of file wrapPyStock.cpp.

References wrapLastCSVUpdate().

Here is the call graph for this function:

static PyObject* wrap_SaveInst ( PyObject *  ,
PyObject *  args 
)
static

Save instantaneous data into file.

The data are written in the format defined by C++, the header is also correctly updated.
Updated file : historical/SYMBOL.INST.csv

Call wrapSaveInst( symbol, [date,value], bool_test )

Parameters
args: symbol, data consists of [date,value], boolean tmp will uodate the file in data_test directory
Returns

Definition at line 325 of file wrapPyStock.cpp.

References INST, Utils::PATH_DATA_TEST, SimpleData::SetData(), Utils::SetPathData(), and Stock::UpdateCSV_Inst().

Here is the call graph for this function:

static PyObject* wrap_UpdateCSV ( PyObject *  ,
PyObject *  args 
)
static

Python wrapper to Stock::wrapUpdateCSV().

wrap_UpdateCVS(symbol,list_data)
Call need symbol and a list of DataCVS
include volume in data, will be split in the function list_data format = [ [date,op,pl,mo,cl,vol],[date,op,..] ]

Definition at line 207 of file wrapPyStock.cpp.

References SimpleData::SetData(), DataCSV::SetData(), and wrapUpdateCSV().

Here is the call graph for this function:

long int wrapLastCSVUpdate ( const char *  symbol,
bool  btest 
)

Get last date available from file.

Here pure C++, called by wrap_LastCSVUpdate which translate python argument and return
Create a stock, call stock::LastCSVUpdate and delete it at the end

Now call static function, read only ETime::DAY, need to extend ?

Parameters
symbolname of the stock
btestboolean variable to read data in data_test/historical and write in data_test/historical_tmp

Definition at line 56 of file wrapPyStock.cpp.

References DAY, Utils::get_fldate_default(), Utils::firstlast_dates::last, Utils::PATH_DATA_TEST, Stock::Read_HeaderCSV_static(), and Utils::SetPathData().

Referenced by wrap_LastCSVUpdate().

Here is the call graph for this function:

Here is the caller graph for this function:

int wrapUpdateCSV ( const char *  symbol,
std::vector< DataCSV > &  new_csv,
std::vector< SimpleData > &  new_vol,
bool  btest 
)

Uses to add data from yahoo (DAY) for StockCSV and Volume.

From Yahoo we get historical data in DAY, want to save permanently.
Boursorama Inst data, python adds by itself / send to the server, could also call a function of Stock test version, write complete data in tmp subdirectory.

Todo:

writing data with option, directly in /csv

check the order of the data and consistent with ListDataStock

Parameters
symbolof the stock, given by dictstocks.txt
new_csv,new_volvector with new data
testif test in true, read data from data_test, writes output data_test/historical_tmp

Definition at line 137 of file wrapPyStock.cpp.

References Stock::AddListDataToMap(), DAY, NO_CHRONO, ListDataStock< T, PolicyChronologic >::Order(), Utils::PATH_DATA_TEST, ListDataStock< T, PolicyChronologic >::PrintData(), Stock::PrintMapChrono(), Stock::SaveCSV(), ListDataStock< T, PolicyChronologic >::SetDates(), and Utils::SetPathData().

Referenced by wrap_UpdateCSV().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

PyObject* WrapError
static

Definition at line 401 of file wrapPyStock.cpp.

Referenced by initwrapPyStock().

PyMethodDef WrapMethods[]
static
Initial value:
= {
{"hello", wrap_hello, METH_VARARGS, "Execute a print hello."},
{"LastCSVUpdate", wrap_LastCSVUpdate, METH_VARARGS, "Execute LastUpdate"},
{"UpdateCSV", wrap_UpdateCSV, METH_VARARGS, "Execute UpdateCVS"},
{"SaveInst", wrap_SaveInst, METH_VARARGS, "Execute SaveInst"},
{NULL, NULL, 0, NULL}
}
static PyObject * wrap_SaveInst(PyObject *, PyObject *args)
Save instantaneous data into file.
static PyObject * wrap_UpdateCSV(PyObject *, PyObject *args)
Python wrapper to Stock::wrapUpdateCSV().
static PyObject * wrap_hello(PyObject *, PyObject *args)
static PyObject * wrap_LastCSVUpdate(PyObject *, PyObject *args)
Get last date available from file (only DAY at this stage).
Definition: wrapPyStock.cpp:97

Definition at line 406 of file wrapPyStock.cpp.

Referenced by initwrapPyStock().