testmeout Posted July 20, 2007 Posted July 20, 2007 (edited) Ok, so I have been going at this for hours, and I finally had a break through, well sort of. I hardly know anything about dlls, so it might be my error I just don't know.Here's the situation I have a valid open source .net program working and I am trying to recreate it in auto it. So I know what the correct output should be to compare it to.Heres what it should be outputting:OHLC: reqId=2 time=4/17/2007 4:00:00 AM open=473.91 high=476.38 low=471.6 close=472.8 volume=1621659OHLC: reqId=2 time=4/18/2007 4:00:00 AM open=471.26 high=479.89 low=469.57 close=476.01 volume=2756627Message: reqId=2 code=10 description=End of historical data now is 21:00:40.7031250Here is what I am getting:OHLC : reqId=0x00000002 time=2007/04/19 04:00:00 open=0 high=4.66726165096798e-062 low =-4.95295507965927e-136 close=9.45874673648795e-013 volume=15193829061689344OHLC : reqId=0x00000002 time=2007/04/18 04:00:00 open=9223372036854775807 high=3.94265078188669e+234 low =-2.10648611329792e-037 close=-1.7835458927581e+259 volume=11839622812270592Message: reqId=0x00000002 code=10 description=End of historical data Time is 9:09:07 PMInteresting PartThen when I change the OpenPrice to a float instead of a double it almost works except for the shift of the numbers, and the Volume:OHLC : reqId=0x00000002 time=2007/04/19 04:00:00 open=0 high=474.48 low =481.95 close=469.59volume=15193829061689344OHLC : reqId=0x00000002 time=2007/04/18 04:00:00 open=0 high=471.26 low =479.89 close=469.57 volume=11839622812270592Message: reqId=0x00000002 code=10 description=End of historical data Time is 8:53:42 PMHere is the pertinant code:Global Const $StructDef_OTFEEDMSG_HIST_OHLC = "int Timestamp; int64 Volume; double OpenPrice; double HighPrice; double LowPrice; double ClosePrice" case $OTFEED_HIST_OHLC $struct= DllStructCreate($StructDef_OTFEEDMSG_HIST_OHLC, $lParam) $Timestamp=DllStructGetData($struct, "Timestamp") $Volume=DllStructGetData($struct, "Volume") $Open=DllStructGetData($struct, "OpenPrice") $High=DllStructGetData($struct, "HighPrice") $Low=DllStructGetData($struct, "LowPrice") $Close=DllStructGetData($struct, "ClosePrice") $sNewDate = _DateAdd( 's', $Timestamp, "1970/01/01 00:00:00") ConsoleWrite("OHLC : reqId="&$wParam&" time="&$sNewDate&" open="&$Open&" high="&$High&" low ="&$Low&" close="&$Close&" volume="&$Volume) Func RequestHistData($exchange, $symbol, $begdate, $enddate) Local $aResult $iDateCalcbeg = _DateDiff( 's',"1970/01/01 00:00:00", $begdate&" 14:00:00") $iDateCalcend = _DateDiff( 's',"1970/01/01 00:00:00", $enddate&" 14:00:00") $aResult = DllCall($hDLL, "int", "RequestHistData", "str", $exchange, "str", $symbol, "int", $iDateCalcbeg, "int", $iDateCalcend, "int", 5, "int", 1) Writeln("RequestHistData returned: " & $aResult[0]) EndFuncHere is the dll codeOTFEED_HIST_OHLC wParam = (int)RequestId; lParam = (LPARAM)(OTFEEDMSG_HIST_OHLC*); typedef struct _OTFEEDMSG_HIST_OHLC { int Timestamp; __int64 Volume; double OpenPrice; double HighPrice; double LowPrice; double ClosePrice; } OTFEEDMSG_HIST_OHLC;Anyone have any ideas to what is wrong?Any info is greatly appreciated, if anyone is interested in helping me debug this, I would gladly send all of the code Edited July 20, 2007 by testmeout
testmeout Posted July 20, 2007 Author Posted July 20, 2007 Ok so playing with it more I know have all the numbers working, but I have no clue why or how, if someone could explain I would greatly appreciate it. Here is my patch Global Const $StructDef_OTFEEDMSG_HIST_OHLC = "int Timestamp;float test;int64 Volume;double OpenPrice;double HighPrice;double LowPrice;double ClosePrice" I just added the float test ; which has nothing to do with the dll and here is the output: OHLC : reqId=0x00000002 time=2007/04/19 04:00:00 open=474.48 high=481.95 low =469.59 close=471.69 volume=3537589 OHLC : reqId=0x00000002 time=2007/04/18 04:00:00 open=471.26 high=479.89 low =469.57 close=476.01 volume=2756627 Message: reqId=0x00000002 code=10 description=End of historical data Time is 10:15:01 PM It also works as int or anything else just needed a placeholder I guess So yea! it works but I don't know why
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now