EVE PI

This is a script i wrote to see if i was making ISK in eve by importing PI basic or refined commodities and making Specialized commodities.  At some point I want to make this script do all PI commodities but for now its setup for robots.  If you know your item IDs you can edit it for your commodities.

param([switch]$Debug)
if($Debug){$DebugPreference = 'Continue'}
Write-Debug "ON"

$ItemIDs = @{
    "ReactiveMetals" = 2398
    "PreciousMetals" = 2399
    "ToxicMetals" = 2400
    "ChiralStructures" = 2401
    "MechanicalParts" = 3689
    "ConsumerElectronics" = 9836
    "Robotics" = 9848
}

$Items = @{
    2398 = "ReactiveMetals"
    2399 = "PreciousMetals"
    2400 = "ToxicMetals"
    2401 = "ChiralStructures"
    3689 = "MechanicalParts"
    9836 = "ConsumerElectronics"
    9848 = "Robotics"
}

function GetPriceData
{

    param
    (
        $IDs,
        $Region = 10000002 #the forge
    )

    $IDString = ''
    $IDs | %{$IDString += "typeid="+"$_"+'&'}
    
    $XMLString = "http://api.eve-central.com/api/marketstat?"+"$IDString"+"regionlimit=$Region"
    $XML = New-Object system.xml.xmldocument
    $XML.load($XMLString)
    
    Write-Debug $XMLString
    
    #$BaseNode = "/evec_api/marketstat"
    
    $Returns = @{}
    $Root = $XML.evec_api.marketstat
    foreach($Node in $Root.ChildNodes)
    {
        [int32]$TypeID = $Node.id
        $Buy = $Node.buy
        $Sell = $Node.sell

        Write-Debug $ItemsIDs[$TypeID]

        $Returns[$Items[$TypeID]] = New-Object -TypeName PSObject -Property (@{
        'ID' = $TypeID
        'SellPrice' = [double]$Sell.min
        'BuyPrice' = [double]$Buy.max})
    }
       
    return $Returns

}

$BasicQuantity = 80
$RefinedQuantity = 10
$SpecializedQuantity = 3
$BasicTax = 2000 # per 80
$RefinedTax = 4500 # per 10
$SpecializedTax = 21000 # per 3
$SalesTax = 0.01 # lv5 sales tax

$PriceData = GetPriceData (
    $ItemIDs.ReactiveMetals,
    $ItemIDs.PreciousMetals,
    $ItemIDs.ToxicMetals,
    $ItemIDs.ChiralStructures,
    $ItemIDs.MechanicalParts,
    $ItemIDs.ConsumerElectronics,
    $ItemIDs.Robotics
    )


if(!$PriceData){Write-Debug 'Nothing returned'}

$Sales = $PriceData.Robotics.BuyPrice * $SpecializedQuantity * (1 - $SalesTax)

#this bit needs to be a function for things other then robotics

$Costs = ($PriceData.ReactiveMetals.SellPrice * $BasicQuantity`
    + $PriceData.PreciousMetals.SellPrice * $BasicQuantity`
    + $PriceData.ToxicMetals.SellPrice * $BasicQuantity`
    + $PriceData.ChiralStructures.SellPrice * $BasicQuantity)`
    * (1 + $SalesTax)
    
$Tax = 4 * $BasicTax + $SpecializedTax

$Profits = ($Sales - $Costs) - $Tax

if($Profits -ge 0){$Color = "Green"}
else{$Color = "Red"}

Write-Host -ForegroundColor $Color "Basic:" $Profits "Per Day:" ($Profits*24)

$Costs = ($PriceData.MechanicalParts.SellPrice * $RefinedQuantity`
    + $PriceData.ConsumerElectronics.SellPrice * $RefinedQuantity)`
    * (1 + $SalesTax)
    
$Tax = 2 * $RefinedTax + $SpecializedTax

$Profits = ($Sales - $Costs) - $Tax

if($Profits -ge 0){$Color = "Green"}
else{$Color = "Red"}

Write-Host -ForegroundColor $Color "Refined:" $Profits "Per Day:" ($Profits*24)