Jump to content

NoizeBit

Active Members
  • Posts

    51
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

NoizeBit's Achievements

Wayfarer

Wayfarer (2/7)

1

Reputation

  1. I've managed to fix it by invoking a macro to do the same task. It will be easier to maintain. Thanks.
  2. You're right, edited my previous post with the full code, a part of it was missing from file I've copied from originally
  3. The site has not changed a bit, tags remain the same. Here's the full script: #include <Date.au3> #include <File.au3> #include <IE.au3> Global $oIE = _IECreate("https://www.bosscapital.com/app/?lang=EN#Trade", 0, 0, 1, 0) Global $Broker_User = "xxx" Global $Broker_Pass = "yyy" Global $Balance_File = @ScriptDir & "\balance.txt" CheckIfLoginBroker() Sleep(5000) Global $sCurrentBalance Global $sPreviousBalance = GetPreviousBalance() $tags = $oIE.document.GetElementsByTagName("div") For $tag In $tags $class_value = $tag.GetAttribute("class") If $class_value = "gwt-HTML" Then $sCurrentBalance = $tag.innerText FileWriteLine($Balance_File, _NowDate() & @TAB & $sCurrentBalance) ExitLoop EndIf Next Global $iCurrentBalanceCalc = StringTrimLeft($sCurrentBalance, 1) Global $iPreviousBalanceCalc = StringTrimLeft($sPreviousBalance, 1) Global $iBalanceDifference = Round($iCurrentBalanceCalc - $iPreviousBalanceCalc, 2) Global $iBalDiffPerc = Round($iBalanceDifference / $iPreviousBalanceCalc * 100, 2) Global $iBalanceDifferenceAbs, $sSignBal Global $iBalDiffPercAbs, $sSignPerc Global $sTextColor If $iBalanceDifference < 0 Then $iBalanceDifferenceAbs = StringTrimLeft($iBalanceDifference, 1) $sSignBal = "-" $sTextColor = "188, 14, 25" ElseIf $iBalanceDifference > 0 Then $iBalanceDifferenceAbs = $iBalanceDifference $sSignBal = "+" $sTextColor = "111, 178, 56" Else $iBalanceDifferenceAbs = $iBalanceDifference $sSignBal = "" $sTextColor = "251, 213, 57" EndIf If $iBalDiffPerc < 0 Then $iBalDiffPercAbs = StringTrimLeft($iBalDiffPerc, 1) $sSignPerc = "-" ElseIf $iBalDiffPerc > 0 Then $iBalDiffPercAbs = $iBalDiffPerc $sSignPerc = "+" Else $iBalDiffPercAbs = "0" $sSignPerc = "" EndIf _IEQuit($oIE) Func GetPreviousBalance() $tempString = FileRead($Balance_File) If StringInStr($tempString, @TAB) < 1 Then Return 0 Return StringTrimLeft($tempString, StringInStr($tempString, @TAB, 0, -1)) EndFunc ;==>GetPreviousBalance Func CheckIfLoginBroker() ;Look for login form on broker's site (active status) $tags = $oIE.document.GetElementsByTagName("input") $found = False For $tag In $tags $class_value = $tag.GetAttribute("class") If $class_value = "gwt-TextBox navigation_menu_username_field" Then $tag.click() $found = True ExitLoop EndIf Next If $found Then ;Login if login form is visible (inactive status) $tags = $oIE.document.GetElementsByTagName("input") $found = False For $tag In $tags $class_value = $tag.GetAttribute("class") If $class_value = "gwt-TextBox navigation_menu_username_field" Then _IEFormElementSetValue($tag, $Broker_User) EndIf If $class_value = "gwt-TextBox navigation_menu_password_field" Then _IEFormElementSetValue($tag, $Broker_Pass) EndIf Next $tags = $oIE.document.GetElementsByTagName("div") $found = False For $tag In $tags $class_value = $tag.GetAttribute("class") If $class_value = "navigation_menu_login_button" Then $tag.click() ExitLoop EndIf Next Sleep(5000) _IELoadWait($oIE) EndIf EndFunc ;==>CheckIfLoginBroker
  4. Fellow Scripters, Once again I'd like to ask for some assistance on a strange issue I've encountered recently. The snippet looks like this: $tags = $oIE.document.GetElementsByTagName("div") For $tag In $tags $class_value = $tag.GetAttribute("class") If $class_value = "gwt-HTML" Then $sCurrentBalance = $tag.innerText FileWriteLine($Balance_File, _NowDate() & @TAB & $sCurrentBalance) ExitLoop EndIf Next This was working correctly about a year ago, but now the command FileWriteLine($Balance_File, _NowDate() & @TAB & $sCurrentBalance) doesn't do anything and the variable $sCurrentBalance doesn't show it's value using MsgBox. Strangely, some calculations after this part do get the value of this variable and seems not to be affected by this problem. Any thoughts, ideas? I was thinking about that upgrading AutoIt might have something to do with this, but after compiling using a previous version the issue remains nonetheless...
  5. I can't argue with that, but I thank both of you for pushing me toward the right direction
  6. Yeah, only the returning part was a bit cloudy for me, but now it produces the exact result I was looking for, thanks.
  7. Got it, I'll put it to good use
  8. Thanks for the fast reply, czardas! I see now what was missing, thanks for the contribution
  9. I'm trying to put yor UDF inside a function, but I can't figure out why does it return the original data instead of the sorted result? #include <Array.au3> #include <File.au3> #include <ArrayMultiColSort.au3> Global $sSourceCSV = @ScriptDir & "\test.csv" Global $aArray, $sCSVContentSorted SortCSVLines() MsgBox(0, "", $sCSVContentSorted) Func SortCSVLines() ;Sorts lines first by Expiry Time and then by Order Time _FileReadToArray($sSourceCSV, $aArray, ",") For $i = 0 To UBound($aArray) - 1 Local $aSortData[2][2] = [[4, 0], [8, 0]] _ArrayMultiColSort($aArray, $aSortData, 1) $sCSVContentSorted &= $aArray[$i] & @LF Next Return $sCSVContentSorted EndFunc ;==>SortCSVLines
  10. Thanks Melba, I'll update my script accordingly.
  11. Just one thing: how do I return the result to a variable? If I do so it returns only 0, but how do I return the sorted content? #include <Array.au3> #include <File.au3> #include <ArrayMultiColSort.au3> Global $sSourceCSV = @ScriptDir & "\test.csv" Global $sCSVContentSorted SortCSVLines() MsgBox(0, "", $sCSVContentSorted) Func SortCSVLines() ;Sorts lines first by Expiry Time and then by Order Time Local $aArray _FileReadToArray($sSourceCSV, $aArray, $FRTA_NOCOUNT, ",") Local $aSortData[2][2] = [[4, 0], [8, 0]] $sCSVContentSorted = _ArrayMultiColSort($aArray, $aSortData, 1) Return $sCSVContentSorted EndFunc ;==>SortCSVLines
  12. Hi Melba, Thanks a lot, just when I thought I'd have to automate a csv editor to do the sorting you've supplied the best solution Great work!
  13. Hi, I'd like to ask for a little assistance again, but this time related to array sorting. I have the following code: Global $sSourceCSV Global $sCSVContent DeleteCSVEOLCommas() Func DeleteCSVEOLCommas() ;Deletes end of line commas from source .csv file Local $aArray = FileReadToArray($sSourceCSV) For $i = 0 To UBound($aArray) - 1 $sCSVContent &= StringTrimRight($aArray[$i], 1) & @LF Next Return $sCSVContent EndFunc ;==>DeleteCSVEOLCommasAnd the content of $sSourceCSV: Instrument,Type,Asset,Order #,Order Time,Invested,Target Price,Expiry Price,Expiry Time,Return, High / Low,Low,AUD/USD,36007202,02-09-15 17:51:06,24.00,0.70351,0.70414,02-09-15 18:30:00,0.00, High / Low,Low,AUD/USD,36007200,01-09-15 17:45:03,24.00,0.70350,0.70411,02-09-15 18:30:00,0.00, High / Low,Low,NZD/USD,36004443,02-09-15 16:53:52,24.00,0.63465,0.63534,02-09-15 17:30:00,0.00, High / Low,Low,AUD/USD,36004413,02-09-15 16:53:20,24.00,0.70238,0.70347,02-09-15 17:30:00,0.00, This script removes the commas at the end of every line and adds a line feed - this is necessary to be able to process it further with an external application and it's working as intended so far What I'd like to achieve is to sort the lines first according to the "Expiry Time" field (ascending) and then by the "Order Time" field (also ascending). So the result would be this: Instrument,Type,Asset,Order #,Order Time,Invested,Target Price,Expiry Price,Expiry Time,Return High / Low,Low,AUD/USD,36004413,02-09-15 16:53:20,24.00,0.70238,0.70347,02-09-15 17:30:00,0.00 High / Low,Low,NZD/USD,36004443,02-09-15 16:53:52,24.00,0.63465,0.63534,02-09-15 17:30:00,0.00 High / Low,Low,AUD/USD,36007200,01-09-15 17:45:03,24.00,0.70350,0.70411,02-09-15 18:30:00,0.00 High / Low,Low,AUD/USD,36007202,02-09-15 17:51:06,24.00,0.70351,0.70414,02-09-15 18:30:00,0.00 The function should be extended with this part so the returned $sCSVContent var would contain the result. Any ideas are welcome and appreciated
  14. Alright, will do.
  15. @kylomas - you're right, that was the plan, thanks @jguinch - thanks a lot for helping me out
×
×
  • Create New...