instancevariables
stocks : seqof StockRecord;
stockWatchers : map StockIdentifier to StockWatcher;
actionLog : seqof ActionEvent := [];
balance : int; inv balance >= 0; -- no stock can have the same name invforall x,y insetinds stocks & x <> y => stocks(x).Name <> stocks(y).Name;
--says that foreach ActionEvent in the log if there exist a next action with the same --Stock name, it should have a different ActionType. this insures that you dont sell or buy the same --two times in a row invlet stockIdentifiers = {si.Name | si insetelems stocks} in forall stockIdentifier inset stockIdentifiers & let allEventsStock = [ e | e inseq actionLog
& e.StockName = stockIdentifier] in
(forall i insetinds allEventsStock &
(i <> len allEventsStock) =>
(allEventsStock(i).Type <> allEventsStock(i+1).Type));
let i insetinds stocks best stocks(i).Name = potAction.Name in
(
stocks(i) := mu(potAction, State |-> <Bought>, Cost |-> value );
sw.updateStockRecord(stocks(i))
)
) pre potAction.State = <PotentialBuy> and
stockWatchers(potAction.Name).GetTriggeredAction() = <Buy> post balance >= 0;
let i insetinds stocks best stocks(i).Name = potAction.Name in
(
stocks(i) := mu(potAction, State |-> <PotentialBuy>, Cost |-> 0);
sw.updateStockRecord(stocks(i))
)
) pre potAction.State = <Bought> and
stockWatchers(potAction.Name).GetTriggeredAction() = <Sell> post balance >= 0;
ObserveAllStocks: nat ==> ()
ObserveAllStocks(time) == forall i insetinds stocks do let stock = stocks(i), csw = stockWatchers(stock.Name) in csw.ObserveStock(time);
public Step: nat ==> ()
Step(time) == (
ObserveAllStocks(time);
let potBuys = GetStocksWithActiveActionTrigger(<PotentialBuy>) ,
potSells = GetStocksWithActiveActionTrigger(<Bought>),
validBuy = FindValidBuy(potBuys,time) in
( if(len potSells > 0) then (PerformSell(FindValidSell(potSells,time), time);) elseskip;
IO`print("\npot sels : ");
IO`print(potSells);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.