This repository has been archived by the owner on May 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from Regner/feature/save-orders-locally
Initial work on setting the client up to save market orders locally on disk.
- Loading branch information
Showing
4 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package utils | ||
|
||
import ( | ||
"os" | ||
"time" | ||
"fmt" | ||
"log" | ||
) | ||
|
||
func SaveMarketItems(marketItems []string) { | ||
date := time.Now().Local().Format("2006-01-02") | ||
filename := fmt.Sprintf("marketorder-%v.txt", date) | ||
|
||
f, err := os.OpenFile(filename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666) | ||
if err != nil{ | ||
log.Printf("Error opeing file for saving: %v", err) | ||
return | ||
} | ||
|
||
defer f.Close() | ||
|
||
for _, order := range marketItems { | ||
_, err := f.WriteString(fmt.Sprintf("%v\n", order)) | ||
if err != nil { | ||
log.Printf("Error appending to file: %v", err) | ||
return | ||
} | ||
} | ||
|
||
log.Printf("Saved %v market orders to disk.", len(marketItems)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package utils | ||
|
||
type ClientConfig struct { | ||
DeviceName string | ||
IngestUrl string | ||
DisableUpload bool | ||
SaveLocally bool | ||
} |