# Mini Margin Tool Script

**URL:** <https://forums.eveonline.com/t/mini-margin-tool-script/347775>\
**Category:** Third Party Developers\
**Created:** [January 30, 2022, 1:38am UTC](https://forums.eveonline.com/t/mini-margin-tool-script/347775 "2022-01-30T01:38:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Piastra](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/piastra/32/409475_2.png) [@Piastra](https://forums.eveonline.com/u/Piastra)\
**Post date:** [January 30, 2022, 1:38am UTC](https://forums.eveonline.com/t/mini-margin-tool-script/347775/1 "2022-01-30T01:38:42Z")

</div>

Hello.  
I made a small PowerShell script to check the marginality.  
This script reads Marketlogs when you click on the button “Export to File”

As a rule, the program (PowerShell) is preinstalled in Windows

1. Open Windows Power Shell ISE
2. Сopy and paste the text below
3. Run the script
4. Each time you select a trading position, click “Export to File”

!!! I hope this script does not violate any rules !!!

 ![Снимок.PNG](https://global.discourse-cdn.com/eveonline/original/4X/a/0/3/a0367334b191dff781f8c0c129cf55eda9553889.jpeg)

```auto
# If you liked this script, 
# you can make an ISK donation to the Piastra character
# tnx

$CONFIG = @{
    'BrokerFee' = 0.027
    'SaleTax' = 0.08
    'LogFolderPath' = 'Documents\EVE\logs\Marketlogs'
    'FileType' = '*.txt'
    'Margin' = 2
    'Divider' = 1000000

}

$param = @{
    Path = $env:HOMEPATH + "\$($CONFIG.LogFolderPath)"
    Filter = $CONFIG.FileType -as [string]
}
$LastFile = Get-ChildItem @param |
    Sort-Object LastAccessTime -Descending |
    Select-Object -First 1
 
$PastName = $null
$MarginItemList = [System.Collections.Generic.List[PSObject]]::New() 

while ($true){
    
    $param = @{
        Path = $env:HOMEPATH + "\$($CONFIG.LogFolderPath)" -as [string]
        Filter = $CONFIG.FileType -as [string]
    }
    $LastFile = Get-ChildItem @param |
        Sort-Object LastAccessTime -Descending |
        Select-Object -First 1
    
    $param = @{
        Path = $LastFile.FullName
    }
    $RawItemData = Import-Csv @param

    $MinSellOrder = $($SellOrders.price |
        Select-Object -First 1) -as [float]

    $MinSelle = [math]::Round($($MinSellOrder * (1.0 + $CONFIG.SaleTax)), 2)
    
    $fIndex = $LastFile.Name.IndexOf('-')
    $lIndex = $LastFile.Name.LastIndexOf('-')
    $ItemName = $LastFile.Name.Substring($fIndex + 1, $lIndex - ($fIndex + 1))

    if($PastName -ne $ItemName){
        
        $PastName = $ItemName
        
        $param = @{
            Property = 'price', 'volRemaining', 'volEntered', 'minVolume', 'jumps', 'typeID'
        }
        $SellOrders = $RawItemData |
            Where-Object { $_.bid -eq 'False' -and $_.jumps -eq 0} |
            Select-Object @param
        $BuyOrders = $RawItemData |
            Where-Object { $_.bid -eq 'True' -and $_.jumps -eq 0 } |
            Select-Object @param  

        $MinSellOrder = $($SellOrders.price |
            Select-Object -First 1) -as [float]
        $MaxBuyOrder = $($BuyOrders.price |
            Select-Object -First 1) -as [float]
        
        $ItemData = [pscustomobject]@{
            ItemName = $ItemName
            MaxPossibleBuy = [math]::Round($MaxBuyOrder * (1.0 + $CONFIG.BrokerFee), 2)
            MinPossibleSell = [math]::Round($MinSellOrder - ($MinSellOrder * ($CONFIG.SaleTax + $CONFIG.BrokerFee)), 2)
        }
        if($ItemData.MinPossibleSell -gt $MinSellOrder) {
            $param = @{
                MemberType = 'NoteProperty'
                Name = 'Marginality'
                Value = ($ItemData.MinPossibleSell - $ItemData.MaxPossibleBuy) / $ItemData.MaxPossibleBuy * 100 * - 1
            }
            $ItemData | Add-Member @param
        }
        else {
            $param = @{
                MemberType = 'NoteProperty'
                Name = 'Marginality'
                Value = ($ItemData.MinPossibleSell - $ItemData.MaxPossibleBuy) / $ItemData.MaxPossibleBuy * 100
            }
            $ItemData | Add-Member @param

            $param = @{
                MemberType = 'NoteProperty'
                Name = 'Profit'
                Value = $ItemData.MinPossibleSell - $ItemData.MaxPossibleBuy
            }
            $ItemData | Add-Member @param
        }
        Clear-Host

        if($ItemData.Marginality -gt $CONFIG.Margin){  
             $MarginItemList.Add($ItemData)
        }

        Write-Host "List of margin items: $($MarginItemList.Count)".ToUpper()
        

        $param = @{
            Propert = @(
                @{n='Item'; e={ $_.ItemName } },
                @{n='Spend'; e={ '{0:N6}' -f $($_.MaxPossibleBuy / $CONFIG.Divider) } }
                @{n='Get'; e={ '{0:N6}' -f $($_.MinPossibleSell / $CONFIG.Divider) } }
                @{n='Profit'; e={ '{0:N6}' -f $($_.Profit / $CONFIG.Divider) } }
                @{n='Margin'; e={ '{0:N2} %' -f $_.Marginality } }
            )
        }
        $MarginItemList |
            Sort-Object -Unique -Property Marginality -Descending |
            Select-Object @param |
            ft -Property * -AutoSize

        Write-Host "Checking the item".ToUpper()

        $param = @{
            Propert = @(
                @{n='Item'; e={ $_.ItemName } },
                @{n='Spend'; e={ '{0:N6}' -f $($_.MaxPossibleBuy / $CONFIG.Divider) } }
                @{n='Get'; e={ '{0:N6}' -f $($_.MinPossibleSell / $CONFIG.Divider) } }
                @{n='Profit'; e={ '{0:N6}' -f $($_.Profit / $CONFIG.Divider) } }
                @{n='Margin'; e={ '{0:N2} %' -f $_.Marginality } }
            )
        }
        $ItemDataDisplay = $ItemData | Select-Object @param
        $ItemDataDisplay | ft

     }
    
    Start-Sleep -Seconds 1
}

```

---

<div class="post-metadata">

**Author:** ![Geo\_Eclipse\_Oksaras](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/geo_eclipse_oksaras/32/500781_2.png) [@Geo\_Eclipse\_Oksaras](https://forums.eveonline.com/u/Geo_Eclipse_Oksaras)\
**Post date:** [January 30, 2022, 5:23am UTC](https://forums.eveonline.com/t/mini-margin-tool-script/347775/2 "2022-01-30T05:23:26Z")

</div>

if you have doubts of something being against the rules, your best option, is to submit a ticket… its better to ask, than to assume you aren’t violating the rules, than to do this and be violating them.

---

<div class="post-metadata">

**Author:** ![Golden\_Gnu](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/golden_gnu/32/459734_2.png) [@Golden\_Gnu](https://forums.eveonline.com/u/Golden_Gnu)\
**Post date:** [January 30, 2022, 11:22am UTC](https://forums.eveonline.com/t/mini-margin-tool-script/347775/3 "2022-01-30T11:22:57Z")

</div>

> [@Piastra](#):
>
> I hope this script does not violate any rules

I’m not sure what you script does.  
All automation is against the EULA, that means simulating keys/mouse in eve is not okay.  
However, modifying the windows clipboard and reading the eve export files, are not considered exploits.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/eveonline/original/3X/4/1/41ec4921cbaca7a6f9ea556e7cc20018461eae5e.png) [@system](https://forums.eveonline.com/u/system)\
**Post date:** [April 30, 2022, 11:23am UTC](https://forums.eveonline.com/t/mini-margin-tool-script/347775/4 "2022-04-30T11:23:20Z")

</div>

Closed on April 30, 2022, 11:23am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
