├── bin └── readme.txt ├── includes ├── boost │ └── readme.txt └── forexconnect │ ├── ForexConnect.h │ ├── IAddRef.h │ ├── Readers │ ├── IO2GOrderResponseReader.h │ ├── IO2GLastOrderUpdateResponseReader.h │ ├── IO2GSystemProperties.h │ ├── IO2GTimeConverter.h │ ├── IO2GMarketDataSnapshotResponseReader.h │ ├── IO2GTablesUpdatesReader.h │ └── IO2GMarketDataResponseReader.h │ ├── IO2GRow.h │ ├── Enums │ ├── SummariesColumnsEnum.h │ ├── MessagesColumnsEnum.h │ ├── AccountsColumnsEnum.h │ ├── OffersColumnsEnum.h │ ├── TradesColumnsEnum.h │ ├── ClosedTradesColumnsEnum.h │ └── OrdersColumnsEnum.h │ ├── IO2GLoginRules.h │ ├── Rows │ ├── IO2GMessageRow.h │ ├── IO2GSummaryRow.h │ ├── IO2GAccountRow.h │ ├── IO2GTradeRow.h │ ├── IO2GClosedTradeRow.h │ ├── IO2GOrderRow.h │ └── IO2GOfferRow.h │ ├── IO2GColumn.h │ ├── O2GDateUtils.h │ ├── interfaces_all.h │ ├── IO2GTimeFrame.h │ ├── O2GTransport.h │ ├── O2G2ptr.h │ ├── O2GRequestParamsEnum.h │ ├── O2GEnum.h │ ├── IO2GRequest.h │ ├── IO2GTradingSettingsProvider.h │ ├── IO2GResponse.h │ ├── O2GOrderType.h │ ├── IO2GSession.h │ └── IO2GPermissionChecker.h ├── libs └── x64 │ ├── boost │ └── readme.txt │ └── forexconnect │ └── ForexConnect.lib ├── src └── ForexConnectClient │ ├── fx.market.watcher │ ├── dialogs │ │ ├── __init__.py │ │ └── order.py │ └── fx.market.watcher.pyproj │ ├── forex.connect │ ├── SessionStatusListener.h │ ├── stdafx.cpp │ ├── targetver.h │ ├── IAddRef.cpp │ ├── forex.connect.cpp │ ├── IO2GOrderResponseReader.cpp │ ├── IO2GLastOrderUpdateResponseReader.cpp │ ├── O2GDateUtils.cpp │ ├── IO2GTimeConverter.cpp │ ├── IO2GSystemPropertiesReader.cpp │ ├── IO2GRow.cpp │ ├── forex.connect.h │ ├── sample_tools.h │ ├── O2GTransport.cpp │ ├── ResponseListener.h │ ├── SummariesColumnsEnum.cpp │ ├── IO2GLoginRules.cpp │ ├── IO2GMessageRow.cpp │ ├── MessagesColumnsEnum.cpp │ ├── Offer.h │ ├── TableListener.h │ ├── IO2GColumn.cpp │ ├── IO2GTimeframe.cpp │ ├── IO2GTablesUpdatesReader.cpp │ ├── dllmain.cpp │ ├── IO2GSummaryRow.cpp │ ├── stdafx.h │ ├── IO2GTradingSettingsProvider.cpp │ ├── TableListener.cpp │ ├── IO2GMarketDataSnapshotResponseReader.cpp │ ├── AccountsColumnsEnum.cpp │ ├── Offer.cpp │ ├── OffersColumnsEnum.cpp │ ├── TradesColumnsEnum.cpp │ ├── ResponseListener.cpp │ ├── IO2GAccountRow.cpp │ ├── O2GEnum.cpp │ ├── SessionStatusListener.cpp │ ├── IO2GTradeRow.cpp │ ├── O2G2ptr.cpp │ ├── ClosedTradesColumnsEnum.cpp │ ├── IO2GRequest.cpp │ ├── OrdersColumnsEnum.cpp │ ├── IO2GMarketDataResponseReader.cpp │ ├── O2GRequestParamsEnum.cpp │ ├── IO2GClosedTradeRow.cpp │ ├── IO2GOrderRow.cpp │ ├── IO2GResponse.cpp │ └── IO2GOfferRow.cpp │ ├── fx.console │ ├── listeners │ │ ├── __init__.py │ │ ├── table.py │ │ └── sessionstatus.py │ └── fx.console.pyproj │ └── ForexConnectClient.sln ├── module └── x64 │ └── forexconnect.pyd ├── .gitignore └── README.md /bin/readme.txt: -------------------------------------------------------------------------------- 1 | project output dir -------------------------------------------------------------------------------- /includes/boost/readme.txt: -------------------------------------------------------------------------------- 1 | place Boost header files here -------------------------------------------------------------------------------- /libs/x64/boost/readme.txt: -------------------------------------------------------------------------------- 1 | Place Boost x64 lib files here -------------------------------------------------------------------------------- /src/ForexConnectClient/fx.market.watcher/dialogs/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ["Dialog", "ClosePosition", "OpenPosition"] -------------------------------------------------------------------------------- /module/x64/forexconnect.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomas-rampas/forex-connect-py/HEAD/module/x64/forexconnect.pyd -------------------------------------------------------------------------------- /libs/x64/forexconnect/ForexConnect.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomas-rampas/forex-connect-py/HEAD/libs/x64/forexconnect/ForexConnect.lib -------------------------------------------------------------------------------- /includes/forexconnect/ForexConnect.h: -------------------------------------------------------------------------------- 1 | #ifdef WIN32 2 | #define Order2Go2 __declspec(dllimport) 3 | #else 4 | #define Order2Go2 5 | #endif 6 | 7 | #include "interfaces_all.h" 8 | 9 | -------------------------------------------------------------------------------- /includes/forexconnect/IAddRef.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class Order2Go2 IAddRef 3 | { 4 | public: 5 | virtual ~IAddRef(); 6 | virtual long addRef() = 0; 7 | virtual long release() = 0; 8 | }; 9 | 10 | typedef double DATE; 11 | 12 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/SessionStatusListener.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class SessionStatusListener : public IO2GSessionStatus 4 | { 5 | public: 6 | virtual void onSessionStatusChanged(O2GSessionStatus status) = 0; 7 | virtual void onLoginFailed(const char* error) = 0; 8 | }; 9 | -------------------------------------------------------------------------------- /includes/forexconnect/Readers/IO2GOrderResponseReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Order2Go2 IO2GOrderResponseReader : public IAddRef 4 | { 5 | protected: 6 | IO2GOrderResponseReader(); 7 | public: 8 | virtual const char* getOrderID() = 0; 9 | virtual bool isUnderDealerIntervention() = 0; 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // forex.connect.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /includes/forexconnect/Readers/IO2GLastOrderUpdateResponseReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Order2Go2 IO2GLastOrderUpdateResponseReader : public IAddRef 4 | { 5 | protected: 6 | IO2GLastOrderUpdateResponseReader(); 7 | public: 8 | /** Get order update type. */ 9 | virtual O2GTableUpdateType getUpdateType() = 0; 10 | /** Get order row. */ 11 | virtual IO2GOrderRow *getOrder() = 0; 12 | }; 13 | -------------------------------------------------------------------------------- /includes/forexconnect/IO2GRow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class IO2GTableColumnCollection; 3 | 4 | class IO2GRow : public IAddRef 5 | { 6 | protected: 7 | IO2GRow(); 8 | 9 | public: 10 | /** Gets the cell value.*/ 11 | virtual const void *getCell(int column) = 0; 12 | 13 | /** Is cell changed?*/ 14 | virtual bool isCellChanged(int column) = 0; 15 | 16 | /** Gets columns */ 17 | virtual IO2GTableColumnCollection *columns() = 0; 18 | 19 | /** Gets table type */ 20 | virtual O2GTable getTableType() = 0; 21 | }; 22 | 23 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IAddRef.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | using namespace boost::python; 5 | 6 | class IAddRefWrap : public IAddRef, public wrapper < IAddRef > 7 | { 8 | public: 9 | long addRef() { return this->get_override("addRef")(); } 10 | long release() { return this->get_override("release")(); } 11 | }; 12 | 13 | void export_IAddRefClass() 14 | { 15 | class_("IAddRef", no_init) 16 | .def("addRef", pure_virtual(&IAddRef::addRef)) 17 | .def("release", pure_virtual(&IAddRef::release)) 18 | ; 19 | typedef double DATE; 20 | } -------------------------------------------------------------------------------- /includes/forexconnect/Readers/IO2GSystemProperties.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /** System properties reader.*/ 4 | class IO2GSystemPropertiesReader : public IAddRef 5 | { 6 | protected: 7 | IO2GSystemPropertiesReader(){}; 8 | public: 9 | /** Gets property by the name. 10 | @return 0 in case the property not found. 11 | */ 12 | virtual const char *findProperty(const char *propertyName) = 0; 13 | /** Gets property by the index.*/ 14 | 15 | virtual const char *getProperty(int index, const char *&value) = 0; 16 | 17 | /** Gets a number of properties*/ 18 | virtual int size() = 0; 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/forex.connect.cpp: -------------------------------------------------------------------------------- 1 | // forex.connect.cpp : Defines the exported functions for the DLL application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "forex.connect.h" 6 | 7 | 8 | //// This is an example of an exported variable 9 | //FOREXCONNECT_API int nforexconnect=0; 10 | // 11 | //// This is an example of an exported function. 12 | //FOREXCONNECT_API int fnforexconnect(void) 13 | //{ 14 | // return 42; 15 | //} 16 | // 17 | //// This is the constructor of a class that has been exported. 18 | //// see forex.connect.h for the class definition 19 | //Cforexconnect::Cforexconnect() 20 | //{ 21 | // return; 22 | //} 23 | -------------------------------------------------------------------------------- /includes/forexconnect/Enums/SummariesColumnsEnum.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | !!! Caution: 4 | Do not change anything in this source code because it was automatically generated 5 | from XML class description 6 | */ 7 | 8 | #pragma once 9 | 10 | class SummariesTableColumnsEnum 11 | { 12 | public: 13 | enum Columns 14 | { 15 | OfferID = 0, 16 | DefaultSortOrder = 1, 17 | Instrument = 2, 18 | SellNetPL = 3, 19 | SellAmount = 4, 20 | SellAvgOpen = 5, 21 | BuyClose = 6, 22 | SellClose = 7, 23 | BuyAvgOpen = 8, 24 | BuyAmount = 9, 25 | BuyNetPL = 10, 26 | Amount = 11, 27 | GrossPL = 12, 28 | NetPL = 13 29 | }; 30 | }; 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Compiled Dynamic libraries 8 | *.so 9 | *.dylib 10 | *.dll 11 | *.pyd 12 | 13 | # Compiled Static libraries 14 | *.lai 15 | *.la 16 | *.a 17 | *.lib 18 | 19 | # Executables 20 | *.exe 21 | *.out 22 | *.app 23 | 24 | #sln files 25 | *.filters 26 | *.sdf 27 | *.opensdf 28 | *.suo 29 | *.user 30 | *.ipch 31 | 32 | #additionals 33 | includes/boost/**/ 34 | includes/boost/**/*.h 35 | includes/boost/**/*.hpp 36 | includes/boost/**/*.ipp 37 | 38 | #sln folders 39 | /**/Debug 40 | /**/Release 41 | ForexConnectClient/**/x64 42 | /**/ipch 43 | 44 | #files 45 | src/ForexConnectClient/**/ReadMe.txt 46 | /src/ForexConnectClient/forex.connect/x64 47 | settings.py 48 | *.pyc 49 | /src/ForexConnectClient/fx.market.watcher/.idea 50 | -------------------------------------------------------------------------------- /includes/forexconnect/Enums/MessagesColumnsEnum.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | !!! Caution: 4 | Do not change anything in this source code because it was automatically generated 5 | from XML class description 6 | */ 7 | 8 | #pragma once 9 | 10 | class MessageColumnsEnum 11 | { 12 | public: 13 | enum Columns 14 | { 15 | MsgID = 0, 16 | Time = 1, 17 | From = 2, 18 | Type = 3, 19 | Feature = 4, 20 | Text = 5, 21 | Subject = 6, 22 | HTMLFragmentFlag = 7 23 | }; 24 | }; 25 | 26 | class MessageTableColumnsEnum 27 | { 28 | public: 29 | enum Columns 30 | { 31 | MsgID = 0, 32 | Time = 1, 33 | From = 2, 34 | Type = 3, 35 | Feature = 4, 36 | Text = 5, 37 | Subject = 6, 38 | HTMLFragmentFlag = 7 39 | }; 40 | }; 41 | -------------------------------------------------------------------------------- /includes/forexconnect/IO2GLoginRules.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /** Provide information about loaded table.*/ 4 | class Order2Go2 IO2GLoginRules : public IAddRef 5 | { 6 | protected: 7 | IO2GLoginRules(); 8 | public: 9 | /** Check loading table during login.*/ 10 | virtual bool isTableLoadedByDefault(O2GTable table) = 0; 11 | /** Get response for loaded table.*/ 12 | virtual IO2GResponse* getTableRefreshResponse(O2GTable table) = 0; 13 | /** Gets system properties.*/ 14 | virtual IO2GResponse* getSystemPropertiesResponse() = 0; 15 | /** Gets permission checker. */ 16 | virtual IO2GPermissionChecker* getPermissionChecker() = 0; 17 | /** Gets trading settings provider. */ 18 | virtual IO2GTradingSettingsProvider* getTradingSettingsProvider() = 0; 19 | }; 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GOrderResponseReader.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | using namespace boost::python; 5 | 6 | class IO2GOrderResponseReaderWrap : public IO2GOrderResponseReader, public wrapper < IO2GOrderResponseReader > 7 | { 8 | public: 9 | const char* getOrderID(){ return this->get_override("getOrderID")(); } 10 | bool isUnderDealerIntervention() { return this->get_override("isUnderDealerIntervention")(); } 11 | }; 12 | 13 | void export_IO2GOrderResponseReader() 14 | { 15 | class_, boost::noncopyable>("IO2GOrderResponseReader", no_init) 16 | .def("getOrderID", pure_virtual(&IO2GOrderResponseReader::getOrderID)) 17 | .def("isUnderDealerIntervention", pure_virtual(&IO2GOrderResponseReader::isUnderDealerIntervention)) 18 | ; 19 | }; 20 | -------------------------------------------------------------------------------- /includes/forexconnect/Readers/IO2GTimeConverter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /** Converts a date and time from one time zone to another.*/ 3 | class IO2GTimeConverter : public IAddRef 4 | { 5 | protected: 6 | IO2GTimeConverter(); 7 | public: 8 | typedef enum 9 | { 10 | UTC, 11 | Local, 12 | EST, 13 | Server 14 | } TimeZone; 15 | 16 | /** Converts the date and time from/to the UTC, EST, local and server time zones.. 17 | @param dtSource The date and time to convert. 18 | @param fromZone The time zone to convert from.. 19 | @param fromZone The time zone to convert to. 20 | @return The date and time in the time zone which you select in the OutputZone parameter.. 21 | */ 22 | virtual DATE convert(DATE dtSource, TimeZone fromZone, TimeZone toZone) = 0; 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /includes/forexconnect/Rows/IO2GMessageRow.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | !!! Caution: 4 | Do not change anything in this source code because it was automatically generated 5 | from XML class description 6 | */ 7 | #pragma once 8 | 9 | class IO2GMessageRow : public IO2GRow 10 | { 11 | protected: 12 | IO2GMessageRow(); 13 | 14 | public: 15 | 16 | 17 | virtual const char* getMsgID() = 0; 18 | virtual DATE getTime() = 0; 19 | virtual const char* getFrom() = 0; 20 | virtual const char* getType() = 0; 21 | virtual const char* getFeature() = 0; 22 | virtual const char* getText() = 0; 23 | virtual const char* getSubject() = 0; 24 | virtual bool getHTMLFragmentFlag() = 0; 25 | // 26 | 27 | }; 28 | 29 | 30 | class IO2GMessageTableRow : public IO2GMessageRow 31 | { 32 | protected: 33 | IO2GMessageTableRow(); 34 | 35 | public: 36 | 37 | // 38 | 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /includes/forexconnect/IO2GColumn.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class IO2GTableColumn : public IAddRef 4 | { 5 | protected: 6 | IO2GTableColumn(); 7 | public: 8 | typedef enum 9 | { 10 | Integer, 11 | Double, 12 | String, 13 | Date, 14 | Boolean 15 | } O2GTableColumnType; 16 | /** Gets the unique identifier of the column.*/ 17 | virtual const char * getID() = 0; 18 | /** Get the type of the column.*/ 19 | virtual O2GTableColumnType getType() = 0; 20 | }; 21 | 22 | class IO2GTableColumnCollection : public IAddRef 23 | { 24 | protected: 25 | IO2GTableColumnCollection(); 26 | public: 27 | /** Gets a number of the columns.*/ 28 | virtual int size() = 0; 29 | /** Gets the column by the index.*/ 30 | virtual IO2GTableColumn *get(int index) = 0; 31 | /** Find the column by the unique identifier.*/ 32 | virtual IO2GTableColumn *find(const char *id) = 0; 33 | }; 34 | 35 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GLastOrderUpdateResponseReader.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | using namespace boost::python; 5 | 6 | class IO2GLastOrderUpdateResponseReaderWrap : public IO2GLastOrderUpdateResponseReader, public wrapper < IO2GLastOrderUpdateResponseReader > 7 | { 8 | public: 9 | O2GTableUpdateType getUpdateType() { return this->get_override("getUpdateType")(); } 10 | IO2GOrderRow* getOrder() { return this->get_override("getOrder")(); } 11 | }; 12 | 13 | void export_IO2GLastOrderUpdateResponseReader() 14 | { 15 | class_, boost::noncopyable>("IO2GLastOrderUpdateResponseReader", no_init) 16 | .def("getUpdateType", pure_virtual(&IO2GLastOrderUpdateResponseReader::getUpdateType)) 17 | .def("getOrder", pure_virtual(&IO2GLastOrderUpdateResponseReader::getOrder), return_value_policy()) 18 | ; 19 | } -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/O2GDateUtils.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | using namespace boost::python; 4 | 5 | void export_O2GDateUtils() 6 | { 7 | //enum_("SYSTEMTIME_DEFINED") 8 | // ; 9 | class_("CO2GDateUtils", init<>()) 10 | .def("CTimeToOleTime", &CO2GDateUtils::CTimeToOleTime) 11 | .staticmethod("CTimeToOleTime") 12 | .def("CTimeToWindowsTime", &CO2GDateUtils::CTimeToWindowsTime) 13 | .staticmethod("CTimeToWindowsTime") 14 | .def("OleTimeToWindowsTime", &CO2GDateUtils::OleTimeToWindowsTime) 15 | .staticmethod("OleTimeToWindowsTime") 16 | .def("OleTimeToCTime", &CO2GDateUtils::OleTimeToCTime) 17 | .staticmethod("OleTimeToCTime") 18 | .def("WindowsTimeToOleTime", &CO2GDateUtils::WindowsTimeToOleTime) 19 | .staticmethod("WindowsTimeToOleTime") 20 | .def("WindowsTimeToCTime", &CO2GDateUtils::WindowsTimeToCTime) 21 | .staticmethod("WindowsTimeToCTime") 22 | ; 23 | }; -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GTimeConverter.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | using namespace boost::python; 5 | 6 | class IO2GTimeConverterWrap : public IO2GTimeConverter, public wrapper < IO2GTimeConverter > 7 | { 8 | DATE convert(DATE dtSource, TimeZone fromZone, TimeZone toZone) { return this->get_override("convert")(); } 9 | }; 10 | 11 | void export_IO2GTimeConverter(){ 12 | 13 | object obj_IO2GTimeConverter = class_, boost::noncopyable>("IO2GTimeConverter", no_init) 14 | .def("convert", pure_virtual(&IO2GTimeConverter::convert)) 15 | ; 16 | { 17 | scope in_IO2GTimeConverter(obj_IO2GTimeConverter); 18 | enum_("TimeZone") 19 | .value("UTC", IO2GTimeConverter::UTC) 20 | .value("Local", IO2GTimeConverter::Local) 21 | .value("EST", IO2GTimeConverter::EST) 22 | .value("Server", IO2GTimeConverter::Server) 23 | .export_values() 24 | ; 25 | } 26 | } -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GSystemPropertiesReader.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | using namespace boost::python; 5 | 6 | class IO2GSystemPropertiesReaderWrap : public IO2GSystemPropertiesReader, public wrapper < IO2GSystemPropertiesReader > 7 | { 8 | public: 9 | const char* findProperty(const char*) { return this->get_override("findProperty")(); } 10 | const char* getProperty(int index, const char*&){ return this->get_override("getProperty")(); } 11 | int size(){ return this->get_override("size")(); } 12 | }; 13 | 14 | void export_IO2GSystemPropertiesReader() 15 | { 16 | class_, boost::noncopyable>("IO2GSystemPropertiesReader", no_init) 17 | .def("findProperty", pure_virtual(&IO2GSystemPropertiesReader::findProperty)) 18 | .def("getProperty", pure_virtual(&IO2GSystemPropertiesReader::getProperty)) 19 | .def("size", pure_virtual(&IO2GSystemPropertiesReader::size)) 20 | ; 21 | } 22 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GRow.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | using namespace boost::python; 4 | 5 | class IO2GRowWrap : public IO2GRow, public wrapper < IO2GRow > 6 | { 7 | public: 8 | const void* getCell(int column){ return this->get_override("getCell")(column);} 9 | bool isCellChanged(int column){ return this->get_override("isCellChanged")();} 10 | IO2GTableColumnCollection* columns(){ return this->get_override("columns")();} 11 | O2GTable getTableType(){ return this->get_override("getTableType")();} 12 | 13 | }; 14 | 15 | void export_IO2GRow() 16 | { 17 | class_, boost::noncopyable>("IO2GRow", no_init) 18 | .def("getCell", pure_virtual((PyObject *(IO2GRow::*)(int))(&IO2GRow::getCell))) 19 | .def("isCellChanged", pure_virtual(&IO2GRow::isCellChanged)) 20 | .def("columns", pure_virtual(&IO2GRow::columns), return_value_policy()) 21 | .def("getTableType", pure_virtual(&IO2GRow::getTableType)) 22 | ; 23 | }; -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/forex.connect.h: -------------------------------------------------------------------------------- 1 | // The following ifdef block is the standard way of creating macros which make exporting 2 | // from a DLL simpler. All files within this DLL are compiled with the FOREXCONNECT_EXPORTS 3 | // symbol defined on the command line. This symbol should not be defined on any project 4 | // that uses this DLL. This way any other project whose source files include this file see 5 | // FOREXCONNECT_API functions as being imported from a DLL, whereas this DLL sees symbols 6 | // defined with this macro as being exported. 7 | #ifdef FOREXCONNECT_EXPORTS 8 | #define FOREXCONNECT_API __declspec(dllexport) 9 | #else 10 | #define FOREXCONNECT_API __declspec(dllimport) 11 | #endif 12 | 13 | // This class is exported from the forex.connect.dll 14 | class FOREXCONNECT_API Cforexconnect { 15 | public: 16 | Cforexconnect(void); 17 | // TODO: add your methods here. 18 | }; 19 | 20 | extern FOREXCONNECT_API int nforexconnect; 21 | 22 | FOREXCONNECT_API int fnforexconnect(void); 23 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/sample_tools.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Forex Capital Markets LLC 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use these files except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | */ 15 | 16 | #pragma once 17 | 18 | #ifdef WIN32 19 | # define GSTOOL3 __declspec(dllimport) 20 | #else 21 | # define GSTOOL3 22 | # define PTHREADS 23 | # define PTHREADS_MUTEX 24 | #endif 25 | 26 | #include "win_emul/winEmul.h" 27 | #include "date/date.h" 28 | #include "mutex/Mutex.h" 29 | #include "threading/Interlocked.h" 30 | #include "threading/AThread.h" 31 | #include "threading/ThreadHandle.h" 32 | 33 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/O2GTransport.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | using namespace boost::python; 4 | 5 | void export_CO2GTransport() 6 | { 7 | class_("CO2GTransport", init<>()) 8 | .def("createSession", &CO2GTransport::createSession, return_value_policy()) 9 | .def("setProxy", &CO2GTransport::setProxy) 10 | .def("setCAInfo", &CO2GTransport::setCAInfo) 11 | .def("setNumberOfReconnections", &CO2GTransport::setNumberOfReconnections) 12 | .def("setApplicationID", &CO2GTransport::setApplicationID) 13 | .def("getApplicationID", &CO2GTransport::getApplicationID) 14 | .def("setClosedHistorySize", &CO2GTransport::setClosedHistorySize) 15 | .def("getClosedHistorySize", &CO2GTransport::getClosedHistorySize) 16 | .staticmethod("createSession") 17 | .staticmethod("setProxy") 18 | .staticmethod("setCAInfo") 19 | .staticmethod("setNumberOfReconnections") 20 | .staticmethod("setApplicationID") 21 | .staticmethod("getApplicationID") 22 | .staticmethod("setClosedHistorySize") 23 | .staticmethod("getClosedHistorySize") 24 | ; 25 | }; 26 | -------------------------------------------------------------------------------- /includes/forexconnect/O2GDateUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if !defined(SYSTEMTIME_DEFINED) && !defined(WIN32) 4 | typedef struct _SYSTEMTIME { 5 | unsigned short wYear; 6 | unsigned short wMonth; 7 | unsigned short wDayOfWeek; 8 | unsigned short wDay; 9 | unsigned short wHour; 10 | unsigned short wMinute; 11 | unsigned short wSecond; 12 | unsigned short wMilliseconds; 13 | } SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME; 14 | #define SYSTEMTIME_DEFINED 15 | #endif 16 | 17 | #ifdef WIN32 18 | #include 19 | #if !defined WINPHONE8 20 | #include 21 | #endif 22 | #endif 23 | 24 | class Order2Go2 CO2GDateUtils 25 | { 26 | public: 27 | static bool CTimeToOleTime(const struct tm *t, double *dt); 28 | static void CTimeToWindowsTime(const struct tm *t, SYSTEMTIME *st); 29 | static bool OleTimeToWindowsTime(const double dt, SYSTEMTIME *st); 30 | static bool OleTimeToCTime(const double dt, struct tm *t); 31 | static bool WindowsTimeToOleTime(const SYSTEMTIME *st, double *dt); 32 | static void WindowsTimeToCTime(const SYSTEMTIME *st, struct tm *t); 33 | 34 | }; 35 | 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | forex-connect-py 2 | 3 | FXCM's Forex Connect API wrapper enabling it as Python module 4 | 5 | Develompent environment: 6 | 7 | * Windows 7 64 bit, 8 | * Visual Studio 2013, 9 | * [PyCharm](https://www.jetbrains.com/pycharm/) for more advanced Python programming 10 | * Python 2.7, 11 | * [Python Tools for Visual Studio](http://pytools.codeplex.com/), 12 | * [Boost 1.55](http://www.boost.org/), 13 | * [Forex Connect API 1.3](http://www.dailyfx.com/forex_forum/forexconnect/392705-forexconnect-api-subscribe-updates-3.html#post1951709) 14 | 15 | Python version 2.7 has been chosen as base platform to develop for. The reason is that this project is part of bigger machine learning solution using also another modules (like numpy, scipy, pandas, matplotlib etc.) that are not always available for Python 3. 16 | 17 | Precompiled python module 18 | 19 | Because it can be difficult to set up dev. environment correctly hence for the time being I've added precompiled Windows 64bit pyd in module subfolder (see /module/x64 subfolder). Place it under your local Python's DLL subfolder. You can use Python projects (i.e. fx.console and fx.market.watcher) as guidance how to use it. 20 | -------------------------------------------------------------------------------- /includes/forexconnect/Rows/IO2GSummaryRow.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | !!! Caution: 4 | Do not change anything in this source code because it was automatically generated 5 | from XML class description 6 | */ 7 | #pragma once 8 | 9 | class IO2GSummaryRow : public IO2GRow 10 | { 11 | protected: 12 | IO2GSummaryRow(); 13 | 14 | public: 15 | 16 | 17 | // 18 | 19 | }; 20 | 21 | 22 | class IO2GSummaryTableRow : public IO2GSummaryRow 23 | { 24 | protected: 25 | IO2GSummaryTableRow(); 26 | 27 | public: 28 | 29 | virtual const char* getOfferID() = 0; 30 | virtual int getDefaultSortOrder() = 0; 31 | virtual const char* getInstrument() = 0; 32 | virtual double getSellNetPL() = 0; 33 | virtual double getSellAmount() = 0; 34 | virtual double getSellAvgOpen() = 0; 35 | virtual double getBuyClose() = 0; 36 | virtual double getSellClose() = 0; 37 | virtual double getBuyAvgOpen() = 0; 38 | virtual double getBuyAmount() = 0; 39 | virtual double getBuyNetPL() = 0; 40 | virtual double getAmount() = 0; 41 | virtual double getGrossPL() = 0; 42 | virtual double getNetPL() = 0; 43 | // 44 | 45 | }; 46 | 47 | -------------------------------------------------------------------------------- /includes/forexconnect/interfaces_all.h: -------------------------------------------------------------------------------- 1 | #include "IAddRef.h" 2 | #include "O2G2ptr.h" 3 | #include "O2GEnum.h" 4 | #include "O2GRequestParamsEnum.h" 5 | #include "IO2GRow.h" 6 | #include "IO2GColumn.h" 7 | #include "IO2GTable.h" 8 | #include "IO2GTimeFrame.h" 9 | #include "IO2GRequest.h" 10 | #include "./Readers/IO2GSystemProperties.h" 11 | #include "./Readers/IO2GMarketDataSnapshotResponseReader.h" 12 | #include "./Readers/IO2GMarketDataResponseReader.h" 13 | #include "./Readers/IO2GTimeConverter.h" 14 | #include "./Readers/IO2GTablesUpdatesReader.h" 15 | #include "./Readers/IO2GOrderResponseReader.h" 16 | #include "./Readers/IO2GLastOrderUpdateResponseReader.h" 17 | #include "./IO2GPermissionChecker.h" 18 | #include "./IO2GTradingSettingsProvider.h" 19 | #include "IO2GResponse.h" 20 | #include "IO2GLoginRules.h" 21 | #include "IO2GSession.h" 22 | #include "O2GTransport.h" 23 | #include "O2GOrderType.h" 24 | #include "O2GDateUtils.h" 25 | #include "./Enums/AccountsColumnsEnum.h" 26 | #include "./Enums/OffersColumnsEnum.h" 27 | #include "./Enums/OrdersColumnsEnum.h" 28 | #include "./Enums/TradesColumnsEnum.h" 29 | #include "./Enums/ClosedTradesColumnsEnum.h" 30 | #include "./Enums/SummariesColumnsEnum.h" 31 | #include "./Enums/MessagesColumnsEnum.h" 32 | -------------------------------------------------------------------------------- /includes/forexconnect/IO2GTimeFrame.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | typedef enum 3 | { 4 | Tick = 0, //!< tick 5 | Min = 1, //!< 1 minute 6 | Hour = 2, //!< 1 hour 7 | Day = 3, //!< 1 day 8 | Week = 4, //!< 1 week 9 | Month = 5, //!< 1 month 10 | Year = 6 11 | } O2GTimeframeUnit; 12 | 13 | 14 | /** */ 15 | class Order2Go2 IO2GTimeframe : public IAddRef 16 | { 17 | protected: 18 | IO2GTimeframe(); 19 | public: 20 | /** Gets the unique identifier of the timeframe.*/ 21 | virtual const char *getID() = 0; 22 | 23 | virtual O2GTimeframeUnit getUnit() = 0; 24 | 25 | virtual int getQueryDepth() = 0; 26 | 27 | /** Gets number of */ 28 | virtual int getSize() = 0; 29 | }; 30 | 31 | 32 | 33 | class Order2Go2 IO2GTimeframeCollection : public IAddRef 34 | { 35 | protected: 36 | IO2GTimeframeCollection(); 37 | public: 38 | /** Get numbers of the time frames.*/ 39 | virtual int size() = 0; 40 | /** Gets time frame by the index.*/ 41 | virtual IO2GTimeframe *get(int index) = 0; 42 | /** Gets time frame by the unique id.*/ 43 | virtual IO2GTimeframe *get(const char *id) = 0; 44 | }; 45 | 46 | -------------------------------------------------------------------------------- /src/ForexConnectClient/fx.console/listeners/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ["sessionstatus", "table"] 2 | 3 | from multiprocessing import Process, Value, Lock 4 | 5 | class Counter(object): 6 | def __init__(self, initval=0): 7 | self.val = Value('i', initval) 8 | self.lock = Lock() 9 | 10 | def increment(self, n = 1): 11 | with self.lock: 12 | self.val.value += n 13 | 14 | def decrement(self, n = 1): 15 | with self.lock: 16 | self.val.value -= n 17 | 18 | @property 19 | def value(self): 20 | with self.lock: 21 | return self.val.value 22 | 23 | class EventHook(object): 24 | def __init__(self): 25 | self.__handlers = [] 26 | 27 | def __iadd__(self, handler): 28 | self.__handlers.append(handler) 29 | return self 30 | 31 | def __isub__(self, handler): 32 | self.__handlers.remove(handler) 33 | return self 34 | 35 | def fire(self, *args, **keywargs): 36 | for handler in self.__handlers: 37 | handler(*args, **keywargs) 38 | 39 | def clearObjectHandlers(self, inObject): 40 | self.__handlers = [h for h in self.__handlers if h.im_self != obj] 41 | for theHandler in self.__handlers: 42 | if theHandler.im_self == inObject: 43 | self -= theHandler -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/ResponseListener.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /** Response listener class. */ 4 | 5 | class ResponseListener : public IO2GResponseListener 6 | { 7 | public: 8 | ResponseListener(IO2GSession *session); 9 | /** Destructor. */ 10 | virtual ~ResponseListener(); 11 | 12 | /** Increase reference counter. */ 13 | virtual long addRef(); 14 | 15 | /** Decrease reference counter. */ 16 | virtual long release(); 17 | 18 | /** Set request ID. */ 19 | void setRequestID(const char *sRequestID); 20 | 21 | /** Wait for request execution or error. */ 22 | bool waitEvents(); 23 | 24 | /** Get response.*/ 25 | IO2GResponse* getResponse(); 26 | 27 | /** Request execution completed data handler. */ 28 | virtual void onRequestCompleted(const char *requestId, IO2GResponse *response = 0); 29 | 30 | /** Request execution failed data handler. */ 31 | virtual void onRequestFailed(const char *requestId, const char *error); 32 | 33 | /** Request update data received data handler. */ 34 | virtual void onTablesUpdates(IO2GResponse *data); 35 | 36 | private: 37 | long mRefCount; 38 | /** Session object. */ 39 | IO2GSession *mSession; 40 | /** Request we are waiting for. */ 41 | std::string mRequestID; 42 | /** Response Event handle. */ 43 | HANDLE mResponseEvent; 44 | 45 | /** State of last request. */ 46 | IO2GResponse *mResponse; 47 | }; 48 | 49 | -------------------------------------------------------------------------------- /includes/forexconnect/Enums/AccountsColumnsEnum.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | !!! Caution: 4 | Do not change anything in this source code because it was automatically generated 5 | from XML class description 6 | */ 7 | 8 | #pragma once 9 | 10 | class AccountColumnsEnum 11 | { 12 | public: 13 | enum Columns 14 | { 15 | AccountID = 0, 16 | AccountName = 1, 17 | AccountKind = 2, 18 | Balance = 3, 19 | NonTradeEquity = 4, 20 | M2MEquity = 5, 21 | UsedMargin = 6, 22 | UsedMargin3 = 7, 23 | MarginCallFlag = 8, 24 | LastMarginCallDate = 9, 25 | MaintenanceType = 10, 26 | AmountLimit = 11, 27 | BaseUnitSize = 12, 28 | MaintenanceFlag = 13, 29 | ManagerAccountID = 14, 30 | LeverageProfileID = 15 31 | }; 32 | }; 33 | 34 | class AccountTableColumnsEnum 35 | { 36 | public: 37 | enum Columns 38 | { 39 | AccountID = 0, 40 | AccountName = 1, 41 | AccountKind = 2, 42 | Balance = 3, 43 | NonTradeEquity = 4, 44 | M2MEquity = 5, 45 | UsedMargin = 6, 46 | UsedMargin3 = 7, 47 | MarginCallFlag = 8, 48 | LastMarginCallDate = 9, 49 | MaintenanceType = 10, 50 | AmountLimit = 11, 51 | BaseUnitSize = 12, 52 | MaintenanceFlag = 13, 53 | ManagerAccountID = 14, 54 | LeverageProfileID = 15, 55 | Equity = 16, 56 | DayPL = 17, 57 | UsableMargin = 18, 58 | GrossPL = 19 59 | }; 60 | }; 61 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/SummariesColumnsEnum.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | void export_SummariesColumnsEnum() 5 | { 6 | using namespace boost::python; 7 | 8 | object obj_SummariesTableColumnsEnum 9 | = class_("SummariesTableColumnsEnum", "Summaries table columns enumeration", init<>()); 10 | { 11 | scope in_SummariesTableColumnsEnum(obj_SummariesTableColumnsEnum); 12 | enum_("Columns") 13 | .value("OfferID", SummariesTableColumnsEnum::OfferID) 14 | .value("DefaultSortOrder", SummariesTableColumnsEnum::DefaultSortOrder) 15 | .value("Instrument", SummariesTableColumnsEnum::Instrument) 16 | .value("SellNetPL", SummariesTableColumnsEnum::SellNetPL) 17 | .value("SellAmount", SummariesTableColumnsEnum::SellAmount) 18 | .value("SellAvgOpen", SummariesTableColumnsEnum::SellAvgOpen) 19 | .value("BuyClose", SummariesTableColumnsEnum::BuyClose) 20 | .value("SellClose", SummariesTableColumnsEnum::SellClose) 21 | .value("BuyAvgOpen", SummariesTableColumnsEnum::BuyAvgOpen) 22 | .value("BuyAmount", SummariesTableColumnsEnum::BuyAmount) 23 | .value("BuyNetPL", SummariesTableColumnsEnum::BuyNetPL) 24 | .value("Amount", SummariesTableColumnsEnum::Amount) 25 | .value("GrossPL", SummariesTableColumnsEnum::GrossPL) 26 | .value("NetPL", SummariesTableColumnsEnum::NetPL) 27 | .export_values() 28 | ; 29 | } 30 | } -------------------------------------------------------------------------------- /includes/forexconnect/Rows/IO2GAccountRow.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | !!! Caution: 4 | Do not change anything in this source code because it was automatically generated 5 | from XML class description 6 | */ 7 | #pragma once 8 | 9 | class IO2GAccountRow : public IO2GRow 10 | { 11 | protected: 12 | IO2GAccountRow(); 13 | 14 | public: 15 | 16 | 17 | virtual const char* getAccountID() = 0; 18 | virtual const char* getAccountName() = 0; 19 | virtual const char* getAccountKind() = 0; 20 | virtual double getBalance() = 0; 21 | virtual double getNonTradeEquity() = 0; 22 | virtual double getM2MEquity() = 0; 23 | virtual double getUsedMargin() = 0; 24 | virtual double getUsedMargin3() = 0; 25 | virtual const char* getMarginCallFlag() = 0; 26 | virtual DATE getLastMarginCallDate() = 0; 27 | virtual const char* getMaintenanceType() = 0; 28 | virtual int getAmountLimit() = 0; 29 | virtual int getBaseUnitSize() = 0; 30 | virtual bool getMaintenanceFlag() = 0; 31 | virtual const char* getManagerAccountID() = 0; 32 | virtual const char* getLeverageProfileID() = 0; 33 | // 34 | 35 | }; 36 | 37 | 38 | class IO2GAccountTableRow : public IO2GAccountRow 39 | { 40 | protected: 41 | IO2GAccountTableRow(); 42 | 43 | public: 44 | 45 | virtual double getEquity() = 0; 46 | virtual double getDayPL() = 0; 47 | virtual double getUsableMargin() = 0; 48 | virtual double getGrossPL() = 0; 49 | // 50 | 51 | }; 52 | 53 | -------------------------------------------------------------------------------- /includes/forexconnect/Enums/OffersColumnsEnum.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | !!! Caution: 4 | Do not change anything in this source code because it was automatically generated 5 | from XML class description 6 | */ 7 | 8 | #pragma once 9 | 10 | class OfferColumnsEnum 11 | { 12 | public: 13 | enum Columns 14 | { 15 | OfferID = 0, 16 | Instrument = 1, 17 | QuoteID = 2, 18 | Bid = 3, 19 | Ask = 4, 20 | Low = 5, 21 | High = 6, 22 | Volume = 7, 23 | Time = 8, 24 | BidTradable = 9, 25 | AskTradable = 10, 26 | SellInterest = 11, 27 | BuyInterest = 12, 28 | ContractCurrency = 13, 29 | Digits = 14, 30 | PointSize = 15, 31 | SubscriptionStatus = 16, 32 | InstrumentType = 17, 33 | ContractMultiplier = 18, 34 | TradingStatus = 19, 35 | ValueDate = 20 36 | }; 37 | }; 38 | 39 | class OfferTableColumnsEnum 40 | { 41 | public: 42 | enum Columns 43 | { 44 | OfferID = 0, 45 | Instrument = 1, 46 | QuoteID = 2, 47 | Bid = 3, 48 | Ask = 4, 49 | Low = 5, 50 | High = 6, 51 | Volume = 7, 52 | Time = 8, 53 | BidTradable = 9, 54 | AskTradable = 10, 55 | SellInterest = 11, 56 | BuyInterest = 12, 57 | ContractCurrency = 13, 58 | Digits = 14, 59 | PointSize = 15, 60 | SubscriptionStatus = 16, 61 | InstrumentType = 17, 62 | ContractMultiplier = 18, 63 | TradingStatus = 19, 64 | ValueDate = 20, 65 | PipCost = 21 66 | }; 67 | }; 68 | -------------------------------------------------------------------------------- /includes/forexconnect/Enums/TradesColumnsEnum.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | !!! Caution: 4 | Do not change anything in this source code because it was automatically generated 5 | from XML class description 6 | */ 7 | 8 | #pragma once 9 | 10 | class TradeColumnsEnum 11 | { 12 | public: 13 | enum Columns 14 | { 15 | TradeID = 0, 16 | AccountID = 1, 17 | AccountName = 2, 18 | AccountKind = 3, 19 | OfferID = 4, 20 | Amount = 5, 21 | BuySell = 6, 22 | OpenRate = 7, 23 | OpenTime = 8, 24 | OpenQuoteID = 9, 25 | OpenOrderID = 10, 26 | OpenOrderReqID = 11, 27 | OpenOrderRequestTXT = 12, 28 | Commission = 13, 29 | RolloverInterest = 14, 30 | TradeIDOrigin = 15, 31 | UsedMargin = 16, 32 | ValueDate = 17, 33 | Parties = 18 34 | }; 35 | }; 36 | 37 | class TradeTableColumnsEnum 38 | { 39 | public: 40 | enum Columns 41 | { 42 | TradeID = 0, 43 | AccountID = 1, 44 | AccountName = 2, 45 | AccountKind = 3, 46 | OfferID = 4, 47 | Amount = 5, 48 | BuySell = 6, 49 | OpenRate = 7, 50 | OpenTime = 8, 51 | OpenQuoteID = 9, 52 | OpenOrderID = 10, 53 | OpenOrderReqID = 11, 54 | OpenOrderRequestTXT = 12, 55 | Commission = 13, 56 | RolloverInterest = 14, 57 | TradeIDOrigin = 15, 58 | UsedMargin = 16, 59 | ValueDate = 17, 60 | Parties = 18, 61 | PL = 19, 62 | GrossPL = 20, 63 | Close = 21, 64 | Stop = 22, 65 | Limit = 23 66 | }; 67 | }; 68 | -------------------------------------------------------------------------------- /includes/forexconnect/O2GTransport.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define INFINITE_NUMBER_OF_RECONNECTIONS INT_MAX 4 | #ifndef WIN32 5 | #ifndef INFINITE 6 | #define INFINITE 0xFFFFFFF 7 | #endif 8 | #endif 9 | 10 | class Order2Go2 CO2GTransport 11 | { 12 | public: 13 | /** Create transport session.*/ 14 | static IO2GSession* createSession(); 15 | 16 | /** Set proxy. 17 | @param proxyHost Proxy host. 18 | @param iPort Proxy port. 19 | @param user User name. 20 | @param password User password. 21 | */ 22 | static void setProxy(const char* proxyHost, int port, const char* user, const char* password); 23 | 24 | /** Set CA info (Useless in Windows OS) 25 | @param caFilePath File path to certificate (certificate bundle) in PEM format. 26 | */ 27 | static void setCAInfo(const char* caFilePath); 28 | 29 | /** Set number of reconnection tries 30 | @param iNumber Number of reconnection tries. 31 | */ 32 | static void setNumberOfReconnections(const int number); 33 | /** Set application id.*/ 34 | static void setApplicationID(const char* applicationID); 35 | /** Get appalication id.*/ 36 | static void getApplicationID(char* applicationID, size_t &len); 37 | 38 | /** Set histore size 39 | @param iSize The maximum number of closed positions to be stored 40 | */ 41 | static void setClosedHistorySize(const int size); 42 | 43 | /** Get history size */ 44 | static int getClosedHistorySize(); 45 | }; 46 | 47 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GLoginRules.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | using namespace boost::python; 5 | 6 | class IO2GLoginRulesWrap : public IO2GLoginRules, public wrapper < IO2GLoginRules > 7 | { 8 | public: 9 | bool isTableLoadedByDefault(O2GTable){ return this->get_override("isTableLoadedByDefault")();} 10 | IO2GResponse* getTableRefreshResponse(O2GTable){ return this->get_override("getTableRefreshResponse")();} 11 | IO2GResponse* getSystemPropertiesResponse(){ return this->get_override("getSystemPropertiesResponse")();} 12 | IO2GPermissionChecker* getPermissionChecker(){ return this->get_override("getPermissionChecker")();} 13 | IO2GTradingSettingsProvider* getTradingSettingsProvider(){ return this->get_override("getTradingSettingsProvider")();} 14 | }; 15 | 16 | void export_IO2GLoginRules() 17 | { 18 | class_, boost::noncopyable>("IO2GLoginRules", no_init) 19 | .def("isTableLoadedByDefault", pure_virtual(&IO2GLoginRules::isTableLoadedByDefault)) 20 | .def("getTableRefreshResponse", pure_virtual(&IO2GLoginRules::getTableRefreshResponse), return_value_policy()) 21 | .def("getSystemPropertiesResponse", pure_virtual(&IO2GLoginRules::getSystemPropertiesResponse), return_value_policy()) 22 | .def("getPermissionChecker", pure_virtual(&IO2GLoginRules::getPermissionChecker), return_value_policy()) 23 | .def("getTradingSettingsProvider", pure_virtual(&IO2GLoginRules::getTradingSettingsProvider), return_value_policy()) 24 | ; 25 | }; 26 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GMessageRow.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | using namespace boost::python; 4 | 5 | class IO2GMessageRowWrap : public IO2GMessageRow, public wrapper < IO2GMessageRow > 6 | { 7 | public: 8 | const char* getMsgID(){ return this->get_override("getMsgID")();} 9 | DATE getTime(){ return this->get_override("getTime")();} 10 | const char* getFrom(){ return this->get_override("getFrom")();} 11 | const char* getType(){ return this->get_override("getType")();} 12 | const char* getFeature(){ return this->get_override("getFeature")();} 13 | const char* getText(){ return this->get_override("getText")();} 14 | const char* getSubject(){ return this->get_override("getSubject")();} 15 | bool getHTMLFragmentFlag(){ return this->get_override("getHTMLFragmentFlag")();} 16 | }; 17 | 18 | void export_IO2GMessageRow() 19 | { 20 | class_, boost::noncopyable>("IO2GMessageRow", no_init) 21 | .def("getMsgID", pure_virtual(&IO2GMessageRow::getMsgID)) 22 | .def("getTime", pure_virtual(&IO2GMessageRow::getTime)) 23 | .def("getFrom", pure_virtual(&IO2GMessageRow::getFrom)) 24 | .def("getType", pure_virtual(&IO2GMessageRow::getType)) 25 | .def("getFeature", pure_virtual(&IO2GMessageRow::getFeature)) 26 | .def("getText", pure_virtual(&IO2GMessageRow::getText)) 27 | .def("getSubject", pure_virtual(&IO2GMessageRow::getSubject)) 28 | .def("getHTMLFragmentFlag", pure_virtual(&IO2GMessageRow::getHTMLFragmentFlag)) 29 | ; 30 | 31 | class_, boost::noncopyable>("IO2GMessageTableRow", no_init) 32 | ; 33 | }; -------------------------------------------------------------------------------- /includes/forexconnect/O2G2ptr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /** Smart pointer for IAddRef interface. 3 | Use for automatic calculation of instance object reference. 4 | */ 5 | #ifndef WIN32 6 | #include // note: must be include automatically but it does not. 7 | #endif 8 | template class O2G2Ptr 9 | { 10 | public: 11 | O2G2Ptr() : p(0){} 12 | O2G2Ptr(T* source) : p(source) 13 | { 14 | } 15 | O2G2Ptr(const O2G2Ptr& source) : p(source.p) 16 | { 17 | if(p) 18 | p->addRef(); 19 | } 20 | ~O2G2Ptr() 21 | { 22 | if(p) 23 | p->release(); 24 | } 25 | 26 | void Release() 27 | { 28 | if (p) 29 | { 30 | p->release(); 31 | p = NULL; 32 | } 33 | } 34 | T* Detach() {T* pTemp = p; p = NULL; return pTemp;} 35 | operator T*() const {return static_cast(p);} 36 | T& operator*() const {return *p;} 37 | T* operator->() const {return p;} 38 | T* operator=(T* source) 39 | { 40 | Release(); 41 | p=source; 42 | if (p!=NULL) 43 | { 44 | return static_cast(p); 45 | } 46 | return NULL; 47 | } 48 | T* operator=(const O2G2Ptr& source) 49 | { 50 | Release(); 51 | p = source.p; 52 | p->addRef(); 53 | return static_cast(p); 54 | } 55 | bool operator!() const {return p==NULL;} 56 | operator bool() const {return p!=NULL;} 57 | bool operator<(T* pT) const {return p 3 | 4 | void export_MessagesColumnsEnum() 5 | { 6 | using namespace boost::python; 7 | 8 | object obj_MessageColumnsEnum 9 | = class_("MessageColumnsEnum", "Message columns enumeration", init<>()); 10 | { 11 | scope in_AccountColumnsEnum(obj_MessageColumnsEnum); 12 | enum_("Columns") 13 | .value("MsgID", MessageColumnsEnum::MsgID) 14 | .value("Time", MessageColumnsEnum::Time) 15 | .value("From", MessageColumnsEnum::From) 16 | .value("Type", MessageColumnsEnum::Type) 17 | .value("Feature", MessageColumnsEnum::Feature) 18 | .value("Text", MessageColumnsEnum::Text) 19 | .value("Subject", MessageColumnsEnum::Subject) 20 | .value("HTMLFragmentFlag", MessageColumnsEnum::HTMLFragmentFlag) 21 | .export_values() 22 | ; 23 | } 24 | 25 | object obj_MessageTableColumnsEnum 26 | = class_("MessageTableColumnsEnum", "Message table columns enumeration", init<>()); 27 | { 28 | scope in_MessageTableColumnsEnum(obj_MessageTableColumnsEnum); 29 | enum_("Columns") 30 | .value("MsgID", MessageTableColumnsEnum::MsgID) 31 | .value("Time", MessageTableColumnsEnum::Time) 32 | .value("From", MessageTableColumnsEnum::From) 33 | .value("Type", MessageTableColumnsEnum::Type) 34 | .value("Feature", MessageTableColumnsEnum::Feature) 35 | .value("Text", MessageTableColumnsEnum::Text) 36 | .value("Subject", MessageTableColumnsEnum::Subject) 37 | .value("HTMLFragmentFlag", MessageTableColumnsEnum::HTMLFragmentFlag) 38 | .export_values() 39 | ; 40 | ; 41 | } 42 | } -------------------------------------------------------------------------------- /includes/forexconnect/O2GRequestParamsEnum.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | typedef enum 5 | { 6 | UnknownParam = -1, 7 | Command = 1, 8 | AccountID = 2, 9 | OfferID = 3, 10 | TradeID = 4, 11 | BuySell = 5, 12 | Amount = 6, 13 | Rate = 7, 14 | RateStop = 8, 15 | RateLimit = 9, 16 | TrailStepStop = 10, 17 | TrailStep = 11, 18 | TimeInForce = 12, 19 | CustomID = 13, 20 | OrderID = 14, 21 | PegOffsetStop = 15, 22 | PegOffsetLimit = 16, 23 | PegTypeStop = 17, 24 | PegTypeLimit = 18, 25 | PegOffset = 19, 26 | PegType = 20, 27 | NetQuantity = 21, 28 | OrderType = 22, 29 | RateMin = 23, 30 | RateMax = 24, 31 | ContingencyID = 25, 32 | SubscriptionStatus = 26, 33 | ClientRate = 27, 34 | ContingencyGroupType = 28, 35 | PrimaryQID = 29, 36 | AccountName = 30, 37 | Key = 31, 38 | Id = 32, 39 | Bid = 33, 40 | Ask = 34, 41 | LoginID = 35, 42 | ReportID = 36, 43 | Lifetime = 37, 44 | Symbol = 38, 45 | Psw = 39, 46 | IntrBuy = 40, 47 | IntrSel = 41, 48 | IntrMult = 42, 49 | Status = 43, 50 | IntrFlag = 44, 51 | Msg = 45, 52 | DealerIntFlg = 46, 53 | AutoLimit = 47, 54 | MrgnReq = 48, 55 | EntryMrgnReq = 49, 56 | RateVariat = 50, 57 | RfqLifetime = 51, 58 | OrdrLifetime = 52, 59 | SellIntr = 53, 60 | BuyIntr = 54, 61 | Feed = 55, 62 | FeedPrice = 56, 63 | FeedAsk = 57, 64 | FeedBid = 58, 65 | PercentCost = 59, 66 | AcctID = 60, 67 | IntrSign = 61, 68 | MrgnReqEntry = 62, 69 | OrderPriceFlg = 63, 70 | MrgnEnabledFlg = 64, 71 | MrgnReqAware = 65, 72 | Login = 66, 73 | OrderPrice = 67, 74 | SeatBelt = 68, 75 | AutoMrgn = 69, 76 | CondDistance = 70, 77 | CondDistanceE = 71, 78 | MaxQuantity = 72, 79 | PanicFlg = 73, 80 | GoneToPeeFlg = 74, 81 | ManualPrices = 75, 82 | CrossCurrency = 76, 83 | PanicLevel = 77, 84 | IntrMultNone = 78, 85 | EqtyEnabledFlg = 79, 86 | EqtyStop = 80, 87 | EqtyLimit = 81, 88 | ExpireDateTime = 82 89 | } O2GRequestParamsEnum; 90 | -------------------------------------------------------------------------------- /src/ForexConnectClient/fx.console/fx.console.pyproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | 2.0 6 | 3a533c8e-ee7c-4c04-ab98-106ddb55df05 7 | . 8 | fx.console.py 9 | 10 | 11 | . 12 | . 13 | fx.console 14 | fx.console 15 | {929fd3b6-b7f4-4f18-8279-20762a12412b} 16 | 2.7 17 | False 18 | 19 | 20 | true 21 | false 22 | 23 | 24 | true 25 | false 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /includes/forexconnect/Rows/IO2GClosedTradeRow.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | !!! Caution: 4 | Do not change anything in this source code because it was automatically generated 5 | from XML class description 6 | */ 7 | #pragma once 8 | 9 | class IO2GClosedTradeRow : public IO2GRow 10 | { 11 | protected: 12 | IO2GClosedTradeRow(); 13 | 14 | public: 15 | 16 | 17 | virtual const char* getTradeID() = 0; 18 | virtual const char* getAccountID() = 0; 19 | virtual const char* getAccountName() = 0; 20 | virtual const char* getAccountKind() = 0; 21 | virtual const char* getOfferID() = 0; 22 | virtual int getAmount() = 0; 23 | virtual const char* getBuySell() = 0; 24 | virtual double getGrossPL() = 0; 25 | virtual double getCommission() = 0; 26 | virtual double getRolloverInterest() = 0; 27 | virtual double getOpenRate() = 0; 28 | virtual const char* getOpenQuoteID() = 0; 29 | virtual DATE getOpenTime() = 0; 30 | virtual const char* getOpenOrderID() = 0; 31 | virtual const char* getOpenOrderReqID() = 0; 32 | virtual const char* getOpenOrderRequestTXT() = 0; 33 | virtual const char* getOpenOrderParties() = 0; 34 | virtual double getCloseRate() = 0; 35 | virtual const char* getCloseQuoteID() = 0; 36 | virtual DATE getCloseTime() = 0; 37 | virtual const char* getCloseOrderID() = 0; 38 | virtual const char* getCloseOrderReqID() = 0; 39 | virtual const char* getCloseOrderRequestTXT() = 0; 40 | virtual const char* getCloseOrderParties() = 0; 41 | virtual const char* getTradeIDOrigin() = 0; 42 | virtual const char* getTradeIDRemain() = 0; 43 | virtual const char* getValueDate() = 0; 44 | // 45 | 46 | }; 47 | 48 | 49 | class IO2GClosedTradeTableRow : public IO2GClosedTradeRow 50 | { 51 | protected: 52 | IO2GClosedTradeTableRow(); 53 | 54 | public: 55 | 56 | virtual double getPL() = 0; 57 | // 58 | 59 | }; 60 | 61 | -------------------------------------------------------------------------------- /includes/forexconnect/Readers/IO2GTablesUpdatesReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class IO2GTablesUpdatesReader : public IAddRef 4 | { 5 | protected: 6 | IO2GTablesUpdatesReader(); 7 | public: 8 | /** Gets current server timestamp. 9 | @return Server Timestamp 10 | */ 11 | virtual DATE getServerTime() = 0; 12 | /** Gets updates size.*/ 13 | virtual int size() = 0; 14 | /** Gets update type.*/ 15 | virtual O2GTableUpdateType getUpdateType(int index) = 0; 16 | /** Gets update table*/ 17 | virtual O2GTable getUpdateTable(int index) = 0; 18 | /** Gets offer row by index. 19 | @return Offer row. If the specified row is not offer then 20 | return NULL. 21 | */ 22 | virtual IO2GOfferRow *getOfferRow(int index) = 0; 23 | /** Get account row. 24 | @return Account row .If the specified row is not account then 25 | return NULL. 26 | */ 27 | virtual IO2GAccountRow *getAccountRow(int index) = 0; 28 | /** Get account row. 29 | @return Order row. If the specified row is not order then 30 | return NULL. 31 | */ 32 | virtual IO2GOrderRow *getOrderRow(int index) = 0; 33 | /** Get trade row. 34 | @return Trade row. If the specified row is not order then 35 | return NULL. 36 | */ 37 | virtual IO2GTradeRow *getTradeRow(int index) = 0; 38 | /** Get closed trade row. 39 | @return Closed trade row. If the specified row is not order then 40 | return NULL. 41 | */ 42 | virtual IO2GClosedTradeRow *getClosedTradeRow(int index) = 0; 43 | /** Get message row. 44 | @return Message row. If the specified row is not order then 45 | return NULL. 46 | */ 47 | virtual IO2GMessageRow *getMessageRow(int index) = 0; 48 | }; 49 | 50 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/Offer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /** Class to keep offers */ 4 | class Offer 5 | { 6 | private: 7 | std::string mID; // offer identifier 8 | std::string mInstrument; // instrument 9 | int mPrecision; // offer precision 10 | DATE mDate; // date and time of the offer change 11 | double mPipSize; // offer pipsize 12 | double mBid; // offer bid 13 | double mAsk; // offer ask 14 | public: 15 | /** Constructor. */ 16 | Offer(const char *id, const char *instrument, int precision, double pipsize, double date, double bid, double ask); 17 | 18 | /** Update bid. */ 19 | void setBid(double bid); 20 | 21 | /** Update ask. */ 22 | void setAsk(double ask); 23 | 24 | /** Update date. */ 25 | void setDate(DATE date); 26 | 27 | /** Get id. */ 28 | const char *getID() const; 29 | 30 | /** Get instrument. */ 31 | const char *getInstrument() const; 32 | 33 | /** Get precision. */ 34 | int getPrecision() const; 35 | 36 | /** Get pipsize. */ 37 | double getPipSize() const; 38 | 39 | /** Get bid. */ 40 | double getBid() const; 41 | 42 | /** Get ask. */ 43 | double getAsk() const; 44 | 45 | /** Get date. */ 46 | DATE getDate() const; 47 | }; 48 | 49 | /** Collection of the offers. */ 50 | class OfferCollection 51 | { 52 | private: 53 | std::vector mOffers; 54 | std::map mIndex; 55 | mutable sample_tools::Mutex m_Mutex; 56 | public: 57 | /** Constructor. */ 58 | OfferCollection(); 59 | /** Destructor. */ 60 | virtual ~OfferCollection(); 61 | /** Add offer to collection. */ 62 | void addOffer(Offer *offer); 63 | /** Find offer by id. */ 64 | Offer *findOffer(const char *id) const; 65 | /** Get number of offers. */ 66 | int size() const; 67 | /** Get offer by index. */ 68 | Offer *get(int index) const; 69 | /** Clear offer collection. */ 70 | void clear(); 71 | }; 72 | 73 | -------------------------------------------------------------------------------- /includes/forexconnect/Enums/ClosedTradesColumnsEnum.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | !!! Caution: 4 | Do not change anything in this source code because it was automatically generated 5 | from XML class description 6 | */ 7 | 8 | #pragma once 9 | 10 | class ClosedTradeColumnsEnum 11 | { 12 | public: 13 | enum Columns 14 | { 15 | TradeID = 0, 16 | AccountID = 1, 17 | AccountName = 2, 18 | AccountKind = 3, 19 | OfferID = 4, 20 | Amount = 5, 21 | BuySell = 6, 22 | GrossPL = 7, 23 | Commission = 8, 24 | RolloverInterest = 9, 25 | OpenRate = 10, 26 | OpenQuoteID = 11, 27 | OpenTime = 12, 28 | OpenOrderID = 13, 29 | OpenOrderReqID = 14, 30 | OpenOrderRequestTXT = 15, 31 | OpenOrderParties = 16, 32 | CloseRate = 17, 33 | CloseQuoteID = 18, 34 | CloseTime = 19, 35 | CloseOrderID = 20, 36 | CloseOrderReqID = 21, 37 | CloseOrderRequestTXT = 22, 38 | CloseOrderParties = 23, 39 | TradeIDOrigin = 24, 40 | TradeIDRemain = 25, 41 | ValueDate = 26 42 | }; 43 | }; 44 | 45 | class ClosedTradeTableColumnsEnum 46 | { 47 | public: 48 | enum Columns 49 | { 50 | TradeID = 0, 51 | AccountID = 1, 52 | AccountName = 2, 53 | AccountKind = 3, 54 | OfferID = 4, 55 | Amount = 5, 56 | BuySell = 6, 57 | GrossPL = 7, 58 | Commission = 8, 59 | RolloverInterest = 9, 60 | OpenRate = 10, 61 | OpenQuoteID = 11, 62 | OpenTime = 12, 63 | OpenOrderID = 13, 64 | OpenOrderReqID = 14, 65 | OpenOrderRequestTXT = 15, 66 | OpenOrderParties = 16, 67 | CloseRate = 17, 68 | CloseQuoteID = 18, 69 | CloseTime = 19, 70 | CloseOrderID = 20, 71 | CloseOrderReqID = 21, 72 | CloseOrderRequestTXT = 22, 73 | CloseOrderParties = 23, 74 | TradeIDOrigin = 24, 75 | TradeIDRemain = 25, 76 | ValueDate = 26, 77 | PL = 27 78 | }; 79 | }; 80 | -------------------------------------------------------------------------------- /includes/forexconnect/O2GEnum.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef enum 4 | { 5 | TableUnknown = - 1, 6 | Offers = 0, 7 | Accounts = 1, 8 | Orders = 2, 9 | Trades = 3, 10 | ClosedTrades = 4, 11 | Messages = 5, 12 | Summary = 6 13 | } O2GTable; 14 | 15 | typedef enum 16 | { 17 | ResponseUnknown = -1, 18 | TablesUpdates = 0, 19 | MarketDataSnapshot = 1, 20 | GetAccounts = 2, 21 | GetOffers = 3, 22 | GetOrders = 4, 23 | GetTrades = 5, 24 | GetClosedTrades = 6, 25 | GetMessages = 7, 26 | CreateOrderResponse = 8, 27 | GetSystemProperties = 9, 28 | CommandResponse = 10, 29 | MarginRequirementsResponse = 11, 30 | GetLastOrderUpdate = 12, 31 | MarketData = 13 32 | } O2GResponseType; 33 | 34 | typedef enum 35 | { 36 | UpdateUnknown = - 1, 37 | Insert = 0, 38 | Update = 1, 39 | Delete = 2 40 | } O2GTableUpdateType; 41 | 42 | typedef enum 43 | { 44 | PermissionDisabled = 0, 45 | PermissionEnabled = 1, 46 | PermissionHidden = -2 47 | } O2GPermissionStatus; 48 | 49 | typedef enum 50 | { 51 | MarketStatusOpen = 0, //!< Trading is allowed. 52 | MarketStatusClosed = 1, //!< Trading is not allowed. 53 | MarketStatusUndefined = 2 //!< Undefined or unknown status 54 | } O2GMarketStatus; 55 | 56 | typedef enum 57 | { 58 | Default = 0, 59 | NoPrice = 1 60 | } O2GPriceUpdateMode; 61 | 62 | typedef enum 63 | { 64 | No = 0, 65 | Yes = 1 66 | } O2GTableManagerMode; 67 | 68 | typedef enum 69 | { 70 | Initial = 0, // initial status. 71 | Refreshing = 1, // refresh in progress. 72 | Refreshed = 2, // refresh is finished, table filled. 73 | Failed = 3 // refresh is failed. 74 | } O2GTableStatus; 75 | 76 | typedef enum 77 | { 78 | ReportUrlNotSupported = -1, 79 | ReportUrlTooSmallBuffer = -2, 80 | ReportUrlNotLogged = -3 81 | } O2GReportUrlError; 82 | 83 | typedef enum 84 | { 85 | TablesLoading = 0, 86 | TablesLoaded = 1, 87 | TablesLoadFailed = 2 88 | } O2GTableManagerStatus; 89 | -------------------------------------------------------------------------------- /src/ForexConnectClient/fx.market.watcher/fx.market.watcher.pyproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | 2.0 6 | e9607f20-c508-4ab4-a652-f63913e16305 7 | . 8 | fx.market.watcher.py 9 | D:\!projects\!github\pyfxconnect\bin 10 | . 11 | . 12 | fx.market.watcher 13 | fx.market.watcher 14 | True 15 | {929fd3b6-b7f4-4f18-8279-20762a12412b} 16 | 2.7 17 | Standard Python launcher 18 | False 19 | 20 | 21 | true 22 | false 23 | 24 | 25 | true 26 | false 27 | 28 | 29 | 30 | Code 31 | 32 | 33 | Code 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/TableListener.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | using namespace boost::python; 4 | 5 | class TableListener : public IO2GTableListener 6 | { 7 | public: 8 | virtual void onAdded(const char *rowID, IO2GRow *rowData) = 0; 9 | virtual void onChanged(const char *rowID, IO2GRow *rowData) = 0; 10 | virtual void onDeleted(const char *rowID, IO2GRow *rowData) = 0; 11 | virtual void onStatusChanged(O2GTableStatus status) = 0; 12 | virtual long addRef() = 0; 13 | virtual long release() = 0; 14 | }; 15 | 16 | class TableListenerImpl : public TableListener 17 | { 18 | public: 19 | TableListenerImpl(PyObject* pyObject) : self(pyObject){} 20 | TableListenerImpl(PyObject* pyObject, const TableListener& listener) : self(pyObject), TableListener(listener){} 21 | 22 | void onAdded(const char *rowID, IO2GRow *rowData) 23 | { 24 | PyGILState_STATE gstate = PyGILState_Ensure(); 25 | call_method(self, "onAdded", rowID, boost::ref(rowData)); 26 | PyGILState_Release(gstate); 27 | }; 28 | 29 | void onChanged(const char *rowID, IO2GRow *rowData) 30 | { 31 | PyGILState_STATE gstate = PyGILState_Ensure(); 32 | call_method(self, "onChanged", rowID, boost::ref(rowData)); 33 | PyGILState_Release(gstate); 34 | }; 35 | void onDeleted(const char *rowID, IO2GRow *rowData) 36 | { 37 | PyGILState_STATE gstate = PyGILState_Ensure(); 38 | call_method(self, "onDeleted", rowID, boost::ref(rowData)); 39 | PyGILState_Release(gstate); 40 | }; 41 | void onStatusChanged(O2GTableStatus status) 42 | { 43 | PyGILState_STATE gstate = PyGILState_Ensure(); 44 | call_method(self, "onStatusChanged", status); 45 | PyGILState_Release(gstate); 46 | }; 47 | long addRef() 48 | { 49 | PyGILState_STATE gstate = PyGILState_Ensure(); 50 | long refCount = call_method(self, "addRef"); 51 | PyGILState_Release(gstate); 52 | return refCount; 53 | } 54 | 55 | long release() 56 | { 57 | PyGILState_STATE gstate = PyGILState_Ensure(); 58 | long refCount = call_method(self, "release"); 59 | PyGILState_Release(gstate); 60 | return refCount; 61 | } 62 | 63 | private: 64 | PyObject* const self; 65 | }; -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GColumn.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | using namespace boost::python; 5 | 6 | class IO2GTableColumnWrap : public IO2GTableColumn, public wrapper < IO2GTableColumn > 7 | { 8 | public: 9 | const char* getID() { return this->get_override("getID")(); } 10 | O2GTableColumnType getType(){ return this->get_override("getType")(); } 11 | }; 12 | 13 | class IO2GTableColumnCollectionWrap : public IO2GTableColumnCollection, public wrapper < IO2GTableColumnCollection > 14 | { 15 | public: 16 | int size() { return this->get_override("size")(); } 17 | IO2GTableColumn* get(int) { return this->get_override("get")(); } 18 | IO2GTableColumn* find(const char *){ return this->get_override("find")(); } 19 | }; 20 | 21 | void export_IO2GColumn() 22 | { 23 | object obj_IO2GTableColumn = class_, boost::noncopyable>("IO2GTableColumn", no_init) 24 | .def("getID", pure_virtual(&IO2GTableColumn::getID)) 25 | .def("getType", pure_virtual(&IO2GTableColumn::getType)) 26 | ; 27 | { 28 | scope in_IO2GTableColumn(obj_IO2GTableColumn); 29 | enum_("IO2GTableColumnType") 30 | .value("Integer", IO2GTableColumn::O2GTableColumnType::Integer) 31 | .value("Double", IO2GTableColumn::O2GTableColumnType::Double) 32 | .value("String", IO2GTableColumn::O2GTableColumnType::String) 33 | .value("Date", IO2GTableColumn::O2GTableColumnType::Date) 34 | .value("Boolean", IO2GTableColumn::O2GTableColumnType::Boolean) 35 | .export_values() 36 | ; 37 | 38 | } 39 | 40 | class_, boost::noncopyable>("IO2GTableColumnCollection", no_init) 41 | //.def("__len__", &IO2GTableColumnCollection::size) 42 | //.def("__getitem__", &IO2GTableColumnCollection::get, return_value_policy()) 43 | .def("size", pure_virtual( &IO2GTableColumnCollection::size)) 44 | .def("get", pure_virtual(&IO2GTableColumnCollection::get), return_value_policy()) 45 | .def("find", pure_virtual(&IO2GTableColumnCollection::find), return_value_policy()) 46 | ; 47 | } -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GTimeframe.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | using namespace boost::python; 4 | 5 | //IO2GTimeframe 6 | class IO2GTimeframeWrap : public IO2GTimeframe, public wrapper 7 | { 8 | public: 9 | const char* getID(){ return this->get_override("getID")();} 10 | O2GTimeframeUnit getUnit(){ return this->get_override("getUnit")();} 11 | int getQueryDepth(){ return this->get_override("getQueryDepth")();} 12 | int getSize(){ return this->get_override("getSize")();} 13 | }; 14 | 15 | //IO2GTimeframeCollection 16 | class IO2GTimeframeCollectionWrap : public IO2GTimeframeCollection, public wrapper 17 | { 18 | public: 19 | int size(){ return this->get_override("size")();} 20 | IO2GTimeframe* get(int index){ return this->get_override("get")();} 21 | IO2GTimeframe* get(const char *id){ return this->get_override("get")();} 22 | }; 23 | 24 | void export_IO2GTimeframe() 25 | { 26 | enum_("O2GTimeframeUnit") 27 | .value("Tick", O2GTimeframeUnit::Tick) 28 | .value("Min", O2GTimeframeUnit::Min) 29 | .value("Hour", O2GTimeframeUnit::Hour) 30 | .value("Day", O2GTimeframeUnit::Day) 31 | .value("Week", O2GTimeframeUnit::Week) 32 | .value("Month", O2GTimeframeUnit::Month) 33 | .value("Year", O2GTimeframeUnit::Year) 34 | .export_values() 35 | ; 36 | 37 | class_, boost::noncopyable>("IO2GTimeframe", no_init) 38 | .def("getID", pure_virtual(&IO2GTimeframe::getID)) 39 | .def("getUnit", pure_virtual(&IO2GTimeframe::getUnit)) 40 | .def("getQueryDepth", pure_virtual(&IO2GTimeframe::getQueryDepth)) 41 | .def("getSize", pure_virtual(&IO2GTimeframe::getSize)) 42 | ; 43 | 44 | class_, boost::noncopyable>("IO2GTimeframeCollection", no_init) 45 | .def("size", pure_virtual(&IO2GTimeframeCollection::size)) 46 | .def("get", pure_virtual((IO2GTimeframe*(IO2GTimeframeCollection::*)(int))(&IO2GTimeframeCollection::get)), return_value_policy()) 47 | .def("get", pure_virtual((IO2GTimeframe*(IO2GTimeframeCollection::*)(const char *))(&IO2GTimeframeCollection::get)), return_value_policy()) 48 | ; 49 | }; 50 | 51 | -------------------------------------------------------------------------------- /includes/forexconnect/IO2GRequest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class Order2Go2 IO2GRequest : public IAddRef 3 | { 4 | protected: 5 | IO2GRequest(); 6 | public: 7 | virtual const char *getRequestID() = 0; 8 | virtual int getChildrenCount() = 0; 9 | virtual IO2GRequest* getChildRequest(int index) = 0; 10 | }; 11 | 12 | class Order2Go2 IO2GValueMap : public IAddRef 13 | { 14 | protected: 15 | IO2GValueMap(); 16 | public: 17 | 18 | virtual void setString(O2GRequestParamsEnum param, const char* value) = 0; 19 | virtual void setDouble(O2GRequestParamsEnum param , double value) = 0; 20 | virtual void setInt(O2GRequestParamsEnum param, int value) = 0; 21 | virtual void setBoolean(O2GRequestParamsEnum param, bool value) = 0; 22 | 23 | virtual IO2GValueMap* clone() = 0; 24 | virtual void clear() = 0; 25 | 26 | virtual int getChildrenCount() = 0; 27 | virtual IO2GValueMap* getChild(int index) = 0; 28 | virtual void appendChild(IO2GValueMap* valueMap) = 0; 29 | }; 30 | 31 | /** Request factory.*/ 32 | class Order2Go2 IO2GRequestFactory : public IAddRef 33 | { 34 | protected: 35 | IO2GRequestFactory(); 36 | public: 37 | 38 | /** Gets time frames collection.*/ 39 | virtual IO2GTimeframeCollection *getTimeFrameCollection() = 0; 40 | 41 | /** Create market a data snapshot request.*/ 42 | virtual IO2GRequest *createMarketDataSnapshotRequestInstrument(const char *instrument, IO2GTimeframe *timeframe, int maxBars = 300) = 0; 43 | 44 | /** Fill parameters the market data snapshot*/ 45 | virtual void fillMarketDataSnapshotRequestTime(IO2GRequest *request, DATE timeFrom = 0, DATE timeTo = 0, bool isIncludeWeekends = false) = 0; 46 | 47 | /** Gets refresh request.*/ 48 | virtual IO2GRequest *createRefreshTableRequest(O2GTable table) = 0; 49 | 50 | /** Gets refresh request by the account.*/ 51 | virtual IO2GRequest *createRefreshTableRequestByAccount(O2GTable table, const char* account) = 0; 52 | 53 | /** Create order request.*/ 54 | virtual IO2GRequest *createOrderRequest(IO2GValueMap *valueMap) = 0; 55 | 56 | /** Create value map.*/ 57 | virtual IO2GValueMap *createValueMap() = 0; 58 | 59 | /** Get last error.*/ 60 | virtual const char* getLastError() = 0; 61 | }; 62 | 63 | -------------------------------------------------------------------------------- /includes/forexconnect/Rows/IO2GOrderRow.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | !!! Caution: 4 | Do not change anything in this source code because it was automatically generated 5 | from XML class description 6 | */ 7 | #pragma once 8 | 9 | class IO2GOrderRow : public IO2GRow 10 | { 11 | protected: 12 | IO2GOrderRow(); 13 | 14 | public: 15 | 16 | 17 | virtual const char* getOrderID() = 0; 18 | virtual const char* getRequestID() = 0; 19 | virtual double getRate() = 0; 20 | virtual double getExecutionRate() = 0; 21 | virtual double getRateMin() = 0; 22 | virtual double getRateMax() = 0; 23 | virtual const char* getTradeID() = 0; 24 | virtual const char* getAccountID() = 0; 25 | virtual const char* getAccountName() = 0; 26 | virtual const char* getOfferID() = 0; 27 | virtual bool getNetQuantity() = 0; 28 | virtual const char* getBuySell() = 0; 29 | virtual const char* getStage() = 0; 30 | virtual const char* getType() = 0; 31 | virtual const char* getStatus() = 0; 32 | virtual DATE getStatusTime() = 0; 33 | virtual int getAmount() = 0; 34 | virtual double getLifetime() = 0; 35 | virtual double getAtMarket() = 0; 36 | virtual int getTrailStep() = 0; 37 | virtual double getTrailRate() = 0; 38 | virtual const char* getTimeInForce() = 0; 39 | virtual const char* getAccountKind() = 0; 40 | virtual const char* getRequestTXT() = 0; 41 | virtual const char* getContingentOrderID() = 0; 42 | virtual int getContingencyType() = 0; 43 | virtual const char* getPrimaryID() = 0; 44 | virtual int getOriginAmount() = 0; 45 | virtual int getFilledAmount() = 0; 46 | virtual bool getWorkingIndicator() = 0; 47 | virtual const char* getPegType() = 0; 48 | virtual double getPegOffset() = 0; 49 | virtual DATE getExpireDate() = 0; 50 | virtual const char* getValueDate() = 0; 51 | virtual const char* getParties() = 0; 52 | // 53 | 54 | }; 55 | 56 | 57 | class IO2GOrderTableRow : public IO2GOrderRow 58 | { 59 | protected: 60 | IO2GOrderTableRow(); 61 | 62 | public: 63 | 64 | virtual double getStop() = 0; 65 | virtual double getLimit() = 0; 66 | virtual int getStopTrailStep() = 0; 67 | virtual double getStopTrailRate() = 0; 68 | // 69 | 70 | }; 71 | 72 | -------------------------------------------------------------------------------- /src/ForexConnectClient/fx.console/listeners/table.py: -------------------------------------------------------------------------------- 1 | import forexconnect as fx 2 | from listeners import Counter, EventHook 3 | 4 | class TableListener(fx.TableListener): 5 | def __init__(self): 6 | super(TableListener, self).__init__() 7 | self.refcount = Counter(1) 8 | self.instrument = "" 9 | self.offers = [] 10 | self.onOffersChanged = EventHook() 11 | 12 | def __del__(self): 13 | pass 14 | 15 | def addRef(self): 16 | self.refcount.increment() 17 | ref = self.refcount.value 18 | return ref 19 | 20 | def release(self): 21 | self.refcount.decrement() 22 | ref = self.refcount.value 23 | if self.refcount.value == 0: 24 | del self 25 | return ref 26 | 27 | def setInstrument(self, instrument): 28 | self.instrument = instrument 29 | 30 | def onAdded(self, rowID, rowData): 31 | print "onAdded" 32 | 33 | def onChanged(self, rowID, rowData): 34 | rowData.__class__ = fx.IO2GOfferRow 35 | self.onOffersChanged.fire(rowData) 36 | 37 | def onDelete(self, rowID, rowData): 38 | print "onDelete" 39 | 40 | def onStatusChanged(self, status): 41 | print status 42 | 43 | def printOffers(self, offersTable, instrument): 44 | iterator = fx.IO2GTableIterator() 45 | offerRow = offersTable.getNextRow(iterator) 46 | while offerRow: 47 | self.printOffer(offerRow, instrument) 48 | offerRow.release() 49 | offerRow = offersTable.getNextRow(iterator) 50 | 51 | def printOffer(self, offerRow, instrument): 52 | if self.instrument == offerRow.getInstrument(): 53 | print offerRow.getInstrument(), "Bid: ", offerRow.getBid(), "Ask: ", offerRow.getAsk() 54 | 55 | def subscribeEvents(self, manager): 56 | offersTable = manager.getTable(fx.O2GTable.Offers) 57 | offersTable.__class__ = fx.IO2GOffersTable 58 | offersTable.subscribeUpdate(fx.O2GTableUpdateType.Update, self) 59 | 60 | def unsubscribeEvents(self, manager): 61 | offersTable = manager.getTable(fx.O2GTable.Offers) 62 | offersTable.__class__ = fx.IO2GOffersTable 63 | offersTable.unsubscribeUpdate(fx.O2GTableUpdateType.Update, self) 64 | -------------------------------------------------------------------------------- /includes/forexconnect/Enums/OrdersColumnsEnum.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | !!! Caution: 4 | Do not change anything in this source code because it was automatically generated 5 | from XML class description 6 | */ 7 | 8 | #pragma once 9 | 10 | class OrderColumnsEnum 11 | { 12 | public: 13 | enum Columns 14 | { 15 | OrderID = 0, 16 | RequestID = 1, 17 | Rate = 2, 18 | ExecutionRate = 3, 19 | RateMin = 4, 20 | RateMax = 5, 21 | TradeID = 6, 22 | AccountID = 7, 23 | AccountName = 8, 24 | OfferID = 9, 25 | NetQuantity = 10, 26 | BuySell = 11, 27 | Stage = 12, 28 | Type = 13, 29 | Status = 14, 30 | StatusTime = 15, 31 | Amount = 16, 32 | Lifetime = 17, 33 | AtMarket = 18, 34 | TrailStep = 19, 35 | TrailRate = 20, 36 | TimeInForce = 21, 37 | AccountKind = 22, 38 | RequestTXT = 23, 39 | ContingentOrderID = 24, 40 | ContingencyType = 25, 41 | PrimaryID = 26, 42 | OriginAmount = 27, 43 | FilledAmount = 28, 44 | WorkingIndicator = 29, 45 | PegType = 30, 46 | PegOffset = 31, 47 | ExpireDate = 32, 48 | ValueDate = 33, 49 | Parties = 34 50 | }; 51 | }; 52 | 53 | class OrderTableColumnsEnum 54 | { 55 | public: 56 | enum Columns 57 | { 58 | OrderID = 0, 59 | RequestID = 1, 60 | Rate = 2, 61 | ExecutionRate = 3, 62 | RateMin = 4, 63 | RateMax = 5, 64 | TradeID = 6, 65 | AccountID = 7, 66 | AccountName = 8, 67 | OfferID = 9, 68 | NetQuantity = 10, 69 | BuySell = 11, 70 | Stage = 12, 71 | Type = 13, 72 | Status = 14, 73 | StatusTime = 15, 74 | Amount = 16, 75 | Lifetime = 17, 76 | AtMarket = 18, 77 | TrailStep = 19, 78 | TrailRate = 20, 79 | TimeInForce = 21, 80 | AccountKind = 22, 81 | RequestTXT = 23, 82 | ContingentOrderID = 24, 83 | ContingencyType = 25, 84 | PrimaryID = 26, 85 | OriginAmount = 27, 86 | FilledAmount = 28, 87 | WorkingIndicator = 29, 88 | PegType = 30, 89 | PegOffset = 31, 90 | ExpireDate = 32, 91 | ValueDate = 33, 92 | Parties = 34, 93 | Stop = 35, 94 | Limit = 36, 95 | StopTrailStep = 37, 96 | StopTrailRate = 38 97 | }; 98 | }; 99 | -------------------------------------------------------------------------------- /includes/forexconnect/IO2GTradingSettingsProvider.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /** Trading settings provider.*/ 4 | class IO2GTradingSettingsProvider : public IAddRef 5 | { 6 | protected: 7 | IO2GTradingSettingsProvider(){}; 8 | public: 9 | 10 | /** Gets condition distance for the stop. */ 11 | virtual int getCondDistStopForTrade(const char* instrument) = 0; 12 | 13 | /** Gets condition distance for the limit. */ 14 | virtual int getCondDistLimitForTrade(const char* instrument) = 0; 15 | 16 | /** Gets condition distance for the entry stop. */ 17 | virtual int getCondDistEntryStop(const char* instrument) = 0; 18 | 19 | /** Gets condition distance for the entry limit. */ 20 | virtual int getCondDistEntryLimit(const char* instrument) = 0; 21 | 22 | /** Gets minimum quantity (in lots) for an order for specified instrument and account. */ 23 | virtual int getMinQuantity(const char* instrument, IO2GAccountRow* account) = 0; 24 | 25 | /** Gets maximum quantity (in lots) for an order for specified instrument and account. */ 26 | virtual int getMaxQuantity(const char* instrument, IO2GAccountRow* account) = 0; 27 | 28 | /** Gets base unit size by the account identifier and instrument identifier. */ 29 | virtual int getBaseUnitSize(const char* instrument, IO2GAccountRow* account) = 0; 30 | 31 | /** Gets marker status. */ 32 | virtual O2GMarketStatus getMarketStatus(const char* instrument) = 0; 33 | 34 | /** Gets minimal trailing step. */ 35 | virtual int getMinTrailingStep() = 0; 36 | 37 | /** Gets maximal trailing step. */ 38 | virtual int getMaxTrailingStep() = 0; 39 | 40 | /** Gets the MMR for the specified instrument by account. */ 41 | virtual double getMMR(const char* instrument, IO2GAccountRow* account) = 0; 42 | 43 | /** Gets the MMR/LMR/EMR for the specified instrument by account. 44 | 45 | @param instrument Instrument. 46 | @param account Account row. 47 | @param mmr [out] MMR. 48 | @param emr [out] EMR. 49 | @param lmr [out] LMR. 50 | 51 | @return Whether three level margin is used. 52 | */ 53 | virtual bool getMargins(const char* instrument, IO2GAccountRow* account, double& mmr, double& emr, double& lmr) = 0; 54 | 55 | }; 56 | 57 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GTablesUpdatesReader.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | using namespace boost::python; 5 | 6 | class IO2GTablesUpdatesReaderWrap : public IO2GTablesUpdatesReader, public wrapper < IO2GTablesUpdatesReader > 7 | { 8 | public: 9 | DATE getServerTime(){ return this->get_override("getServerTime")(); } 10 | int size(){ return this->get_override("size")(); } 11 | O2GTableUpdateType getUpdateType(int){ return this->get_override("getUpdateType")(); } 12 | O2GTable getUpdateTable(int){ return this->get_override("getUpdateTable")(); } 13 | IO2GOfferRow* getOfferRow(int){ return this->get_override("getOfferRow")(); } 14 | IO2GAccountRow* getAccountRow(int){ return this->get_override("getAccountRow")(); } 15 | IO2GOrderRow* getOrderRow(int){ return this->get_override("getOrderRow")(); } 16 | IO2GTradeRow* getTradeRow(int){ return this->get_override("getTradeRow")(); } 17 | IO2GClosedTradeRow* getClosedTradeRow(int){ return this->get_override("getClosedTradeRow")(); } 18 | IO2GMessageRow* getMessageRow(int){ return this->get_override("getMessageRow")(); } 19 | }; 20 | 21 | void export_IO2GTablesUpdatesReader() 22 | { 23 | class_("IO2GTablesUpdatesReader", no_init) 24 | .def("getServerTime", pure_virtual(&IO2GTablesUpdatesReader::getServerTime)) 25 | .def("size", pure_virtual(&IO2GTablesUpdatesReader::size)) 26 | .def("getUpdateType", pure_virtual(&IO2GTablesUpdatesReader::getUpdateType)) 27 | .def("getUpdateTable", pure_virtual(&IO2GTablesUpdatesReader::getUpdateTable)) 28 | .def("getOfferRow", pure_virtual(&IO2GTablesUpdatesReader::getOfferRow), return_value_policy()) 29 | .def("getAccountRow", pure_virtual(&IO2GTablesUpdatesReader::getAccountRow), return_value_policy()) 30 | .def("getOrderRow", pure_virtual(&IO2GTablesUpdatesReader::getOrderRow), return_value_policy()) 31 | .def("getTradeRow", pure_virtual(&IO2GTablesUpdatesReader::getTradeRow), return_value_policy()) 32 | .def("getClosedTradeRow", pure_virtual(&IO2GTablesUpdatesReader::getClosedTradeRow), return_value_policy()) 33 | .def("getMessageRow", pure_virtual(&IO2GTablesUpdatesReader::getMessageRow), return_value_policy()) 34 | ; 35 | } 36 | -------------------------------------------------------------------------------- /includes/forexconnect/Rows/IO2GOfferRow.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | !!! Caution: 4 | Do not change anything in this source code because it was automatically generated 5 | from XML class description 6 | */ 7 | #pragma once 8 | 9 | class IO2GOfferRow : public IO2GRow 10 | { 11 | protected: 12 | IO2GOfferRow(); 13 | 14 | public: 15 | 16 | 17 | virtual const char* getOfferID() = 0; 18 | virtual const char* getInstrument() = 0; 19 | virtual const char* getQuoteID() = 0; 20 | virtual double getBid() = 0; 21 | virtual double getAsk() = 0; 22 | virtual double getLow() = 0; 23 | virtual double getHigh() = 0; 24 | virtual int getVolume() = 0; 25 | virtual DATE getTime() = 0; 26 | virtual const char* getBidTradable() = 0; 27 | virtual const char* getAskTradable() = 0; 28 | virtual double getSellInterest() = 0; 29 | virtual double getBuyInterest() = 0; 30 | virtual const char* getContractCurrency() = 0; 31 | virtual int getDigits() = 0; 32 | virtual double getPointSize() = 0; 33 | virtual const char* getSubscriptionStatus() = 0; 34 | virtual int getInstrumentType() = 0; 35 | virtual double getContractMultiplier() = 0; 36 | virtual const char* getTradingStatus() = 0; 37 | virtual const char* getValueDate() = 0; 38 | // 39 | 40 | virtual bool isOfferIDValid() = 0; 41 | virtual bool isInstrumentValid() = 0; 42 | virtual bool isQuoteIDValid() = 0; 43 | virtual bool isBidValid() = 0; 44 | virtual bool isAskValid() = 0; 45 | virtual bool isLowValid() = 0; 46 | virtual bool isHighValid() = 0; 47 | virtual bool isVolumeValid() = 0; 48 | virtual bool isTimeValid() = 0; 49 | virtual bool isBidTradableValid() = 0; 50 | virtual bool isAskTradableValid() = 0; 51 | virtual bool isSellInterestValid() = 0; 52 | virtual bool isBuyInterestValid() = 0; 53 | virtual bool isContractCurrencyValid() = 0; 54 | virtual bool isDigitsValid() = 0; 55 | virtual bool isPointSizeValid() = 0; 56 | virtual bool isSubscriptionStatusValid() = 0; 57 | virtual bool isInstrumentTypeValid() = 0; 58 | virtual bool isContractMultiplierValid() = 0; 59 | virtual bool isTradingStatusValid() = 0; 60 | virtual bool isValueDateValid() = 0; 61 | }; 62 | 63 | 64 | class IO2GOfferTableRow : public IO2GOfferRow 65 | { 66 | protected: 67 | IO2GOfferTableRow(); 68 | 69 | public: 70 | 71 | virtual double getPipCost() = 0; 72 | // 73 | 74 | }; 75 | 76 | -------------------------------------------------------------------------------- /includes/forexconnect/Readers/IO2GMarketDataResponseReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Order2Go2 IO2GMarketDataResponseReader : public IAddRef 4 | { 5 | protected: 6 | IO2GMarketDataResponseReader(); 7 | public: 8 | /** Gets QuoteID.*/ 9 | virtual const char *getQuoteID() = 0; 10 | /** Gets Instrument.*/ 11 | virtual const char *getInstrument() = 0; 12 | /** Gets Symbol ID (i.e. Offer ID).*/ 13 | virtual int getSymbolID() = 0; 14 | /** Gets DateTime.*/ 15 | virtual DATE getDateTime() = 0; 16 | 17 | /** Gets AskLow.*/ 18 | virtual double getAskLow() = 0; 19 | /** Gets AskHigh.*/ 20 | virtual double getAskHigh() = 0; 21 | /** Gets AskOpen.*/ 22 | virtual double getAskOpen() = 0; 23 | /** Gets AskClose.*/ 24 | virtual double getAskClose() = 0; 25 | 26 | /** Gets BidLow.*/ 27 | virtual double getBidLow() = 0; 28 | /** Gets BidHigh.*/ 29 | virtual double getBidHigh() = 0; 30 | /** Gets BidOpen.*/ 31 | virtual double getBidOpen() = 0; 32 | /** Gets BidClose.*/ 33 | virtual double getBidClose() = 0; 34 | 35 | /** Gets Low.*/ 36 | virtual double getLow() = 0; 37 | /** Gets High.*/ 38 | virtual double getHigh() = 0; 39 | 40 | /** Gets Timing Interval.*/ 41 | virtual int getTimingInterval() = 0; 42 | /** Gets True if candle is completed, overwise False.*/ 43 | virtual bool isCandleCompleted() = 0; 44 | /** Gets Market Data Request ID.*/ 45 | virtual const char *getMarketDataRequestID() = 0; 46 | /** Gets Trading Session ID.*/ 47 | virtual const char *getTradingSessionID() = 0; 48 | /** Gets Trading Session sub ID.*/ 49 | virtual const char *getTradingSessionSubID() = 0; 50 | /** Gets Continuous Flag.*/ 51 | virtual int getContinuosFlag() = 0; 52 | 53 | /** Gets Bid ID.*/ 54 | virtual const char *getBidID() = 0; 55 | /** Gets Bid Quote Condition.*/ 56 | virtual const char *getBidQuoteCondition() = 0; 57 | /** Gets Bid Quote Type.*/ 58 | virtual int getBidQuoteType() = 0; 59 | /** Gets Bid Expire Date Time.*/ 60 | virtual DATE getBidExpireDateTime() = 0; 61 | 62 | /** Gets Ask ID.*/ 63 | virtual const char *getAskID() = 0; 64 | /** Gets Ask Quote Condition.*/ 65 | virtual const char *getAskQuoteCondition() = 0; 66 | /** Gets Ask Quote Type.*/ 67 | virtual int getAskQuoteType() = 0; 68 | /** Gets Ask Expire Date Time.*/ 69 | virtual DATE getAskExpireDateTime() = 0; 70 | }; 71 | 72 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "stdafx.h" 3 | #include "SessionStatusListener.h" 4 | #include "TableListener.h" 5 | 6 | BOOST_PYTHON_MODULE(forexconnect) 7 | { 8 | //root 9 | export_IAddRefClass(); 10 | export_IO2GColumn(); 11 | export_IO2GLoginRules(); 12 | export_IO2GPermissionChecker(); 13 | export_IO2GRequest(); 14 | export_IO2GResponse(); 15 | export_IO2GRow(); 16 | export_IO2GSession(); 17 | //IO2GTable_Begin 18 | export_IO2GGenericTableResponseReader(); 19 | export_IO2GOffersTableResponseReader(); 20 | export_IO2GAccountsTableResponseReader(); 21 | export_IO2GOrdersTableResponseReader(); 22 | export_IO2GTradesTableResponseReader(); 23 | export_IO2GClosedTradesTableResponseReader(); 24 | export_IO2GMessagesTableResponseReader(); 25 | export_IO2GTableIterator(); 26 | export_IO2GTableListener(); 27 | export_IO2GTable(); 28 | export_IO2GTableManager(); 29 | export_IO2GOffersTable(); 30 | export_IO2GAccountsTable(); 31 | export_IO2GOrdersTable(); 32 | export_IO2GTradesTable(); 33 | export_IO2GClosedTradesTable(); 34 | export_IO2GMessagesTable(); 35 | export_IO2GSummaryTable(); 36 | //IO2GTable_End 37 | export_IO2GTimeframe(); 38 | export_IO2GTradingSettingsProvider(); 39 | export_O2GDateUtils(); 40 | export_O2GEnum(); 41 | export_O2GRequestParamsEnum(); 42 | export_CO2GTransport(); 43 | // enumerations exports 44 | export_AccountsColumnsEnum(); 45 | export_TradesColumnsEnum(); 46 | export_ClosedTradesColumnsEnum(); 47 | export_MessagesColumnsEnum(); 48 | export_OffersColumnsEnum(); 49 | export_OrdersColumnsEnum(); 50 | export_SummariesColumnsEnum(); 51 | // readers 52 | export_IO2GLastOrderUpdateResponseReader(); 53 | export_IO2GMarketDataResponseReader(); 54 | export_IO2GMarketDataSnapshotResponseReader(); 55 | export_IO2GOrderResponseReader(); 56 | export_IO2GSystemPropertiesReader(); 57 | export_IO2GTablesUpdatesReader(); 58 | export_IO2GTimeConverter(); 59 | // rows 60 | export_IO2GAccountRow(); 61 | export_IO2GClosedTradeRow(); 62 | export_IO2GMessageRow(); 63 | export_IO2GOfferRow(); 64 | export_IO2GOrderRow(); 65 | export_IO2GSummaryRow(); 66 | export_IO2GTradeRow(); 67 | 68 | export_O2G2PteredClasses(); 69 | 70 | }; 71 | 72 | 73 | BOOL APIENTRY DllMain( HMODULE hModule, 74 | DWORD ul_reason_for_call, 75 | LPVOID lpReserved 76 | ) 77 | { 78 | switch (ul_reason_for_call) 79 | { 80 | case DLL_PROCESS_ATTACH: 81 | case DLL_THREAD_ATTACH: 82 | case DLL_THREAD_DETACH: 83 | case DLL_PROCESS_DETACH: 84 | break; 85 | } 86 | return TRUE; 87 | }; 88 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GSummaryRow.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | using namespace boost::python; 5 | 6 | //IO2GSummaryRow 7 | class IO2GSummaryRowWrap : public IO2GSummaryRow, public wrapper < IO2GSummaryRow > 8 | { 9 | public: 10 | }; 11 | 12 | //IO2GSummaryTableRow 13 | class IO2GSummaryTableRowWrap : public IO2GSummaryTableRow, public wrapper < IO2GSummaryTableRow > 14 | { 15 | public: 16 | const char* getOfferID(){ return this->get_override("getOfferID")();} 17 | int getDefaultSortOrder(){ return this->get_override("getDefaultSortOrder")();} 18 | const char* getInstrument(){ return this->get_override("getInstrument")();} 19 | double getSellNetPL(){ return this->get_override("getSellNetPL")();} 20 | double getSellAmount(){ return this->get_override("getSellAmount")();} 21 | double getSellAvgOpen(){ return this->get_override("getSellAvgOpen")();} 22 | double getBuyClose(){ return this->get_override("getBuyClose")();} 23 | double getSellClose(){ return this->get_override("getSellClose")();} 24 | double getBuyAvgOpen(){ return this->get_override("getBuyAvgOpen")();} 25 | double getBuyAmount(){ return this->get_override("getBuyAmount")();} 26 | double getBuyNetPL(){ return this->get_override("getBuyNetPL")();} 27 | double getAmount(){ return this->get_override("getAmount")();} 28 | double getGrossPL(){ return this->get_override("getGrossPL")();} 29 | double getNetPL(){ return this->get_override("getNetPL")();} 30 | }; 31 | 32 | void export_IO2GSummaryRow() 33 | { 34 | class_, boost::noncopyable>("IO2GSummaryRow", no_init) 35 | ; 36 | 37 | class_, boost::noncopyable>("IO2GSummaryTableRow", no_init) 38 | .def("getOfferID", pure_virtual(&IO2GSummaryTableRow::getOfferID)) 39 | .def("getDefaultSortOrder", pure_virtual(&IO2GSummaryTableRow::getDefaultSortOrder)) 40 | .def("getInstrument", pure_virtual(&IO2GSummaryTableRow::getInstrument)) 41 | .def("getSellNetPL", pure_virtual(&IO2GSummaryTableRow::getSellNetPL)) 42 | .def("getSellAmount", pure_virtual(&IO2GSummaryTableRow::getSellAmount)) 43 | .def("getSellAvgOpen", pure_virtual(&IO2GSummaryTableRow::getSellAvgOpen)) 44 | .def("getBuyClose", pure_virtual(&IO2GSummaryTableRow::getBuyClose)) 45 | .def("getSellClose", pure_virtual(&IO2GSummaryTableRow::getSellClose)) 46 | .def("getBuyAvgOpen", pure_virtual(&IO2GSummaryTableRow::getBuyAvgOpen)) 47 | .def("getBuyAmount", pure_virtual(&IO2GSummaryTableRow::getBuyAmount)) 48 | .def("getBuyNetPL", pure_virtual(&IO2GSummaryTableRow::getBuyNetPL)) 49 | .def("getAmount", pure_virtual(&IO2GSummaryTableRow::getAmount)) 50 | .def("getGrossPL", pure_virtual(&IO2GSummaryTableRow::getGrossPL)) 51 | .def("getNetPL", pure_virtual(&IO2GSummaryTableRow::getNetPL)) 52 | ; 53 | }; -------------------------------------------------------------------------------- /includes/forexconnect/IO2GResponse.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Order2Go2 IO2GResponse : public IAddRef 4 | { 5 | protected: 6 | IO2GResponse(); 7 | public: 8 | virtual O2GResponseType getType() = 0; 9 | virtual const char * getRequestID() = 0; 10 | }; 11 | 12 | 13 | class Order2Go2 IO2GResponseListener : public IAddRef 14 | { 15 | protected: 16 | IO2GResponseListener(); 17 | public: 18 | virtual void onRequestCompleted(const char * requestId, IO2GResponse *response = 0) = 0; 19 | virtual void onRequestFailed(const char *requestId , const char *error) = 0; 20 | virtual void onTablesUpdates(IO2GResponse *tablesUpdates) = 0; 21 | }; 22 | 23 | 24 | class Order2Go2 IO2GResponseReaderFactory : public IAddRef 25 | { 26 | protected: 27 | IO2GResponseReaderFactory(); 28 | public: 29 | /** Create table updates response reader.*/ 30 | virtual IO2GTablesUpdatesReader *createTablesUpdatesReader(IO2GResponse *response) = 0; 31 | 32 | /** Create market data snapshot response.*/ 33 | virtual IO2GMarketDataSnapshotResponseReader *createMarketDataSnapshotReader(IO2GResponse *response) = 0; 34 | 35 | /** Create market data response.*/ 36 | virtual IO2GMarketDataResponseReader *createMarketDataReader(IO2GResponse *response) = 0; 37 | 38 | /** Create offers table response reader.*/ 39 | virtual IO2GOffersTableResponseReader *createOffersTableReader(IO2GResponse *response) = 0; 40 | 41 | /** Create Account table response reader.*/ 42 | virtual IO2GAccountsTableResponseReader *createAccountsTableReader(IO2GResponse *response) = 0; 43 | 44 | /** Create Order table response reader.*/ 45 | virtual IO2GOrdersTableResponseReader *createOrdersTableReader(IO2GResponse *response) = 0; 46 | 47 | /** Create trades table response reader.*/ 48 | virtual IO2GTradesTableResponseReader *createTradesTableReader(IO2GResponse *response) = 0; 49 | 50 | /** Create closed trades table response reader.*/ 51 | virtual IO2GClosedTradesTableResponseReader *createClosedTradesTableReader(IO2GResponse *response) = 0; 52 | 53 | /** Create messages table response reader.*/ 54 | virtual IO2GMessagesTableResponseReader *createMessagesTableReader(IO2GResponse *response) = 0; 55 | 56 | /** Create order response reader.*/ 57 | virtual IO2GOrderResponseReader *createOrderResponseReader(IO2GResponse *response) = 0; 58 | 59 | /** Create last order update response reader. */ 60 | virtual IO2GLastOrderUpdateResponseReader *createLastOrderUpdateResponseReader(IO2GResponse *response) = 0; 61 | 62 | /** Create system properties reader.*/ 63 | virtual IO2GSystemPropertiesReader *createSystemPropertiesReader(IO2GResponse *response) = 0; 64 | 65 | /** Process margin requirements response.*/ 66 | virtual bool processMarginRequirementsResponse(IO2GResponse *response) = 0; 67 | }; 68 | 69 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | //#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files: 12 | //#include 13 | 14 | #define BOOST_ALL_DYN_LINK 15 | #define BOOST_LIB_DIAGNOSTIC 16 | #define BOOST_PYTHON_STATIC_LIB 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | //#include 30 | 31 | #define _TIMEOUT 30000 32 | 33 | // Declaration 34 | void export_AccountsColumnsEnum(); 35 | void export_TradesColumnsEnum(); 36 | void export_ClosedTradesColumnsEnum(); 37 | void export_MessagesColumnsEnum(); 38 | void export_OffersColumnsEnum(); 39 | void export_OrdersColumnsEnum(); 40 | void export_SummariesColumnsEnum(); 41 | void export_IAddRefClass(); 42 | void export_IO2GLastOrderUpdateResponseReader(); 43 | void export_IO2GMarketDataResponseReader(); 44 | void export_IO2GMarketDataSnapshotResponseReader(); 45 | void export_IO2GOrderResponseReader(); 46 | void export_IO2GSystemPropertiesReader(); 47 | void export_IO2GTablesUpdatesReader(); 48 | void export_IO2GTimeConverter(); 49 | void export_IO2GAccountRow(); 50 | void export_IO2GClosedTradeRow(); 51 | void export_IO2GMessageRow(); 52 | void export_IO2GOfferRow(); 53 | void export_IO2GOrderRow(); 54 | void export_IO2GSummaryRow(); 55 | void export_IO2GTradeRow(); 56 | void export_IO2GColumn(); 57 | void export_IO2GLoginRules(); 58 | void export_IO2GPermissionChecker(); 59 | void export_IO2GRequest(); 60 | void export_IO2GResponse(); 61 | void export_IO2GRow(); 62 | void export_IO2GSession(); 63 | //IO2GTable_Begin 64 | void export_IO2GGenericTableResponseReader(); 65 | void export_IO2GOffersTableResponseReader(); 66 | void export_IO2GAccountsTableResponseReader(); 67 | void export_IO2GOrdersTableResponseReader(); 68 | void export_IO2GTradesTableResponseReader(); 69 | void export_IO2GClosedTradesTableResponseReader(); 70 | void export_IO2GMessagesTableResponseReader(); 71 | void export_IO2GTableIterator(); 72 | void export_IO2GTableListener(); 73 | void export_IO2GTable(); 74 | void export_IO2GTableManager(); 75 | void export_IO2GOffersTable(); 76 | void export_IO2GAccountsTable(); 77 | void export_IO2GOrdersTable(); 78 | void export_IO2GTradesTable(); 79 | void export_IO2GClosedTradesTable(); 80 | void export_IO2GMessagesTable(); 81 | void export_IO2GSummaryTable(); 82 | //IO2GTable_End 83 | void export_IO2GTimeframe(); 84 | void export_IO2GTradingSettingsProvider(); 85 | void export_O2GDateUtils(); 86 | void export_O2GEnum(); 87 | void export_O2GRequestParamsEnum(); 88 | void export_CO2GTransport(); 89 | void export_O2G2PteredClasses(); 90 | 91 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GTradingSettingsProvider.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | using namespace boost::python; 4 | 5 | //IO2GTradingSettingsProvider 6 | class IO2GTradingSettingsProviderWrap : public IO2GTradingSettingsProvider, public wrapper 7 | { 8 | public: 9 | int getCondDistStopForTrade(const char* instrument){ return this->get_override("getCondDistStopForTrade")();} 10 | int getCondDistLimitForTrade(const char* instrument){ return this->get_override("getCondDistLimitForTrade")();} 11 | int getCondDistEntryStop(const char* instrument){ return this->get_override("getCondDistEntryStop")();} 12 | int getCondDistEntryLimit(const char* instrument){ return this->get_override("getCondDistEntryLimit")();} 13 | int getMinQuantity(const char* instrument, IO2GAccountRow* account){ return this->get_override("getMinQuantity")();} 14 | int getMaxQuantity(const char* instrument, IO2GAccountRow* account){ return this->get_override("getMaxQuantity")();} 15 | int getBaseUnitSize(const char* instrument, IO2GAccountRow* account){ return this->get_override("getBaseUnitSize")();} 16 | O2GMarketStatus getMarketStatus(const char* instrument){ return this->get_override("getMarketStatus")();} 17 | int getMinTrailingStep(){ return this->get_override("getMinTrailingStep")();} 18 | int getMaxTrailingStep(){ return this->get_override("getMaxTrailingStep")();} 19 | double getMMR(const char* instrument, IO2GAccountRow* account){ return this->get_override("getMMR")();} 20 | bool getMargins(const char* instrument, IO2GAccountRow* account, double& mmr, double& emr, double& lmr) 21 | { return this->get_override("getMargins")();} 22 | }; 23 | 24 | void export_IO2GTradingSettingsProvider() 25 | { 26 | class_, boost::noncopyable>("IO2GTradingSettingsProvider", no_init) 27 | .def("getCondDistStopForTrade", pure_virtual(&IO2GTradingSettingsProvider::getCondDistStopForTrade)) 28 | .def("getCondDistLimitForTrade", pure_virtual(&IO2GTradingSettingsProvider::getCondDistLimitForTrade)) 29 | .def("getCondDistEntryStop", pure_virtual(&IO2GTradingSettingsProvider::getCondDistEntryStop)) 30 | .def("getCondDistEntryLimit", pure_virtual(&IO2GTradingSettingsProvider::getCondDistEntryLimit)) 31 | .def("getMinQuantity", pure_virtual(&IO2GTradingSettingsProvider::getMinQuantity)) 32 | .def("getMaxQuantity", pure_virtual(&IO2GTradingSettingsProvider::getMaxQuantity)) 33 | .def("getBaseUnitSize", pure_virtual(&IO2GTradingSettingsProvider::getBaseUnitSize)) 34 | .def("getMarketStatus", pure_virtual(&IO2GTradingSettingsProvider::getMarketStatus)) 35 | .def("getMinTrailingStep", pure_virtual(&IO2GTradingSettingsProvider::getMinTrailingStep)) 36 | .def("getMaxTrailingStep", pure_virtual(&IO2GTradingSettingsProvider::getMaxTrailingStep)) 37 | .def("getMMR", pure_virtual(&IO2GTradingSettingsProvider::getMMR)) 38 | .def("getMargins", pure_virtual(&IO2GTradingSettingsProvider::getMargins)) 39 | ; 40 | }; -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/TableListener.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Offer.h" 3 | #include "TableListener.h" 4 | 5 | TableListener::TableListener() 6 | { 7 | mRefCount = 1; 8 | mInstrument = ""; 9 | mOffers = new OfferCollection(); 10 | std::cout.precision(2); 11 | } 12 | 13 | TableListener::~TableListener(void) 14 | { 15 | delete mOffers; 16 | } 17 | 18 | long TableListener::addRef() 19 | { 20 | return InterlockedIncrement(&mRefCount); 21 | } 22 | 23 | long TableListener::release() 24 | { 25 | InterlockedDecrement(&mRefCount); 26 | if (mRefCount == 0) 27 | delete this; 28 | return mRefCount; 29 | } 30 | 31 | void TableListener::setInstrument(const char *sInstrument) 32 | { 33 | mInstrument = sInstrument; 34 | } 35 | 36 | void TableListener::onAdded(const char *rowID, IO2GRow *row) 37 | { 38 | } 39 | 40 | void TableListener::onChanged(const char *rowID, IO2GRow *row) 41 | { 42 | if (row->getTableType() == Offers) 43 | { 44 | printOffer((IO2GOfferTableRow *)row, mInstrument.c_str()); 45 | } 46 | } 47 | 48 | void TableListener::onDeleted(const char *rowID, IO2GRow *row) 49 | { 50 | } 51 | 52 | void TableListener::onStatusChanged(O2GTableStatus status) 53 | { 54 | } 55 | 56 | void TableListener::printOffers(IO2GOffersTable *offersTable, const char *sInstrument) 57 | { 58 | IO2GOfferTableRow *offerRow = NULL; 59 | IO2GTableIterator iterator; 60 | while (offersTable->getNextRow(iterator, offerRow)) 61 | { 62 | printOffer(offerRow, sInstrument); 63 | offerRow->release(); 64 | } 65 | } 66 | 67 | void TableListener::printOffer(IO2GOfferTableRow *offerRow, const char *sInstrument) 68 | { 69 | Offer *offer = mOffers->findOffer(offerRow->getOfferID()); 70 | if (offer) 71 | { 72 | if (offerRow->isTimeValid() && offerRow->isBidValid() && offerRow->isAskValid()) 73 | { 74 | offer->setDate(offerRow->getTime()); 75 | offer->setBid(offerRow->getBid()); 76 | offer->setAsk(offerRow->getAsk()); 77 | } 78 | } 79 | else 80 | { 81 | offer = new Offer(offerRow->getOfferID(), offerRow->getInstrument(), 82 | offerRow->getDigits(), offerRow->getPointSize(), offerRow->getTime(), 83 | offerRow->getBid(), offerRow->getAsk()); 84 | mOffers->addOffer(offer); 85 | } 86 | if (!sInstrument || strlen(sInstrument) == 0 || strcmp(offerRow->getInstrument(), sInstrument) == 0) 87 | { 88 | std::cout << offer->getID() << ", " << offer->getInstrument() << ", " 89 | << "Bid=" << std::fixed << offer->getBid() << ", " 90 | << "Ask=" << std::fixed << offer->getAsk() << std::endl; 91 | } 92 | } 93 | 94 | void TableListener::subscribeEvents(IO2GTableManager *manager) 95 | { 96 | O2G2Ptr offersTable = (IO2GOffersTable *)manager->getTable(Offers); 97 | 98 | offersTable->subscribeUpdate(Update, this); 99 | } 100 | 101 | void TableListener::unsubscribeEvents(IO2GTableManager *manager) 102 | { 103 | O2G2Ptr offersTable = (IO2GOffersTable *)manager->getTable(Offers); 104 | 105 | offersTable->unsubscribeUpdate(Update, this); 106 | } 107 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GMarketDataSnapshotResponseReader.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | using namespace boost::python; 5 | 6 | class IO2GMarketDataSnapshotResponseReaderWrap : public IO2GMarketDataSnapshotResponseReader, public wrapper < IO2GMarketDataSnapshotResponseReader > 7 | { 8 | public: 9 | bool isBar() { return this->get_override("isBar")(); } 10 | int size() { return this->get_override("size")(); } 11 | DATE getDate(int) { return this->get_override("getDate")(); } 12 | double getBid(int) { return this->get_override("getBid")(); } 13 | double getAsk(int) { return this->get_override("getAsk")(); } 14 | double getBidOpen(int) { return this->get_override("getBidOpen")(); } 15 | double getBidHigh(int) { return this->get_override("getBidHigh")(); } 16 | double getBidLow(int) { return this->get_override("getBidLow")(); } 17 | double getBidClose(int) { return this->get_override("getBidClose")(); } 18 | double getAskOpen(int) { return this->get_override("getAskOpen")(); } 19 | double getAskHigh(int) { return this->get_override("getAskHigh")(); } 20 | double getAskLow(int) { return this->get_override("getAskLow")(); } 21 | double getAskClose(int) { return this->get_override("getAskClose")(); } 22 | int getVolume(int) { return this->get_override("getVolume")(); } 23 | int getLastBarVolume() { return this->get_override("getLastBarVolume")(); } 24 | DATE getLastBarTime() { return this->get_override("getLastBarTime")(); } 25 | }; 26 | 27 | void export_IO2GMarketDataSnapshotResponseReader() 28 | { 29 | class_, boost::noncopyable>("IO2GMarketDataSnapshotResponseReader", no_init) 30 | .def("isBar", pure_virtual(&IO2GMarketDataSnapshotResponseReader::isBar)) 31 | .def("size", pure_virtual(&IO2GMarketDataSnapshotResponseReader::size)) 32 | .def("getDate", pure_virtual(&IO2GMarketDataSnapshotResponseReader::getDate)) 33 | .def("getBid", pure_virtual(&IO2GMarketDataSnapshotResponseReader::getBid)) 34 | .def("getAsk", pure_virtual(&IO2GMarketDataSnapshotResponseReader::getAsk)) 35 | .def("getBidOpen", pure_virtual(&IO2GMarketDataSnapshotResponseReader::getBidOpen)) 36 | .def("getBidHigh", pure_virtual(&IO2GMarketDataSnapshotResponseReader::getBidHigh)) 37 | .def("getBidLow", pure_virtual(&IO2GMarketDataSnapshotResponseReader::getBidLow)) 38 | .def("getBidClose", pure_virtual(&IO2GMarketDataSnapshotResponseReader::getBidClose)) 39 | .def("getAskOpen", pure_virtual(&IO2GMarketDataSnapshotResponseReader::getAskOpen)) 40 | .def("getAskHigh", pure_virtual(&IO2GMarketDataSnapshotResponseReader::getAskHigh)) 41 | .def("getAskLow", pure_virtual(&IO2GMarketDataSnapshotResponseReader::getAskLow)) 42 | .def("getAskClose", pure_virtual(&IO2GMarketDataSnapshotResponseReader::getAskClose)) 43 | .def("getVolume", pure_virtual(&IO2GMarketDataSnapshotResponseReader::getVolume)) 44 | .def("getLastBarVolume", pure_virtual(&IO2GMarketDataSnapshotResponseReader::getLastBarVolume)) 45 | .def("getLastBarTime", pure_virtual(&IO2GMarketDataSnapshotResponseReader::getLastBarTime)) 46 | ; 47 | } -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/AccountsColumnsEnum.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | using namespace boost::python; 5 | 6 | void export_AccountsColumnsEnum(){ 7 | object obj_AccountColumnsEnum 8 | = class_("AccountColumnsEnum", "Account columns enumeration", init<>()); 9 | { 10 | scope in_AccountColumnsEnum(obj_AccountColumnsEnum); 11 | enum_("Columns") 12 | .value("AccountID", AccountColumnsEnum::AccountID) 13 | .value("AccountName", AccountColumnsEnum::AccountName) 14 | .value("AccountKind", AccountColumnsEnum::AccountKind) 15 | .value("Balance", AccountColumnsEnum::Balance) 16 | .value("NonTradeEquity", AccountColumnsEnum::NonTradeEquity) 17 | .value("M2MEquity", AccountColumnsEnum::M2MEquity) 18 | .value("UsedMargin", AccountColumnsEnum::UsedMargin) 19 | .value("UsedMargin3", AccountColumnsEnum::UsedMargin3) 20 | .value("MarginCallFlag", AccountColumnsEnum::MarginCallFlag) 21 | .value("LastMarginCallDate", AccountColumnsEnum::LastMarginCallDate) 22 | .value("MaintenanceType", AccountColumnsEnum::MaintenanceType) 23 | .value("AmountLimit", AccountColumnsEnum::AmountLimit) 24 | .value("BaseUnitSize", AccountColumnsEnum::BaseUnitSize) 25 | .value("MaintenanceFlag", AccountColumnsEnum::MaintenanceFlag) 26 | .value("ManagerAccountID", AccountColumnsEnum::ManagerAccountID) 27 | .value("LeverageProfileID", AccountColumnsEnum::LeverageProfileID) 28 | .export_values() 29 | ; 30 | }; 31 | 32 | object obj_AccountTableColumnsEnum 33 | = class_("AccountTableColumnsEnum", "Account table columns enumeratrion", init<>()); 34 | { 35 | scope in_AccountTableColumnsEnum(obj_AccountTableColumnsEnum); 36 | enum_("Columns") 37 | .value("AccountID", AccountTableColumnsEnum::AccountID) 38 | .value("AccountName", AccountTableColumnsEnum::AccountName) 39 | .value("AccountKind", AccountTableColumnsEnum::AccountKind) 40 | .value("Balance", AccountTableColumnsEnum::Balance) 41 | .value("NonTradeEquity", AccountTableColumnsEnum::NonTradeEquity) 42 | .value("M2MEquity", AccountTableColumnsEnum::M2MEquity) 43 | .value("UsedMargin", AccountTableColumnsEnum::UsedMargin) 44 | .value("UsedMargin3", AccountTableColumnsEnum::UsedMargin3) 45 | .value("MarginCallFlag", AccountTableColumnsEnum::MarginCallFlag) 46 | .value("LastMarginCallDate", AccountTableColumnsEnum::LastMarginCallDate) 47 | .value("MaintenanceType", AccountTableColumnsEnum::MaintenanceType) 48 | .value("AmountLimit", AccountTableColumnsEnum::AmountLimit) 49 | .value("BaseUnitSize", AccountTableColumnsEnum::BaseUnitSize) 50 | .value("MaintenanceFlag", AccountTableColumnsEnum::MaintenanceFlag) 51 | .value("ManagerAccountID", AccountTableColumnsEnum::ManagerAccountID) 52 | .value("LeverageProfileID", AccountTableColumnsEnum::LeverageProfileID) 53 | .value("Equity", AccountTableColumnsEnum::Equity) 54 | .value("DayPL", AccountTableColumnsEnum::DayPL) 55 | .value("UsableMargin", AccountTableColumnsEnum::UsableMargin) 56 | .value("GrossPL", AccountTableColumnsEnum::GrossPL) 57 | .export_values() 58 | ; 59 | } 60 | } -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/Offer.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | #include 4 | #include 5 | #include "Offer.h" 6 | 7 | /** Constructor. */ 8 | Offer::Offer(const char *id, const char *instrument, int precision, double pipsize, DATE date, double bid, double ask) 9 | { 10 | mID = id; 11 | mInstrument = instrument; 12 | mPrecision = precision; 13 | mPipSize = pipsize; 14 | mDate = date; 15 | mBid = bid; 16 | mAsk = ask; 17 | } 18 | 19 | /** Update bid. */ 20 | void Offer::setBid(double bid) 21 | { 22 | mBid = bid; 23 | } 24 | 25 | /** Update ask. */ 26 | void Offer::setAsk(double ask) 27 | { 28 | mAsk = ask; 29 | } 30 | 31 | /** Update date. */ 32 | void Offer::setDate(DATE date) 33 | { 34 | mDate = date; 35 | } 36 | 37 | /** Get id. */ 38 | const char *Offer::getID() const 39 | { 40 | return mID.c_str(); 41 | } 42 | 43 | /** Get instrument. */ 44 | const char *Offer::getInstrument() const 45 | { 46 | return mInstrument.c_str(); 47 | } 48 | 49 | /** Get precision. */ 50 | int Offer::getPrecision() const 51 | { 52 | return mPrecision; 53 | } 54 | 55 | /** Get pipsize. */ 56 | double Offer::getPipSize() const 57 | { 58 | return mPipSize; 59 | } 60 | 61 | /** Get bid. */ 62 | double Offer::getBid() const 63 | { 64 | return mBid; 65 | } 66 | 67 | /** Get ask. */ 68 | double Offer::getAsk() const 69 | { 70 | return mAsk; 71 | } 72 | 73 | /** Get date. */ 74 | DATE Offer::getDate() const 75 | { 76 | return mDate; 77 | } 78 | 79 | 80 | /** Constructor. */ 81 | OfferCollection::OfferCollection() 82 | { 83 | } 84 | 85 | /** Destructor. */ 86 | OfferCollection::~OfferCollection() 87 | { 88 | clear(); 89 | } 90 | 91 | /** Add offer to collection. */ 92 | void OfferCollection::addOffer(Offer *offer) 93 | { 94 | sample_tools::Mutex::Lock l(m_Mutex); 95 | std::map::const_iterator iter = mIndex.find(offer->getID()); 96 | if (iter != mIndex.end()) 97 | { 98 | for (int i = 0; i < (int)mOffers.size(); i++) 99 | { 100 | if (mOffers[i] == offer) 101 | { 102 | delete mOffers[i]; 103 | mOffers.erase(mOffers.begin() + i); 104 | break; 105 | } 106 | } 107 | } 108 | mOffers.push_back(offer); 109 | mIndex[offer->getID()] = offer; 110 | } 111 | 112 | /** Find offer by id. */ 113 | Offer *OfferCollection::findOffer(const char *id) const 114 | { 115 | sample_tools::Mutex::Lock l(m_Mutex); 116 | std::map::const_iterator iter = mIndex.find(id); 117 | if (iter == mIndex.end()) 118 | return 0; 119 | else 120 | return iter->second; 121 | } 122 | 123 | /** Get number of offers. */ 124 | int OfferCollection::size() const 125 | { 126 | sample_tools::Mutex::Lock l(m_Mutex); 127 | return (int)mOffers.size(); 128 | } 129 | 130 | /** Get offer by index. */ 131 | Offer *OfferCollection::get(int index) const 132 | { 133 | sample_tools::Mutex::Lock l(m_Mutex); 134 | return mOffers[index]; 135 | } 136 | 137 | void OfferCollection::clear() 138 | { 139 | sample_tools::Mutex::Lock l(m_Mutex); 140 | int i; 141 | for (i = 0; i < (int)mOffers.size(); ++i) 142 | delete mOffers[i]; 143 | mOffers.clear(); 144 | mIndex.clear(); 145 | } 146 | 147 | -------------------------------------------------------------------------------- /src/ForexConnectClient/fx.market.watcher/dialogs/order.py: -------------------------------------------------------------------------------- 1 | from Tkinter import * 2 | import tkMessageBox 3 | import os 4 | 5 | class OrderDialog(Toplevel): 6 | 7 | def __init__(self, parent, title=None): 8 | Toplevel.__init__(self, parent) 9 | self.transient(parent) 10 | if title: 11 | self.title(title) 12 | 13 | self.parent = parent 14 | self.result = None 15 | body = Frame(self) 16 | self.initial_focus = self.body(body) 17 | body.pack(padx=5, pady=5) 18 | self.buttonbox() 19 | self.grab_set() 20 | if not self.initial_focus: 21 | self.initial_focus = self 22 | 23 | self.protocol("WM_DELETE_WINDOW", self.cancel) 24 | self.geometry("+%d+%d" % (parent.winfo_rootx() + 50, 25 | parent.winfo_rooty() + 50)) 26 | self.initial_focus.focus_set() 27 | self.wait_window(self) 28 | 29 | def body(self, master): 30 | pass 31 | 32 | def buttonbox(self): 33 | box = Frame(self) 34 | w = Button(box, text="OK", width=10, command=self.ok, default=ACTIVE) 35 | w.pack(side=LEFT, padx=5, pady=5) 36 | w = Button(box, text="Cancel", width=10, command=self.cancel) 37 | w.pack(side=LEFT, padx=5, pady=5) 38 | self.bind("", self.ok) 39 | self.bind("", self.cancel) 40 | box.pack() 41 | 42 | def ok(self, event=None): 43 | 44 | if not self.validate(): 45 | self.initial_focus.focus_set() 46 | return 47 | self.withdraw() 48 | self.update_idletasks() 49 | self.apply() 50 | self.cancel() 51 | 52 | def cancel(self, event=None): 53 | self.parent.focus_set() 54 | self.destroy() 55 | 56 | def validate(self): 57 | return 1 58 | 59 | def apply(self): 60 | pass 61 | 62 | class OpenPosition(OrderDialog): 63 | """description of class""" 64 | def __init__(self, parent, order=None, title=None): 65 | OrderDialog.__init__(self, parent, title) 66 | self.order = order 67 | 68 | def body(self, master): 69 | Label(master, text="Pair:").grid(row=0, sticky=W) 70 | Label(master, text="Amount:").grid(row=1, sticky=W) 71 | Label(master, text="Take Profit:").grid(row=2, sticky=W) 72 | Label(master, text="Stop Loss:").grid(row=3, sticky=W) 73 | 74 | self.e1 = Entry(master) 75 | self.e2 = Entry(master) 76 | self.e1.grid(row=0, column=1) 77 | self.e2.grid(row=1, column=1) 78 | self.tp = Entry(master) 79 | self.tp.grid(row=2, column=1) 80 | self.sl = Entry(master) 81 | self.sl.grid(row=3, column=1) 82 | 83 | def apply(self): 84 | try: 85 | pair = self.e1.get() 86 | amount = int(self.e2.get()) 87 | tp = float(self.tp.get()) 88 | sl = float(self.sl.get()) 89 | self.result = {'pair': pair, 'amount': amount, 'tp': tp, 'sl': sl } 90 | except ValueError: 91 | tkMessageBox.showwarning("Bad input","Illegal values, please try again") 92 | 93 | class ClosePosition(OrderDialog): 94 | """description of class""" 95 | pass 96 | 97 | 98 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/OffersColumnsEnum.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | void export_OffersColumnsEnum() 5 | { 6 | using namespace boost::python; 7 | 8 | object obj_OfferColumnsEnum 9 | = class_("OfferColumnsEnum", "Offer columns enumeration", init<>()); 10 | { 11 | scope obj_OfferColumnsEnum; 12 | enum_("OfferColumnsEnum") 13 | .value("OfferID", OfferColumnsEnum::OfferID) 14 | .value("Instrument", OfferColumnsEnum::Instrument) 15 | .value("QuoteID", OfferColumnsEnum::QuoteID) 16 | .value("Bid", OfferColumnsEnum::Bid) 17 | .value("Ask", OfferColumnsEnum::Ask) 18 | .value("Low", OfferColumnsEnum::Low) 19 | .value("High", OfferColumnsEnum::High) 20 | .value("Volume", OfferColumnsEnum::Volume) 21 | .value("Time", OfferColumnsEnum::Time) 22 | .value("BidTradable", OfferColumnsEnum::BidTradable) 23 | .value("AskTradable", OfferColumnsEnum::AskTradable) 24 | .value("SellInterest", OfferColumnsEnum::SellInterest) 25 | .value("BuyInterest", OfferColumnsEnum::BuyInterest) 26 | .value("ContractCurrency", OfferColumnsEnum::ContractCurrency) 27 | .value("Digits", OfferColumnsEnum::Digits) 28 | .value("PointSize", OfferColumnsEnum::PointSize) 29 | .value("SubscriptionStatus", OfferColumnsEnum::SubscriptionStatus) 30 | .value("InstrumentType", OfferColumnsEnum::InstrumentType) 31 | .value("ContractMultiplier", OfferColumnsEnum::ContractMultiplier) 32 | .value("TradingStatus", OfferColumnsEnum::TradingStatus) 33 | .value("ValueDate", OfferColumnsEnum::ValueDate) 34 | .export_values() 35 | ; 36 | } 37 | 38 | object obj_OfferTableColumnsEnum 39 | = class_("OfferTableColumnsEnum", "Offer table columns enumeration", init<>()); 40 | { 41 | scope obj_OfferTableColumnsEnum; 42 | enum_("OfferTableColumnsEnum") 43 | .value("OfferID", OfferTableColumnsEnum::OfferID) 44 | .value("Instrument", OfferTableColumnsEnum::Instrument) 45 | .value("QuoteID", OfferTableColumnsEnum::QuoteID) 46 | .value("Bid", OfferTableColumnsEnum::Bid) 47 | .value("Ask", OfferTableColumnsEnum::Ask) 48 | .value("Low", OfferTableColumnsEnum::Low) 49 | .value("High", OfferTableColumnsEnum::High) 50 | .value("Volume", OfferTableColumnsEnum::Volume) 51 | .value("Time", OfferTableColumnsEnum::Time) 52 | .value("BidTradable", OfferTableColumnsEnum::BidTradable) 53 | .value("AskTradable", OfferTableColumnsEnum::AskTradable) 54 | .value("SellInterest", OfferTableColumnsEnum::SellInterest) 55 | .value("BuyInterest", OfferTableColumnsEnum::BuyInterest) 56 | .value("ContractCurrency", OfferTableColumnsEnum::ContractCurrency) 57 | .value("Digits", OfferTableColumnsEnum::Digits) 58 | .value("PointSize", OfferTableColumnsEnum::PointSize) 59 | .value("SubscriptionStatus", OfferTableColumnsEnum::SubscriptionStatus) 60 | .value("InstrumentType", OfferTableColumnsEnum::InstrumentType) 61 | .value("ContractMultiplier", OfferTableColumnsEnum::ContractMultiplier) 62 | .value("TradingStatus", OfferTableColumnsEnum::TradingStatus) 63 | .value("ValueDate", OfferTableColumnsEnum::ValueDate) 64 | .value("PipCost", OfferTableColumnsEnum::PipCost) 65 | .export_values() 66 | ; 67 | } 68 | } -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/TradesColumnsEnum.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | 5 | void export_TradesColumnsEnum() 6 | { 7 | using namespace boost::python; 8 | 9 | object obj_TradeColumnsEnum = 10 | class_ ("TradeColumnsEnum", "Trade columns enumeration", init<>()); 11 | 12 | { 13 | scope in_TradeColumnsEnum(obj_TradeColumnsEnum); 14 | enum_ 15 | ("Columns") 16 | .value("TradeID", TradeColumnsEnum::TradeID) 17 | .value("AccountID", TradeColumnsEnum::AccountID) 18 | .value("AccountName", TradeColumnsEnum::AccountName) 19 | .value("AccountKind", TradeColumnsEnum::AccountKind) 20 | .value("OfferID", TradeColumnsEnum::OfferID) 21 | .value("Amount", TradeColumnsEnum::Amount) 22 | .value("BuySell", TradeColumnsEnum::BuySell) 23 | .value("OpenRate", TradeColumnsEnum::OpenRate) 24 | .value("OpenTime", TradeColumnsEnum::OpenTime) 25 | .value("OpenQuoteID", TradeColumnsEnum::OpenQuoteID) 26 | .value("OpenOrderID", TradeColumnsEnum::OpenOrderID) 27 | .value("OpenOrderReqID", TradeColumnsEnum::OpenOrderReqID) 28 | .value("OpenOrderRequestTXT", TradeColumnsEnum::OpenOrderRequestTXT) 29 | .value("Commission", TradeColumnsEnum::Commission) 30 | .value("RolloverInterest", TradeColumnsEnum::RolloverInterest) 31 | .value("TradeIDOrigin", TradeColumnsEnum::TradeIDOrigin) 32 | .value("UsedMargin", TradeColumnsEnum::UsedMargin) 33 | .value("ValueDate", TradeColumnsEnum::ValueDate) 34 | .value("Parties", TradeColumnsEnum::Parties) 35 | .export_values() 36 | ; 37 | } 38 | 39 | object obj_TradeTableColumnsEnum = 40 | class_("TradeTableColumnsEnum", "TradeTableColumnsEnum", init<>()); 41 | 42 | { 43 | scope in_TradeTableColumnsEnum(obj_TradeTableColumnsEnum); 44 | enum_ 45 | ("Columns") 46 | .value("TradeID", TradeTableColumnsEnum::TradeID) 47 | .value("AccountID", TradeTableColumnsEnum::AccountID) 48 | .value("AccountName", TradeTableColumnsEnum::AccountName) 49 | .value("AccountKind", TradeTableColumnsEnum::AccountKind) 50 | .value("OfferID", TradeTableColumnsEnum::OfferID) 51 | .value("Amount", TradeTableColumnsEnum::Amount) 52 | .value("BuySell", TradeTableColumnsEnum::BuySell) 53 | .value("OpenRate", TradeTableColumnsEnum::OpenRate) 54 | .value("OpenTime", TradeTableColumnsEnum::OpenTime) 55 | .value("OpenQuoteID", TradeTableColumnsEnum::OpenQuoteID) 56 | .value("OpenOrderID", TradeTableColumnsEnum::OpenOrderID) 57 | .value("OpenOrderReqID", TradeTableColumnsEnum::OpenOrderReqID) 58 | .value("OpenOrderRequestTXT", TradeTableColumnsEnum::OpenOrderRequestTXT) 59 | .value("Commission", TradeTableColumnsEnum::Commission) 60 | .value("RolloverInterest", TradeTableColumnsEnum::RolloverInterest) 61 | .value("TradeIDOrigin", TradeTableColumnsEnum::TradeIDOrigin) 62 | .value("UsedMargin", TradeTableColumnsEnum::UsedMargin) 63 | .value("ValueDate", TradeTableColumnsEnum::ValueDate) 64 | .value("Parties", TradeTableColumnsEnum::Parties) 65 | .value("PL", TradeTableColumnsEnum::PL) 66 | .value("GrossPL", TradeTableColumnsEnum::GrossPL) 67 | .value("Close", TradeTableColumnsEnum::Close) 68 | .value("Stop", TradeTableColumnsEnum::Stop) 69 | .value("Limit", TradeTableColumnsEnum::Limit) 70 | .export_values() 71 | ; 72 | } 73 | }; -------------------------------------------------------------------------------- /src/ForexConnectClient/fx.console/listeners/sessionstatus.py: -------------------------------------------------------------------------------- 1 | import forexconnect as fx 2 | from win32api import CloseHandle 3 | from win32event import CreateEvent, SetEvent, WaitForSingleObject, WAIT_OBJECT_0 4 | from listeners import Counter 5 | 6 | class SessionStatusListener(fx.SessionStatusListener): 7 | def __init__(self, session): 8 | super(SessionStatusListener, self). __init__() 9 | self.reset() 10 | self.sessionId = "" 11 | self.pin = "" 12 | self.refcount = Counter(1) 13 | self.status = fx.IO2GSessionStatus.Disconnected 14 | self.session = session 15 | self.session.addRef() 16 | self.event = CreateEvent(None, 0, 0, None); 17 | 18 | def __del__(self): 19 | self.session.release() 20 | CloseHandle(self.event) 21 | 22 | def get_status(self): 23 | return self._status 24 | 25 | def set_status(self, value): 26 | self._status = value 27 | 28 | status = property(get_status, set_status) 29 | 30 | def addRef(self): 31 | self.refcount.increment() 32 | ref = self.refcount.value 33 | return ref 34 | 35 | def release(self): 36 | self.refcount.decrement() 37 | ref = self.refcount.value 38 | if self.refcount.value == 0: 39 | del self 40 | return ref 41 | 42 | def printStatus(self): 43 | print self.status 44 | 45 | def onSessionStatusChanged(self, status): 46 | print status 47 | self.status = status 48 | if self.status == fx.IO2GSessionStatus.Disconnected: 49 | self.connected = False 50 | SetEvent(self.event) 51 | elif self.status == fx.IO2GSessionStatus.Connecting: 52 | pass 53 | elif self.status == fx.IO2GSessionStatus.TradingSessionRequested: 54 | descriptors = session.getTradingSessionDescriptors(); 55 | found = False 56 | if descriptors is not None: 57 | for i in range(descriptors.size()): 58 | desc = descriptors.get(i) 59 | print " id:='", desc.getID(), "' name='", desc.getName(), "' description='", desc.getDescription(), "'" 60 | if self.sessionId == desc.getID: 61 | found = True 62 | break 63 | 64 | if found: 65 | session.setTradingSession(self.sessionId, self.pin) 66 | pass 67 | else: 68 | pass 69 | elif self.status == fx.IO2GSessionStatus.Connected: 70 | self.connected = True 71 | SetEvent(self.event) 72 | elif self.status == fx.IO2GSessionStatus.Reconnecting: 73 | pass 74 | elif self.status == fx.IO2GSessionStatus.Disconnecting: 75 | pass 76 | elif self.status == fx.IO2GSessionStatus.SessionLost: 77 | pass 78 | 79 | def onLoginFailed(self, error): 80 | print "Login error %s" % (error) 81 | self.error = True 82 | 83 | def reset(self): 84 | self.connected = False 85 | self.error = False 86 | 87 | def hasError(self): 88 | return self.error 89 | 90 | def waitEvents(self): 91 | return (WaitForSingleObject(self.event, 30000) == WAIT_OBJECT_0) 92 | 93 | def isConnected(self): 94 | return self.connected -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/ResponseListener.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include "ResponseListener.h" 8 | 9 | ResponseListener::ResponseListener(IO2GSession *session) 10 | { 11 | mSession = session; 12 | mSession->addRef(); 13 | mRefCount = 1; 14 | mResponseEvent = CreateEvent(0, FALSE, FALSE, 0); 15 | mRequestID = ""; 16 | mResponse = NULL; 17 | std::cout.precision(2); 18 | } 19 | 20 | ResponseListener::~ResponseListener() 21 | { 22 | if (mResponse) 23 | mResponse->release(); 24 | mSession->release(); 25 | CloseHandle(mResponseEvent); 26 | } 27 | 28 | /** Increase reference counter. */ 29 | long ResponseListener::addRef() 30 | { 31 | return InterlockedIncrement(&mRefCount); 32 | } 33 | 34 | /** Decrease reference counter. */ 35 | long ResponseListener::release() 36 | { 37 | long rc = InterlockedDecrement(&mRefCount); 38 | if (rc == 0) 39 | delete this; 40 | return rc; 41 | } 42 | 43 | /** Set request. */ 44 | void ResponseListener::setRequestID(const char *sRequestID) 45 | { 46 | mRequestID = sRequestID; 47 | if (mResponse) 48 | { 49 | mResponse->release(); 50 | mResponse = NULL; 51 | } 52 | ResetEvent(mResponseEvent); 53 | } 54 | 55 | bool ResponseListener::waitEvents() 56 | { 57 | return WaitForSingleObject(mResponseEvent, _TIMEOUT) == 0; 58 | } 59 | 60 | /** Gets response.*/ 61 | IO2GResponse *ResponseListener::getResponse() 62 | { 63 | if (mResponse) 64 | mResponse->addRef(); 65 | return mResponse; 66 | } 67 | 68 | /** Request execution completed data handler. */ 69 | void ResponseListener::onRequestCompleted(const char *requestId, IO2GResponse *response) 70 | { 71 | if (response && mRequestID == requestId) 72 | { 73 | mResponse = response; 74 | mResponse->addRef(); 75 | if (response->getType() != CreateOrderResponse) 76 | SetEvent(mResponseEvent); 77 | } 78 | } 79 | 80 | /** Request execution failed data handler. */ 81 | void ResponseListener::onRequestFailed(const char *requestId, const char *error) 82 | { 83 | if (mRequestID == requestId) 84 | { 85 | std::cout << "The request has been failed. ID: " << requestId << " : " << error << std::endl; 86 | SetEvent(mResponseEvent); 87 | } 88 | } 89 | 90 | /** Request update data received data handler. */ 91 | void ResponseListener::onTablesUpdates(IO2GResponse *data) 92 | { 93 | if (data) 94 | { 95 | O2G2Ptr factory = mSession->getResponseReaderFactory(); 96 | if (factory) 97 | { 98 | O2G2Ptr reader = factory->createTablesUpdatesReader(data); 99 | if (reader) 100 | { 101 | for (int i = 0; i < reader->size(); ++i) 102 | { 103 | if (reader->getUpdateTable(i) == Orders) 104 | { 105 | O2G2Ptr order = reader->getOrderRow(i); 106 | if (reader->getUpdateType(i) == Insert) 107 | { 108 | if (mRequestID == order->getRequestID()) 109 | { 110 | std::cout << "The order has been added. OrderID='" << order->getOrderID() << "', " 111 | << "Type='" << order->getType() << "', " 112 | << "BuySell='" << order->getBuySell() << "', " 113 | << "Rate='" << order->getRate() << "', " 114 | << "TimeInForce='" << order->getTimeInForce() << "'" 115 | << std::endl; 116 | SetEvent(mResponseEvent); 117 | } 118 | } 119 | } 120 | } 121 | } 122 | } 123 | } 124 | } 125 | 126 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GAccountRow.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | using namespace boost::python; 5 | 6 | class IO2GAccountRowWrap : public IO2GAccountRow, public wrapper < IO2GAccountRow > 7 | { 8 | public: 9 | const char* getAccountID(){ return this->get_override("getAccountID")();} 10 | const char* getAccountName(){ return this->get_override("getAccountName")();} 11 | const char* getAccountKind(){ return this->get_override("getAccountKind")();} 12 | double getBalance(){ return this->get_override("getBalance")();} 13 | double getNonTradeEquity(){ return this->get_override("getNonTradeEquity")();} 14 | double getM2MEquity(){ return this->get_override("getM2MEquity")();} 15 | double getUsedMargin(){ return this->get_override("getUsedMargin")();} 16 | double getUsedMargin3(){ return this->get_override("getUsedMargin3")();} 17 | const char* getMarginCallFlag(){ return this->get_override("getMarginCallFlag")();} 18 | DATE getLastMarginCallDate(){ return this->get_override("getLastMarginCallDate")();} 19 | const char* getMaintenanceType(){ return this->get_override("getMaintenanceType")();} 20 | int getAmountLimit(){ return this->get_override("getAmountLimit")();} 21 | int getBaseUnitSize(){ return this->get_override("getBaseUnitSize")();} 22 | bool getMaintenanceFlag(){ return this->get_override("getMaintenanceFlag")();} 23 | const char* getManagerAccountID(){ return this->get_override("getManagerAccountID")();} 24 | const char* getLeverageProfileID(){ return this->get_override("getLeverageProfileID")();} 25 | }; 26 | 27 | class IO2GAccountTableRowWrap : public IO2GAccountTableRow, public wrapper < IO2GAccountTableRow > 28 | { 29 | public: 30 | double getEquity(){ return this->get_override("getEquity")();} 31 | double getDayPL(){ return this->get_override("getDayPL")();} 32 | double getUsableMargin(){ return this->get_override("getUsableMargin")();} 33 | double getGrossPL(){ return this->get_override("getGrossPL")();} 34 | }; 35 | 36 | void export_IO2GAccountRow() 37 | { 38 | class_, boost::noncopyable>("IO2GAccountRow", no_init) 39 | .def("getAccountID", pure_virtual(&IO2GAccountRow::getAccountID)) 40 | .def("getAccountName", pure_virtual(&IO2GAccountRow::getAccountName)) 41 | .def("getAccountKind", pure_virtual(&IO2GAccountRow::getAccountKind)) 42 | .def("getBalance", pure_virtual(&IO2GAccountRow::getBalance)) 43 | .def("getNonTradeEquity", pure_virtual(&IO2GAccountRow::getNonTradeEquity)) 44 | .def("getM2MEquity", pure_virtual(&IO2GAccountRow::getM2MEquity)) 45 | .def("getUsedMargin", pure_virtual(&IO2GAccountRow::getUsedMargin)) 46 | .def("getUsedMargin3", pure_virtual(&IO2GAccountRow::getUsedMargin3)) 47 | .def("getMarginCallFlag", pure_virtual(&IO2GAccountRow::getMarginCallFlag)) 48 | .def("getLastMarginCallDate", pure_virtual(&IO2GAccountRow::getLastMarginCallDate)) 49 | .def("getMaintenanceType", pure_virtual(&IO2GAccountRow::getMaintenanceType)) 50 | .def("getAmountLimit", pure_virtual(&IO2GAccountRow::getAmountLimit)) 51 | .def("getBaseUnitSize", pure_virtual(&IO2GAccountRow::getBaseUnitSize)) 52 | .def("getMaintenanceFlag", pure_virtual(&IO2GAccountRow::getMaintenanceFlag)) 53 | .def("getManagerAccountID", pure_virtual(&IO2GAccountRow::getManagerAccountID)) 54 | .def("getLeverageProfileID", pure_virtual(&IO2GAccountRow::getLeverageProfileID)) 55 | ; 56 | 57 | class_, boost::noncopyable>("IO2GAccountTableRow", no_init) 58 | .def("getEquity", pure_virtual(&IO2GAccountTableRow::getEquity)) 59 | .def("getDayPL", pure_virtual(&IO2GAccountTableRow::getDayPL)) 60 | .def("getUsableMargin", pure_virtual(&IO2GAccountTableRow::getUsableMargin)) 61 | .def("getGrossPL", pure_virtual(&IO2GAccountTableRow::getGrossPL)) 62 | ; 63 | } -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/O2GEnum.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | void export_O2GEnum() 5 | { 6 | using namespace boost::python; 7 | 8 | enum_("O2GTable") 9 | .value("TableUnknown", O2GTable::TableUnknown) 10 | .value("Offers", O2GTable::Offers) 11 | .value("Accounts", O2GTable::Accounts) 12 | .value("Orders", O2GTable::Orders) 13 | .value("Trades", O2GTable::Trades) 14 | .value("ClosedTrades", O2GTable::ClosedTrades) 15 | .value("Messages", O2GTable::Messages) 16 | .value("Summary", O2GTable::Summary) 17 | .export_values() 18 | ; 19 | 20 | enum_("O2GResponseType") 21 | .value("ResponseUnknown", O2GResponseType::ResponseUnknown) 22 | .value("TablesUpdates", O2GResponseType::TablesUpdates) 23 | .value("MarketDataSnapshot", O2GResponseType::MarketDataSnapshot) 24 | .value("GetAccounts", O2GResponseType::GetAccounts) 25 | .value("GetOffers", O2GResponseType::GetOffers) 26 | .value("GetOrders", O2GResponseType::GetOrders) 27 | .value("GetTrades", O2GResponseType::GetTrades) 28 | .value("GetClosedTrades", O2GResponseType::GetClosedTrades) 29 | .value("GetMessages", O2GResponseType::GetMessages) 30 | .value("CreateOrderResponse", O2GResponseType::CreateOrderResponse) 31 | .value("GetSystemProperties", O2GResponseType::GetSystemProperties) 32 | .value("CommandResponse", O2GResponseType::CommandResponse) 33 | .value("MarginRequirementsResponse", O2GResponseType::MarginRequirementsResponse) 34 | .value("GetLastOrderUpdate", O2GResponseType::GetLastOrderUpdate) 35 | .value("MarketData", O2GResponseType::MarketData) 36 | .export_values() 37 | ; 38 | 39 | enum_("O2GTableUpdateType") 40 | .value("UpdateUnknown", O2GTableUpdateType::UpdateUnknown) 41 | .value("Insert", O2GTableUpdateType::Insert) 42 | .value("Update", O2GTableUpdateType::Update) 43 | .value("Delete", O2GTableUpdateType::Delete) 44 | .export_values() 45 | ; 46 | 47 | enum_("O2GPermissionStatus") 48 | .value("PermissionDisabled", O2GPermissionStatus::PermissionDisabled) 49 | .value("PermissionEnabled", O2GPermissionStatus::PermissionEnabled) 50 | .value("PermissionHidden ", O2GPermissionStatus::PermissionHidden) 51 | .export_values() 52 | ; 53 | 54 | enum_("O2GMarketStatus") 55 | .value("MarketStatusOpen", O2GMarketStatus::MarketStatusOpen) 56 | .value("MarketStatusClosed", O2GMarketStatus::MarketStatusClosed) 57 | .value("MarketStatusUndefined", O2GMarketStatus::MarketStatusUndefined) 58 | .export_values() 59 | ; 60 | 61 | enum_("O2GPriceUpdateMode") 62 | .value("Default", O2GPriceUpdateMode::Default) 63 | .value("NoPrice", O2GPriceUpdateMode::NoPrice) 64 | .export_values() 65 | ; 66 | 67 | enum_("O2GTableManagerMode") 68 | .value("No", O2GTableManagerMode::No) 69 | .value("Yes", O2GTableManagerMode::Yes) 70 | .export_values() 71 | ; 72 | 73 | enum_("O2GTableStatus") 74 | .value("Initial", O2GTableStatus::Initial) 75 | .value("Refreshing", O2GTableStatus::Refreshing) 76 | .value("Refreshed", O2GTableStatus::Refreshed) 77 | .value("Failed", O2GTableStatus::Failed) 78 | .export_values() 79 | ; 80 | 81 | enum_("O2GReportUrlError") 82 | .value("ReportUrlNotSupported", O2GReportUrlError::ReportUrlNotSupported) 83 | .value("ReportUrlTooSmallBuffer", O2GReportUrlError::ReportUrlTooSmallBuffer) 84 | .value("ReportUrlNotLogged", O2GReportUrlError::ReportUrlNotLogged) 85 | .export_values() 86 | ; 87 | 88 | enum_("O2GTableManagerStatus") 89 | .value("TablesLoading", O2GTableManagerStatus::TablesLoading) 90 | .value("TablesLoaded", O2GTableManagerStatus::TablesLoaded) 91 | .value("TablesLoadFailed", O2GTableManagerStatus::TablesLoadFailed) 92 | .export_values() 93 | ; 94 | } -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/SessionStatusListener.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | /*#include 3 | #include "SessionStatusListener.h" 4 | SessionStatusListener::SessionStatusListener(IO2GSession *session, bool printSubsessions, const char *sessionID, const char *pin) 5 | { 6 | if (sessionID != 0) 7 | mSessionID = sessionID; 8 | else 9 | mSessionID = ""; 10 | if (pin != 0) 11 | mPin = pin; 12 | else 13 | mPin = ""; 14 | mSession = session; 15 | mSession->addRef(); 16 | reset(); 17 | mPrintSubsessions = printSubsessions; 18 | mRefCount = 1; 19 | mSessionEvent = CreateEvent(0, FALSE, FALSE, 0); 20 | } 21 | 22 | SessionStatusListener::~SessionStatusListener() 23 | { 24 | mSession->release(); 25 | mSessionID.clear(); 26 | mPin.clear(); 27 | CloseHandle(mSessionEvent); 28 | } 29 | 30 | long SessionStatusListener::addRef() 31 | { 32 | return InterlockedIncrement(&mRefCount); 33 | } 34 | 35 | long SessionStatusListener::release() 36 | { 37 | long rc = InterlockedDecrement(&mRefCount); 38 | if (rc == 0) 39 | delete this; 40 | return rc; 41 | } 42 | 43 | void SessionStatusListener::reset() 44 | { 45 | std::cout << "reset" << std::endl; 46 | mConnected = false; 47 | mDisconnected = false; 48 | mError = false; 49 | } 50 | 51 | void SessionStatusListener::onLoginFailed(const char *error) 52 | { 53 | std::cout << "Login error: " << error << std::endl; 54 | mError = true; 55 | SetEvent(mSessionEvent); 56 | } 57 | 58 | void SessionStatusListener::onSessionStatusChanged(IO2GSessionStatus::O2GSessionStatus status) 59 | { 60 | switch (status) 61 | { 62 | case IO2GSessionStatus::Disconnected: 63 | std::cout << "status::disconnected" << std::endl; 64 | mConnected = false; 65 | mDisconnected = true; 66 | SetEvent(mSessionEvent); 67 | break; 68 | case IO2GSessionStatus::Connecting: 69 | std::cout << "status::connecting" << std::endl; 70 | break; 71 | case IO2GSessionStatus::TradingSessionRequested: 72 | { 73 | std::cout << "status::trading session requested" << std::endl; 74 | O2G2Ptr descriptors = mSession->getTradingSessionDescriptors(); 75 | bool found = false; 76 | if (descriptors) 77 | { 78 | if (mPrintSubsessions) 79 | std::cout << "descriptors available:" << std::endl; 80 | for (int i = 0; i < descriptors->size(); ++i) 81 | { 82 | O2G2Ptr descriptor = descriptors->get(i); 83 | if (mPrintSubsessions) 84 | std::cout << " id:='" << descriptor->getID() 85 | << "' name='" << descriptor->getName() 86 | << "' description='" << descriptor->getDescription() 87 | << "' " << (descriptor->requiresPin() ? "requires pin" : "") << std::endl; 88 | if (mSessionID == descriptor->getID()) 89 | { 90 | found = true; 91 | break; 92 | } 93 | } 94 | } 95 | if (!found) 96 | { 97 | onLoginFailed("The specified sub session identifier is not found"); 98 | } 99 | else 100 | { 101 | mSession->setTradingSession(mSessionID.c_str(), mPin.c_str()); 102 | } 103 | } 104 | break; 105 | case IO2GSessionStatus::Connected: 106 | std::cout << "status::connected" << std::endl; 107 | mConnected = true; 108 | mDisconnected = false; 109 | SetEvent(mSessionEvent); 110 | break; 111 | case IO2GSessionStatus::Reconnecting: 112 | std::cout << "status::reconnecting" << std::endl; 113 | break; 114 | case IO2GSessionStatus::Disconnecting: 115 | std::cout << "status::disconnecting" << std::endl; 116 | break; 117 | case IO2GSessionStatus::SessionLost: 118 | std::cout << "status::session lost" << std::endl; 119 | break; 120 | } 121 | } 122 | 123 | bool SessionStatusListener::hasError() const 124 | { 125 | return mError; 126 | } 127 | 128 | bool SessionStatusListener::isConnected() const 129 | { 130 | return mConnected; 131 | } 132 | 133 | bool SessionStatusListener::isDisconnected() const 134 | { 135 | return mDisconnected; 136 | } 137 | 138 | bool SessionStatusListener::waitEvents() 139 | { 140 | return WaitForSingleObject(mSessionEvent, _TIMEOUT) == 0; 141 | }*/ -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GTradeRow.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | using namespace boost::python; 4 | 5 | class IO2GTradeRowWrap : public IO2GTradeRow, public wrapper < IO2GTradeRow > 6 | { 7 | public: 8 | const char* getTradeID(){ return this->get_override("getTradeID")();} 9 | const char* getAccountID(){ return this->get_override("getAccountID")();} 10 | const char* getAccountName(){ return this->get_override("getAccountName")();} 11 | const char* getAccountKind(){ return this->get_override("getAccountKind")();} 12 | const char* getOfferID(){ return this->get_override("getOfferID")();} 13 | int getAmount(){ return this->get_override("getAmount")();} 14 | const char* getBuySell(){ return this->get_override("getBuySell")();} 15 | double getOpenRate(){ return this->get_override("getOpenRate")();} 16 | DATE getOpenTime(){ return this->get_override("getOpenTime")();} 17 | const char* getOpenQuoteID(){ return this->get_override("getOpenQuoteID")();} 18 | const char* getOpenOrderID(){ return this->get_override("getOpenOrderID")();} 19 | const char* getOpenOrderReqID(){ return this->get_override("getOpenOrderReqID")();} 20 | const char* getOpenOrderRequestTXT(){ return this->get_override("getOpenOrderRequestTXT")();} 21 | double getCommission(){ return this->get_override("getCommission")();} 22 | double getRolloverInterest(){ return this->get_override("getRolloverInterest")();} 23 | const char* getTradeIDOrigin(){ return this->get_override("getTradeIDOrigin")();} 24 | double getUsedMargin(){ return this->get_override("getUsedMargin")();} 25 | const char* getValueDate(){ return this->get_override("getValueDate")();} 26 | const char* getParties(){ return this->get_override("getParties")();} 27 | }; 28 | 29 | class IO2GTradeTableRowWrap : public IO2GTradeTableRow, public wrapper < IO2GTradeTableRow > 30 | { 31 | public: 32 | double getPL(){ return this->get_override("getPL")();} 33 | double getGrossPL(){ return this->get_override("getGrossPL")();} 34 | double getClose(){ return this->get_override("getClose")();} 35 | double getStop(){ return this->get_override("getStop")();} 36 | double getLimit(){ return this->get_override("getLimit")();} 37 | }; 38 | 39 | void export_IO2GTradeRow() 40 | { 41 | class_, boost::noncopyable>("IO2GTradeRow", no_init) 42 | .def("getTradeID", pure_virtual(&IO2GTradeRow::getTradeID)) 43 | .def("getAccountID", pure_virtual(&IO2GTradeRow::getAccountID)) 44 | .def("getAccountName", pure_virtual(&IO2GTradeRow::getAccountName)) 45 | .def("getAccountKind", pure_virtual(&IO2GTradeRow::getAccountKind)) 46 | .def("getOfferID", pure_virtual(&IO2GTradeRow::getOfferID)) 47 | .def("getAmount", pure_virtual(&IO2GTradeRow::getAmount)) 48 | .def("getBuySell", pure_virtual(&IO2GTradeRow::getBuySell)) 49 | .def("getOpenRate", pure_virtual(&IO2GTradeRow::getOpenRate)) 50 | .def("getOpenTime", pure_virtual(&IO2GTradeRow::getOpenTime)) 51 | .def("getOpenQuoteID", pure_virtual(&IO2GTradeRow::getOpenQuoteID)) 52 | .def("getOpenOrderID", pure_virtual(&IO2GTradeRow::getOpenOrderID)) 53 | .def("getOpenOrderReqID", pure_virtual(&IO2GTradeRow::getOpenOrderReqID)) 54 | .def("getOpenOrderRequestTXT", pure_virtual(&IO2GTradeRow::getOpenOrderRequestTXT)) 55 | .def("getCommission", pure_virtual(&IO2GTradeRow::getCommission)) 56 | .def("getRolloverInterest", pure_virtual(&IO2GTradeRow::getRolloverInterest)) 57 | .def("getTradeIDOrigin", pure_virtual(&IO2GTradeRow::getTradeIDOrigin)) 58 | .def("getUsedMargin", pure_virtual(&IO2GTradeRow::getUsedMargin)) 59 | .def("getValueDate", pure_virtual(&IO2GTradeRow::getValueDate)) 60 | .def("getParties", pure_virtual(&IO2GTradeRow::getParties)) 61 | ; 62 | 63 | class_, boost::noncopyable>("IO2GTradeTableRow", no_init) 64 | .def("getPL", pure_virtual(&IO2GTradeTableRow::getPL)) 65 | .def("getGrossPL", pure_virtual(&IO2GTradeTableRow::getGrossPL)) 66 | .def("getClose", pure_virtual(&IO2GTradeTableRow::getClose)) 67 | .def("getStop", pure_virtual(&IO2GTradeTableRow::getStop)) 68 | .def("getLimit", pure_virtual(&IO2GTradeTableRow::getLimit)) 69 | ; 70 | }; -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/O2G2ptr.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | #include 4 | 5 | using namespace boost::python; 6 | 7 | template class O2G2PtrWrap : public O2G2Ptr, public wrapper> 8 | { 9 | }; 10 | 11 | class IO2GSessionPtr : public O2G2Ptr < IO2GSession >/*, public wrapper>*/ {}; 12 | 13 | class IO2GLoginRulesPtr : public O2G2Ptr < IO2GLoginRules > {}; 14 | 15 | class IO2GSessionDescriptorCollectionPtr : public O2G2Ptr < IO2GSessionDescriptorCollection > {}; 16 | 17 | class IO2GAccountRowPtr : public O2G2Ptr < IO2GAccountRow > {}; 18 | 19 | class IO2GTableManagerPtr : public O2G2Ptr < IO2GTableManager > {}; 20 | 21 | template class IO2GOffersTablePtr : public O2G2Ptr < IO2GOffersTable>, public wrapper> 22 | { 23 | public: 24 | void subscribeUpdate(O2GTableUpdateType updateType, IO2GTableListener *listener){ this->get_override("subscribeUpdate")(); } 25 | }; 26 | 27 | //template class O2G2PtrWrap < IO2GSession >; 28 | void export_O2G2PteredClasses() 29 | { 30 | class_, boost::noncopyable>("O2GPtr", no_init); 31 | 32 | class_("IO2GSessionPtr", init<>()) 33 | .def(init()) 34 | .def("release", &IO2GSessionPtr::Release) 35 | .def("detach", (IO2GSession*(IO2GSessionPtr::*)())(&IO2GSessionPtr::Detach), return_value_policy()) 36 | .def("assign", &IO2GSessionPtr::operator=, return_value_policy()) 37 | .def("__eq__", &IO2GSessionPtr::operator==) 38 | .def("__lt__", &IO2GSessionPtr::operator<) 39 | .def("__not__", &IO2GSessionPtr::operator!) 40 | ; 41 | class_("IO2GAccountRowPtr", init<>()) 42 | .def(init()) 43 | .def("release", &IO2GAccountRowPtr::Release) 44 | .def("detach", (IO2GAccountRow*(IO2GAccountRowPtr::*)())(&IO2GAccountRowPtr::Detach), return_value_policy()) 45 | .def("assign", &IO2GAccountRowPtr::operator=, return_value_policy()) 46 | .def("__eq__", &IO2GAccountRowPtr::operator==) 47 | .def("__lt__", &IO2GAccountRowPtr::operator<) 48 | .def("__not__", &IO2GAccountRowPtr::operator!) 49 | ; 50 | class_("IO2GSessionDescriptorCollectionPtr", init<>()) 51 | .def(init()) 52 | .def("release", &IO2GSessionDescriptorCollectionPtr::Release) 53 | .def("detach", (IO2GSessionDescriptorCollection*(IO2GSessionDescriptorCollectionPtr::*)())(&IO2GSessionDescriptorCollectionPtr::Detach), return_value_policy()) 54 | .def("assign", &IO2GSessionDescriptorCollectionPtr::operator=, return_value_policy()) 55 | .def("__eq__", &IO2GSessionDescriptorCollectionPtr::operator==) 56 | .def("__lt__", &IO2GSessionDescriptorCollectionPtr::operator<) 57 | .def("__not__", &IO2GSessionDescriptorCollectionPtr::operator!) 58 | ; 59 | 60 | class_("IO2GTableManagerPtr", init<>()) 61 | .def(init()) 62 | .def("release", &IO2GTableManagerPtr::Release) 63 | .def("detach", (IO2GTableManager*(IO2GTableManagerPtr::*)())(&IO2GTableManagerPtr::Detach), return_value_policy()) 64 | .def("assign", &IO2GTableManagerPtr::operator=, return_value_policy()) 65 | .def("__eq__", &IO2GTableManagerPtr::operator==) 66 | .def("__lt__", &IO2GTableManagerPtr::operator<) 67 | .def("__not__", &IO2GTableManagerPtr::operator!) 68 | ; 69 | 70 | 71 | class_, boost::noncopyable>("IO2GOffersTablePtr", init<>()) 72 | //.def(init()) 73 | //.def("release", &IO2GOffersTablePtr::Release) 74 | .def("detach", (IO2GOffersTable*(IO2GOffersTablePtr::*)())(&IO2GOffersTablePtr::Detach), return_value_policy()) 75 | //.def("assign", &IO2GOffersTablePtr::operator=, return_value_policy()) 76 | //.def("__eq__", &IO2GOffersTablePtr::operator==) 77 | //.def("__lt__", &IO2GOffersTablePtr::operator<) 78 | //.def("__not__", &IO2GOffersTablePtr::operator!) 79 | .def("subscribeUpdate", pure_virtual(&IO2GOffersTablePtr::subscribeUpdate)) 80 | ; 81 | 82 | }; 83 | -------------------------------------------------------------------------------- /src/ForexConnectClient/ForexConnectClient.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30501.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "forex.connect", "forex.connect\forex.connect.vcxproj", "{0F8C63DA-E604-4740-A120-36F555C69550}" 7 | EndProject 8 | Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "fx.console", "fx.console\fx.console.pyproj", "{3A533C8E-EE7C-4C04-AB98-106DDB55DF05}" 9 | EndProject 10 | Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "fx.market.watcher", "fx.market.watcher\fx.market.watcher.pyproj", "{E9607F20-C508-4AB4-A652-F63913E16305}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Debug|Mixed Platforms = Debug|Mixed Platforms 16 | Debug|Win32 = Debug|Win32 17 | Debug|x64 = Debug|x64 18 | Release|Any CPU = Release|Any CPU 19 | Release|Mixed Platforms = Release|Mixed Platforms 20 | Release|Win32 = Release|Win32 21 | Release|x64 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {0F8C63DA-E604-4740-A120-36F555C69550}.Debug|Any CPU.ActiveCfg = Debug|Win32 25 | {0F8C63DA-E604-4740-A120-36F555C69550}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 26 | {0F8C63DA-E604-4740-A120-36F555C69550}.Debug|Mixed Platforms.Build.0 = Debug|Win32 27 | {0F8C63DA-E604-4740-A120-36F555C69550}.Debug|Win32.ActiveCfg = Debug|Win32 28 | {0F8C63DA-E604-4740-A120-36F555C69550}.Debug|Win32.Build.0 = Debug|Win32 29 | {0F8C63DA-E604-4740-A120-36F555C69550}.Debug|x64.ActiveCfg = Debug|x64 30 | {0F8C63DA-E604-4740-A120-36F555C69550}.Debug|x64.Build.0 = Debug|x64 31 | {0F8C63DA-E604-4740-A120-36F555C69550}.Release|Any CPU.ActiveCfg = Release|Win32 32 | {0F8C63DA-E604-4740-A120-36F555C69550}.Release|Mixed Platforms.ActiveCfg = Release|Win32 33 | {0F8C63DA-E604-4740-A120-36F555C69550}.Release|Mixed Platforms.Build.0 = Release|Win32 34 | {0F8C63DA-E604-4740-A120-36F555C69550}.Release|Win32.ActiveCfg = Release|Win32 35 | {0F8C63DA-E604-4740-A120-36F555C69550}.Release|Win32.Build.0 = Release|Win32 36 | {0F8C63DA-E604-4740-A120-36F555C69550}.Release|x64.ActiveCfg = Release|x64 37 | {0F8C63DA-E604-4740-A120-36F555C69550}.Release|x64.Build.0 = Release|x64 38 | {3A533C8E-EE7C-4C04-AB98-106DDB55DF05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {3A533C8E-EE7C-4C04-AB98-106DDB55DF05}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {3A533C8E-EE7C-4C04-AB98-106DDB55DF05}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 41 | {3A533C8E-EE7C-4C04-AB98-106DDB55DF05}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 42 | {3A533C8E-EE7C-4C04-AB98-106DDB55DF05}.Debug|Win32.ActiveCfg = Debug|Any CPU 43 | {3A533C8E-EE7C-4C04-AB98-106DDB55DF05}.Debug|x64.ActiveCfg = Debug|Any CPU 44 | {3A533C8E-EE7C-4C04-AB98-106DDB55DF05}.Release|Any CPU.ActiveCfg = Release|Any CPU 45 | {3A533C8E-EE7C-4C04-AB98-106DDB55DF05}.Release|Any CPU.Build.0 = Release|Any CPU 46 | {3A533C8E-EE7C-4C04-AB98-106DDB55DF05}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 47 | {3A533C8E-EE7C-4C04-AB98-106DDB55DF05}.Release|Mixed Platforms.Build.0 = Release|Any CPU 48 | {3A533C8E-EE7C-4C04-AB98-106DDB55DF05}.Release|Win32.ActiveCfg = Release|Any CPU 49 | {3A533C8E-EE7C-4C04-AB98-106DDB55DF05}.Release|x64.ActiveCfg = Release|Any CPU 50 | {E9607F20-C508-4AB4-A652-F63913E16305}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 51 | {E9607F20-C508-4AB4-A652-F63913E16305}.Debug|Any CPU.Build.0 = Debug|Any CPU 52 | {E9607F20-C508-4AB4-A652-F63913E16305}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 53 | {E9607F20-C508-4AB4-A652-F63913E16305}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 54 | {E9607F20-C508-4AB4-A652-F63913E16305}.Debug|Win32.ActiveCfg = Debug|Any CPU 55 | {E9607F20-C508-4AB4-A652-F63913E16305}.Debug|x64.ActiveCfg = Debug|Any CPU 56 | {E9607F20-C508-4AB4-A652-F63913E16305}.Release|Any CPU.ActiveCfg = Release|Any CPU 57 | {E9607F20-C508-4AB4-A652-F63913E16305}.Release|Any CPU.Build.0 = Release|Any CPU 58 | {E9607F20-C508-4AB4-A652-F63913E16305}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 59 | {E9607F20-C508-4AB4-A652-F63913E16305}.Release|Mixed Platforms.Build.0 = Release|Any CPU 60 | {E9607F20-C508-4AB4-A652-F63913E16305}.Release|Win32.ActiveCfg = Release|Any CPU 61 | {E9607F20-C508-4AB4-A652-F63913E16305}.Release|x64.ActiveCfg = Release|Any CPU 62 | EndGlobalSection 63 | GlobalSection(SolutionProperties) = preSolution 64 | HideSolutionNode = FALSE 65 | EndGlobalSection 66 | EndGlobal 67 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/ClosedTradesColumnsEnum.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | void export_ClosedTradesColumnsEnum() 5 | { 6 | using namespace boost::python; 7 | 8 | object obj_ClosedTradeColumnsEnum 9 | = class_("ClosedTradeColumnsEnum", "Closed trade columns enumeration", init<>()); 10 | { 11 | scope in_ClosedTradeColumnsEnum(obj_ClosedTradeColumnsEnum); 12 | enum_("Columns") 13 | .value("TradeID", ClosedTradeColumnsEnum::TradeID) 14 | .value("AccountID", ClosedTradeColumnsEnum::AccountID) 15 | .value("AccountName", ClosedTradeColumnsEnum::AccountName) 16 | .value("AccountKind", ClosedTradeColumnsEnum::AccountKind) 17 | .value("OfferID", ClosedTradeColumnsEnum::OfferID) 18 | .value("Amount", ClosedTradeColumnsEnum::Amount) 19 | .value("BuySell", ClosedTradeColumnsEnum::BuySell) 20 | .value("GrossPL", ClosedTradeColumnsEnum::GrossPL) 21 | .value("Commission", ClosedTradeColumnsEnum::Commission) 22 | .value("RolloverInterest", ClosedTradeColumnsEnum::RolloverInterest) 23 | .value("OpenRate", ClosedTradeColumnsEnum::OpenRate) 24 | .value("OpenQuoteID", ClosedTradeColumnsEnum::OpenQuoteID) 25 | .value("OpenTime", ClosedTradeColumnsEnum::OpenTime) 26 | .value("OpenOrderID", ClosedTradeColumnsEnum::OpenOrderID) 27 | .value("OpenOrderReqID", ClosedTradeColumnsEnum::OpenOrderReqID) 28 | .value("OpenOrderRequestTXT", ClosedTradeColumnsEnum::OpenOrderRequestTXT) 29 | .value("OpenOrderParties", ClosedTradeColumnsEnum::OpenOrderParties) 30 | .value("CloseRate", ClosedTradeColumnsEnum::CloseRate) 31 | .value("CloseQuoteID", ClosedTradeColumnsEnum::CloseQuoteID) 32 | .value("CloseTime", ClosedTradeColumnsEnum::CloseTime) 33 | .value("CloseOrderID", ClosedTradeColumnsEnum::CloseOrderID) 34 | .value("CloseOrderReqID", ClosedTradeColumnsEnum::CloseOrderReqID) 35 | .value("CloseOrderRequestTXT", ClosedTradeColumnsEnum::CloseOrderRequestTXT) 36 | .value("CloseOrderParties", ClosedTradeColumnsEnum::CloseOrderParties) 37 | .value("TradeIDOrigin", ClosedTradeColumnsEnum::TradeIDOrigin) 38 | .value("TradeIDRemain", ClosedTradeColumnsEnum::TradeIDRemain) 39 | .value("ValueDate", ClosedTradeColumnsEnum::ValueDate) 40 | .export_values() 41 | ; 42 | } 43 | 44 | object obj_ClosedTradeTableColumnsEnum 45 | = class_("ClosedTradeTableColumnsEnum", "Closed trade table columns enumeration", init<>()); 46 | { 47 | scope in_ClosedTradeTableColumnsEnum(obj_ClosedTradeTableColumnsEnum); 48 | enum_("Columns") 49 | .value("TradeID", ClosedTradeTableColumnsEnum::TradeID) 50 | .value("AccountID", ClosedTradeTableColumnsEnum::AccountID) 51 | .value("AccountName", ClosedTradeTableColumnsEnum::AccountName) 52 | .value("AccountKind", ClosedTradeTableColumnsEnum::AccountKind) 53 | .value("OfferID", ClosedTradeTableColumnsEnum::OfferID) 54 | .value("Amount", ClosedTradeTableColumnsEnum::Amount) 55 | .value("BuySell", ClosedTradeTableColumnsEnum::BuySell) 56 | .value("GrossPL", ClosedTradeTableColumnsEnum::GrossPL) 57 | .value("Commission", ClosedTradeTableColumnsEnum::Commission) 58 | .value("RolloverInterest", ClosedTradeTableColumnsEnum::RolloverInterest) 59 | .value("OpenRate", ClosedTradeTableColumnsEnum::OpenRate) 60 | .value("OpenQuoteID", ClosedTradeTableColumnsEnum::OpenQuoteID) 61 | .value("OpenTime", ClosedTradeTableColumnsEnum::OpenTime) 62 | .value("OpenOrderID", ClosedTradeTableColumnsEnum::OpenOrderID) 63 | .value("OpenOrderReqID", ClosedTradeTableColumnsEnum::OpenOrderReqID) 64 | .value("OpenOrderRequestTXT", ClosedTradeTableColumnsEnum::OpenOrderRequestTXT) 65 | .value("OpenOrderParties", ClosedTradeTableColumnsEnum::OpenOrderParties) 66 | .value("CloseRate", ClosedTradeTableColumnsEnum::CloseRate) 67 | .value("CloseQuoteID", ClosedTradeTableColumnsEnum::CloseQuoteID) 68 | .value("CloseTime", ClosedTradeTableColumnsEnum::CloseTime) 69 | .value("CloseOrderID", ClosedTradeTableColumnsEnum::CloseOrderID) 70 | .value("CloseOrderReqID", ClosedTradeTableColumnsEnum::CloseOrderReqID) 71 | .value("CloseOrderRequestTXT", ClosedTradeTableColumnsEnum::CloseOrderRequestTXT) 72 | .value("CloseOrderParties", ClosedTradeTableColumnsEnum::CloseOrderParties) 73 | .value("TradeIDOrigin", ClosedTradeTableColumnsEnum::TradeIDOrigin) 74 | .value("TradeIDRemain", ClosedTradeTableColumnsEnum::TradeIDRemain) 75 | .value("ValueDate", ClosedTradeTableColumnsEnum::ValueDate) 76 | .value("PL", ClosedTradeTableColumnsEnum::PL) 77 | .export_values() 78 | ; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GRequest.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | using namespace boost::python; 5 | 6 | class IO2GRequestWrap : public IO2GRequest, public wrapper < IO2GRequest > 7 | { 8 | public: 9 | const char* getRequestID(){ return this->get_override("getRequestID")(); } 10 | int getChildrenCount(){ return this->get_override("getChildrenCount")(); } 11 | IO2GRequest* getChildRequest(int){ return this->get_override("getChildRequest")(); } 12 | }; 13 | 14 | class IO2GValueMapWrap : public IO2GValueMap, public wrapper < IO2GValueMap > 15 | { 16 | public: 17 | void setString(O2GRequestParamsEnum, const char*){ this->get_override("setString")(); } 18 | void setDouble(O2GRequestParamsEnum, double){ this->get_override("setDouble")(); } 19 | void setInt(O2GRequestParamsEnum, int){ this->get_override("setInt")(); } 20 | void setBoolean(O2GRequestParamsEnum, bool){ this->get_override("setBoolean")(); } 21 | IO2GValueMap* clone(){ return this->get_override("clone")(); } 22 | void clear(){ this->get_override("clear")(); } 23 | int getChildrenCount(){ return this->get_override("getChildrenCount")(); } 24 | IO2GValueMap* getChild(int){ return this->get_override("getChild")(); } 25 | void appendChild(IO2GValueMap*){ this->get_override("appendChild")(); } 26 | 27 | }; 28 | 29 | class IO2GRequestFactoryWrap : public IO2GRequestFactory, public wrapper < IO2GRequestFactory > 30 | { 31 | public: 32 | IO2GTimeframeCollection* getTimeFrameCollection(){ return this->get_override("getTimeFrameCollection")(); } 33 | IO2GRequest* createMarketDataSnapshotRequestInstrument(const char *instrument, IO2GTimeframe *timeframe, int maxBars = 300) 34 | { 35 | return this->get_override("createMarketDataSnapshotRequestInstrument")(); 36 | } 37 | void fillMarketDataSnapshotRequestTime(IO2GRequest *request, DATE timeFrom = 0, DATE timeTo = 0, bool isIncludeWeekends = false) 38 | { 39 | this->get_override("fillMarketDataSnapshotRequestTime")(); 40 | } 41 | IO2GRequest* createRefreshTableRequest(O2GTable){ return this->get_override("createRefreshTableRequest")(); } 42 | IO2GRequest* createRefreshTableRequestByAccount(O2GTable, const char*){ return this->get_override("createRefreshTableRequestByAccount")(); } 43 | IO2GRequest* createOrderRequest(IO2GValueMap *){ return this->get_override("createOrderRequest")(); } 44 | IO2GValueMap* createValueMap(){ return this->get_override("createValueMap")(); } 45 | const char* getLastError(){ return this->get_override("getLastError")(); } 46 | }; 47 | 48 | void export_IO2GRequest() 49 | { 50 | class_, boost::noncopyable>("IO2GRequest", no_init) 51 | .def("getRequestID", pure_virtual(&IO2GRequest::getRequestID)) 52 | .def("getChildrenCount", pure_virtual(&IO2GRequest::getChildrenCount)) 53 | .def("getChildRequest", pure_virtual(&IO2GRequest::getChildRequest), return_value_policy()) 54 | ; 55 | 56 | class_, boost::noncopyable>("IO2GValueMap", no_init) 57 | .def("setString", pure_virtual(&IO2GValueMap::setString)) 58 | .def("setDouble", pure_virtual(&IO2GValueMap::setDouble)) 59 | .def("setInt", pure_virtual(&IO2GValueMap::setInt)) 60 | .def("setBoolean", pure_virtual(&IO2GValueMap::setBoolean)) 61 | .def("clone", pure_virtual(&IO2GValueMap::clone), return_value_policy()) 62 | .def("clear", pure_virtual(&IO2GValueMap::clear)) 63 | .def("getChildrenCount", pure_virtual(&IO2GValueMap::getChildrenCount)) 64 | .def("getChild", pure_virtual(&IO2GValueMap::getChild), return_value_policy()) 65 | .def("appendChild", pure_virtual(&IO2GValueMap::appendChild)) 66 | ; 67 | 68 | class_, boost::noncopyable>("IO2GRequestFactory", no_init) 69 | .def("getTimeFrameCollection", pure_virtual(&IO2GRequestFactory::getTimeFrameCollection), return_value_policy()) 70 | .def("createMarketDataSnapshotRequestInstrument", pure_virtual(&IO2GRequestFactory::createMarketDataSnapshotRequestInstrument), 71 | (arg("instrument"), arg("timeFrame"), arg("maxBar") = 300), return_value_policy()) 72 | .def("fillMarketDataSnapshotRequestTime", pure_virtual(&IO2GRequestFactory::fillMarketDataSnapshotRequestTime), 73 | (arg("request"), arg("timeFrom") = 0, arg("timeTo") = 0, arg("isIncludeWeekends") = false)) 74 | .def("createRefreshTableRequest", pure_virtual(&IO2GRequestFactory::createRefreshTableRequest), return_value_policy()) 75 | .def("createRefreshTableRequestByAccount", pure_virtual(&IO2GRequestFactory::createRefreshTableRequestByAccount), return_value_policy()) 76 | .def("createOrderRequest", pure_virtual(&IO2GRequestFactory::createOrderRequest), return_value_policy()) 77 | .def("createValueMap", pure_virtual(&IO2GRequestFactory::createValueMap), return_value_policy()) 78 | .def("getLastError", pure_virtual(&IO2GRequestFactory::getLastError)) 79 | 80 | ; 81 | }; -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/OrdersColumnsEnum.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | void export_OrdersColumnsEnum() 5 | { 6 | using namespace boost::python; 7 | object obj_OrderColumnsEnum 8 | = class_("OrderColumnsEnum", "Order columns enumeration", init<>()); 9 | { 10 | scope in_AccountColumnsEnum(obj_OrderColumnsEnum); 11 | enum_("Columns") 12 | .value("OrderID", OrderColumnsEnum::OrderID) 13 | .value("RequestID", OrderColumnsEnum::RequestID) 14 | .value("Rate", OrderColumnsEnum::Rate) 15 | .value("ExecutionRate", OrderColumnsEnum::ExecutionRate) 16 | .value("RateMin", OrderColumnsEnum::RateMin) 17 | .value("RateMax", OrderColumnsEnum::RateMax) 18 | .value("TradeID", OrderColumnsEnum::TradeID) 19 | .value("AccountID", OrderColumnsEnum::AccountID) 20 | .value("AccountName", OrderColumnsEnum::AccountName) 21 | .value("OfferID", OrderColumnsEnum::OfferID) 22 | .value("NetQuantity", OrderColumnsEnum::NetQuantity) 23 | .value("BuySell", OrderColumnsEnum::BuySell) 24 | .value("Stage", OrderColumnsEnum::Stage) 25 | .value("Type", OrderColumnsEnum::Type) 26 | .value("Status", OrderColumnsEnum::Status) 27 | .value("StatusTime", OrderColumnsEnum::StatusTime) 28 | .value("Amount", OrderColumnsEnum::Amount) 29 | .value("Lifetime", OrderColumnsEnum::Lifetime) 30 | .value("AtMarket", OrderColumnsEnum::AtMarket) 31 | .value("TrailStep", OrderColumnsEnum::TrailStep) 32 | .value("TrailRate", OrderColumnsEnum::TrailRate) 33 | .value("TimeInForce", OrderColumnsEnum::TimeInForce) 34 | .value("AccountKind", OrderColumnsEnum::AccountKind) 35 | .value("RequestTXT", OrderColumnsEnum::RequestTXT) 36 | .value("ContingentOrderID", OrderColumnsEnum::ContingentOrderID) 37 | .value("ContingencyType", OrderColumnsEnum::ContingencyType) 38 | .value("PrimaryID", OrderColumnsEnum::PrimaryID) 39 | .value("OriginAmount", OrderColumnsEnum::OriginAmount) 40 | .value("FilledAmount", OrderColumnsEnum::FilledAmount) 41 | .value("WorkingIndicator", OrderColumnsEnum::WorkingIndicator) 42 | .value("PegType", OrderColumnsEnum::PegType) 43 | .value("PegOffset", OrderColumnsEnum::PegOffset) 44 | .value("ExpireDate", OrderColumnsEnum::ExpireDate) 45 | .value("ValueDate", OrderColumnsEnum::ValueDate) 46 | .value("Parties", OrderColumnsEnum::Parties) 47 | .export_values() 48 | ; 49 | } 50 | 51 | object obj_OrderTableColumnsEnum 52 | = class_("OrderTableColumnsEnum", "Order table columns enumeration", init<>()); 53 | { 54 | scope in_OrderTableColumnsEnum(obj_OrderTableColumnsEnum); 55 | enum_("Columns") 56 | .value("OrderID", OrderTableColumnsEnum::OrderID) 57 | .value("RequestID", OrderTableColumnsEnum::RequestID) 58 | .value("Rate", OrderTableColumnsEnum::Rate) 59 | .value("ExecutionRate", OrderTableColumnsEnum::ExecutionRate) 60 | .value("RateMin", OrderTableColumnsEnum::RateMin) 61 | .value("RateMax", OrderTableColumnsEnum::RateMax) 62 | .value("TradeID", OrderTableColumnsEnum::TradeID) 63 | .value("AccountID", OrderTableColumnsEnum::AccountID) 64 | .value("AccountName", OrderTableColumnsEnum::AccountName) 65 | .value("OfferID", OrderTableColumnsEnum::OfferID) 66 | .value("NetQuantity", OrderTableColumnsEnum::NetQuantity) 67 | .value("BuySell", OrderTableColumnsEnum::BuySell) 68 | .value("Stage", OrderTableColumnsEnum::Stage) 69 | .value("Type", OrderTableColumnsEnum::Type) 70 | .value("Status", OrderTableColumnsEnum::Status) 71 | .value("StatusTime", OrderTableColumnsEnum::StatusTime) 72 | .value("Amount", OrderTableColumnsEnum::Amount) 73 | .value("Lifetime", OrderTableColumnsEnum::Lifetime) 74 | .value("AtMarket", OrderTableColumnsEnum::AtMarket) 75 | .value("TrailStep", OrderTableColumnsEnum::TrailStep) 76 | .value("TrailRate", OrderTableColumnsEnum::TrailRate) 77 | .value("TimeInForce", OrderTableColumnsEnum::TimeInForce) 78 | .value("AccountKind", OrderTableColumnsEnum::AccountKind) 79 | .value("RequestTXT", OrderTableColumnsEnum::RequestTXT) 80 | .value("ContingentOrderID", OrderTableColumnsEnum::ContingentOrderID) 81 | .value("ContingencyType", OrderTableColumnsEnum::ContingencyType) 82 | .value("PrimaryID", OrderTableColumnsEnum::PrimaryID) 83 | .value("OriginAmount", OrderTableColumnsEnum::OriginAmount) 84 | .value("FilledAmount", OrderTableColumnsEnum::FilledAmount) 85 | .value("WorkingIndicator", OrderTableColumnsEnum::WorkingIndicator) 86 | .value("PegType", OrderTableColumnsEnum::PegType) 87 | .value("PegOffset", OrderTableColumnsEnum::PegOffset) 88 | .value("ExpireDate", OrderTableColumnsEnum::ExpireDate) 89 | .value("ValueDate", OrderTableColumnsEnum::ValueDate) 90 | .value("Parties", OrderTableColumnsEnum::Parties) 91 | .value("Stop", OrderTableColumnsEnum::Stop) 92 | .value("Limit", OrderTableColumnsEnum::Limit) 93 | .value("StopTrailStep", OrderTableColumnsEnum::StopTrailStep) 94 | .value("StopTrailRate", OrderTableColumnsEnum::StopTrailRate) 95 | .export_values() 96 | ; 97 | } 98 | } -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GMarketDataResponseReader.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | using namespace boost::python; 5 | 6 | class IO2GMarketDataResponseReaderWrap : public IO2GMarketDataResponseReader, public wrapper < IO2GMarketDataResponseReader > 7 | { 8 | public: 9 | const char* getQuoteID() { return this->get_override("getQuoteID")();} 10 | const char* getInstrument() { return this->get_override("getInstrument")();} 11 | int getSymbolID() { return this->get_override("getSymbolID")();} 12 | DATE getDateTime() { return this->get_override("getDateTime")();} 13 | double getAskLow() { return this->get_override("getAskLow")();} 14 | double getAskHigh() { return this->get_override("getAskHigh")();} 15 | double getAskOpen() { return this->get_override("getAskOpen")();} 16 | double getAskClose() { return this->get_override("getAskClose")();} 17 | double getBidLow() { return this->get_override("getBidLow")();} 18 | double getBidHigh() { return this->get_override("getBidHigh")();} 19 | double getBidOpen() { return this->get_override("getBidOpen")();} 20 | double getBidClose() { return this->get_override("getBidClose")();} 21 | double getLow() { return this->get_override("getLow")();} 22 | double getHigh() { return this->get_override("getHigh")();} 23 | int getTimingInterval() { return this->get_override("getTimingInterval")();} 24 | bool isCandleCompleted() { return this->get_override("isCandleCompleted")();} 25 | const char* getMarketDataRequestID() { return this->get_override("getMarketDataRequestID")();} 26 | const char* getTradingSessionID() { return this->get_override("getTradingSessionID")();} 27 | const char* getTradingSessionSubID() { return this->get_override("getTradingSessionSubID")();} 28 | int getContinuosFlag() { return this->get_override("getContinuosFlag")();} 29 | const char* getBidID() { return this->get_override("getBidID")();} 30 | const char* getBidQuoteCondition() { return this->get_override("getBidQuoteCondition")();} 31 | int getBidQuoteType() { return this->get_override("getBidQuoteType")();} 32 | DATE getBidExpireDateTime() { return this->get_override("")();} 33 | const char* getAskID() { return this->get_override("getAskID")();} 34 | const char* getAskQuoteCondition() { return this->get_override("getAskQuoteCondition")();} 35 | int getAskQuoteType() { return this->get_override("getAskQuoteType")();} 36 | DATE getAskExpireDateTime() { return this->get_override("getAskExpireDateTime")();} 37 | }; 38 | 39 | void export_IO2GMarketDataResponseReader() 40 | { 41 | class_, boost::noncopyable>("IO2GMarketDataResponseReader", no_init) 42 | .def("getQuoteID", pure_virtual(&IO2GMarketDataResponseReader::getQuoteID)) 43 | .def("getInstrument", pure_virtual(&IO2GMarketDataResponseReader::getInstrument)) 44 | .def("getSymbolID", pure_virtual(&IO2GMarketDataResponseReader::getSymbolID)) 45 | .def("getDateTime", pure_virtual(&IO2GMarketDataResponseReader::getDateTime)) 46 | .def("getAskLow", pure_virtual(&IO2GMarketDataResponseReader::getAskLow)) 47 | .def("getAskHigh", pure_virtual(&IO2GMarketDataResponseReader::getAskHigh)) 48 | .def("getAskOpen", pure_virtual(&IO2GMarketDataResponseReader::getAskOpen)) 49 | .def("getAskClose", pure_virtual(&IO2GMarketDataResponseReader::getAskClose)) 50 | .def("getBidLow", pure_virtual(&IO2GMarketDataResponseReader::getBidLow)) 51 | .def("getBidHigh", pure_virtual(&IO2GMarketDataResponseReader::getBidHigh)) 52 | .def("getBidOpen", pure_virtual(&IO2GMarketDataResponseReader::getBidOpen)) 53 | .def("getBidClose", pure_virtual(&IO2GMarketDataResponseReader::getBidClose)) 54 | .def("getLow", pure_virtual(&IO2GMarketDataResponseReader::getLow)) 55 | .def("getHigh", pure_virtual(&IO2GMarketDataResponseReader::getHigh)) 56 | .def("getTimingInterval", pure_virtual(&IO2GMarketDataResponseReader::getTimingInterval)) 57 | .def("isCandleCompleted", pure_virtual(&IO2GMarketDataResponseReader::isCandleCompleted)) 58 | .def("getMarketDataRequestID", pure_virtual(&IO2GMarketDataResponseReader::getMarketDataRequestID)) 59 | .def("getTradingSessionID", pure_virtual(&IO2GMarketDataResponseReader::getTradingSessionID)) 60 | .def("getTradingSessionSubID", pure_virtual(&IO2GMarketDataResponseReader::getTradingSessionSubID)) 61 | .def("getContinuosFlag())", pure_virtual(&IO2GMarketDataResponseReader::getContinuosFlag)) 62 | .def("getBidID())", pure_virtual(&IO2GMarketDataResponseReader::getBidID)) 63 | .def("getBidQuoteCondition", pure_virtual(&IO2GMarketDataResponseReader::getBidQuoteCondition)) 64 | .def("getBidQuoteType", pure_virtual(&IO2GMarketDataResponseReader::getBidQuoteType)) 65 | .def("getBidExpireDateTime", pure_virtual(&IO2GMarketDataResponseReader::getBidExpireDateTime)) 66 | .def("getAskID", pure_virtual(&IO2GMarketDataResponseReader::getAskID)) 67 | .def("getAskQuoteCondition", pure_virtual(&IO2GMarketDataResponseReader::getAskQuoteCondition)) 68 | .def("getAskQuoteType", pure_virtual(&IO2GMarketDataResponseReader::getAskQuoteType)) 69 | .def("getAskExpireDateTime", pure_virtual(&IO2GMarketDataResponseReader::getAskExpireDateTime)) 70 | ; 71 | } -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/O2GRequestParamsEnum.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | using namespace boost::python; 4 | 5 | void export_O2GRequestParamsEnum() 6 | { 7 | enum_("O2GRequestParamsEnum") 8 | .value("UnknownParam", O2GRequestParamsEnum::UnknownParam) 9 | .value("Command", O2GRequestParamsEnum::Command) 10 | .value("AccountID", O2GRequestParamsEnum::AccountID) 11 | .value("OfferID", O2GRequestParamsEnum::OfferID) 12 | .value("TradeID", O2GRequestParamsEnum::TradeID) 13 | .value("BuySell", O2GRequestParamsEnum::BuySell) 14 | .value("Amount", O2GRequestParamsEnum::Amount) 15 | .value("Rate", O2GRequestParamsEnum::Rate) 16 | .value("RateStop", O2GRequestParamsEnum::RateStop) 17 | .value("RateLimit", O2GRequestParamsEnum::RateLimit) 18 | .value("TrailStepStop", O2GRequestParamsEnum::TrailStepStop) 19 | .value("TrailStep", O2GRequestParamsEnum::TrailStep) 20 | .value("TimeInForce", O2GRequestParamsEnum::TimeInForce) 21 | .value("CustomID", O2GRequestParamsEnum::CustomID) 22 | .value("OrderID", O2GRequestParamsEnum::OrderID) 23 | .value("PegOffsetStop", O2GRequestParamsEnum::PegOffsetStop) 24 | .value("PegOffsetLimit", O2GRequestParamsEnum::PegOffsetLimit) 25 | .value("PegTypeStop", O2GRequestParamsEnum::PegTypeStop) 26 | .value("PegTypeLimit", O2GRequestParamsEnum::PegTypeLimit) 27 | .value("PegOffset", O2GRequestParamsEnum::PegOffset) 28 | .value("PegType", O2GRequestParamsEnum::PegType) 29 | .value("NetQuantity", O2GRequestParamsEnum::NetQuantity) 30 | .value("OrderType", O2GRequestParamsEnum::OrderType) 31 | .value("RateMin", O2GRequestParamsEnum::RateMin) 32 | .value("RateMax", O2GRequestParamsEnum::RateMax) 33 | .value("ContingencyID", O2GRequestParamsEnum::ContingencyID) 34 | .value("SubscriptionStatus", O2GRequestParamsEnum::SubscriptionStatus) 35 | .value("ClientRate", O2GRequestParamsEnum::ClientRate) 36 | .value("ContingencyGroupType", O2GRequestParamsEnum::ContingencyGroupType) 37 | .value("PrimaryQID", O2GRequestParamsEnum::PrimaryQID) 38 | .value("AccountName", O2GRequestParamsEnum::AccountName) 39 | .value("Key", O2GRequestParamsEnum::Key) 40 | .value("Id", O2GRequestParamsEnum::Id) 41 | .value("Bid", O2GRequestParamsEnum::Bid) 42 | .value("Ask", O2GRequestParamsEnum::Ask) 43 | .value("LoginID", O2GRequestParamsEnum::LoginID) 44 | .value("ReportID", O2GRequestParamsEnum::ReportID) 45 | .value("Lifetime", O2GRequestParamsEnum::Lifetime) 46 | .value("Symbol", O2GRequestParamsEnum::Symbol) 47 | .value("Psw", O2GRequestParamsEnum::Psw) 48 | .value("IntrBuy", O2GRequestParamsEnum::IntrBuy) 49 | .value("IntrSel", O2GRequestParamsEnum::IntrSel) 50 | .value("IntrMult", O2GRequestParamsEnum::IntrMult) 51 | .value("Status", O2GRequestParamsEnum::Status) 52 | .value("IntrFlag", O2GRequestParamsEnum::IntrFlag) 53 | .value("Msg", O2GRequestParamsEnum::Msg) 54 | .value("DealerIntFlg", O2GRequestParamsEnum::DealerIntFlg) 55 | .value("AutoLimit", O2GRequestParamsEnum::AutoLimit) 56 | .value("MrgnReq", O2GRequestParamsEnum::MrgnReq) 57 | .value("EntryMrgnReq", O2GRequestParamsEnum::EntryMrgnReq) 58 | .value("RateVariat", O2GRequestParamsEnum::RateVariat) 59 | .value("RfqLifetime", O2GRequestParamsEnum::RfqLifetime) 60 | .value("OrdrLifetime", O2GRequestParamsEnum::OrdrLifetime) 61 | .value("SellIntr", O2GRequestParamsEnum::SellIntr) 62 | .value("BuyIntr", O2GRequestParamsEnum::BuyIntr) 63 | .value("Feed", O2GRequestParamsEnum::Feed) 64 | .value("FeedPrice", O2GRequestParamsEnum::FeedPrice) 65 | .value("FeedAsk", O2GRequestParamsEnum::FeedAsk) 66 | .value("FeedBid", O2GRequestParamsEnum::FeedBid) 67 | .value("PercentCost", O2GRequestParamsEnum::PercentCost) 68 | .value("AcctID", O2GRequestParamsEnum::AcctID) 69 | .value("IntrSign", O2GRequestParamsEnum::IntrSign) 70 | .value("MrgnReqEntry", O2GRequestParamsEnum::MrgnReqEntry) 71 | .value("OrderPriceFlg", O2GRequestParamsEnum::OrderPriceFlg) 72 | .value("MrgnEnabledFlg", O2GRequestParamsEnum::MrgnEnabledFlg) 73 | .value("MrgnReqAware", O2GRequestParamsEnum::MrgnReqAware) 74 | .value("Login", O2GRequestParamsEnum::Login) 75 | .value("OrderPrice", O2GRequestParamsEnum::OrderPrice) 76 | .value("SeatBelt", O2GRequestParamsEnum::SeatBelt) 77 | .value("AutoMrgn", O2GRequestParamsEnum::AutoMrgn) 78 | .value("CondDistance", O2GRequestParamsEnum::CondDistance) 79 | .value("CondDistanceE", O2GRequestParamsEnum::CondDistanceE) 80 | .value("MaxQuantity", O2GRequestParamsEnum::MaxQuantity) 81 | .value("PanicFlg", O2GRequestParamsEnum::PanicFlg) 82 | .value("GoneToPeeFlg", O2GRequestParamsEnum::GoneToPeeFlg) 83 | .value("ManualPrices", O2GRequestParamsEnum::ManualPrices) 84 | .value("CrossCurrency", O2GRequestParamsEnum::CrossCurrency) 85 | .value("PanicLevel", O2GRequestParamsEnum::PanicLevel) 86 | .value("IntrMultNone", O2GRequestParamsEnum::IntrMultNone) 87 | .value("EqtyEnabledFlg", O2GRequestParamsEnum::EqtyEnabledFlg) 88 | .value("EqtyStop", O2GRequestParamsEnum::EqtyStop) 89 | .value("EqtyLimit", O2GRequestParamsEnum::EqtyLimit) 90 | .value("ExpireDateTime", O2GRequestParamsEnum::ExpireDateTime) 91 | .export_values() 92 | ; 93 | } -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GClosedTradeRow.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | using namespace boost::python; 5 | 6 | class IO2GClosedTradeRowWrap : public IO2GClosedTradeRow, public wrapper < IO2GClosedTradeRow > 7 | { 8 | public: 9 | const char* getTradeID(){ return this->get_override("getTradeID()")();} 10 | const char* getAccountID(){ return this->get_override("getAccountID")();} 11 | const char* getAccountName(){ return this->get_override("getAccountName")();} 12 | const char* getAccountKind(){ return this->get_override("getAccountKind")();} 13 | const char* getOfferID(){ return this->get_override("getOfferID")();} 14 | int getAmount(){ return this->get_override("getAmount()")();} 15 | const char* getBuySell(){ return this->get_override("getBuySell")();} 16 | double getGrossPL(){ return this->get_override("getGrossPL")();} 17 | double getCommission(){ return this->get_override("getCommission")();} 18 | double getRolloverInterest(){ return this->get_override("getRolloverInterest")();} 19 | double getOpenRate(){ return this->get_override("getOpenRate")();} 20 | const char* getOpenQuoteID(){ return this->get_override("getOpenQuoteID")();} 21 | DATE getOpenTime(){ return this->get_override("getOpenTime")();} 22 | const char* getOpenOrderID(){ return this->get_override("getOpenOrderID")();} 23 | const char* getOpenOrderReqID(){ return this->get_override("getOpenOrderReqID")();} 24 | const char* getOpenOrderRequestTXT(){ return this->get_override("getOpenOrderRequestTXT")();} 25 | const char* getOpenOrderParties(){ return this->get_override("getOpenOrderParties")();} 26 | double getCloseRate(){ return this->get_override("getCloseRate")();} 27 | const char* getCloseQuoteID(){ return this->get_override("getCloseQuoteID")();} 28 | DATE getCloseTime(){ return this->get_override("getCloseTime")();} 29 | const char* getCloseOrderID(){ return this->get_override("getCloseOrderID")();} 30 | const char* getCloseOrderReqID(){ return this->get_override("getCloseOrderReqID")();} 31 | const char* getCloseOrderRequestTXT(){ return this->get_override("getCloseOrderRequestTXT")();} 32 | const char* getCloseOrderParties(){ return this->get_override("getCloseOrderParties")();} 33 | const char* getTradeIDOrigin(){ return this->get_override("getTradeIDOrigin")();} 34 | const char* getTradeIDRemain(){ return this->get_override("getTradeIDRemain")();} 35 | const char* getValueDate(){ return this->get_override("getValueDate")();} 36 | }; 37 | 38 | class IO2GClosedTradeTableRowWrap : public IO2GClosedTradeTableRow, public wrapper < IO2GClosedTradeTableRow > 39 | { 40 | double getPL() {return this->get_override("getPL")();} 41 | }; 42 | 43 | void export_IO2GClosedTradeRow() 44 | { 45 | class_, boost::noncopyable>("IO2GClosedTradeRow", no_init) 46 | .def("getTradeID", pure_virtual(&IO2GClosedTradeRow::getTradeID)) 47 | .def("getAccountID", pure_virtual(&IO2GClosedTradeRow::getAccountID)) 48 | .def("getAccountName", pure_virtual(&IO2GClosedTradeRow::getAccountName)) 49 | .def("getAccountKind", pure_virtual(&IO2GClosedTradeRow::getAccountKind)) 50 | .def("getOfferID", pure_virtual(&IO2GClosedTradeRow::getOfferID)) 51 | .def("getAmount", pure_virtual(&IO2GClosedTradeRow::getAmount)) 52 | .def("getBuySell", pure_virtual(&IO2GClosedTradeRow::getBuySell)) 53 | .def("getGrossPL", pure_virtual(&IO2GClosedTradeRow::getGrossPL)) 54 | .def("getCommission", pure_virtual(&IO2GClosedTradeRow::getCommission)) 55 | .def("getRolloverInterest", pure_virtual(&IO2GClosedTradeRow::getRolloverInterest)) 56 | .def("getOpenRate", pure_virtual(&IO2GClosedTradeRow::getOpenRate)) 57 | .def("getOpenQuoteID", pure_virtual(&IO2GClosedTradeRow::getOpenQuoteID)) 58 | .def("getOpenTime", pure_virtual(&IO2GClosedTradeRow::getOpenTime)) 59 | .def("getOpenOrderID", pure_virtual(&IO2GClosedTradeRow::getOpenOrderID)) 60 | .def("getOpenOrderReqID", pure_virtual(&IO2GClosedTradeRow::getOpenOrderReqID)) 61 | .def("getOpenOrderRequestTXT", pure_virtual(&IO2GClosedTradeRow::getOpenOrderRequestTXT)) 62 | .def("getOpenOrderParties", pure_virtual(&IO2GClosedTradeRow::getOpenOrderParties)) 63 | .def("getCloseRate", pure_virtual(&IO2GClosedTradeRow::getCloseRate)) 64 | .def("getCloseQuoteID", pure_virtual(&IO2GClosedTradeRow::getCloseQuoteID)) 65 | .def("getCloseTime", pure_virtual(&IO2GClosedTradeRow::getCloseTime)) 66 | .def("getCloseOrderID", pure_virtual(&IO2GClosedTradeRow::getCloseOrderID)) 67 | .def("getCloseOrderReqID", pure_virtual(&IO2GClosedTradeRow::getCloseOrderReqID)) 68 | .def("getCloseOrderRequestTXT", pure_virtual(&IO2GClosedTradeRow::getCloseOrderRequestTXT)) 69 | .def("getCloseOrderParties", pure_virtual(&IO2GClosedTradeRow::getCloseOrderParties)) 70 | .def("getTradeIDOrigin", pure_virtual(&IO2GClosedTradeRow::getTradeIDOrigin)) 71 | .def("getTradeIDRemain", pure_virtual(&IO2GClosedTradeRow::getTradeIDRemain)) 72 | .def("getValueDate", pure_virtual(&IO2GClosedTradeRow::getValueDate)) 73 | ; 74 | 75 | class_, boost::noncopyable>("IO2GClosedTradeTableRow", no_init) 76 | .def("getPL", pure_virtual(&IO2GClosedTradeTableRow::getPL)) 77 | ; 78 | }; -------------------------------------------------------------------------------- /includes/forexconnect/O2GOrderType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | namespace O2G2 3 | { 4 | namespace Commands 5 | { 6 | static const char CreateOrder[] = "CreateOrder"; 7 | static const char CreateOCO[] = "CreateOCO"; 8 | static const char CreateOTO[] = "CreateOTO"; 9 | static const char JoinToNewContingencyGroup[] = "JoinToNewContingencyGroup"; 10 | static const char JoinToExistingContingencyGroup[] = "JoinToExistingContingencyGroup"; 11 | static const char RemoveFromContingencyGroup[] = "RemoveFromContingencyGroup"; 12 | static const char EditOrder[] = "EditOrder"; 13 | static const char DeleteOrder[] = "DeleteOrder"; 14 | static const char SetSubscriptionStatus[] = "SetSubscriptionStatus"; 15 | static const char UpdateMarginRequirements[] = "UpdateMarginRequirements"; 16 | static const char GetLastOrderUpdate[] = "GetLastOrderUpdate"; 17 | static const char AcceptOrder[] = "AcceptOrder"; 18 | static const char ChangePassword[] = "ChangePassword"; 19 | } 20 | static const char Buy[] = "B"; 21 | static const char Sell[] = "S"; 22 | 23 | namespace Orders 24 | { 25 | static const char TrueMarketOpen[] = "OM"; 26 | static const char MarketOpen[] = "O"; 27 | static const char MarketOpenRange[] = "OR"; 28 | static const char OpenLimit[] = "OL"; 29 | static const char TrueMarketClose[] = "CM"; 30 | static const char MarketClose[] = "C"; 31 | static const char MarketCloseRange[] = "CR"; 32 | static const char CloseLimit[] = "CL"; 33 | static const char StopEntry[] = "SE"; 34 | static const char LimitEntry[] = "LE"; 35 | static const char Entry[] = "E"; 36 | static const char Stop[] = "S"; 37 | static const char Limit[] = "L"; 38 | static const char StopTrailingEntry[] = "STE"; 39 | static const char LimitTrailingEntry[] = "LTE"; 40 | } 41 | 42 | namespace TIF 43 | { 44 | static const char GTC[] = "GTC"; 45 | static const char IOC[] = "IOC"; 46 | static const char DAY[] = "DAY"; 47 | static const char FOK[] = "FOK"; 48 | static const char GTD[] = "GTD"; 49 | } 50 | 51 | namespace Peg 52 | { 53 | static const char FromOpen[] = "O"; 54 | static const char FromClose[] = "M"; 55 | } 56 | 57 | namespace KeyType 58 | { 59 | static const char OrderID[] = "OrderID"; 60 | static const char RequestID[] = "OrderQID"; 61 | static const char RequestTXT[] = "OrderQTXT"; 62 | } 63 | 64 | namespace SubscriptionStatuses 65 | { 66 | static const char Tradable[] = "T"; 67 | static const char Disable[] = "D"; 68 | static const char ViewOnly[] = "V"; 69 | } 70 | 71 | namespace SystemProperties 72 | { 73 | static const char BASE_CRNCY[] = "BASE_CRNCY"; 74 | static const char BASE_UNIT_SIZE[] = "BASE_UNIT_SIZE"; 75 | static const char BASE_CRNCY_PRECISION[] = "BASE_CRNCY_PRECISION"; 76 | static const char BASE_CRNCY_SYMBOL[] = "BASE_CRNCY_SYMBOL"; 77 | static const char BASE_TIME_ZONE[] = "BASE_TIME_ZONE"; 78 | static const char COND_DIST[] = "COND_DIST"; 79 | static const char COND_DIST_ENTRY[] = "COND_DIST_ENTRY"; 80 | static const char END_TRADING_DAY[] = "END_TRADING_DAY"; 81 | static const char FORCE_PASSWORD_CHANGE[] = "FORCE_PASSWORD_CHANGE"; 82 | static const char MARKET_OPEN[] = "MARKET_OPEN"; 83 | static const char QUERYDEPTH_0[] = "QUERYDEPTH_0"; 84 | static const char QUERYDEPTH_1[] = "QUERYDEPTH_1"; 85 | static const char QUERYDEPTH_2[] = "QUERYDEPTH_2"; 86 | static const char QUERYDEPTH_3[] = "QUERYDEPTH_3"; 87 | static const char QUERYDEPTH_4[] = "QUERYDEPTH_4"; 88 | static const char QUERYDEPTH_5[] = "QUERYDEPTH_5"; 89 | static const char QUERYDEPTH_6[] = "QUERYDEPTH_6"; 90 | static const char QUERYDEPTH_7[] = "QUERYDEPTH_7"; 91 | static const char QUERYDEPTH_8[] = "QUERYDEPTH_8"; 92 | static const char QUERYDEPTH_h2[] = "QUERYDEPTH_h2"; 93 | static const char QUERYDEPTH_h3[] = "QUERYDEPTH_h3"; 94 | static const char QUERYDEPTH_h4[] = "QUERYDEPTH_h4"; 95 | static const char QUERYDEPTH_h6[] = "QUERYDEPTH_h6"; 96 | static const char QUERYDEPTH_h8[] = "QUERYDEPTH_h8"; 97 | static const char SERVER_TIME_UTC[] = "SERVER_TIME_UTC"; 98 | static const char SupportTickVolume[] = "SupportTickVolume"; 99 | static const char TP_170[] = "TP_170"; 100 | static const char TP_171[] = "TP_171"; 101 | static const char TP_172[] = "TP_172"; 102 | static const char TP_86[] = "TP_86"; 103 | static const char TP_88[] = "TP_88"; 104 | static const char TP_89[] = "TP_89"; 105 | static const char TP_94[] = "TP_94"; 106 | static const char CP_170[] = "CP_170"; 107 | static const char CP_171[] = "CP_171"; 108 | static const char CP_172[] = "CP_172"; 109 | static const char CP_86[] = "CP_86"; 110 | static const char CP_88[] = "CP_88"; 111 | static const char CP_89[] = "CP_89"; 112 | static const char CP_94[] = "CP_94"; 113 | static const char TRAILING_DYNAMIC[] = "TRAILING_DYNAMIC"; 114 | static const char TRAILING_FLUCTUATE[] = "TRAILING_FLUCTUATE"; 115 | static const char TRAILING_FLUCTUATE_PTS_MAX[] = "TRAILING_FLUCTUATE_PTS_MAX"; 116 | static const char TRAILING_FLUCTUATE_PTS_MIN[] = "TRAILING_FLUCTUATE_PTS_MIN"; 117 | static const char PEGGED_STOP_LIMIT_DISABLED[] = "PEGGED_STOP_LIMIT_DISABLED"; 118 | 119 | } 120 | } 121 | 122 | -------------------------------------------------------------------------------- /includes/forexconnect/IO2GSession.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Order2Go2 IO2GSessionDescriptor : public IAddRef 4 | { 5 | protected: 6 | IO2GSessionDescriptor(); 7 | public: 8 | /** Gets the unique identifier of the descriptor. */ 9 | virtual const char * getID() = 0; 10 | /** Gets the readable name of the descriptor. */ 11 | virtual const char *getName() = 0; 12 | /** Gets the description of the descriptor. */ 13 | virtual const char *getDescription() = 0; 14 | 15 | virtual bool requiresPin() = 0; 16 | }; 17 | 18 | class Order2Go2 IO2GSessionDescriptorCollection : public IAddRef 19 | { 20 | protected: 21 | IO2GSessionDescriptorCollection(); 22 | public: 23 | /** Gets number of session descriptors. */ 24 | virtual int size() = 0; 25 | /** Gets the session descriptor by index.*/ 26 | virtual IO2GSessionDescriptor *get(int index) = 0; 27 | }; 28 | 29 | class Order2Go2 IO2GSessionStatus : public IAddRef 30 | { 31 | protected: 32 | IO2GSessionStatus(); 33 | public: 34 | typedef enum 35 | { 36 | Disconnected = 0, 37 | Connecting = 1, 38 | TradingSessionRequested = 2, 39 | Connected = 3, 40 | Reconnecting = 4, 41 | Disconnecting = 5, 42 | SessionLost = 6, 43 | PriceSessionReconnecting = 7, 44 | ConnectedWithNeedToChangePassword = 8 45 | } O2GSessionStatus; 46 | 47 | virtual void onSessionStatusChanged(O2GSessionStatus status) = 0; 48 | virtual void onLoginFailed(const char *error) = 0; 49 | }; 50 | 51 | class Order2Go2 IO2GTableManagerListener : public IAddRef 52 | { 53 | protected: 54 | IO2GTableManagerListener(); 55 | public: 56 | virtual void onStatusChanged(O2GTableManagerStatus status, IO2GTableManager *tableManager) = 0; 57 | }; 58 | 59 | 60 | 61 | class Order2Go2 IO2GSession : public IAddRef 62 | { 63 | protected: 64 | IO2GSession(); 65 | public: 66 | virtual IO2GLoginRules *getLoginRules() = 0; 67 | /** Establishes connection with the trade server.*/ 68 | virtual void login(const char *user, const char *pwd, const char *url, const char *connection) = 0; 69 | /** Closes connection with the trade server.*/ 70 | virtual void logout() = 0; 71 | /* Subscribes the session status listener.*/ 72 | virtual void subscribeSessionStatus(IO2GSessionStatus *listener) = 0; 73 | /* Unsubscribes the session status listener.*/ 74 | virtual void unsubscribeSessionStatus(IO2GSessionStatus *listener) = 0; 75 | /** Gets the session descriptors collection.*/ 76 | virtual IO2GSessionDescriptorCollection *getTradingSessionDescriptors() = 0; 77 | /** Sets the trading session identifier and pin.*/ 78 | virtual void setTradingSession(const char *sessionId, const char *pin) = 0; 79 | /** Subscribes response listener.*/ 80 | virtual void subscribeResponse(IO2GResponseListener *listener) = 0; 81 | /** Unsubscribes response listener.*/ 82 | virtual void unsubscribeResponse(IO2GResponseListener *listener) = 0; 83 | /** Get the request factory.*/ 84 | virtual IO2GRequestFactory * getRequestFactory() = 0 ; 85 | /** Gets the response factory reader.*/ 86 | virtual IO2GResponseReaderFactory *getResponseReaderFactory() = 0; 87 | /** Send the request to the trade server.*/ 88 | virtual void sendRequest(IO2GRequest *request) = 0; 89 | /** Gets time converter for converting request and markes snapshot date.*/ 90 | virtual IO2GTimeConverter *getTimeConverter() = 0; 91 | /** Set session mode.*/ 92 | virtual void setPriceUpdateMode(O2GPriceUpdateMode mode) = 0; 93 | /** Get session mode.*/ 94 | virtual O2GPriceUpdateMode getPriceUpdateMode() = 0; 95 | /** Get server time.*/ 96 | virtual DATE getServerTime() = 0; 97 | /** Gets report URL. 98 | 99 | @param urlBuffer [out] URL buffer. 100 | @param bufferSize Buffer size. 101 | @param account Account. 102 | @param dateFrom Start date of the report period. 103 | @param dateTo End date of the report period. 104 | @param format Report format. HTML will be used in case of 0. 105 | @param reportType Report type. 106 | @param langID Language and locale of the report. 107 | @param ansiCP Code page. 108 | 109 | @return Number of characters written to the URL buffer if the function succeeds and urlBuffer is nonzero. 110 | The required size, in characters, for a buffer that can receive the URL string if the function succeeds and urlBuffer is zero. 111 | Negative value indicates failure. See O2GReportUrlError for possible values. 112 | */ 113 | virtual int getReportURL(char* urlBuffer, int bufferSize, IO2GAccountRow* account, 114 | DATE dateFrom, DATE dateTo, const char* format, const char* reportType, 115 | const char* langID, long ansiCP) = 0; 116 | 117 | /** Get table manager.*/ 118 | virtual IO2GTableManager *getTableManager() = 0; 119 | 120 | /** Get table manager by account.*/ 121 | virtual IO2GTableManager *getTableManagerByAccount(const char *accountID) = 0; 122 | 123 | /** Set how to use table manager.*/ 124 | virtual void useTableManager(O2GTableManagerMode mode, IO2GTableManagerListener *tablesListener) = 0; 125 | 126 | /** Gets current session status.*/ 127 | virtual IO2GSessionStatus::O2GSessionStatus getSessionStatus() = 0; 128 | }; 129 | 130 | -------------------------------------------------------------------------------- /includes/forexconnect/IO2GPermissionChecker.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /** Permission checker.*/ 4 | class IO2GPermissionChecker : public IAddRef 5 | { 6 | protected: 7 | IO2GPermissionChecker(){}; 8 | public: 9 | 10 | /** Whether the open market order can be created. */ 11 | virtual O2GPermissionStatus canCreateMarketOpenOrder(const char* instrument) = 0; 12 | 13 | /** Whether the open market order can be changed. */ 14 | virtual O2GPermissionStatus canChangeMarketOpenOrder(const char* instrument) = 0; 15 | 16 | /** Whether the open market order can be deleted. */ 17 | virtual O2GPermissionStatus canDeleteMarketOpenOrder(const char* instrument) = 0; 18 | 19 | /** Whether the close market order can be created. */ 20 | virtual O2GPermissionStatus canCreateMarketCloseOrder(const char* instrument) = 0; 21 | 22 | /** Whether the close market order can be changed. */ 23 | virtual O2GPermissionStatus canChangeMarketCloseOrder(const char* instrument) = 0; 24 | 25 | /** Whether the close market order can be deleted. */ 26 | virtual O2GPermissionStatus canDeleteMarketCloseOrder(const char* instrument) = 0; 27 | 28 | /** Whether the open entry order can be created. */ 29 | virtual O2GPermissionStatus canCreateEntryOrder(const char* instrument) = 0; 30 | 31 | /** Whether the open entry order can be changed. */ 32 | virtual O2GPermissionStatus canChangeEntryOrder(const char* instrument) = 0; 33 | 34 | /** Whether the open entry order can be deleted. */ 35 | virtual O2GPermissionStatus canDeleteEntryOrder(const char* instrument) = 0; 36 | 37 | /** Whether the open entry order can be created. */ 38 | virtual O2GPermissionStatus canCreateStopLimitOrder(const char* instrument) = 0; 39 | 40 | /** Whether the open entry order can be changed. */ 41 | virtual O2GPermissionStatus canChangeStopLimitOrder(const char* instrument) = 0; 42 | 43 | /** Whether the open entry order can be deleted. */ 44 | virtual O2GPermissionStatus canDeleteStopLimitOrder(const char* instrument) = 0; 45 | 46 | /** Whether it is possible to request a quote. */ 47 | virtual O2GPermissionStatus canRequestQuote(const char* instrument) = 0; 48 | 49 | /** Whether it is possible to accept the quote provided by the dealer. */ 50 | virtual O2GPermissionStatus canAcceptQuote(const char* instrument) = 0; 51 | 52 | /** Whether it is possible to delete the quote provided by the dealer. */ 53 | virtual O2GPermissionStatus canDeleteQuote(const char* instrument) = 0; 54 | 55 | /** Whether it is possible to create the new OCO. */ 56 | virtual O2GPermissionStatus canCreateOCO(const char* instrument) = 0; 57 | 58 | /** Whether it is possible to create the new OTO. */ 59 | virtual O2GPermissionStatus canCreateOTO(const char* instrument) = 0; 60 | 61 | /** Whether it is possible to add new orders to the existing ContingencyGroup or creating new. */ 62 | virtual O2GPermissionStatus canJoinToNewContingencyGroup(const char* instrument) = 0; 63 | 64 | /** Whether it is possible to add new orders to the existing ContingencyGroup or creating new. */ 65 | virtual O2GPermissionStatus canJoinToExistingContingencyGroup(const char* instrument) = 0; 66 | 67 | /** Whether it is possible to exclude orders from the existing ContingencyGroup. */ 68 | virtual O2GPermissionStatus canRemoveFromContingencyGroup(const char* instrument) = 0; 69 | 70 | /** Whether it is possible to change the offers subscription. */ 71 | virtual O2GPermissionStatus canChangeOfferSubscription(const char* instrument) = 0; 72 | 73 | /** Determines whether the user may create order for close all positions for an instrument on an account. */ 74 | virtual O2GPermissionStatus canCreateNetCloseOrder(const char* instrument) = 0; 75 | 76 | /** Determines whether the user may change order for close all positions for an instrument on an account. */ 77 | virtual O2GPermissionStatus canChangeNetCloseOrder(const char* instrument) = 0; 78 | 79 | /** Determines whether the user may delete order for close all positions for an instrument on an account. */ 80 | virtual O2GPermissionStatus canDeleteNetCloseOrder(const char* instrument) = 0; 81 | 82 | /** Determines whether the user may create net stop/limit order. */ 83 | virtual O2GPermissionStatus canCreateNetStopLimitOrder(const char* instrument) = 0; 84 | 85 | /** Determines whether the user may change net stop/limit order. */ 86 | virtual O2GPermissionStatus canChangeNetStopLimitOrder(const char* instrument) = 0; 87 | 88 | /** Determines whether the user may delete net stop/limit order. */ 89 | virtual O2GPermissionStatus canDeleteNetStopLimitOrder(const char* instrument) = 0; 90 | 91 | /** Determines whether the trailing stop is dymanic */ 92 | virtual O2GPermissionStatus canUseDynamicTrailingForStop() = 0; 93 | 94 | /** Determines whether the trailing limit is dymanic */ 95 | virtual O2GPermissionStatus canUseDynamicTrailingForLimit() = 0; 96 | 97 | /** Determines whether the trailing entry stop is dymanic */ 98 | virtual O2GPermissionStatus canUseDynamicTrailingForEntryStop() = 0; 99 | 100 | /** Determines whether the trailing entry limit is dymanic */ 101 | virtual O2GPermissionStatus canUseDynamicTrailingForEntryLimit() = 0; 102 | 103 | /** Determines whether the trailing stop is fluctuate */ 104 | virtual O2GPermissionStatus canUseFluctuateTrailingForStop() = 0; 105 | 106 | /** Determines whether the trailing limit is fluctuate */ 107 | virtual O2GPermissionStatus canUseFluctuateTrailingForLimit() = 0; 108 | 109 | /** Determines whether the trailing entry stop is fluctuate */ 110 | virtual O2GPermissionStatus canUseFluctuateTrailingForEntryStop() = 0; 111 | 112 | /** Determines whether the trailing entry limit is fluctuate */ 113 | virtual O2GPermissionStatus canUseFluctuateTrailingForEntryLimit() = 0; 114 | }; 115 | 116 | -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GOrderRow.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | using namespace boost::python; 4 | 5 | class IO2GOrderRowWrap : public IO2GOrderRow, public wrapper < IO2GOrderRow > 6 | { 7 | public: 8 | const char* getOrderID(){ return this->get_override("getOrderID")();} 9 | const char* getRequestID(){ return this->get_override("getRequestID")();} 10 | double getRate(){ return this->get_override("getRate")();} 11 | double getExecutionRate(){ return this->get_override("getExecutionRate")();} 12 | double getRateMin(){ return this->get_override("getRateMin")();} 13 | double getRateMax(){ return this->get_override("getRateMax")();} 14 | const char* getTradeID(){ return this->get_override("getTradeID")();} 15 | const char* getAccountID(){ return this->get_override("getAccountID")();} 16 | const char* getAccountName(){ return this->get_override("getAccountName")();} 17 | const char* getOfferID(){ return this->get_override("getOfferID")();} 18 | bool getNetQuantity(){ return this->get_override("getNetQuantity")();} 19 | const char* getBuySell(){ return this->get_override("getBuySell")();} 20 | const char* getStage(){ return this->get_override("getStage")();} 21 | const char* getType(){ return this->get_override("getType")();} 22 | const char* getStatus(){ return this->get_override("getStatus")();} 23 | DATE getStatusTime(){ return this->get_override("getStatusTime")();} 24 | int getAmount(){ return this->get_override("getAmount")();} 25 | double getLifetime(){ return this->get_override("getLifetime")();} 26 | double getAtMarket(){ return this->get_override("getAtMarket")();} 27 | int getTrailStep(){ return this->get_override("getTrailStep")();} 28 | double getTrailRate(){ return this->get_override("getTrailRate")();} 29 | const char* getTimeInForce(){ return this->get_override("getTimeInForce")();} 30 | const char* getAccountKind(){ return this->get_override("getAccountKind")();} 31 | const char* getRequestTXT(){ return this->get_override("getRequestTXT")();} 32 | const char* getContingentOrderID(){ return this->get_override("getContingentOrderID")();} 33 | int getContingencyType(){ return this->get_override("getContingencyType")();} 34 | const char* getPrimaryID(){ return this->get_override("getPrimaryID")();} 35 | int getOriginAmount(){ return this->get_override("getOriginAmount")();} 36 | int getFilledAmount(){ return this->get_override("getFilledAmount")();} 37 | bool getWorkingIndicator(){ return this->get_override("getWorkingIndicator")();} 38 | const char* getPegType(){ return this->get_override("getPegType")();} 39 | double getPegOffset(){ return this->get_override("getPegOffset")();} 40 | DATE getExpireDate(){ return this->get_override("getExpireDate")();} 41 | const char* getValueDate(){ return this->get_override("getValueDate")();} 42 | const char* getParties(){ return this->get_override("getParties")();} 43 | }; 44 | 45 | class IO2GOrderTableRowWrap : public IO2GOrderTableRow, public wrapper < IO2GOrderTableRow > 46 | { 47 | public: 48 | double getStop(){ return this->get_override("getStop")();} 49 | double getLimit(){ return this->get_override("getLimit")();} 50 | int getStopTrailStep(){ return this->get_override("getStopTrailStep")();} 51 | double getStopTrailRate(){ return this->get_override("getStopTrailRate")();} 52 | }; 53 | 54 | void export_IO2GOrderRow() 55 | { 56 | class_, boost::noncopyable>("IO2GOrderRow", no_init) 57 | .def("getOrderID", pure_virtual(&IO2GOrderRow::getOrderID)) 58 | .def("getRequestID", pure_virtual(&IO2GOrderRow::getRequestID)) 59 | .def("getRate", pure_virtual(&IO2GOrderRow::getRate)) 60 | .def("getExecutionRate", pure_virtual(&IO2GOrderRow::getExecutionRate)) 61 | .def("getRateMin", pure_virtual(&IO2GOrderRow::getRateMin)) 62 | .def("getRateMax", pure_virtual(&IO2GOrderRow::getRateMax)) 63 | .def("getTradeID", pure_virtual(&IO2GOrderRow::getTradeID)) 64 | .def("getAccountID", pure_virtual(&IO2GOrderRow::getAccountID)) 65 | .def("getAccountName", pure_virtual(&IO2GOrderRow::getAccountName)) 66 | .def("getOfferID", pure_virtual(&IO2GOrderRow::getOfferID)) 67 | .def("getNetQuantity", pure_virtual(&IO2GOrderRow::getNetQuantity)) 68 | .def("getBuySell", pure_virtual(&IO2GOrderRow::getBuySell)) 69 | .def("getStage", pure_virtual(&IO2GOrderRow::getStage)) 70 | .def("getType", pure_virtual(&IO2GOrderRow::getType)) 71 | .def("getStatus", pure_virtual(&IO2GOrderRow::getStatus)) 72 | .def("getStatusTime", pure_virtual(&IO2GOrderRow::getStatusTime)) 73 | .def("getAmount", pure_virtual(&IO2GOrderRow::getAmount)) 74 | .def("getLifetime", pure_virtual(&IO2GOrderRow::getLifetime)) 75 | .def("getAtMarket", pure_virtual(&IO2GOrderRow::getAtMarket)) 76 | .def("getTrailStep", pure_virtual(&IO2GOrderRow::getTrailStep)) 77 | .def("getTrailRate", pure_virtual(&IO2GOrderRow::getTrailRate)) 78 | .def("getTimeInForce", pure_virtual(&IO2GOrderRow::getTimeInForce)) 79 | .def("getAccountKind", pure_virtual(&IO2GOrderRow::getAccountKind)) 80 | .def("getRequestTXT", pure_virtual(&IO2GOrderRow::getRequestTXT)) 81 | .def("getContingentOrderID", pure_virtual(&IO2GOrderRow::getContingentOrderID)) 82 | .def("getContingencyType", pure_virtual(&IO2GOrderRow::getContingencyType)) 83 | .def("getPrimaryID", pure_virtual(&IO2GOrderRow::getPrimaryID)) 84 | .def("getOriginAmount", pure_virtual(&IO2GOrderRow::getOriginAmount)) 85 | .def("getFilledAmount", pure_virtual(&IO2GOrderRow::getFilledAmount)) 86 | .def("getWorkingIndicator", pure_virtual(&IO2GOrderRow::getWorkingIndicator)) 87 | .def("getPegType", pure_virtual(&IO2GOrderRow::getPegType)) 88 | .def("getPegOffset", pure_virtual(&IO2GOrderRow::getPegOffset)) 89 | .def("getExpireDate", pure_virtual(&IO2GOrderRow::getExpireDate)) 90 | .def("getValueDate", pure_virtual(&IO2GOrderRow::getValueDate)) 91 | .def("getParties", pure_virtual(&IO2GOrderRow::getParties)) 92 | ; 93 | 94 | class_, boost::noncopyable>("IO2GOrderTableRow", no_init) 95 | .def("getStop", pure_virtual(&IO2GOrderTableRow::getStop)) 96 | .def("getLimit", pure_virtual(&IO2GOrderTableRow::getLimit)) 97 | .def("getStopTrailStep", pure_virtual(&IO2GOrderTableRow::getStopTrailStep)) 98 | .def("getStopTrailRate", pure_virtual(&IO2GOrderTableRow::getStopTrailRate)) 99 | ; 100 | }; -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GResponse.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "IO2GResponse.h" 3 | #include "ResponseListener.h" 4 | 5 | using namespace boost::python; 6 | 7 | class IO2GResponseWrap : public IO2GResponse, public wrapper < IO2GResponse > 8 | { 9 | public: 10 | O2GResponseType getType() { return this->get_override("getType")(); } 11 | const char * getRequestID() { return this->get_override("getRequestID")(); } 12 | }; 13 | 14 | class IO2GResponseListenerWrap : public IO2GResponseListener, public wrapper < IO2GResponseListener > 15 | { 16 | public: 17 | void onRequestCompleted(const char * requestId, IO2GResponse* response = 0) { this->get_override("onRequestCompleted")(); } 18 | void onRequestFailed(const char *, const char *) { this->get_override("onRequestFailed")(); } 19 | void onTablesUpdates(IO2GResponse *) { this->get_override("onTablesUpdates")(); } 20 | }; 21 | 22 | 23 | class IO2GResponseReaderFactoryWrap : public IO2GResponseReaderFactory, public wrapper < IO2GResponseReaderFactory > 24 | { 25 | public: 26 | IO2GTablesUpdatesReader* createTablesUpdatesReader(IO2GResponse *response){ return this->get_override("createTablesUpdatesReader")(); } 27 | IO2GMarketDataSnapshotResponseReader* createMarketDataSnapshotReader(IO2GResponse *response){ return this->get_override("createMarketDataSnapshotReader")(); } 28 | IO2GMarketDataResponseReader* createMarketDataReader(IO2GResponse *response){ return this->get_override("createMarketDataReader")(); } 29 | IO2GOffersTableResponseReader* createOffersTableReader(IO2GResponse *response){ return this->get_override("createOffersTableReader")(); } 30 | IO2GAccountsTableResponseReader* createAccountsTableReader(IO2GResponse *response){ return this->get_override("createAccountsTableReader")(); } 31 | IO2GOrdersTableResponseReader* createOrdersTableReader(IO2GResponse *response){ return this->get_override("createOrdersTableReader")(); } 32 | IO2GTradesTableResponseReader* createTradesTableReader(IO2GResponse *response){ return this->get_override("createTradesTableReader")(); } 33 | IO2GClosedTradesTableResponseReader* createClosedTradesTableReader(IO2GResponse *response){ return this->get_override("createClosedTradesTableReader")(); } 34 | IO2GMessagesTableResponseReader* createMessagesTableReader(IO2GResponse *response){ return this->get_override("createMessagesTableReader")(); } 35 | IO2GOrderResponseReader* createOrderResponseReader(IO2GResponse *response){ return this->get_override("createOrderResponseReader")(); } 36 | IO2GLastOrderUpdateResponseReader* createLastOrderUpdateResponseReader(IO2GResponse *response){ return this->get_override("createLastOrderUpdateResponseReader")(); } 37 | IO2GSystemPropertiesReader* createSystemPropertiesReader(IO2GResponse *response){ return this->get_override("createSystemPropertiesReader")(); } 38 | bool processMarginRequirementsResponse(IO2GResponse *response){ return this->get_override("processMarginRequirementsResponse")(); } 39 | }; 40 | 41 | //BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(onRequestCompleted_overload, onRequestCompleted, 1, 2) 42 | 43 | void export_IO2GResponse() 44 | { 45 | 46 | //void(IO2GResponseListener::*orq)(const char *, IO2GResponse *) = &IO2GResponseListener::onRequestCompleted; 47 | 48 | class_, boost::noncopyable>("IO2GResponse", no_init) 49 | .def("getType", pure_virtual(&IO2GResponse::getType)) 50 | .def("getRequestID", pure_virtual(&IO2GResponse::getRequestID)) 51 | ; 52 | class_, boost::noncopyable>("IO2GResponseListener", no_init) 53 | .def("onRequestCompleted", pure_virtual(&IO2GResponseListener::onRequestCompleted), (arg("requestId"), arg("response") = 0)) 54 | //onRequestCompleted_overload(args("requestId", "response"), "doc str")) 55 | .def("onRequestFailed", pure_virtual(&IO2GResponseListener::onRequestFailed)) 56 | .def("onTablesUpdates", pure_virtual(&IO2GResponseListener::onTablesUpdates)) 57 | ; 58 | class_, boost::noncopyable >("IO2GResponseReaderFactory", no_init) 59 | .def("createTablesUpdatesReader", pure_virtual(&IO2GResponseReaderFactory::createTablesUpdatesReader), return_value_policy()) 60 | .def("createMarketDataSnapshotReader", pure_virtual(&IO2GResponseReaderFactory::createMarketDataSnapshotReader), return_value_policy()) 61 | .def("createMarketDataReader", pure_virtual(&IO2GResponseReaderFactory::createMarketDataReader), return_value_policy()) 62 | .def("createOffersTableReader", pure_virtual(&IO2GResponseReaderFactory::createOffersTableReader), return_value_policy()) 63 | .def("createAccountsTableReader", pure_virtual(&IO2GResponseReaderFactory::createAccountsTableReader), return_value_policy()) 64 | .def("createOrdersTableReader", pure_virtual(&IO2GResponseReaderFactory::createOrdersTableReader), return_value_policy()) 65 | .def("createTradesTableReader", pure_virtual(&IO2GResponseReaderFactory::createTradesTableReader), return_value_policy()) 66 | .def("createClosedTradesTableReader", pure_virtual(&IO2GResponseReaderFactory::createClosedTradesTableReader), return_value_policy()) 67 | .def("createMessagesTableReader", pure_virtual(&IO2GResponseReaderFactory::createMessagesTableReader), return_value_policy()) 68 | .def("createOrderResponseReader", pure_virtual(&IO2GResponseReaderFactory::createOrderResponseReader), return_value_policy()) 69 | .def("createLastOrderUpdateResponseReader", pure_virtual(&IO2GResponseReaderFactory::createLastOrderUpdateResponseReader), return_value_policy()) 70 | .def("createSystemPropertiesReader", pure_virtual(&IO2GResponseReaderFactory::createSystemPropertiesReader), return_value_policy()) 71 | .def("processMarginRequirementsResponse", pure_virtual(&IO2GResponseReaderFactory::processMarginRequirementsResponse)) 72 | ; 73 | 74 | class_>("ResponseListener", init()) 75 | .def("getResponse", &ResponseListener::getResponse, return_value_policy()) 76 | .def("onRequestCompleted", &ResponseListener::onRequestCompleted) 77 | .def("onRequestFailed", &ResponseListener::onRequestFailed) 78 | .def("onTablesUpdates", &ResponseListener::onTablesUpdates) 79 | ; 80 | }; -------------------------------------------------------------------------------- /src/ForexConnectClient/forex.connect/IO2GOfferRow.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | using namespace boost::python; 5 | 6 | class IO2GOfferRowWrap : public IO2GOfferRow, public wrapper < IO2GOfferRow > 7 | { 8 | public: 9 | const char* getOfferID(){ return this->get_override("getOfferID")(); } 10 | const char* getInstrument(){ return this->get_override("getInstrument")(); } 11 | const char* getQuoteID(){ return this->get_override("getQuoteID")(); } 12 | double getBid(){ return this->get_override("getBid")(); } 13 | double getAsk(){ return this->get_override("getAsk")(); } 14 | double getLow(){ return this->get_override("getLow")(); } 15 | double getHigh(){ return this->get_override("getHigh")(); } 16 | int getVolume(){ return this->get_override("getVolume")(); } 17 | DATE getTime(){ return this->get_override("getTime")(); } 18 | const char* getBidTradable(){ return this->get_override("getBidTradable")(); } 19 | const char* getAskTradable(){ return this->get_override("getAskTradable")(); } 20 | double getSellInterest(){ return this->get_override("getSellInterest")(); } 21 | double getBuyInterest(){ return this->get_override("getBuyInterest")(); } 22 | const char* getContractCurrency(){ return this->get_override("getContractCurrency")(); } 23 | int getDigits(){ return this->get_override("getDigits")(); } 24 | double getPointSize(){ return this->get_override("getPointSize")(); } 25 | const char* getSubscriptionStatus(){ return this->get_override("getSubscriptionStatus")(); } 26 | int getInstrumentType(){ return this->get_override("getInstrumentType")(); } 27 | double getContractMultiplier(){ return this->get_override("getContractMultiplier")(); } 28 | const char* getTradingStatus(){ return this->get_override("getTradingStatus")(); } 29 | const char* getValueDate(){ return this->get_override("getValueDate")(); } 30 | bool isOfferIDValid(){ return this->get_override("isOfferIDValid")(); } 31 | bool isInstrumentValid(){ return this->get_override("isInstrumentValid")(); } 32 | bool isQuoteIDValid(){ return this->get_override("isQuoteIDValid")(); } 33 | bool isBidValid(){ return this->get_override("isBidValid")(); } 34 | bool isAskValid(){ return this->get_override("isAskValid")(); } 35 | bool isLowValid(){ return this->get_override("isLowValid")(); } 36 | bool isHighValid(){ return this->get_override("isHighValid")(); } 37 | bool isVolumeValid(){ return this->get_override("isVolumeValid")(); } 38 | bool isTimeValid(){ return this->get_override("isTimeValid")(); } 39 | bool isBidTradableValid(){ return this->get_override("isBidTradableValid")(); } 40 | bool isAskTradableValid(){ return this->get_override("isAskTradableValid")(); } 41 | bool isSellInterestValid(){ return this->get_override("isSellInterestValid")(); } 42 | bool isBuyInterestValid(){ return this->get_override("isBuyInterestValid")(); } 43 | bool isContractCurrencyValid(){ return this->get_override("isContractCurrencyValid")(); } 44 | bool isDigitsValid(){ return this->get_override("isDigitsValid")(); } 45 | bool isPointSizeValid(){ return this->get_override("isPointSizeValid")(); } 46 | bool isSubscriptionStatusValid(){ return this->get_override("isSubscriptionStatusValid")(); } 47 | bool isInstrumentTypeValid(){ return this->get_override("isInstrumentTypeValid")(); } 48 | bool isContractMultiplierValid(){ return this->get_override("isContractMultiplierValid")(); } 49 | bool isTradingStatusValid(){ return this->get_override("isTradingStatusValid")(); } 50 | bool isValueDateValid(){ return this->get_override("isValueDateValid")(); } 51 | }; 52 | 53 | class IO2GOfferTableRowWrap : public IO2GOfferTableRow, public wrapper < IO2GOfferTableRow > 54 | { 55 | public: 56 | double getPipCost() { return this->get_override("getPipCost")(); } 57 | }; 58 | 59 | void export_IO2GOfferRow() 60 | { 61 | class_, boost::noncopyable>("IO2GOfferRow", no_init) 62 | .def("getOfferID", pure_virtual(&IO2GOfferRow::getOfferID)) 63 | .def("getInstrument", pure_virtual(&IO2GOfferRow::getInstrument)) 64 | .def("getQuoteID", pure_virtual(&IO2GOfferRow::getQuoteID)) 65 | .def("getBid", pure_virtual(&IO2GOfferRow::getBid)) 66 | .def("getAsk", pure_virtual(&IO2GOfferRow::getAsk)) 67 | .def("getLow", pure_virtual(&IO2GOfferRow::getLow)) 68 | .def("getHigh", pure_virtual(&IO2GOfferRow::getHigh)) 69 | .def("getVolume", pure_virtual(&IO2GOfferRow::getVolume)) 70 | .def("getTime", pure_virtual(&IO2GOfferRow::getTime)) 71 | .def("getBidTradable", pure_virtual(&IO2GOfferRow::getBidTradable)) 72 | .def("getAskTradable", pure_virtual(&IO2GOfferRow::getAskTradable)) 73 | .def("getSellInterest", pure_virtual(&IO2GOfferRow::getSellInterest)) 74 | .def("getBuyInterest", pure_virtual(&IO2GOfferRow::getBuyInterest)) 75 | .def("getContractCurrency", pure_virtual(&IO2GOfferRow::getContractCurrency)) 76 | .def("getDigits", pure_virtual(&IO2GOfferRow::getDigits)) 77 | .def("getPointSize", pure_virtual(&IO2GOfferRow::getPointSize)) 78 | .def("getSubscriptionStatus", pure_virtual(&IO2GOfferRow::getSubscriptionStatus)) 79 | .def("getInstrumentType", pure_virtual(&IO2GOfferRow::getInstrumentType)) 80 | .def("getContractMultiplier", pure_virtual(&IO2GOfferRow::getContractMultiplier)) 81 | .def("getTradingStatus", pure_virtual(&IO2GOfferRow::getTradingStatus)) 82 | .def("getValueDate", pure_virtual(&IO2GOfferRow::getValueDate)) 83 | .def("isOfferIDValid", pure_virtual(&IO2GOfferRow::isOfferIDValid)) 84 | .def("isInstrumentValid", pure_virtual(&IO2GOfferRow::isInstrumentValid)) 85 | .def("isQuoteIDValid", pure_virtual(&IO2GOfferRow::isQuoteIDValid)) 86 | .def("isBidValid", pure_virtual(&IO2GOfferRow::isBidValid)) 87 | .def("isAskValid", pure_virtual(&IO2GOfferRow::isAskValid)) 88 | .def("isLowValid", pure_virtual(&IO2GOfferRow::isLowValid)) 89 | .def("isHighValid", pure_virtual(&IO2GOfferRow::isHighValid)) 90 | .def("isVolumeValid", pure_virtual(&IO2GOfferRow::isVolumeValid)) 91 | .def("isTimeValid", pure_virtual(&IO2GOfferRow::isTimeValid)) 92 | .def("isBidTradableValid", pure_virtual(&IO2GOfferRow::isBidTradableValid)) 93 | .def("isAskTradableValid", pure_virtual(&IO2GOfferRow::isAskTradableValid)) 94 | .def("isSellInterestValid", pure_virtual(&IO2GOfferRow::isSellInterestValid)) 95 | .def("isBuyInterestValid", pure_virtual(&IO2GOfferRow::isBuyInterestValid)) 96 | .def("isContractCurrencyValid", pure_virtual(&IO2GOfferRow::isContractCurrencyValid)) 97 | .def("isDigitsValid", pure_virtual(&IO2GOfferRow::isDigitsValid)) 98 | .def("isPointSizeValid", pure_virtual(&IO2GOfferRow::isPointSizeValid)) 99 | .def("isSubscriptionStatusValid", pure_virtual(&IO2GOfferRow::isSubscriptionStatusValid)) 100 | .def("isInstrumentTypeValid", pure_virtual(&IO2GOfferRow::isInstrumentTypeValid)) 101 | .def("isContractMultiplierValid", pure_virtual(&IO2GOfferRow::isContractMultiplierValid)) 102 | .def("isTradingStatusValid", pure_virtual(&IO2GOfferRow::isTradingStatusValid)) 103 | .def("isValueDateValid", pure_virtual(&IO2GOfferRow::isValueDateValid)) 104 | ; 105 | 106 | class_, boost::noncopyable>("IO2GOfferTableRow", no_init) 107 | .def("getPipCost", pure_virtual(&IO2GOfferTableRow::getPipCost)) 108 | ; 109 | }; 110 | --------------------------------------------------------------------------------