|
Trulayne Newbie
Joined: 18 Jul 2006 Posts: 1 Location: Appleton,WI--USA
|
|
|
|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Tue Jul 18, 2006 2:21 pm |
You'll need to provide us with some sample text from the mud that shows the values you'd use to calculate the spread, and also tell us what you normally have to calculate manually, so that we can help provide an automated method.
|
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
|
Tanetti Newbie
Joined: 01 Nov 2006 Posts: 8
|
Posted: Wed Nov 01, 2006 4:06 am |
Here is some of the data... line that start with input are what you type in, lines with output is what is returned. NUMBERS in parenthesis are added to help follow different scenarios in how to calculate spread. to calc, need contract price (1st section), and current exchange price (2nd section)
-------------------------
input di futures
output >di futures
output
output Mercury Futures Exchange
output Margin 4000ig/contract
output (Minimum 2000ig/contract)
output Min movement 1ig/ton
output Max hourly movement 5ig/ton
output Long contracts in toxicmunchers - trading suspended at 588ig/ton. (1)
output Long contracts in artifacts available at 547ig/ton. (2)
output Long contracts in biochips available at 814ig/ton. (3)
output Short contracts in clays available at 646ig/ton. (4)
output Short contracts in studios available at 294ig/ton. (5)
----------------------------------
input >c price artifacts (2)
output +++ The exchange display shows the prices for Artifacts +++
output +++ Exchange has 700 tons for sale +++
output +++ Offer price is 619ig/ton for first 75 tons +++
input >c price biochips (3)
output +++ The exchange display shows the prices for BioChips +++
output +++ Exchange will buy 75 tons at 745ig/ton +++
input >c price clays (4)
output +++ The exchange display shows the prices for Clays +++
output +++ Exchange will buy 75 tons at 602ig/ton +++
input >c price studios (5)
output +++ The exchange display shows the prices for Studios +++
output +++ Exchange has 700 tons for sale +++
output +++ Offer price is 330ig/ton for first 75 tons +++
-------------------------
Situation:
1 Trading suspended… no more contracts available.
2 Long Contracts - planet exchange should be selling (it is)
3 Long Contracts - planet exchange should be selling (it's not)
4 Short Contracts - planet exchange should be buying (it is)
5 Short Contracts - planet exchange should be buying (it's not)
----------------------------------
Formula - what is done manually at present
1 Trading suspended… no more contracts available.
**nothing to calculate**
2 we want to compare value of 619ig/ton with contract price of 547ig/ton
LONG formula: ((exchange $) / .9) - (contract $)
result: 687.78 - 547
result: 140.78
Then add a classification to the result.
Under 20, don't buy
20-70, ok to buy
70-120, good to buy
over 120, must buy
3 Planet Exchange is BUYING - no evaluation needed, don't buy
4 we want to compare value of 602ig/ton with contract price of 646ig/ton
SHORT formula: ((exchange $) * .9) - (contract $)
result: 541.8 - 646
result: -104.20
Add same classification as above
5 Planet Exchange is SELLING - no evaluation needed, don't buy
-------------------------------
I have some idea to do this with triggers and variables, but thought there must be an easier way :)
Any help is great!
Tanetti |
|
|
|
Klytos Newbie
Joined: 11 May 2007 Posts: 6
|
Posted: Fri May 11, 2007 8:10 pm calculating futures |
I've been trying to do this futures thing, and got stuck as I can't figure out how to load an array using an iteration. So I thought I'd post the problem here, and maybe someone will have a better solution. I'll try to only include information that is required to create the trigger(s), for more info on how Federation 2 exchanges and futures work, check out www.ibgames.net.
First, on every planet there is an exchange, and each exchange offers futures which are either a long (Promise to buy) or a short (promise to sell) based on an underlying commodity. The 'spread' between the future price and the actual exchange price determines whether or not a prospective trader would want to purchase that future. There are six possible combinations between a future contract and the underlying commodity:
Long/buy - the future is a long contract and the exchange is currently buying the underlying commodity.
Long/sell - the future is a long, and the exchange is currently selling the commodity.
Long/Mix - the future is long, and the exchange is both selling and buying.
Short/buy, Short/sell, and Short/mix are the other three. Basically (to keep things simple) we would only consider looking at long/buy or short/sell conditions.
The exchange's list of futures contracts look like this:
> di futures
Rhea Futures Exchange
Margin 4000ig/contract
(Minimum 2000ig/contract)
Min movement 1ig/ton
Max hourly movement 5ig/ton
Long contracts in antimatter available at 603ig/ton.
Long contracts in artifacts available at 901ig/ton.
Long contracts in cereals available at 199ig/ton.
Short contracts in clays available at 647ig/ton.
(the list is shortened, usually there are about 15 or so futures listed)
Rhea is the planet name, the margin, minimum, min, and max are not pertinent and can be disregarded.
Consider antimatter, it is a long contract so when checking for a price, we'd want to see a 'buy' situation:
>c price anti
+++ The exchange display shows the prices for AntiMatter +++
+++ Exchange will buy 75 tons at 556ig/ton +++
Which it is, Rhea's exchange buys at 534 (all exchanges buy and sell only in quantities of 75 tons.)
The calculation to find the spread for a long/buy is: (Exchange price /.9)- contract price.
Now look at furs, the futures contract is:
Short contracts in furs available at 483ig/ton.
The exchange shows:
>c price furs
+++ The exchange display shows the prices for Furs +++
+++ Exchange has 700 tons for sale +++
+++ Offer price is 551ig/ton for first 75 tons +++
so this is a short/sell situation and the calculation for the spread is: contract price - (exchange price/1.1).
So the trigger would need to look for the type (long or short) the commod, and the price, then check the price of that commodity (c price <commodity>), determine if it is a long/buy or short/sell (any other situation would be ignored) and then calculate and report the spread something like:
<commodity name> is a <type> with a spread of <calculated spread>.
We would assume the trader is standing in the exchange that he/she wants to check. (remote checking of exhcange prices is available but not for futures).
One thing about the exchange prices, while standing in an exchange, the exchange sends out current prices of all commodities, one at a time alphabetically. So while standing there, and doing a price check, the exchange will send out prices of other commodities as well, one about every 15 seconds. like this:
>c price furs
+++ The exchange display shows the prices for Furs +++
+++ Exchange has 700 tons for sale +++
+++ Offer price is 551ig/ton for first 75 tons +++
+++ The exchange display shows the prices for MicroScalpels +++
+++ Exchange will buy 75 tons at 370ig/ton +++
+++ The exchange display shows the prices for Monopoles +++
+++ Exchange will buy 75 tons at 785ig/ton +++
So, any trigger must be able to ignore lines that are not generated from the 'c price' command. |
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Sat May 12, 2007 8:53 pm |
How about something like this?
the alias StartFutures gets everything started.
Once di futures is done then the alias DoFutures will start the next part.
Umm the functions FUNC_Short and FUNC_Long may not have the correct formulae so have a look at that.
Tanetti and Klytos gave different formulae for calculating the Spread so I'll leave it to you to sort those functions out.
As is they calculate the spread with %1 being the exchange price and %2 being the contract price.
I'm sure script could be vastly improved, but since nobody else posted anything I thought I'd get things started.
Code: |
#CLASS {Futures}
#ALIAS DoPrice {#VAR TARGET %pop( itemlist);#IF (@TARGET = "") {#T- PRICECHECKER;#ECHO ALL DONE} {c price @TARGET}}
#ALIAS CALCSpread {#var Fut_Temp %lower( %1)
#if %eval( @Fut_Temp = @TARGET) {#IF %eval( %db( %db( @Products, @Fut_Temp), Term)= "Short") {
#ECHO
#echo ATTENTION:%1 is a Short with a spread of @FUNC_Short(%2,%db( %db( @Products, @Fut_Temp), CPrice)).} {
#ECHO
#echo ATTENTION:%1 is a Long with a spread of @FUNC_Long(%2,%db( %db( @Products, @Fut_Temp), CPrice)).}} {}}
#ALIAS DoFutures {#T- PRICEGRABBER;#loopdb @Products {#if %eval( %db( %val, Trading) = true) {#additem itemlist %key}};#T+ PRICECHECKER;DoPrice}
#ALIAS StartFutures {#T- PRICECHECKER;#T+ PRICEGRABBER;#var Products {};#var TREC {};#var itemlist {};#Var TARGET {};#var Fut_Temp {};di futures}
#VAR Products {}
#VAR FUNC_Long {%eval( (%1/0.9)-%2)}
#VAR FUNC_Short {%eval( %2 -(%1*0.9))}
#VAR TREC {}
#VAR TARGET {}
#VAR Fut_Temp {} {artifacts}
#VAR itemlist {}
#REGEX "PRICEGRABBER" {^(Long|Short) contracts in (\w+) ((?:\- trading suspended)|available) at (\d+)ig/ton\.$} {TREC = ""
TREC.Term = %1
TREC.CPrice = %4
TREC.Trading = %if(%eval("%3" != "available"),false,true)
Products.%2 = @TREC}
#REGEX "PRICECHECKER" {^\+\+\+ The exchange display shows the prices for (\a+) \+\+\+\n(?:(?:^\+\+\+ Exchange will buy (\d+) tons at (\d+)ig/ton \+\+\+)|(?:^\+\+\+ Exchange has (\d+) tons for sale \+\+\+\n^\+\+\+ Offer price is (\d+)ig/ton for first (\d+) tons \+\+\+))$} {#if %eval( %numparam > 3) {CALCSpread %1 %5} {};DoPrice} "" {skip|param=1|disable}
#CLASS 0
|
|
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
Klytos Newbie
Joined: 11 May 2007 Posts: 6
|
Posted: Mon May 14, 2007 4:04 am |
This is a great start, and far beyond anything I've had the time to learn. I've run it a few times and the script ignores the 'long' contracts, the 'Products' list only gets loaded with the 'short' contract commodities.
Also, when it does calculate a spread it comes out as 0... perhaps a problem with a float var somewhere? I couldn't find it but like I said, I'm just starting to use the scripting and don't know a whole lot. |
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Mon May 14, 2007 4:50 am |
I'm not really sure why its not capturing the Long items either. Since according to the sample text provided above the only difference between the Long and the Short contract/availability lines is the word Long and the word Short.
The sample text posted above was very helpful in working out how things work, however maybe you can post some unedited captures of a sample trading session. There might be some slight differences that aren't apparent. Regardless it would help me, or anyone else that cares to contribute, in testing any scripts.
It would also be great if you could confirm and repost the formulae used for both short and long contracts :) |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon May 14, 2007 10:49 am |
It can also help if you enclose your example text in the forum's code tags, because the forums sometimes eat extra spaces.
|
|
|
|
Klytos Newbie
Joined: 11 May 2007 Posts: 6
|
Posted: Wed May 23, 2007 2:07 am |
Sorry I haven't got back here, was out of town for a bit.... Here's an example of standing in the planet Rhea's exchange and asking for a list of the futures available..
The command is di futures
>di futures
Rhea Futures Exchange
Margin 4000ig/contract
(Minimum 2000ig/contract)
Min movement 1ig/ton
Max hourly movement 5ig/ton
Short contracts in alloys available at 220ig/ton.
Long contracts in antimatter - trading suspended at 596ig/ton.
Short contracts in cereals available at 203ig/ton.
Long contracts in clays available at 645ig/ton.
Short contracts in games - trading suspended at 264ig/ton.
Long contracts in katydidics available at 765ig/ton.
Short contracts in meats available at 315ig/ton.
Short contracts in munitions available at 312ig/ton.
Short contracts in nanos available at 688ig/ton.
Short contracts in nitros available at 287ig/ton.
Long contracts in probes available at 631ig/ton.
Short contracts in rna available at 475ig/ton.
Short contracts in sensamps available at 645ig/ton.
Long contracts in simulations available at 390ig/ton.
Short contracts in synths available at 701ig/ton.
Short contracts in toxicmunchers available at 590ig/ton.
Long contracts in univators available at 707ig/ton.
To get the current price and whether it is a buy or a sell I type: c price alloys
>c price alloys
+++ The exchange display shows the prices for Alloys +++
+++ Exchange will buy 75 tons at 204ig/ton +++
+++ The exchange display shows the prices for Crystals +++
+++ Exchange will buy 75 tons at 752ig/ton +++
Note that the exchange sent the price of Crystals right after, it scrolls through prices alphabetically sending one every 5 seconds or so. Since Alloys are being bought by this exchange and the future is a short, I would ignore it. The second future is for antimatter and it is currently suspended. I would ignore that one also. (the price of the future moves toward the price of the underlying commodity 1 point every exchange cycle, up to a maximum movement of 5 points in an hour, if the future's price moves 5 points in any direction, it gets suspended until the end of that exchange's hour.
Cereals are a short future and the exchange is selling them:
>c price cereals
+++ The exchange display shows the prices for Cereals +++
+++ Exchange has 700 tons for sale +++
+++ Offer price is 218ig/ton for first 75 tons +++
The number of tons for sale is on the second line, and the actual sale price for the first 75 tons is on the third line. So the futures price is 203 and the exchange price is 218, for a short/sell situation the formula is: Contract Price - (Exchange price/1.1) or 203-218/1.1.
Hope that helps! And thanks again. |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|