The CompuBBS code (2/4)
From
SPP@21:1/5 to
All on Mon Jul 26 22:49:45 2021
[continued from previous message]
running under bash" exit 1
fi
# Get script root (as we are sourced from another script, $0 will not be
# us)
declare -r menuScript=$(readlink -f ${BASH_SOURCE[0]})
menuRoot=$(dirname "$menuScript")
# Ensure we can access our dependencies
if [ ! -s "$menuRoot/bash-draw.sh" ]; then echo "ERROR: Missing required
draw.sh script" exit 1
fi
# Load terminal drawing functions
. "$menuRoot/bash-draw.sh"
################################
# Private Variables
#
# These should not be overridden
################################
declare -a menuItems declare -a menuActions
menuHeaderText="" menuFooterText="" menuBorderText=""
################################
# Setup Menu
#
# These are defaults which should be overridden as required. ################################
# Top of menu (row 2)
menuTop=2
# Left offset for menu items (not border)
menuLeft=15
# Width of menu
menuWidth=42
# Left offset for menu border (not menu items)
menuMargin=4
menuItems[0]="Exit" menuActions[0]="return 0"
menuItemCount=1 menuLastItem=0
menuColour=$DRAW_COL_WHITE menuHighlight=$DRAW_COL_GREEN
menuTitle=" Super Bash Menu System" menuFooter=" Enter=Select, Up/Down=Prev/Next Option"
################################
# Initialise Menu
################################
menuInit() { menuItemCount=${#menuItems[@]}
menuLastItem=$((menuItemCount-1))
# Ensure header and footer are padded appropriately
menuHeaderText=`printf "%-${menuWidth}s" "$menuTitle"`
menuFooterText=`printf "%-${menuWidth}s" "$menuFooter"`
# Menu (side) borders
local marginSpaces=$((menuMargin-1)) local
menuSpaces=$((menuWidth-2)) local leftGap=`printf
"%${marginSpaces}s" ""` local midGap=`printf "%${menuSpaces}s" ""`
menuBorderText="${leftGap}x${midGap}x"
}
################################
# Show Menu
################################
menu_Display() { local menuSize=$((menuItemCount+2)) local
menuEnd=$((menuSize+menuTop+1))
drawClear drawColour $menuColour $menuHighlight
# Menu header
drawHighlightAt $menuTop $menuMargin "$menuHeaderText" 1
# Menu (side) borders
for row in $(seq 1 $menuSize); do drawSpecial "$menuBorderText" 1
done
# Menu footer
drawHighlightAt $menuEnd $menuMargin "$menuFooterText" 1
# Menu items
for item in $(seq 0 $menuLastItem); do menu_ClearItem $item done
}
################################
# Mark Menu Items
################################
# Ensure menu item is not highlighted
menu_ClearItem() { local item=$1 local top=$((menuTop+item+2)) local
menuText=${menuItems[$item]}
drawPlainAt $top $menuLeft "$menuText"
}
# Highlight menu item
menu_HighlightItem() { local item=$1 local top=$((menuTop+item+2)) local
menuText=${menuItems[$item]}
drawHighlightAt $top $menuLeft "$menuText"
}
################################
# Wait for and process user input
################################
menu_HandleInput() { local choice=$1
local after=$((choice+1)) [[ $after -gt $menuLastItem ]] && after=0
local before=$((choice-1)) [[ $before -lt 0 ]] &&
before=$menuLastItem
# Clear highlight from prev/next menu items
menu_ClearItem $before menu_ClearItem $after
# Highlight current menu item
menu_HighlightItem $choice
# Get keyboard input
local key="" local extra=""
read -s -n1 key 2> /dev/null >&2 while read -s -n1 -t .05 extra 2>
/dev/null >&2 ; do
key="$key$extra" done
# Handle known keys
local escKey=`echo -en "\033"` local upKey=`echo -en "\033[A"` local
downKey=`echo -en "\033[B"`
if [[ $key = $upKey ]]; then return $before elif [[ $key = $downKey
]]; then
return $after elif [[ $key = $escKey ]]; then if [[ $choice -eq
$menuLastItem ]]; then
# Pressing Esc while on last menu item will trigger action
# This is a helper as we assume the last menu option is exit
key="" else
# Jumping possibly more than 1 (next/prev) item
menu_ClearItem $choice return $menuLastItem fi elif [[
${#key} -eq 1 ]]; then
# See if we wanrt to jump to a menu item by entering the first
# character
for index in $(seq 0 $menuLastItem) ; do local
item=${menuItems[$index]} local startChar=${item:0:1} if [[
"$key" = "$startChar" ]]; then
# Jumping possibly more than 1 (next/prev) item
menu_ClearItem $choice return $index fi done fi
if [[ "$key" = "" ]]; then
# Notify that Enter key was pressed
return 255 fi
return $choice
}
################################
# Main Menu Loop
################################
menuLoop() { local choice=0 local running=1
menu_Display
while [[ $running -eq 1 ]]; do
# Enable case insensitive matching
local caseMatch=`shopt -p nocasematch` shopt -s nocasematch
menu_HandleInput $choice local newChoice=$?
# Revert to previous case matching
$caseMatch
if [[ $newChoice -eq 255 ]]; then
# Enter pressed - run menu action
drawClear action=${menuActions[$choice]} $action running=$?
# Back from action If we are still running, redraw menu
[[ $running -eq 1 ]] && menu_Display
elif [[ $newChoice -lt $menuItemCount ]]; then
# Update selected menu item
choice=$newChoice fi done
# Cleanup screen
drawClear
}
----------------------------------------------------------------------------- ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- bash-draw.sh - file below between horizontal rule ----------------------------------------------------------------------------- #!/bin/bash
#
# Public Functions:
#
# drawClear() drawColour(colour = DRAW_COL_DEF, bgColour =
# DRAW_COL_DEF)
#
# drawPlain(text, newLine = 0) drawSpecial(text, newLine = 0)
# drawHighlight(text, newLine = 0) drawPlainAt(left, top, text,
# newLine = 0) drawHighlightAt(left, top, text, newLine = 0)
#
#
# Colours
#
# DRAW_COL_DEF # Default colour DRAW_COL_BLACK DRAW_COL_WHITE
# DRAW_COL_RED DRAW_COL_GREEN DRAW_COL_YELLOW DRAW_COL_BLUE
# DRAW_COL_GRAY # Light gray (grey?)
#
# Ensure we are running under bash (will not work under sh or dash etc)
if [ "$BASH_SOURCE" = "" ]; then echo "ERROR: bash-draw requires to be
running under bash" exit 1
fi
DRAW_COL_DEF=39 DRAW_COL_BLACK=30 DRAW_COL_WHITE=97 DRAW_COL_RED=31 DRAW_COL_GREEN=32 DRAW_COL_YELLOW=33 DRAW_COL_BLUE=34 DRAW_COL_GRAY=37
# drawClear()
drawClear() { $ESC_WRITE "\033c"
}
# drawColour(colour = DRAW_COL_DEF, bgColour = DRAW_COL_DEF)
drawColour() { local colour=$DRAW_COL_DEF local
bgColour=$((DRAW_COL_DEF+10))
if [[ ! -z "$1" && "$1" != "" ]]; then colour="$1" fi
if [[ ! -z "$2" && "$2" != "" ]]; then bgColour="$2" fi
$ESC_ECHO "\033c\033[H\033[J\033[${colour};${bgColour}m\033[J"
}
# drawPlain(text, newLine = 0)
drawPlain() { if [[ -z "$2" || "$2" -eq 0 ]]; then $ESC_WRITE "$1" else
$ESC_ECHO "$1"
fi
}
# drawSpecial(text, newLine = 0)
drawSpecial() { [[ -z "$2" ]] && newLine=0 || newLine="$2"
draw_SetDrawMode drawPlain "$1" "$newLine" draw_SetWriteMode
}
# drawHighlight(text, newLine = 0)
drawHighlight() { [[ -z "$2" ]] && newLine=0 || newLine="$2"
draw_StartHighlight drawPlain "$1" "$newLine" draw_EndHighlight
}
# drawPlainAt(left, top, text, newLine = 0)
drawPlainAt() { [[ -z "$4" ]] && newLine=0 || newLine="$4"
draw_MoveTo $1 $2 drawPlain "$3" "$newLine"
}
# drawHighlightAt(left, top, text, newLine = 0)
drawHighlightAt() { [[ -z "$4" ]] && newLine=0 || newLine="$4"
draw_StartHighlight drawPlainAt "$1" "$2" "$3" "$newLine"
draw_EndHighlight
}
# Write escape sequence with no newline
ESC_WRITE='echo -en'
# Write escape sequence adding newline
ESC_ECHO='echo -e'
# Move cursor to specified location
draw_MoveTo() { $ESC_WRITE "\033[${1};${2}H"
}
draw_StartHighlight() { $ESC_WRITE "\033[7m"
}
draw_EndHighlight() { $ESC_WRITE "\033[27m"
}
draw_SetDrawMode() { $ESC_WRITE "\033%@\033(0"
}
draw_SetWriteMode() { $ESC_WRITE "\033(B"
}
----------------------------------------------------------------------------- ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- CompuBBS - ECN code ----------------------------------------------------------------------------- Please find below the CompuBBS ECN code originally developed by Josh
Greene. It is something a former friend of mine once told me about as
he worked at Daytek during the dawn of the internet. At the time I was
to oblivous to the fact that money is the very means by which our lives
revolve around. As they say, "when men and women get together [money]
gets in the way". The Josh Greene's ECN day trading code is intended as
a game for now until it becomes more viable for the purposes of the Cybermatrix.
The below ECN day trading code is in Python. So check it out. Try to
make it into a game at first so that you and your network can learn how
to play it before proceeding. I heard when it comes to the stock market
one can literally loose their shirt on this. So beware. Ignorance is
not bliss.
The intention for this code is toward the establishment of the
cybermatrix or to say the opern source fiat like monies initiative for
the sake of synergy or mutual success. The meaning of cybermartix is
virtual as in cyber and a database of the nth dimension as in matrix.
So the cybermatrix is a network of databases of a given
dimension(matricees) with a larger databases of the nth
dimension(matrix). So, let's do this.
God bless and God speed for Jesus Christ is God. Always a pleasure.
Good luck to you all. I want you to win. Allahu Akhbar! ----------------------------------------------------------------------------- Josh Greene's Island ECN day trading code in Python between horizontal
rule ----------------------------------------------------------------------------- SET TALK OFF SET CURSOR OFF SET SAFETY OFF SET MEMOWIDTH TO 80 CLEAR ALL
CLOSE ALL CLEAR CLEAR MACRO && Get rid of F keys typing commands SET
HELP OFF && Needed to clear out F1 key too
=rand(-1)
#define COREDEST "FFFFFFFF0673"
gstoredflag = .F. && Are there any messages buffered that could be
flushed?
#define VERSION "2.40"
malertfile = "M:\logs\island2.err" mholdofffile =
"M:\island2\holdoff.txt"
blanknbuffer="R"+replicate( " " , 200 ) && get BRIGADEN message here
#define CORELINELEN 124 define COREMESSAGELEN 122
#define READPORT "067F"
load int99
define window title from 0,0 to 0,scols()-1 COLOR "W/B" NONE define
window output from 1,0 to 10,scols()-1 NONE COLOR "W+/N" define window
ticker from 12,0 to srows()-1,scols()-1 NONE define window status from
11,0 to 11,scols()-1 COLOR "W+/R" NONE
do title do initstatus
activate window title activate window status
activate window output activate window ticker
s = fopen( "ISLAND2.TXT" )
if s <= 0 wait window "COULD NOT FIND ISLAND2.TXT IN CURRENT DIR. RUN
RESET." quit
endif
x = fgets( s )
if "ISLAND2" # x wait window "ACCOUNT IN ISLAND2.TXT DOES NOT MATCH
ACCOUNT ENV VAR. RUN RESET." =fclose( s ) quit
endif
tcount = 0 && For counting random stuff
tseq = val( fgets( s ) ) && Next order number tmatch = val( fgets( s ) )
&& Next match number tnextdead = val( fgets( s ) ) && Next dead order (zero=none) =fclose( s )
select select(1) use events set order to WHEN
tnow = 0
ttoolate = 0 && Count the too late to cancel events
gaccept = .F. && Let any orders in? Set by SOD, cleared by EOD
gactaccept = .F. && Let ACT orders in? Set by SOD, cleared by EOA
geom = .F. && Have we gotten EOM yet?
gprinting = .F. && Print incoming messages?
go top
if eof("EVENTS")
tnext = 99999.999
else
tnext = WHEN && Time of next event
endif
select 0 use sources set order to SOURCE
select select(1) use island
gsx = alltrim( str( date() - {2/6/1996} ) )
gsession = left( "0000000000" , 9-len( gsx ) ) + gsx + "F"
s="N"+gsession+"5050" && Open the islandfile for writing Mold on port
5050 call int99 with s
if s # "n" && Valid open file?
do alert with "InitMold filed with reason >"+s
do case
case s = "i"
sm ="Error opening files in deney-write mode"
case s = "j"
sm = "a file had a partial line fragment"
case s = "k"
sm = "not all trailing files are empty"
case s = "l"
sm = "all files full"
otherwise
sm = "Unknown error"
endcase
do alert with sm
wait window "Error on ISLAND.OUT or ISLAND2.OUT OPEN:"+s
quit
endif
select island
tecount = 0 && Assume worst case, just to make sure ecount is high
enough txcount = 0 && Cancels
x = "L"+READPORT+" " && Read Island2 requests call int99 with x if x #
"l"
do alert with "Could not open Command listen!" endif
gstatdelay = 0.25 do showstatus gnextstats = seconds() + gstatdelay
gmolddelay = 1 && Time between mold heartbeats gmoldheart = seconds() + gmolddelay && Time to send a MOLD heartbeat by doing a FLUSH
gmessages = 0 && Number of messages written to the stream gpackets = 0
&& Number of packets writtento the stream
mdone = .F.
do while !mdone
tnow = seconds()
do while tnow >= tnext
if !EVENTS.PROCESSED
do swrite with "G" , EVENTS.CODE
select EVENTS replace PROCESSED with .T. select
ISLAND
else
? time()+" Event bypassed:"+ EVENTS.CODE
endif
do seteventflags with EVENTS.CODE
skip 1 in EVENTS
if eof("EVENTS")
tnext = 99999.999
else
tnext = EVENTS.WHEN
endif
enddo
nbuffer = blanknbuffer
call int99 with nbuffer
if nbuffer = "r"
tlenstr = substr( nbuffer , 2 , 5 )
tlen = val( tlenstr )
tmessage = substr( nbuffer , 43 , tlen )
if gprinting ? time()+" >"+tmessage+"<" endif
if tmessage = "P" && PING REQUEST
tsource = substr( nbuffer ,11 , 8)
do pingreply with tsource , tmessage
else
do processtcpip with tmessage
endif
else && No pending commands...
if gstoredflag
do flush
gstoredflag = .F.
gmoldheart = seconds() + gmolddelay
gpackets = gpackets + 1
else
if gmoldheart < seconds()
do flush
gmoldheart = seconds() + gmolddelay
endif
endif
endif
if gnextstats <= seconds()
do showstatus gnextstats = seconds() + gstatdelay
endif
lastkey=inkey()
if lastkey # 0
activate window output
do case case lastkey = asc("~") ? time()+" Quitting..."
mdone = .T.
case lastkey = asc("@") ? time()+" Copying to
island2.dbf" set order to copy to
m:\island2\island2 ?? "Done"
case lastkey = asc("#") ? time()+"
Suspending..." suspend
case lastkey = asc("!")
? time()+"
ACCEPT="+iif(gaccept,"T","F")+" ACT="+
iif(gactaccept,"T","F") + "
EOM="+iif(geom,"T","F")+"
NEXT="+str(tnext,9,3)+ "
TOO-LATE="+str(ttoolate,6,0)+"
COUNT="+str(tcount,9,0)
s = "T"+space(60) call int99 with s
if s = "t"
tbuffered = val( substr(s,26,5)
)
? "MOLD INFO:
SESSION="+substr(s,2,10)+"
SEQ="+substr(s,12,10)+"
SOCKET="+substr(s,22,4)+"
BUFFERED="+str(tbuffered,5,0)
else
? "Could not get mold info!"
tbuffered = 0
endif
if gpackets > 0
?
"MESSAGES:"+str(gmessages-tbuffered,
12,0)+"
PACKETS:"+str(gpackets,12,0)+"
("+str( (gmessages-tbuffered)/
gpackets , 5 , 3 )+")"
gmessages = tbuffered gpackets
=0
endif
case lastkey = asc("%") ? time()+" Shutdown
attempt..." do shutdown
case lastkey = asc("(") ? time()+" toggled
gaccept" gaccept = !gaccept
case lastkey = asc("?") ? "@-Copy to island2.DBF
~-Quit !-Status #-Suspend %-ShutDown
$-Print incoming"
case lastkey = asc("$")
if gprinting
? time()+" Printing off"
gprinting = .F.
else
? time()+" Printing on"
gprinting = .T.
endif
endcase
activate window ticker
endif
enddo && Main Loop
activate window output
&& Final flush to mak sure everything is sent
do flush
&& Close file
s = "C" call int99 with s
x = "H"+READPORT call int99 with x if x # "h" do alert with "Could not
close PingPort!"
endif
use && Unuse Island
&& Create fresh waypoint file
f = fcreate("ISLAND2.TXT")
if f<=0 ? "Could not create ISLAND.TXT!" suspend endif
=fputs( f , "ISLAND2" ) && ROLE
=fputs( f , str( tseq , 9 , 0 ) ) && Order number =fputs( f , str(
tmatch , 9 , 0 ) ) && Match number =fputs( f , str( tnextdead , 9 , 0 )
) && Next dead order pointer =fclose(f)
quit
procedure title activate window title SAME clear @ 0,0 SAY " Island2 ú
Version "+VERSION+" (c)1996 Joshua Levine ú Press [?] for help"
activate window ticker SAME
return
proc werror param wcode
do case
case wcode = "w"
return "Error on file write"
case wcode = "s"
return "Error on nework send"
case wcode = "c"
return "Invalid message length"
case wcode = "d"
return "all files full"
endcase
return "Unknown error"
**** write actualy writes a string the the file, steam, and screen
proc write parameter wstring
wl = len( wstring )
ws="W"+chr(wl)+wstring
call int99 with ws
gmessages = gmessages + 1
if ws = 'b'
gstoredflag = .T.
else
if ws = "f"
gpackets = gpackets + 1
gstoredflag = .F.
else
activate window output
? time() +" !!!! ERROR ON WRITE!!!!!!"
? ws
do alert with "Erorr on write:"+werror(ws)
activate window ticker
suspend
endif
endif
return
*** Write a message
**** ACTIONS: **** A - Accept the order was accepted into Island **** B
- Booked this order hit the book **** E - Execute the order was executed
for this many shares at this price **** X - Cancel this many shares were canceled **** C - Break this order was executed, now broken **** G -
Control stock is the control type **** R - Report trade done away but
will report/clear through Island
**** ON Cancel CONTRA = Reason for cancel
***** MINDICATE = on accept always "D" (legacy) ***** on execute "A"=
added liquidity, "R"=Removed liquidity ***** on report "Y" trade report,
"N" don't report, "S" step-out
****** mmatch = on accept or book is MINIMUM shares, in execution is
match number ****** not defined on cancels, but 0 for now
proc mwrite
parameter
maction,mseq,mshares,mprice,mcontra,mindicate,mmatch,mlocate
mwhen = str( tnow , 9 , 3)
w = left( mwhen , 5 ) + "," +maction+","+str(mseq,9,0)+","+PORT+","+USER+","+TOKEN+","+BUY_SELL+"," +str(mshares,9,0)+","+str(mmatch,9,0)+","+STOCK+","+str(mprice,11,4)+","
+str(mlocate,8,0)+ ", 0,"+SHORT+","+MMID+","+PA+","+mcontra+","+mindicate+","+DISPLAY+"," +right(mwhen,3)+","+CLEARING+",D"
do write with w
return
****** Swrite writes a status message that doesnot concern an order,
Like G-Good morning
proc swrite
param maction , mcode
mwhen = str( tnow , 9 , 3)
xcode = left( padr( mcode , 3) , 3 )
w = left( mwhen , 5 ) +","+maction+","+" 0"+", , , , , 0,
0,*"+xcode+" , 0.0000,00000000, 0, , , , , , ,"+right( mwhen , 3
)+", , "
do write with w
return
****** Enter order adds the audit, tries for a match, and if it don't
work, books it. ****** Enter order assumes ostock and obuy_sell are the
right length. ****** Also assumes that buy_sell has aready been checked
to be B or S. ****** Also assumes that the token is no already used
proc enter2order
parameter
oport,ouser,otoken,obuy_sell,oshares,ostock,oprice,otif,oshort,ommid, opa,odisplay,omin,oclearing,oflags
if odisplay = "P"
obasefirm = ouser
else
obasefirm = "####"
endif
&& Get the working record
if tnextdead > 0
tlocate = tnextdead goto tnextdead tnextdead = SEQ
else
insert into ISLAND (LEAVES) values (0) && Keep it out of
the indexes for now tlocate = recno()
endif
tseq = tseq + 1
awhen = str( tnow , 9 , 3)
oleaves = oshares
ofilled = 0
aflag = .f. && have we written the "A" message yet?
if obuy_sell = "B" && Buy order...
set order to SSEEK
do case
case omin > 1 && Minimum quantity specified?
*** if the min is bigger than the size,
set it to the size
if omin > oshares
mmin = oshares
else
mmin = omin
endif
*** First prescan to see if we have
enough size to fill it
if seek( ostock )
scan while mmin > 0 .and. ostock
= STOCK .and. BUY_SELL = "S"
.and. oprice >= PRICE
mmin = mmin - LEAVES
endscan
endif
if mmin <= 0
*** There were at least enough
to fill the minimum quantity
mmax = oshares
else
*** Not enough to fill the min,
so fill none
mmax = 0
endif
case odisplay = "R" .or. odisplay = "P" && Is
this a round-lot only order?
mmax = 0
*** Prescan to find the number of a
shares available
if seek( ostock )
scan while mmax <= oshares .and.
ostock = STOCK .and. BUY_SELL =
"S" .and. oprice >= PRICE .and.
obasefirm # MMID
mmax = mmax + LEAVES
endscan
endif
if mmax >= oshares
*** Max out with the number of
shares specified
mmax = oshares
endif
*** Round down to nearest round lot
wihtout using floating point
mmax = val( substr( str( mmax , 6, 0 ) ,
1 ,4 ) + "00" )
otherwise
mmax = oshares
endcase
do while mmax > 0 .and. seek( ostock ) .and. oprice >=
PRICE
if !aflag
w = left( awhen , 5 ) +",A,"
+str(tseq,9,0) +"," +oport+"," +ouser
+"," +otoken +"," +obuy_sell +", "
+str(oshares,6,0) +", " +str(omin,6,0)
+"," +ostock +"," +str(oprice,11,4) +","
+str(tlocate,8,0) +"," +str(otif,5,0)
+"," +oshort +"," +ommid +","
+opa+","+oflags+", ," +odisplay +","
+right(awhen,3) +"," +oclearing+",D"
do write with w
aflag = .T.
endif
tecount = tecount + 1
eshares = min( LEAVES , mmax )
oleaves = oleaves - eshares
mmax = mmax - eshares
ofilled = ofilled + eshares
tmatch = tmatch + 1
w = left( awhen , 5 ) +",E," +str( SEQ ,9,0)
+"," +PORT +"," +USER +"," +TOKEN +"," +BUY_SELL
+", " +str(eshares,6,0) +"," +str(tmatch,9,0)
+"," +ostock +"," +str(PRICE,11,4) +"," +str(
recno() ,8,0)+ ", 0," +SHORT +"," +MMID +","
+PA+"," +ommid+",A," +DISPLAY +","
+right(awhen,3) +"," +CLEARING+",D"
do write with w
w = left( awhen , 5 ) +",E," +str(tseq,9,0) +","
+oport+"," +ouser +"," +otoken +"," +obuy_sell
+", " +str(eshares,6,0) +"," +str(tmatch,9,0)
+"," +ostock +"," +str(PRICE,11,4) +","
+str(tlocate,8,0)+", 0," +oshort +"," +ommid
+"," +opa+","+MMID+",R," +odisplay +","
+right(awhen,3) +"," +oclearing+",D"
do write with w
dleaves = LEAVES - eshares
if dleaves <= 0 && Dead record?
replace LEAVES with 0 , SEQ with
tnextdead tnextdead = recno()
else
replace LEAVES with dleaves , FILLED
with FILLED + eshares
endif
enddo
else && sell order..
set order to BSEEK
do case
case omin > 1 && Minimum quantity specified?
*** if the min is bigger than the size,
set it to the size
if omin > oshares
mmin = oshares
else
mmin = omin
endif
*** First prescan to see if we have
enough size to fill it
if seek( ostock )
scan while mmin > 0 .and. ostock
= STOCK .and. BUY_SELL = "B"
.and. oprice <= PRICE
mmin = mmin - LEAVES
endscan
endif
if mmin <= 0
mmax = oshares
else
mmax = 0
endif
case odisplay = "R" .or. odisplay = "P" && Is
this a round-lot only order?
mmax = 0
*** Prescan to find the number of a
shares available
if seek( ostock )
scan while mmax <= oshares .and.
ostock = STOCK .and. BUY_SELL =
"B" .and. oprice <= PRICE .and.
obasefirm # MMID
mmax = mmax + LEAVES
endscan
endif
if mmax >= oshares
mmax = oshares
endif
*** Round down to nearest round lot
wihtout using floating point
mmax = val( substr( str( mmax , 6, 0 ) ,
1 ,4 ) + "00" )
otherwise
mmax = oshares
endcase
do while mmax > 0 .and. seek( ostock ) .and. oprice <=
PRICE
if !aflag
w = left( awhen , 5 ) +",A,"
+str(tseq,9,0) +"," +oport+"," +ouser
+"," +otoken +"," +obuy_sell +", "
+str(oshares,6,0) +", " +str(omin,6,0)
+"," +ostock +"," +str(oprice,11,4) +","
+str(tlocate,8,0) +","+str(otif,5,0)
[continued in next message]
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)