MelMan2002
|
|
April 06, 2012, 04:11:28 PM |
|
I'm using C.
... so check your pointers. Make sure nothing is pointing to the stack and so on. Yes, definitely a pointer issue. The problem with set faults and pointers is that the seg fault can often occur at misleading places leading you to believe that the bug is located at a different point in the code. And C gives little to no warning when playing with pointers improperly.
|
19F6veduCZcudwXuWoVosjmzziQz4EhBPS
|
|
|
|
|
|
I HATE TABLES I HATE TABLES I HA(╯°□°)╯︵ ┻━┻ TABLES I HATE TABLES I HATE TABLES
|
|
|
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
|
|
|
|
MatthewLM
Legendary
Offline
Activity: 1190
Merit: 1004
|
|
April 06, 2012, 10:53:19 PM |
|
OK but what is wrong with this line? FILE * file = fopen("price.dat", "rb"); That's as perfect as a line of code can be. It makes me think the compiler is corrupting the program somehow.
|
|
|
|
notme
Legendary
Offline
Activity: 1904
Merit: 1002
|
|
April 07, 2012, 04:15:29 AM |
|
OK but what is wrong with this line? FILE * file = fopen("price.dat", "rb"); That's as perfect as a line of code can be. It makes me think the compiler is corrupting the program somehow. Or you have a bad pointer somewhere and C won't stop you from overwriting your code stack and screwing up the instructions, leading to an error being identified in a bit of code that was fine before the program did exactly what you told it to do.
|
|
|
|
MatthewLM
Legendary
Offline
Activity: 1190
Merit: 1004
|
|
April 07, 2012, 02:58:27 PM |
|
Well I modified the code: int main (int argc, const char * argv[]) { float usd,btc,bid,ask,order_price,possible_price; printf("HALLO\n"); DateData * prices = load_prices(); It never prints HALLO and it now crashes o the printf line...
|
|
|
|
Kettenmonster
Sr. Member
Offline
Activity: 420
Merit: 250
bool eval(bool b){return b ? b==true : b==false;}
|
|
April 07, 2012, 04:05:50 PM |
|
No, it crashes on intializing a lib. Remove all optimizations (compiler + linker) include debug infos and step by step remove one lib after the other.
|
The paining (sic!) is done with the QPainter class inside the paintEvent() method. (source: my internet)
|
|
|
MatthewLM
Legendary
Offline
Activity: 1190
Merit: 1004
|
|
April 07, 2012, 04:57:32 PM |
|
I removed all optimisation and now the line during the crash is shown at entering the main function... I removed all curllib and the same problem occurs... I removed all of the OpenCL and the same problem occurs... What? Is Xcode broken... I replaced the entire program with: #include <stdlib.h> #include <stdio.h>
int main(){ printf(":O"); return EXIT_SUCCESS; }
It works... Time to scratch my head...
|
|
|
|
ohforf
Sr. Member
Offline
Activity: 327
Merit: 250
we are legion
|
|
April 07, 2012, 06:30:05 PM |
|
A IDE / Compiler can be broken. Its possible. Try Compiling on a clean, fresh System. - or at least reinstall xcode. Also check environment variables.. these are very important for most Compilers.
|
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ ▀██████ EAT SLEEP DECENTRALIZE ██████▀▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
|
|
|
Kettenmonster
Sr. Member
Offline
Activity: 420
Merit: 250
bool eval(bool b){return b ? b==true : b==false;}
|
|
April 07, 2012, 06:35:06 PM |
|
Fine so far. Now find the lib or the combination causing trouble and feed that to agony aunt google. btw. if your first line of code would have been: It would have crashed there, so could be RAII isn´t too bad for pure C either.
|
The paining (sic!) is done with the QPainter class inside the paintEvent() method. (source: my internet)
|
|
|
MatthewLM
Legendary
Offline
Activity: 1190
Merit: 1004
|
|
April 08, 2012, 04:31:34 PM |
|
Well I just tried compiling and running outside of Xcode and I get the same thing... Matthew-Mitchell:Parrallel BitCoin Trading Algorithm matt$ gcc -g cmain.c -o test -lcurl -framework OpenCL -std=c99 -arch i386 Matthew-Mitchell:Parrallel BitCoin Trading Algorithm matt$ gdb testGNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 15 16:03:10 UTC 2011) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .... done
(gdb) run Starting program: /Users/matt/Programming/Bit Coin algorithm/Parrallel BitCoin Trading Algorithm/test Reading symbols for shared libraries .+++.................................................................. done
Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0xbea7d7cc 0x00003e9a in main (argc=0, argv=0x1000) at cmain.c:572 572 int main (int argc, const char * argv[]) { (gdb)
Also when running directly in the command line, it returns instantly.
|
|
|
|
Kettenmonster
Sr. Member
Offline
Activity: 420
Merit: 250
bool eval(bool b){return b ? b==true : b==false;}
|
|
April 08, 2012, 08:25:21 PM |
|
Reason: KERN_PROTECTION_FAILURE at address: 0xbea7d7cc wtf is located at 0xbea7d7cc? Is it stack or heap? Did you init it? When did you release that address? Is it always this specific address? ... if yes, why? Where did it come from?
|
The paining (sic!) is done with the QPainter class inside the paintEvent() method. (source: my internet)
|
|
|
MatthewLM
Legendary
Offline
Activity: 1190
Merit: 1004
|
|
April 09, 2012, 12:08:01 AM |
|
At this point in the program nothing is initialised since it's at the main function entry. I ran gdb again and it shows 0xbea7d7cc again. No idea where it came from. What I'll try to do is make and share a minimalist version of the program that replicates the problem...
|
|
|
|
MatthewLM
Legendary
Offline
Activity: 1190
Merit: 1004
|
|
April 09, 2012, 01:22:55 AM |
|
I fiddled with the code and slowly removed parts until I got a super small program that crashes: #include <errno.h>
int main () { if (!errno) { int bar[2096159]; } return 0; } This gives: (null):Parrallel BitCoin Trading Algorithm matt$ gcc -g test.c -o test (null):Parrallel BitCoin Trading Algorithm matt$ gdb test GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 15 16:03:10 UTC 2011) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .. done
(gdb) run Starting program: /Users/matt/Programming/Bit Coin algorithm/Parrallel BitCoin Trading Algorithm/test Reading symbols for shared libraries +. done
Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x00007fff5f3ffff8 0x00007fff5fc1404c in __dyld__ZNK26ImageLoaderMachOCompressed18findExportedSymbolEPKcPPK11ImageLoader () (gdb)
But if the array is one smaller: #include <errno.h>
int main () { if (!errno) { int bar[2096158]; } return 0; } Then this happens: (null):Parrallel BitCoin Trading Algorithm matt$ gcc -g test.c -o test (null):Parrallel BitCoin Trading Algorithm matt$ gdb test GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 15 16:03:10 UTC 2011) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .. done
(gdb) run Starting program: /Users/matt/Programming/Bit Coin algorithm/Parrallel BitCoin Trading Algorithm/test Reading symbols for shared libraries +. done
Program exited normally. (gdb)
Stack trace: (gdb) bt #0 0x00007fff5fc1404c in __dyld__ZNK26ImageLoaderMachOCompressed18findExportedSymbolEPKcPPK11ImageLoader () #1 0x00007fff5fc0f141 in __dyld__ZNK16ImageLoaderMachO18findExportedSymbolEPKcbPPK11ImageLoader () #2 0x00007fff5fc12b34 in __dyld__ZN26ImageLoaderMachOCompressed15resolveTwolevelERKN11ImageLoader11LinkContextEPKS0_bPKcPS5_ () #3 0x00007fff5fc12dd0 in __dyld__ZN26ImageLoaderMachOCompressed7resolveERKN11ImageLoader11LinkContextEPKchiPPKS0_PNS_10LastLookupE () #4 0x00007fff5fc1699e in __dyld__ZN26ImageLoaderMachOCompressed20doBindFastLazySymbolEjRKN11ImageLoader11LinkContextE () #5 0x00007fff5fc0478f in __dyld__ZN4dyld18fastBindLazySymbolEPP11ImageLoaderm () #6 0x00007fff8812800a in dyld_stub_binder () #7 0x0000000100001030 in pvars () #8 0x0000000100000ef4 in start ()
Well I'm stumped...
|
|
|
|
MatthewLM
Legendary
Offline
Activity: 1190
Merit: 1004
|
|
April 09, 2012, 01:50:08 AM |
|
Stack overflow... Now I'll know to be weary of static variables. I'll try replacing large static arrays with allocated memory and hopefully it will work... I thought the stack size would grow to meet larger variables... It would be nice if there was some error or warning when this happens.
|
|
|
|
notme
Legendary
Offline
Activity: 1904
Merit: 1002
|
|
April 09, 2012, 01:56:17 AM |
|
Stack overflow... Now I'll know to be weary of static variables. I'll try replacing large static arrays with allocated memory and hopefully it will work... I thought the stack size would grow to meet larger variables... It would be nice if there was some error or warning when this happens.
That's it... don't make static variables over a few hundered bytes. Just don't.
|
|
|
|
Kettenmonster
Sr. Member
Offline
Activity: 420
Merit: 250
bool eval(bool b){return b ? b==true : b==false;}
|
|
April 09, 2012, 12:04:28 PM |
|
Maybe be you should take a closer look at your data structures.
What do you think a trade looks like? Do you need to store the trades? For what purpose?
Is the decision to buy different from a decision to sell? If yes what is the difference? Is this to be modelled as a struct or function? (could be both)
Is your bot meant to run on a single exchange or will it serve several different exchanges? Thus you have to model the synopsis for the(se) exchange(s).
Then look at the libs you use. What is openCL good for? Do you really need it? It prevents you from using function pointers. Which could be handy when dealing with different exchanges and modelling the decision as a function.
|
The paining (sic!) is done with the QPainter class inside the paintEvent() method. (source: my internet)
|
|
|
MatthewLM
Legendary
Offline
Activity: 1190
Merit: 1004
|
|
April 09, 2012, 04:48:01 PM |
|
Yep, allocation with malloc works fine. Except now I have OpenCL errors, will fix those... Then look at the libs you use. What is openCL good for? Do you really need it? Testing many combinations on an algorithm at once.
|
|
|
|
mem
|
|
April 11, 2012, 03:13:26 AM |
|
Maybe this is the wrong section, but I think you guys can help me here. I want to make a trading bot that will execute trades based on parameters I set according to technical indicators. Thing is, I have almost zero experience with coding. I don't just want to use someone else's code though, I want to build this from scratch, using custom and unique indicators. Is there any resource that I could use that would teach me how to go about creating and implementing this bot?
TL;DR Noob coder needs help building trading bot.
I have already written one, its called bitperl.pl but atm is a private only release. On a good day it earns 0.7% of capital.
|
|
|
|
notme
Legendary
Offline
Activity: 1904
Merit: 1002
|
|
April 11, 2012, 03:14:55 AM |
|
Maybe this is the wrong section, but I think you guys can help me here. I want to make a trading bot that will execute trades based on parameters I set according to technical indicators. Thing is, I have almost zero experience with coding. I don't just want to use someone else's code though, I want to build this from scratch, using custom and unique indicators. Is there any resource that I could use that would teach me how to go about creating and implementing this bot?
TL;DR Noob coder needs help building trading bot.
I have already written one, its called bitperl.pl but atm is a private only release. On a good day it earns 0.7% of capital. What about a bad day?
|
|
|
|
mem
|
|
April 11, 2012, 03:17:05 AM Last edit: April 11, 2012, 03:34:49 AM by mem |
|
Maybe this is the wrong section, but I think you guys can help me here. I want to make a trading bot that will execute trades based on parameters I set according to technical indicators. Thing is, I have almost zero experience with coding. I don't just want to use someone else's code though, I want to build this from scratch, using custom and unique indicators. Is there any resource that I could use that would teach me how to go about creating and implementing this bot?
TL;DR Noob coder needs help building trading bot.
I have already written one, its called bitperl.pl but atm is a private only release. On a good day it earns 0.7% of capital. What about a bad day? The worst Ive seen is it flat line waiting to sell coins for 4 days (back when he had a good sized slump to 4.60). Once the price came back to normal it resumed its micro trading. Currently supports:- Simulations
- Uploads charts output of: profit ph, profit total, buy, sell, target, target break even. Example:
- Logs historical Data. (for simulations)
- The most basic buy low sell high algorithm (more coming).
- Forcing a sell/buy remotely.
- tweets changes and transactions: https://twitter.com/#!/bitperl
- Factors MTGOX transaction charges
Todo:- Nicer web UI
- modular trading algo's
Good luck with your trading bot My advice is thread or daemonize everything to avoid any lag between transactions and mtgox live price. I used to have everything pushed into a single loop - was easy to follow but a simple tweet was enough to miss a good price.
|
|
|
|
notme
Legendary
Offline
Activity: 1904
Merit: 1002
|
|
April 11, 2012, 03:21:30 AM |
|
Maybe this is the wrong section, but I think you guys can help me here. I want to make a trading bot that will execute trades based on parameters I set according to technical indicators. Thing is, I have almost zero experience with coding. I don't just want to use someone else's code though, I want to build this from scratch, using custom and unique indicators. Is there any resource that I could use that would teach me how to go about creating and implementing this bot?
TL;DR Noob coder needs help building trading bot.
I have already written one, its called bitperl.pl but atm is a private only release. On a good day it earns 0.7% of capital. What about a bad day? The worst Ive seen is it flat line waiting to sell coins for 4 days (back when he had a good sized slump to 4.60). Once the price came back to normal it resumed its micro trading. I see... careful with that type of strategy. If it moves too far and you don't have a stop you'll miss the big moves.
|
|
|
|
|