コード例 #1
0
ファイル: MSFL.cs プロジェクト: indangerofcollapsing/wow
        public static System.DateTime FormatTime(int lTime)
        {
            StringBuilder szBuf = new StringBuilder(MSFL.MSFL_MAX_NAME_LENGTH + 1);

            MSFL.MSFL1_FormatTime(szBuf, (ushort)szBuf.Capacity, lTime, true);

            return(System.DateTime.Parse(szBuf.ToString()));
        }
コード例 #2
0
        public OptionSub2From( MSFL.MSFLSecurityInfo[] msflSecurityInfoArray )
        {
            InitializeComponent();

            for ( int iIndex = 0; iIndex < msflSecurityInfoArray.Length; iIndex++ )
            {
                MSFL.MSFLSecurityInfo msflSecurityInfo = msflSecurityInfoArray[iIndex];
                string securityInfo = msflSecurityInfo.szName + "[" + msflSecurityInfo.szSymbol + "]";

                m_SecurityDictionary.Add( securityInfo, msflSecurityInfo );

                this.CheckedListBoxStock.Items.Add( securityInfo );
            }
        }
コード例 #3
0
ファイル: MSFL.cs プロジェクト: indangerofcollapsing/wow
        //[DllImport( "MSFL91.dll", CallingConvention = CallingConvention.StdCall )]
        //private static extern int MSFL2_ReadMultipleRecsByDates();

        //[DllImport( "MSFL91.dll", CallingConvention = CallingConvention.StdCall )]
        //private static extern int MSFL2_RemoveDuplicateDataRecs();

        //[DllImport( "MSFL91.dll", CallingConvention = CallingConvention.StdCall )]
        //private static extern int MSFL2_SortData();

        //[DllImport( "MSFL91.dll", CallingConvention = CallingConvention.StdCall )]
        //private static extern int MSFL2_SortSecurities();

        //[DllImport( "MSFL91.dll", CallingConvention = CallingConvention.StdCall )]
        //private static extern int MSFL2_WriteDataRec();

        //[DllImport( "MSFL91.dll", CallingConvention = CallingConvention.StdCall )]
        //private static extern int MSFL2_WriteMultipleRecs();

        /// <summary>
        ///
        /// </summary>
        /// <param name="iErr"></param>
        public static void DisplayMSFLError(int iErr)
        {
            // If there is an error or message
            if (iErr != (int)MSFL_ERR.MSFL_NO_ERR)
            {
                StringBuilder szErrMsg = new StringBuilder(MSFL.MSFL_MAX_ERR_MSG_LENGTH);

                // Get the error/message text from MSFL
                IntPtr ptrStrInfo = MSFL.MSFL1_GetErrorMessage(iErr, szErrMsg, (ushort)szErrMsg.Capacity);
                //String strInfo = Marshal.PtrToStringAuto( ptrStrInfo );

                // If this is a information message, display the text in a message box
                if (iErr > (int)MSFL_ERR.MSFL_NO_ERR)
                {
                    MessageBox.Show(szErrMsg.ToString(), "MSFL Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                // If there is an error, display the text in a message box
                else
                {
                    MessageBox.Show(szErrMsg.ToString(), "MSFL Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #4
0
        public static bool TryLoadMsflPriceInfo( string stockName, string stockSymbol, string strFilePath, out MSFL.MSFLPriceRecord[] msflPriceRecordArray )
        {
            msflPriceRecordArray = new MSFL.MSFLPriceRecord[0];

            if ( Directory.Exists( strFilePath ) == false )
                return false;

            byte dirNumber = 0;

            int iErr = MSFL.MSFL1_OpenDirectory( strFilePath, ref dirNumber, MSFL.MSFL_DIR_FORCE_USER_IN );
            if ( iErr != (int)MSFL.MSFL_ERR.MSFL_NO_ERR )
                return false;

            MSFL.MSFLDirectoryStatus msflDirectoryStatus = new MSFL.MSFLDirectoryStatus();
            msflDirectoryStatus.dwTotalSize = (uint)Marshal.SizeOf( msflDirectoryStatus );

            iErr = MSFL.MSFL1_GetDirectoryStatus( dirNumber, string.Empty, ref msflDirectoryStatus );
            if ( iErr != (int)MSFL.MSFL_ERR.MSFL_NO_ERR )
                return false;

            if ( msflDirectoryStatus.bExists == false || msflDirectoryStatus.bOpen == false || msflDirectoryStatus.bMetaStockDir == false )
                return false;

            MSFL.MSFLSecurityInfo msflSecurityInfo = new MSFL.MSFLSecurityInfo();
            msflSecurityInfo.dwTotalSize = (uint)Marshal.SizeOf( msflSecurityInfo );

            iErr = MSFL.MSFL1_GetFirstSecurityInfo( dirNumber, ref msflSecurityInfo );
            while ( iErr == (int)MSFL.MSFL_ERR.MSFL_NO_ERR || iErr == (int)MSFL.MSFL_Messages.MSFL_MSG_LAST_SECURITY_IN_DIR )
            {
                if ( msflSecurityInfo.szName == stockName && msflSecurityInfo.szSymbol == stockSymbol )
                {
                    iErr = MSFL.MSFL1_LockSecurity( msflSecurityInfo.hSecurity, MSFL.MSFL_LOCK_PREV_WRITE_LOCK );
                    if ( iErr != (int)MSFL.MSFL_ERR.MSFL_NO_ERR )
                        break;

                    ushort wPriceRecCount = 0;
                    iErr = MSFL.MSFL1_GetDataRecordCount( msflSecurityInfo.hSecurity, ref wPriceRecCount );
                    if ( iErr != (int)MSFL.MSFL_ERR.MSFL_NO_ERR )
                        break;

                    if ( wPriceRecCount > 0 )
                    {
                        iErr = MSFL.MSFL1_SeekBeginData( msflSecurityInfo.hSecurity );
                        if ( iErr != (int)MSFL.MSFL_ERR.MSFL_NO_ERR )
                            break;

                        MSFL.DateTime sDateTime = new MSFL.DateTime();
                        msflPriceRecordArray = new MSFL.MSFLPriceRecord[wPriceRecCount];

                        iErr = MSFL.MSFL2_ReadMultipleRecs( msflSecurityInfo.hSecurity, msflPriceRecordArray, ref sDateTime, ref wPriceRecCount, (int)MSFL.MSFL_FIND.MSFL_FIND_USE_CURRENT_POS );
                        if ( iErr != (int)MSFL.MSFL_ERR.MSFL_NO_ERR )
                            break;

                        // Unlock the security (we're done using it)
                        iErr = MSFL.MSFL1_UnlockSecurity( msflSecurityInfo.hSecurity );

                        iErr = MSFL.MSFL1_CloseDirectory( dirNumber );

                        return true;
                    }

                    break;
                }

                if ( iErr == (int)MSFL.MSFL_Messages.MSFL_MSG_LAST_SECURITY_IN_DIR )
                    break;

                iErr = MSFL.MSFL1_GetNextSecurityInfo( msflSecurityInfo.hSecurity, ref msflSecurityInfo );
            }

            MSFL.MSFL1_CloseDirectory( dirNumber );

            return false;
        }
コード例 #5
0
        public static bool TryLoadMsflSecurityInfo( string strFilePath, out MSFL.MSFLSecurityInfo[] msflSecurityInfoArray )
        {
            msflSecurityInfoArray = new MSFL.MSFLSecurityInfo[0];

            if ( Directory.Exists( strFilePath ) == false )
                return false;

            byte dirNumber = 0;

            int iErr = MSFL.MSFL1_OpenDirectory( strFilePath, ref dirNumber, MSFL.MSFL_DIR_FORCE_USER_IN );
            if ( iErr != (int)MSFL.MSFL_ERR.MSFL_NO_ERR )
                return false;

            MSFL.MSFLDirectoryStatus msflDirectoryStatus = new MSFL.MSFLDirectoryStatus();
            msflDirectoryStatus.dwTotalSize = (uint)Marshal.SizeOf( msflDirectoryStatus );

            iErr = MSFL.MSFL1_GetDirectoryStatus( dirNumber, string.Empty, ref msflDirectoryStatus );
            if ( iErr != (int)MSFL.MSFL_ERR.MSFL_NO_ERR )
                return false;

            if ( msflDirectoryStatus.bExists == false || msflDirectoryStatus.bOpen == false || msflDirectoryStatus.bMetaStockDir == false )
                return false;

            List<MSFL.MSFLSecurityInfo> msflSecurityInfoList = new List<MSFL.MSFLSecurityInfo>();

            MSFL.MSFLSecurityInfo msflSecurityInfo = new MSFL.MSFLSecurityInfo();
            msflSecurityInfo.dwTotalSize = (uint)Marshal.SizeOf( msflSecurityInfo );

            iErr = MSFL.MSFL1_GetFirstSecurityInfo( dirNumber, ref msflSecurityInfo );
            while ( iErr == (int)MSFL.MSFL_ERR.MSFL_NO_ERR || iErr == (int)MSFL.MSFL_Messages.MSFL_MSG_LAST_SECURITY_IN_DIR )
            {
                msflSecurityInfoList.Add( msflSecurityInfo );

                if ( iErr == (int)MSFL.MSFL_Messages.MSFL_MSG_LAST_SECURITY_IN_DIR )
                    break;

                msflSecurityInfo = new MSFL.MSFLSecurityInfo();
                msflSecurityInfo.dwTotalSize = (uint)Marshal.SizeOf( msflSecurityInfo );

                iErr = MSFL.MSFL1_GetNextSecurityInfo( msflSecurityInfo.hSecurity, ref msflSecurityInfo );
            }

            MSFL.MSFL1_CloseDirectory( dirNumber );

            msflSecurityInfoArray = msflSecurityInfoList.ToArray();

            return true;
        }
コード例 #6
0
        private static bool IsGDHK( int currentIndex, MSFL.MSFLPriceRecord[] msflPriceRecordArray )
        {
            if ( ( currentIndex + 1 ) > ( msflPriceRecordArray.Length - 1 ) )
                return false;

            float fLow = MSFL.FormatPrice( msflPriceRecordArray[currentIndex].fLow );

            float fHigh = MSFL.FormatPrice( msflPriceRecordArray[currentIndex + 1].fHigh );

            if ( fLow <= fHigh )
                return false;

            return true;
        }
コード例 #7
0
        private static bool IsGDLK( int currentIndex, MSFL.MSFLPriceRecord[] msflPriceRecordArray )
        {
            if ( ( currentIndex - 1 ) < 0 )
                return false;

            float fHigh = MSFL.FormatPrice( msflPriceRecordArray[currentIndex].fHigh );

            float fLow = MSFL.FormatPrice( msflPriceRecordArray[currentIndex - 1].fLow );

            if ( fHigh >= fLow )
                return false;



            return true;
        }
コード例 #8
0
        private static bool IsDCHP_511( int currentIndex, MSFL.MSFLPriceRecord[] msflPriceRecordArray )
        {
            if ( ( currentIndex + 1 ) > ( msflPriceRecordArray.Length - 1 ) )
                return false;

            if ( ( currentIndex - 5 ) < 0 )
                return false;

            float fHigh = MSFL.FormatPrice( msflPriceRecordArray[currentIndex].fHigh );

            if ( MSFL.FormatPrice( msflPriceRecordArray[currentIndex - 1].fHigh ) >= fHigh )
                return false;

            if ( MSFL.FormatPrice( msflPriceRecordArray[currentIndex - 2].fHigh ) >= fHigh )
                return false;

            if ( MSFL.FormatPrice( msflPriceRecordArray[currentIndex - 3].fHigh ) >= fHigh )
                return false;

            if ( MSFL.FormatPrice( msflPriceRecordArray[currentIndex - 4].fHigh ) >= fHigh )
                return false;

            if ( MSFL.FormatPrice( msflPriceRecordArray[currentIndex - 5].fHigh ) >= fHigh )
                return false;

            if ( MSFL.FormatPrice( msflPriceRecordArray[currentIndex + 1].fHigh ) >= fHigh )
                return false;

            return true;
        }
コード例 #9
0
        private static bool IsDCLP_412( int currentIndex, MSFL.MSFLPriceRecord[] msflPriceRecordArray )
        {
            if ( ( currentIndex + 2 ) > ( msflPriceRecordArray.Length - 1 ) )
                return false;

            if ( ( currentIndex - 4 ) < 0 )
                return false;

            float fLow = MSFL.FormatPrice( msflPriceRecordArray[currentIndex].fLow );

            if ( MSFL.FormatPrice( msflPriceRecordArray[currentIndex - 1].fLow ) <= fLow )
                return false;

            if ( MSFL.FormatPrice( msflPriceRecordArray[currentIndex - 2].fLow ) <= fLow )
                return false;

            if ( MSFL.FormatPrice( msflPriceRecordArray[currentIndex - 3].fLow ) <= fLow )
                return false;

            if ( MSFL.FormatPrice( msflPriceRecordArray[currentIndex - 4].fLow ) <= fLow )
                return false;

            if ( MSFL.FormatPrice( msflPriceRecordArray[currentIndex + 1].fLow ) <= fLow )
                return false;

            if ( MSFL.FormatPrice( msflPriceRecordArray[currentIndex + 2].fLow ) <= fLow )
                return false;

            return true;
        }